Пример #1
0
        public void Should_Copy_Swallow_Objects_In_Props()
        {
            var source = new ComplexClass
            {
                Prop1 = new TestClass {
                    Field = 1, IntProp = 2, LstProp = new string[] { }
                },
                PropList = new List <TestClass>
                {
                    new TestClass {
                        Field = 4, IntProp = 5, LstProp = new List <string> {
                            "a"
                        }
                    }
                }
            };

            var destination = new ComplexClass();
            var numberAffectedProperties = destination.CopyPublicProperties(source);

            Assert.Equal(2, numberAffectedProperties);
            Assert.Same(source.Prop1, destination.Prop1);
            Assert.Same(source.PropList.ToArray()[0], destination.PropList.ToArray()[0]);
        }