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


C# TestInternalPropertyValues类代码示例

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


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

示例1: CreateSimpleValues

        internal static TestInternalPropertyValues<FakeWithProps> CreateSimpleValues(int tag)
        {
            var level3Properties = new Dictionary<string, object>
                                       {
                                           { "ValueTypeProp", 3 + tag },
                                           { "RefTypeProp", "3" + tag },
                                       };
            var level3Values = new TestInternalPropertyValues<FakeWithProps>(level3Properties);

            var level2Properties = new Dictionary<string, object>
                                       {
                                           { "ValueTypeProp", 2 + tag },
                                           { "RefTypeProp", "2" + tag },
                                           { "ComplexProp", level3Values },
                                       };
            var level2Values = new TestInternalPropertyValues<FakeWithProps>(level2Properties, new[] { "ComplexProp" });

            var level1Properties = new Dictionary<string, object>
                                       {
                                           { "ValueTypeProp", 1 + tag },
                                           { "RefTypeProp", "1" + tag },
                                           { "ComplexProp", level2Values },
                                       };
            return new TestInternalPropertyValues<FakeWithProps>(level1Properties, new[] { "ComplexProp" });
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:25,代码来源:FakeWithProps.cs

示例2: 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

示例3: Current_value_returned_for_complex_property_can_be_null

            public void Current_value_returned_for_complex_property_can_be_null()
            {
                var properties = new Dictionary<string, object>
                                     {
                                         { "ComplexProp", null }
                                     };
                var currentValues = new TestInternalPropertyValues<FakeWithProps>(properties, new[] { "ComplexProp" });
                var entityEntry = FakeWithProps.CreateMockInternalEntityEntry(currentValues).Object;
                var propEntry = new InternalEntityPropertyEntry(entityEntry, FakeWithProps.ComplexPropertyMetadata);

                var value = propEntry.CurrentValue;

                Assert.Null(value);
            }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:14,代码来源:InternalEntityPropertyEntryTests.cs

示例4: Scalar_values_can_be_read_from_a_property_dictionary

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

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

示例5: CreateSimpleValues

        private TestInternalPropertyValues<FakeTypeWithProps> CreateSimpleValues()
        {
            var nestedProperties = new Dictionary<string, object>
                                       {
                                           { "Id", 0 }
                                       };
            var nestedValues = new TestInternalPropertyValues<FakeTypeWithProps>(nestedProperties);

            var properties = new Dictionary<string, object>
                                 {
                                     { "Id", 0 },
                                     { "PublicStringProp", null },
                                     { "PrivateStringProp", null },
                                     { "PublicIntProp", 0 },
                                     { "PrivateIntProp", 0 },
                                     { "PublicIntPropWithPrivateSetter", 0 },
                                     { "PublicIntPropWithPrivateGetter", 0 },
                                     { "PublicBinaryProp", null },
                                     { "NestedObject", nestedValues },
                                 };
            return new TestInternalPropertyValues<FakeTypeWithProps>(properties, new[] { "NestedObject" });
        }
开发者ID:junxy,项目名称:entityframework,代码行数:22,代码来源:DbPropertyValuesTests.cs

示例6: Modifying_properties_on_cloned_dictionary_does_not_change_properties_on_original_dictionary_and_vice_versa

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

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

            var clone = values.Clone();
            var nestedClone = (InternalPropertyValues)clone["NestedObject"];

            values["Id"] = -1;
            nestedValues["Id"] = -2;
            clone["Id"] = -3;
            nestedClone["Id"] = -4;

            Assert.Equal(-1, values["Id"]);
            Assert.Equal(-2, nestedValues["Id"]);
            Assert.Equal(-3, clone["Id"]);
            Assert.Equal(-4, nestedClone["Id"]);
        }
开发者ID:junxy,项目名称:entityframework,代码行数:28,代码来源:DbPropertyValuesTests.cs

