当前位置: 首页>>代码示例>>C#>>正文


C# DynamicDictionaryValue.TryParse方法代码示例

本文整理汇总了C#中DynamicDictionaryValue.TryParse方法的典型用法代码示例。如果您正苦于以下问题:C# DynamicDictionaryValue.TryParse方法的具体用法?C# DynamicDictionaryValue.TryParse怎么用?C# DynamicDictionaryValue.TryParse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DynamicDictionaryValue的用法示例。


在下文中一共展示了DynamicDictionaryValue.TryParse方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Should_implicitly_convert_from_datetime_based_on_given_type_of_string

        public void Should_implicitly_convert_from_datetime_based_on_given_type_of_string()
        {
            //This test is unrealistic in my opinion, but it should still call ToString on the datetime value

            //Given
            string expected = DateTime.Parse("22 Nov, 2012").ToString(CultureInfo.InvariantCulture);
            string notExpected = DateTime.Parse("18 Jun, 2011").ToString(CultureInfo.InvariantCulture);
            dynamic value = new DynamicDictionaryValue(DateTime.Parse("22 Nov, 2012"));

            //When
            string actual = value.TryParse(notExpected);

            //Then
            Assert.Equal(expected, actual);
        }
开发者ID:Borzoo,项目名称:Nancy,代码行数:15,代码来源:DynamicDictionaryValueFixture.cs

示例2: Should_implicitly_convert_from_double_based_on_given_type_of_string

        public void Should_implicitly_convert_from_double_based_on_given_type_of_string()
        {
            //Given
            const string expected = "134.22";
            const string notExpected = "187.34";
            dynamic value = new DynamicDictionaryValue(134.22d);

            //When
            string actual = value.TryParse(notExpected);

            //Then
            Assert.Equal(expected, actual);
        }
开发者ID:Borzoo,项目名称:Nancy,代码行数:13,代码来源:DynamicDictionaryValueFixture.cs

示例3: Should_implicitly_convert_from_decimal_based_on_given_type_of_string

        public void Should_implicitly_convert_from_decimal_based_on_given_type_of_string()
        {
            //Given
            const string expected = "88.53234423";
            const string notExpected = "76.3422";
            dynamic value = new DynamicDictionaryValue(88.53234423m);

            //When
            string actual = value.TryParse(notExpected);

            //Then
            Assert.Equal(expected, actual);
        }
开发者ID:Borzoo,项目名称:Nancy,代码行数:13,代码来源:DynamicDictionaryValueFixture.cs

示例4: Should_implicitly_convert_from_string_based_on_given_generic_type_of_datetime

        public void Should_implicitly_convert_from_string_based_on_given_generic_type_of_datetime()
        {
            //Given
            DateTime expected = DateTime.Parse("13 Dec, 2012");
            dynamic value = new DynamicDictionaryValue("13 December 2012");

            //When
            DateTime actual = value.TryParse<DateTime>();

            //Then
            Assert.Equal(expected, actual);
        }
开发者ID:Borzoo,项目名称:Nancy,代码行数:12,代码来源:DynamicDictionaryValueFixture.cs

示例5: Should_return_default_value_if_implicit_convert_fails_on_datetime

        public void Should_return_default_value_if_implicit_convert_fails_on_datetime()
        {
            //Given
            DateTime expected = DateTime.Parse("13 December 2012");
            dynamic value = new DynamicDictionaryValue("Rawrrrr");

            //When
            DateTime actual = value.TryParse(expected);

            //Then
            Assert.Equal(expected, actual);
        }
开发者ID:Borzoo,项目名称:Nancy,代码行数:12,代码来源:DynamicDictionaryValueFixture.cs

示例6: Should_implicitly_convert_from_string_based_on_given_generic_type_of_double

        public void Should_implicitly_convert_from_string_based_on_given_generic_type_of_double()
        {
            //Given
            const double expected = 37.48d;
            dynamic value = new DynamicDictionaryValue("37.48");

            //When
            double actual = value.TryParse<double>();

            //Then
            Assert.Equal(expected, actual);
        }
开发者ID:Borzoo,项目名称:Nancy,代码行数:12,代码来源:DynamicDictionaryValueFixture.cs

示例7: Should_implicitly_convert_from_string_based_on_given_generic_type_of_short

        public void Should_implicitly_convert_from_string_based_on_given_generic_type_of_short()
        {
            //Given
            const short expected = (short)13;
            dynamic value = new DynamicDictionaryValue("13");

            //When
            short actual = value.TryParse<short>();

            //Then
            Assert.Equal(expected, actual);
        }
开发者ID:Borzoo,项目名称:Nancy,代码行数:12,代码来源:DynamicDictionaryValueFixture.cs

示例8: Should_implicitly_convert_from_string_based_on_given_generic_type_of_decimal

        public void Should_implicitly_convert_from_string_based_on_given_generic_type_of_decimal()
        {
            //Given
            const decimal expected = 55.23m;
            dynamic value = new DynamicDictionaryValue("55.23");

            //When
            decimal actual = value.TryParse<decimal>();

            //Then
            Assert.Equal(expected, actual);
        }
开发者ID:Borzoo,项目名称:Nancy,代码行数:12,代码来源:DynamicDictionaryValueFixture.cs

示例9: Should_return_default_when_given_string_that_is_not_a_number

        public void Should_return_default_when_given_string_that_is_not_a_number()
        {
            //Given
            const int expected = 100;
            dynamic value = new DynamicDictionaryValue("4abc2");

            //When
            int actual = value.TryParse<int>(expected);

            //Then
            Assert.Equal(expected, actual);
        }
开发者ID:Borzoo,项目名称:Nancy,代码行数:12,代码来源:DynamicDictionaryValueFixture.cs

示例10: Should_implicitly_convert_from_string_based_on_given_generic_type_of_int

        public void Should_implicitly_convert_from_string_based_on_given_generic_type_of_int()
        {
            //Given
            const int expected = 42;
            dynamic value = new DynamicDictionaryValue("42");

            //When
            int actual = value.TryParse<int>();

            //Then
            Assert.Equal(expected, actual);
        }
开发者ID:Borzoo,项目名称:Nancy,代码行数:12,代码来源:DynamicDictionaryValueFixture.cs

示例11: Should_implicitly_convert_from_datetime_based_on_given_parameter_type_of_nullable_datetime

        public void Should_implicitly_convert_from_datetime_based_on_given_parameter_type_of_nullable_datetime()
        {
            //Given
            DateTime expected = DateTime.Parse ("13 December 2012");
            DateTime? notExpected = expected.AddDays (10);
            dynamic value = new DynamicDictionaryValue (expected);

            //When
            DateTime actual = (DateTime)value.TryParse<DateTime?> (notExpected);

            //Then
            Assert.Equal (expected, actual);
        }
开发者ID:VPashkov,项目名称:Nancy,代码行数:13,代码来源:DynamicDictionaryValueFixture.cs

示例12: Should_implicitly_convert_from_int_based_on_given_parameter_type_of_nullable_long

        public void Should_implicitly_convert_from_int_based_on_given_parameter_type_of_nullable_long()
        {
            //Given
            const int expected = 42;
            long? notExpected = 100;
            dynamic value = new DynamicDictionaryValue (expected);

            //When
            int actual = (int)value.TryParse<long?> (notExpected);

            //Then
            Assert.Equal (expected, actual);
        }
开发者ID:VPashkov,项目名称:Nancy,代码行数:13,代码来源:DynamicDictionaryValueFixture.cs


注:本文中的DynamicDictionaryValue.TryParse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。