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


C# TestInternalPropertyValues.ToObject方法代码示例

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


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

示例1: ToObject_ignores_null_nested_property_dictionary

        public void ToObject_ignores_null_nested_property_dictionary()
        {
            var properties = new Dictionary<string, object>
                                 {
                                     { "Id", 1 },
                                     { "NestedObject", null }
                                 };
            var values = new TestInternalPropertyValues<FakeTypeWithProps>(properties, new[] { "NestedObject" });

            var clone = (FakeTypeWithProps)values.ToObject();

            Assert.Equal(1, clone.Id);
            Assert.Null(clone.NestedObject);
        }
开发者ID:junxy,项目名称:entityframework,代码行数:14,代码来源:DbPropertyValuesTests.cs

示例2: ToObject_throws_when_trying_to_set_null_values_onto_non_nullable_properties

        public void ToObject_throws_when_trying_to_set_null_values_onto_non_nullable_properties()
        {
            var values = new TestInternalPropertyValues<FakeTypeWithProps>(
                new Dictionary<string, object>
                    {
                        { "Id", 1 }
                    });
            values["Id"] = null;

            Assert.Equal(
                Strings.DbPropertyValues_CannotSetNullValue("Id", "Int32", "FakeTypeWithProps"),
                Assert.Throws<InvalidOperationException>(() => values.ToObject()).Message);
        }
开发者ID:junxy,项目名称:entityframework,代码行数:13,代码来源:DbPropertyValuesTests.cs

示例3: ToObject_can_set_reference_propeties_to_null

        public void ToObject_can_set_reference_propeties_to_null()
        {
            var properties = new Dictionary<string, object>
                                 {
                                     { "PublicNonNullStringProp", null }
                                 };
            var values = new TestInternalPropertyValues<FakeTypeWithProps>(properties);

            var clone = (FakeTypeWithProps)values.ToObject();

            Assert.Null(clone.PublicNonNullStringProp);
        }
开发者ID:junxy,项目名称:entityframework,代码行数:12,代码来源:DbPropertyValuesTests.cs

示例4: ToObject_returns_nested_property_dictionary_as_cloned_object

        public void ToObject_returns_nested_property_dictionary_as_cloned_object()
        {
            var nestedProperties = new Dictionary<string, object>
                                       {
                                           { "Id", 1 }
                                       };
            var nestedValues = new TestInternalPropertyValues<FakeTypeWithProps>(nestedProperties);

            var properties = new Dictionary<string, object>
                                 {
                                     { "NestedObject", nestedValues }
                                 };
            var values = new TestInternalPropertyValues<FakeTypeWithProps>(properties, new[] { "NestedObject" });

            var clone = (FakeTypeWithProps)values.ToObject();

            Assert.Equal(1, clone.NestedObject.Id);
        }
开发者ID:junxy,项目名称:entityframework,代码行数:18,代码来源:DbPropertyValuesTests.cs

示例5: ToObject_ignores_properties_that_are_readonly

        public void ToObject_ignores_properties_that_are_readonly()
        {
            var properties = new Dictionary<string, object>
                                 {
                                     { "Id", 1 },
                                     { "PublicReadonlyStringProp", "Foo" },
                                     { "PrivateReadonlyStringProp", "Foo" }
                                 };
            var values = new TestInternalPropertyValues<FakeTypeWithProps>(properties);

            var clone = (FakeTypeWithProps)values.ToObject();

            Assert.Equal(1, clone.Id);
            Assert.Equal("PublicReadonlyStringProp", clone.PublicReadonlyStringProp);
            Assert.Equal(
                "PrivateReadonlyStringProp",
                typeof(FakeTypeWithProps).GetProperty("PrivateReadonlyStringProp", PropertyBindingFlags).GetValue(clone, null));
        }
开发者ID:junxy,项目名称:entityframework,代码行数:18,代码来源:DbPropertyValuesTests.cs