示例7: Clone_clones_nested_property_dictionary_into_new_cloned_nested_dictionary

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

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

            var clone = values.Clone();
            var nestedClone = (InternalPropertyValues)clone["NestedObject"];

            Assert.Equal(1, clone["Id"]);
            Assert.Equal(2, nestedClone["Id"]);

            Assert.False(clone.GetItem("Id").IsComplex);
            Assert.True(clone.GetItem("NestedObject").IsComplex);
            Assert.False(nestedClone.GetItem("Id").IsComplex);
        }
开发者ID:junxy,项目名称:entityframework,代码行数:25,代码来源:DbPropertyValuesTests.cs

示例8: Clone_sets_all_properties_from_the_dictionary_into_the_new_values

        public void Clone_sets_all_properties_from_the_dictionary_into_the_new_values()
        {
            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 = values.Clone();

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

示例9: Attempt_to_copy_values_from_object_of_differnt_type_copies_only_properties_that_match_implementation

        private void Attempt_to_copy_values_from_object_of_differnt_type_copies_only_properties_that_match_implementation(object obj)
        {
            var properties = new Dictionary<string, object>
                                 {
                                     { "Id", 0 },
                                     { "PublicStringProp", null },
                                     { "PrivateStringProp", null },
                                     { "PublicIntProp", 0 },
                                     { "PrivateIntProp", 0 },
                                     { "PublicIntPropWithPrivateSetter", 0 },
                                     { "PublicIntPropWithPrivateGetter", 0 },
                                     { "PublicBinaryProp", null },
                                 };
            var values = new TestInternalPropertyValues<FakeTypeWithProps>(properties);

            values.SetValues(obj);

            Assert.Equal(0, values["Id"]);
            Assert.Equal("PublicStringPropValue", values["PublicStringProp"]);
            Assert.Equal(0, values["PublicIntProp"]);
            Assert.Null(values["PrivateStringProp"]);
            Assert.Equal(3, values["PrivateIntProp"]);
            Assert.Equal(0, values["PublicIntPropWithPrivateSetter"]);
            Assert.Equal(0, values["PublicIntPropWithPrivateGetter"]);
            Assert.Null(values["PublicBinaryProp"]);
        }
开发者ID:junxy,项目名称:entityframework,代码行数:26,代码来源:DbPropertyValuesTests.cs

示例10: Attempt_to_copy_values_from_object_of_differnt_type_copies_no_properties_if_no_properties_match

        public void Attempt_to_copy_values_from_object_of_differnt_type_copies_no_properties_if_no_properties_match()
        {
            var properties = new Dictionary<string, object>
                                 {
                                     { "PublicStringProp", null },
                                     { "PrivateStringProp", null },
                                     { "PublicIntProp", 0 },
                                     { "PrivateIntProp", 0 },
                                 };
            var values = new TestInternalPropertyValues<FakeTypeWithProps>(properties);

            values.SetValues("Bang!");

            Assert.Null(values["PublicStringProp"]);
            Assert.Equal(0, values["PublicIntProp"]);
            Assert.Null(values["PrivateStringProp"]);
            Assert.Equal(0, values["PrivateIntProp"]);
        }
开发者ID:junxy,项目名称:entityframework,代码行数:18,代码来源:DbPropertyValuesTests.cs

示例11: SetValues_copies_values_from_object_to_property_dictionary

        public void SetValues_copies_values_from_object_to_property_dictionary()
        {
            var properties = new Dictionary<string, object>
                                 {
                                     { "Id", 0 },
                                     { "PublicStringProp", null },
                                     { "PrivateStringProp", null },
                                     { "PublicIntProp", 0 },
                                     { "PrivateIntProp", 0 },
                                     { "PublicIntPropWithPrivateSetter", 0 },
                                     { "PublicIntPropWithPrivateGetter", 0 },
                                     { "PublicBinaryProp", null },
                                 };
            var values = new TestInternalPropertyValues<FakeTypeWithProps>(properties);

            var obj = new FakeTypeWithProps(
                1, "PublicStringPropValue", "PrivateStringPropValue", 2, 3, 4, 5, new byte[] { 3, 1, 4, 1, 5, 9 });

            values.SetValues(obj);

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

示例12: 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

示例13: 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

示例14: 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

示例15: 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


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