예제 #1
0
        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" }));
        }
        public void InternalPropertyValues_ToObject_for_non_entity_type_can_be_called_from_multiple_threads()
        {
            ExecuteInParallel(
                () =>
            {
                var values = new TestInternalPropertyValues <DbPropertyValuesTests.FakeTypeWithProps>(null, isEntityValues: true);
                values.MockInternalContext.Setup(c => c.CreateObject(typeof(DbPropertyValuesTests.FakeTypeWithProps))).Returns(
                    new DbPropertyValuesTests.FakeDerivedTypeWithProps());

                var clone = values.ToObject();

                Assert.IsType <DbPropertyValuesTests.FakeDerivedTypeWithProps>(clone);
            });
        }