示例6: ToObject_ignores_properties_that_are_conceptually_in_shadow_state

        public void ToObject_ignores_properties_that_are_conceptually_in_shadow_state()
        {
            var properties = new Dictionary<string, object>
                                 {
                                     { "Id", 1 },
                                     { "MissingProp", "MissingPropValue" }
                                 };
            var values = new TestInternalPropertyValues<FakeTypeWithProps>(properties);

            var clone = (FakeTypeWithProps)values.ToObject();

            Assert.Equal(1, clone.Id);
        }
开发者ID:junxy,项目名称:entityframework,代码行数:13,代码来源:DbPropertyValuesTests.cs

示例7: ToObject_sets_all_properties_from_the_dictionary_onto_the_object_including_those_with_private_setters

        public void ToObject_sets_all_properties_from_the_dictionary_onto_the_object_including_those_with_private_setters()
        {
            var properties = new Dictionary<string, object>
                                 {
                                     { "Id", 1 },
                                     { "PublicStringProp", "PublicStringPropValue" },
                                     { "PrivateStringProp", "PrivateStringPropValue" },
                                     { "PublicIntProp", 2 },
                                     { "PrivateIntProp", 3 },
                                     { "PublicIntPropWithPrivateSetter", 4 },
                                     { "PublicIntPropWithPrivateGetter", 5 },
                                     { "PublicBinaryProp", new byte[] { 3, 1, 4, 1, 5, 9 } },
                                 };
            var values = new TestInternalPropertyValues<FakeTypeWithProps>(properties);

            var clone = (FakeTypeWithProps)values.ToObject();

            Assert.Equal(1, clone.Id);
            Assert.Equal("PublicStringPropValue", clone.PublicStringProp);
            Assert.Equal(2, clone.PublicIntProp);
            Assert.Equal(
                "PrivateStringPropValue",
                typeof(FakeTypeWithProps).GetProperty("PrivateStringProp", PropertyBindingFlags).GetValue(clone, null));
            Assert.Equal(3, typeof(FakeTypeWithProps).GetProperty("PrivateIntProp", PropertyBindingFlags).GetValue(clone, null));
            Assert.Equal(4, clone.PublicIntPropWithPrivateSetter);
            Assert.Equal(
                5, typeof(FakeTypeWithProps).GetProperty("PublicIntPropWithPrivateGetter", PropertyBindingFlags).GetValue(clone, null));
            Assert.True(DbHelpers.KeyValuesEqual(new byte[] { 3, 1, 4, 1, 5, 9 }, clone.PublicBinaryProp));
        }
开发者ID:junxy,项目名称:entityframework,代码行数:29,代码来源:DbPropertyValuesTests.cs

示例8: ToObject_for_complex_object_does_not_use_CreateObject_to_create_instance

        public void ToObject_for_complex_object_does_not_use_CreateObject_to_create_instance()
        {
            var values = new TestInternalPropertyValues<FakeTypeWithProps>();

            var clone = values.ToObject();

            values.MockInternalContext.Verify(c => c.CreateObject(typeof(FakeTypeWithProps)), Times.Never());
            Assert.IsType<FakeTypeWithProps>(clone);
        }
开发者ID:junxy,项目名称:entityframework,代码行数:9,代码来源:DbPropertyValuesTests.cs

示例9: ToObject_for_entity_uses_CreateObject_to_return_instance_of_correct_type

        public void ToObject_for_entity_uses_CreateObject_to_return_instance_of_correct_type()
        {
            var values = new TestInternalPropertyValues<FakeTypeWithProps>(null, isEntityValues: true);
            values.MockInternalContext.Setup(c => c.CreateObject(typeof(FakeTypeWithProps))).Returns(new FakeDerivedTypeWithProps());

            var clone = values.ToObject();

            Assert.IsType<FakeDerivedTypeWithProps>(clone);
        }
开发者ID:junxy,项目名称:entityframework,代码行数:9,代码来源:DbPropertyValuesTests.cs


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