Exemple #1
0
        public void TestReadFromBytes()
        {
            IntegerField field = new IntegerField(1);

            byte[] array = new byte[4];

            try
            {
                field.ReadFromBytes(array);
                Assert.Fail("should have caught IndexOutOfRangeException");
            }
            catch (IndexOutOfRangeException)
            {
                // as expected
            }
            field = new IntegerField(0);
            for (int j = 0; j < _test_array.Length; j++)
            {
                array[0] = ( byte )(_test_array[j] % 256);
                array[1] = ( byte )((_test_array[j] >> 8) % 256);
                array[2] = ( byte )((_test_array[j] >> 16) % 256);
                array[3] = ( byte )((_test_array[j] >> 24) % 256);
                field.ReadFromBytes(array);
                Assert.AreEqual(_test_array[j], field.Value, "testing " + j);
            }
        }