示例#1
0
        public void BinaryMatrix3DConstructorTest()
        {
            bool[][][] initialData = new bool[8][][];
             for (int x = 0; x < 8; x++)
             {
            initialData[x] = new bool[8][];
            for (int y = 0; y < 8; y++)
            {
               initialData[x][y] = new bool[8];
            }
             }

             BinaryMatrix3D target = new BinaryMatrix3D(initialData);

             // check all zeros
             for (int x = 0; x < 8; x++)
             {
            for (int y = 0; y < 8; y++)
            {
               for (int z = 0; z < 8; z++)
               {
                  bool received = target.Get(x, y, z);
                  Assert.IsTrue(!received, "Excepted false but received " + received.ToString());
               }
            }
             }

             // create with a random matrix
             Random r = new Random();
             for (int x = 0; x < 8; x++)
             {
            for (int y = 0; y < 8; y++)
            {
               for (int z = 0; z < 8; z++)
               {
                  initialData[x][y][z] = (r.Next(2) == 1);
               }
            }
             }

             target = new BinaryMatrix3D(initialData);
             // check against expected
             for (int x = 0; x < 8; x++)
             {
            for (int y = 0; y < 8; y++)
            {
               for (int z = 0; z < 8; z++)
               {
                  bool received = target.Get(x, y, z);
                  Assert.IsTrue(received == initialData[x][y][z], "Excepted " + initialData[x][y][z] + " but received " + received.ToString());
               }
            }
             }
        }
示例#2
0
        public void UpdateMatrixTest()
        {
            BinaryMatrix3D target = new BinaryMatrix3D();

             bool[][][] expected = new bool[8][][];
             for (int x = 0; x < 8; x++)
             {
            expected[x] = new bool[8][];
            for (int y = 0; y < 8; y++)
            {
               expected[x][y] = new bool[8];
            }
             }

             target.UpdateMatrix(expected);

             // check all zeros
             for (int x = 0; x < 8; x++)
             {
            for (int y = 0; y < 8; y++)
            {
               for (int z = 0; z < 8; z++)
               {
                  bool received = target.Get(x, y, z);
                  Assert.IsTrue(!received, "Excepted false but received " + received.ToString());
               }
            }
             }

             // create with a random matrix
             Random r = new Random();
             for (int x = 0; x < 8; x++)
             {
            for (int y = 0; y < 8; y++)
            {
               for (int z = 0; z < 8; z++)
               {
                  expected[x][y][z] = (r.Next(2) == 1);
               }
            }
             }

             target.UpdateMatrix(expected);
             // check against expected
             for (int x = 0; x < 8; x++)
             {
            for (int y = 0; y < 8; y++)
            {
               for (int z = 0; z < 8; z++)
               {
                  bool received = target.Get(x, y, z);
                  Assert.IsTrue(received == expected[x][y][z], "Excepted " + expected[x][y][z] + " but received " + received.ToString());
               }
            }
             }
        }
示例#3
0
        public void GetSetTest()
        {
            BinaryMatrix3D target = new BinaryMatrix3D();
             bool[][][] expected = new bool[8][][];
             for (int x = 0; x < 8; x++)
             {
            expected[x] = new bool[8][];
            for (int y = 0; y < 8; y++)
            {
               expected[x][y] = new bool[8];
            }
             }

             Random r = new Random();
             for (int pass = 1; pass < 4; pass++)
             {
            // store values
            for (int x = 0; x < 8; x++)
            {
               for (int y = 0; y < 8; y++)
               {
                  for (int z = 0; z < 8; z++)
                  {
                     expected[x][y][z] = (r.Next(2) == 1);
                     target.Set(x, y, z, expected[x][y][z]);
                  }
               }
            }

            // check values
            for (int x = 0; x < 8; x++)
            {
               for (int y = 0; y < 8; y++)
               {
                  for (int z = 0; z < 8; z++)
                  {
                     bool received = target.Get(x, y, z);
                     Assert.IsTrue(received == expected[x][y][z], "Pass " + pass + " Excepted " + expected[x][y][z] + " but received " + received.ToString());
                  }
               }
            }
             }
        }