Beispiel #1
0
        public void CopyPropertiesTest1()
        {
            var pi1 = new PhoneItem()
            {
                FaxNumber = "456598784532", PhoneNumber = "124565789854"
            };
            var pi2 = new PhoneItem()
            {
                FaxNumber = "789874654312", PhoneNumber = "684763251325"
            };
            var phoneItems = new List <PhoneItem>()
            {
                pi1, pi2
            };
            var address = new Address()
            {
                Id = 1, City = "Rennes", Street = "rue de la paix"
            };

            var objOrigin = new Employee {
                Id = 0, Name = "Bernard", Password = "******", Address = address, PhoneItems = phoneItems
            };
            var objDestination = new Customer();

            CopyUtils.CopyProperties(objDestination, objOrigin);

            Assert.IsTrue(objDestination.Id.Equals(objOrigin.Id));
            Assert.IsNull(objDestination.GetName());
            Assert.IsNull(objDestination.Address);
            Assert.IsNull(objDestination.Emails);
        }
Beispiel #2
0
 /// <summary>
 /// Copy property values from the origin bean to the destination bean for all cases where the property names are the same.
 /// </summary>
 /// <param name="dest">object</param>
 /// <param name="orig">object</param>
 public static void CopyProperties(object dest, object orig)
 {
     try {
         CopyUtils.CopyProperties(dest, orig);
     } catch (ArgumentNullException e) {
         Logger.Error(e, "An error occured while executing method: CopyProperties ");
     }
 }
Beispiel #3
0
        public void CopyPropertiesTest2()
        {
            var address = new CompleteAddress()
            {
                Id = 0, City = "Rennes", Street = "rue de la paix", State = 33, Country = "France"
            };
            var email1 = "*****@*****.**";
            var email2 = "*****@*****.**";
            var emails = new List <string>()
            {
                email1, email2
            };

            var objOrigin = new Customer {
                Id = 0, Address = address, Emails = emails
            };
            var objDestination = new Employee();

            CopyUtils.CopyProperties(objDestination, objOrigin);

            Assert.IsTrue(objDestination.Id.Equals(objOrigin.Id));
            Assert.IsNull(objDestination.Name);
            Assert.IsTrue(objDestination.Address.Equals(objOrigin.Address));
        }