Esempio n. 1
0
        public void AssertAreEqual(SampleArrayNDim actual)
        {
            AssertBoundsAreEqual(A, actual.A);
            if (A.Length > 0)
            {
                Assert.AreEqual(
                    A[A.GetLowerBound(0), A.GetLowerBound(1)],
                    actual.A[A.GetLowerBound(0), A.GetLowerBound(1)]);
            }
            if (A.Length > 1)
            {
                Assert.AreEqual(
                    A[A.GetUpperBound(0), A.GetUpperBound(1)],
                    actual.A[A.GetUpperBound(0), A.GetUpperBound(1)]);
            }

            if (B == null)
            {
                Assert.IsNull(actual.B);
                return;
            }
            AssertBoundsAreEqual(B, actual.B);
            if (B.Length > 0)
            {
                Assert.AreEqual(
                    B[B.GetLowerBound(0), B.GetLowerBound(1), B.GetLowerBound(2)],
                    actual.B[B.GetLowerBound(0), B.GetLowerBound(1), B.GetLowerBound(2)]);
            }
            if (B.Length > 1)
            {
                Assert.AreEqual(
                    B[B.GetUpperBound(0), B.GetUpperBound(1), B.GetUpperBound(2)],
                    actual.B[B.GetUpperBound(0), B.GetUpperBound(1), B.GetUpperBound(2)]);
            }
        }
Esempio n. 2
0
 public void TestArrayNDim()
 {
     TestGen(cl => {
         var src = new SampleArrayNDim {
             A = new int[2, 2] {
                 { 1, 2 }, { 3, 4 }
             },
             B = new string[1, 1, 1] {
                 { { "x" } }
             }
         };
         var dst = cl.Deep(src);
         Assert.AreNotEqual(src, dst);
         Assert.AreNotEqual(src.A, dst.A);
         Assert.AreNotEqual(src.B, dst.B);
         src.AssertAreEqual(dst);
     });
     TestGen(cl => {
         var src = new List <int>[2, 1] {
             { new List <int> {
                   1, 2
               } }, { new List <int> {
                          3
                      } }
         };
         var dst = cl.Deep(src);
         Assert.AreNotEqual(src, dst);
         Assert.AreNotEqual(src[0, 0], dst[0, 0]);
         Assert.AreEqual(src.GetUpperBound(0), dst.GetUpperBound(0));
         CollectionAssert.AreEqual(src[0, 0], dst[0, 0]);
         CollectionAssert.AreEqual(src[1, 0], dst[1, 0]);
     });
     TestGen(cl => {
         var src = new SampleArrayNDimOfClass {
             A = new Sample1[1, 1, 2] {
                 { { new Sample1 {
                         X = 8, Y = "q"
                     }, null } }
             },
         };
         var dst = cl.Deep(src);
         Assert.AreNotEqual(src, dst);
         Assert.AreNotEqual(src.A, dst.A);
         Assert.AreEqual(src.A[0, 0, 0].X, dst.A[0, 0, 0].X);
     });
 }