本文整理汇总了C#中DynamicDictionaryValue.Default方法的典型用法代码示例。如果您正苦于以下问题:C# DynamicDictionaryValue.Default方法的具体用法?C# DynamicDictionaryValue.Default怎么用?C# DynamicDictionaryValue.Default使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DynamicDictionaryValue
的用法示例。
在下文中一共展示了DynamicDictionaryValue.Default方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Should_still_return_default_int_datetime_when_no_default_value_given
public void Should_still_return_default_int_datetime_when_no_default_value_given()
{
//Given
DateTime expected = DateTime.MinValue;
dynamic value = new DynamicDictionaryValue(null);
//When
DateTime actual = value.Default<DateTime>();
//Then
Assert.Equal(expected, actual);
}
示例2: Should_throw_if_unable_to_explicitly_cast
public void Should_throw_if_unable_to_explicitly_cast()
{
//Given
dynamic value = new DynamicDictionaryValue(12.25);
//When
Exception exception = Assert.Throws<InvalidCastException>(() => value.Default<int>());
//Then
Assert.Equal("Cannot convert value of type 'Double' to type 'Int32'", exception.Message);
}
示例3: Should_still_return_default_long_type_when_no_default_value_given
public void Should_still_return_default_long_type_when_no_default_value_given()
{
//Given
const long expected = 0L;
dynamic value = new DynamicDictionaryValue(null);
//When
long actual = value.Default<long>();
//Then
Assert.Equal(expected, actual);
}
示例4: Should_still_return_default_bool_type_when_no_default_value_given
public void Should_still_return_default_bool_type_when_no_default_value_given()
{
//Given
const bool expected = false;
dynamic value = new DynamicDictionaryValue(null);
//When
bool actual = value.Default<bool>();
//Then
Assert.Equal(expected, actual);
}
示例5: Should_still_return_default_short_type_when_no_default_value_given
public void Should_still_return_default_short_type_when_no_default_value_given()
{
//Given
const short expected = (short)0;
dynamic value = new DynamicDictionaryValue(null);
//When
short actual = value.Default<short>();
//Then
Assert.Equal(expected, actual);
}
示例6: Should_still_return_default_float_type_when_no_default_value_given
public void Should_still_return_default_float_type_when_no_default_value_given()
{
//Given
const float expected = 0f;
dynamic value = new DynamicDictionaryValue(null);
//When
float actual = value.Default<float>();
//Then
Assert.Equal(expected, actual);
}
示例7: Should_return_default_value_of_datetime_when_calling_default_given_null
public void Should_return_default_value_of_datetime_when_calling_default_given_null()
{
//Given
DateTime expected = DateTime.Parse("10 Dec, 2012");
dynamic value = new DynamicDictionaryValue(null);
//When
DateTime actual = value.Default(expected);
//Then
Assert.Equal(expected, actual);
}
示例8: Should_still_return_default_double_type_when_no_default_value_given
public void Should_still_return_default_double_type_when_no_default_value_given()
{
//Given
const double expected = 0d;
dynamic value = new DynamicDictionaryValue(null);
//When
double actual = value.Default<double>();
//Then
Assert.Equal(expected, actual);
}
示例9: Should_return_default_value_of_bool_when_calling_default_given_null
public void Should_return_default_value_of_bool_when_calling_default_given_null()
{
//Given
const bool expected = true;
dynamic value = new DynamicDictionaryValue(null);
//When
bool actual = value.Default(expected);
//Then
Assert.Equal(expected, actual);
}
示例10: Should_return_default_value_of_long_when_calling_default_given_null
public void Should_return_default_value_of_long_when_calling_default_given_null()
{
//Given
const long expected = 1000333000222000333L;
dynamic value = new DynamicDictionaryValue(null);
//When
long actual = value.Default(expected);
//Then
Assert.Equal(expected, actual);
}
示例11: Should_return_default_value_of_float_when_calling_default_given_null
public void Should_return_default_value_of_float_when_calling_default_given_null()
{
//Given
const float expected = 9.343f;
dynamic value = new DynamicDictionaryValue(null);
//When
float actual = value.Default(expected);
//Then
Assert.Equal(expected, actual);
}
示例12: Should_return_default_value_of_double_when_calling_default_given_null
public void Should_return_default_value_of_double_when_calling_default_given_null()
{
//Given
const double expected = 44.23d;
dynamic value = new DynamicDictionaryValue(null);
//When
double actual = value.Default(expected);
//Then
Assert.Equal(expected, actual);
}
示例13: Should_return_default_value_of_string_when_calling_default_given_null
public void Should_return_default_value_of_string_when_calling_default_given_null()
{
//Given
const string expected = "default value";
dynamic value = new DynamicDictionaryValue(null);
//When
string actual = value.Default(expected);
//Then
Assert.Equal(expected, actual);
}