Exemple #1
0
            public void Must_map_the_nested_type_too_by_straight_assignment_when_settable_and_types_are_the_same()
            {
                var person = new Person
                {
                    Name     = "Joe",
                    Employer = new Employer
                    {
                        Name    = "Microsoft",
                        Address = new Address
                        {
                            Street = "1 Microsoft Way",
                            City   = "Redmond"
                        }
                    }
                };

                person.Address = new PersonAddress(person)
                {
                    Street = "123 Main",
                    City   = "Dallas"
                };

                var systemUnderTest = new DefaultMapper <Person, Person>();

                systemUnderTest.Validate();

                var person2 = new Person();

                systemUnderTest.Map(person, person2);

                Assert.That(person2.Name, Is.EqualTo(person.Name));
                Assert.That(person2.Employer, Is.SameAs(person.Employer));
                Assert.That(person2.Employer.Name, Is.EqualTo(person.Employer.Name));
                Assert.That(person2.Employer.Address, Is.SameAs(person.Employer.Address));
                Assert.That(person2.Employer.Address.Street, Is.EqualTo(person.Employer.Address.Street));
                Assert.That(person2.Employer.Address.City, Is.EqualTo(person.Employer.Address.City));
                Assert.That(person2.Address, Is.SameAs(person.Address));
                Assert.That(person2.Address.Street, Is.EqualTo(person.Address.Street));
                Assert.That(person2.Address.City, Is.EqualTo(person.Address.City));
            }