Пример #1
0
        public void TestCopy_TestPhoneDto_Succeeds()
        {
            var phoneDto = new TestPhoneDto { PhoneNumber = "123-456-7890" };

            var copyPhoneDto = phoneDto.DeepCopy ();

            Assert.AreEqual ( phoneDto.PhoneNumber, copyPhoneDto.PhoneNumber );

            phoneDto.PhoneNumber = "new";

            Assert.AreEqual ( "123-456-7890", copyPhoneDto.PhoneNumber );
        }
Пример #2
0
        public void TestCopy_TestPersonDto_Succeeds()
        {
            var personPersonDto = new TestPersonDto { BirthDate = DateTime.Today.AddDays ( -1 ), FirstName = "Donald", LastName = "Duck" };

            var phoneDto = new TestPhoneDto { PhoneNumber = "123-456-7890" };

            personPersonDto.Phones.Add ( phoneDto );

            var copyPersonDto = personPersonDto.DeepCopy ();

            Assert.AreEqual ( personPersonDto.FirstName, copyPersonDto.FirstName );
            Assert.AreEqual ( personPersonDto.LastName, copyPersonDto.LastName );
            Assert.AreEqual ( personPersonDto.BirthDate, copyPersonDto.BirthDate );
            Assert.AreEqual ( personPersonDto.Phones.Count, copyPersonDto.Phones.Count );
            Assert.AreNotEqual ( personPersonDto.Phones[0].GetHashCode (), copyPersonDto.Phones[0].GetHashCode () );

            //change the phone number object
            var newPhoneDto = new TestPhoneDto { PhoneNumber = "987-654-3210" };

            personPersonDto.Phones[0] = newPhoneDto;

            Assert.AreEqual ( "123-456-7890", copyPersonDto.Phones[0].PhoneNumber );
        }