Beispiel #1
0
        public void ArrayOneDimensionCompressedTest()
        {
            byte[] _testArray    = new byte[] { 5, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0 };
            Array  _EncodedArray = null;

            using (MemoryStream _stream = new MemoryStream(_testArray))
                using (TestBinaryReader _buffer = new TestBinaryReader(_stream))
                {
                    Assert.IsNotNull(_buffer);
                    _EncodedArray = _buffer.ReadArray <Int32>(_buffer, _buffer.ReadInt32, false);
                    _buffer.Close();
                }
            Assert.IsNotNull(_EncodedArray);
            Assert.AreEqual <int>(1, _EncodedArray.Rank);
            Assert.IsInstanceOfType(_EncodedArray, typeof(Array));
            Assert.AreEqual <int>(5, _EncodedArray.GetLength(0));
            CollectionAssert.AreEqual(new Int32[] { 0, 1, 2, 3, 4 }, _EncodedArray);
        }
Beispiel #2
0
        public void ArrayMultiDimensionTest()
        {
            byte[] _testArray    = new byte[] { 198, 4, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0 };
            Array  _EncodedArray = null;

            using (MemoryStream _stream = new MemoryStream(_testArray))
                using (TestBinaryReader _buffer = new TestBinaryReader(_stream))
                {
                    Assert.IsNotNull(_buffer);
                    _EncodedArray = _buffer.ReadArray <Int32>(_buffer, _buffer.ReadInt32, true);
                    Assert.Fail();
                    _buffer.Close();
                }
            Assert.IsNotNull(_EncodedArray);
            Assert.AreEqual <int>(2, _EncodedArray.Rank);
            Assert.IsInstanceOfType(_EncodedArray, typeof(Array));
            Assert.AreEqual <int>(4, _EncodedArray.Length);
            CollectionAssert.AreEqual(new Int32[] { 0, 1, 2, 3 }, _EncodedArray);
        }