コード例 #1
0
        public void TestReadFromStream()
        {
            IntegerField field = new IntegerField(0);

            byte[] buffer = new byte[_test_array.Length * 4];

            for (int j = 0; j < _test_array.Length; j++)
            {
                buffer[(j * 4) + 0] = ( byte )(_test_array[j] % 256);
                buffer[(j * 4) + 1] = ( byte )((_test_array[j] >> 8) % 256);
                buffer[(j * 4) + 2] = ( byte )((_test_array[j] >> 16) % 256);
                buffer[(j * 4) + 3] = ( byte )((_test_array[j] >> 24) % 256);
            }
            MemoryStream stream = new MemoryStream(buffer);

            for (int j = 0; j < buffer.Length / 4; j++)
            {
                field.ReadFromStream(stream);
                Assert.AreEqual(_test_array[j], field.Value, "Testing " + j);
            }
        }