Пример #1
0
        public void copyFieldsTesting_SimpleClass()
        {
            Dude d   = new Dude("Valera", 22, Dude.Sex.Male);
            Dude res = new Dude();

            Copier.CopyUsingSerializer(d, res);
            Assert.AreEqual(d, res);
        }
Пример #2
0
        public void copyFieldsTesting_ReverseInheritation()
        {
            Parent d   = new Parent("Vitaliy", 44, Dude.Sex.Female, 4);//subclass of Dude
            Dude   res = new Dude("Valera", 22, Dude.Sex.Male);

            Copier.CopyUsingSerializer(d, res);
            bool match = d.name == res.name && d.age == res.age && d.sex == res.sex;

            Assert.IsTrue(match);
        }
Пример #3
0
 public void copyFieldsTesting_Null()
 {
     try
     {
         Dude d   = null;
         Dude res = new Dude();
         Copier.CopyUsingSerializer(d, res);
         Assert.Fail();
     }
     catch
     { Assert.IsTrue(true); }
 }
Пример #4
0
 public void copyFieldsTesting_BrakeReference()
 {
     try
     {
         Dude d   = new Dude();
         Dude res = new Dude();
         Copier.CopyUsingSerializer(d, res);
         d.age = res.age + 1;
         Assert.AreNotEqual(d.age, res.age);
     }
     catch (Exception e)
     { Assert.Fail(e.Message); }
 }
Пример #5
0
 public void copyFieldsTesting_BrakeReferenceInList()
 {
     try
     {
         List <Dude> dudes = new List <Dude>()
         {
             new Dude()
         };
         List <Dude> res = new List <Dude>();
         Copier.CopyUsingSerializer(dudes, res, false);
         dudes[0].age = 2;
         Assert.AreNotEqual(dudes[0].age, res[0].age);
     }
     catch (NotSupportedException e)
     {
     }
     catch (Exception e)
     { Assert.Fail(e.Message); }
 }