Exemple #1
0
 public void TestCollection()
 {
     TestGen(cl => {
         var src = new List <string> {
             "s1", "s2"
         };
         var dst = cl.Deep(src);
         Assert.AreNotEqual(src, dst);
         CollectionAssert.AreEqual(src, dst);
     });
     TestGen(cl => {
         var src = new List <Sample1> {
             new Sample1 {
                 X = 34
             }
         };
         var dst = cl.Deep(src);
         Assert.AreNotEqual(src, dst);
         Assert.AreEqual(src.Count, dst.Count);
         Assert.AreNotEqual(src[0], dst[0]);
         Assert.AreEqual(src[0].X, dst[0].X);
     });
     TestGen(cl => {
         var src = new SampleList {
             E = new List <string> {
                 "sq"
             }
         };
         var dst = cl.Deep(src);
         Assert.AreNotEqual(src, dst);
         Assert.AreEqual(src.E.Count, dst.E.Count);
         Assert.AreNotEqual(src.E, dst.E);
         Assert.AreEqual(src.E[0], dst.E[0]);
     });
     TestGen(cl => {
         var src = new SampleMatrix {
             M = new List <List <int> > {
                 new List <int> {
                     1, 2, 3
                 },
                 new List <int> {
                     4
                 },
             }
         };
         var dst = cl.Deep(src);
         Assert.AreNotEqual(src, dst);
         Assert.AreNotEqual(src.M, dst.M);
         Assert.AreNotEqual(src.M[0], dst.M[0]);
         CollectionAssert.AreEqual(src.M[0], dst.M[0]);
         CollectionAssert.AreEqual(src.M[1], dst.M[1]);
     });
     TestGen(cl => {
         var src = new SampleCollection <int> {
             1, 5
         };
         var dst = cl.Deep(src);
         Assert.AreNotEqual(src, dst);
         int[] srcA = new int[2], dstA = new int[2];
         src.CopyTo(srcA, 0);
         dst.CopyTo(dstA, 0);
         CollectionAssert.AreEqual(srcA, dstA);
     });
     TestGen(cl => {
         var src = new SampleExplicitCollection <int>();
         ((ICollection <int>)src).Add(1);
         ((ICollection <int>)src).Add(5);
         var dst = cl.Deep(src);
         Assert.AreNotEqual(src, dst);
         CollectionAssert.AreEqual(src.ToList(), dst.ToList());
     });
 }