Example #1
0
        public void ShortThenExtend_ReadFixedZeroFilledString_StreamTooShort()
        {
            var stream = new GradualReadMemoryStream(Encoding.ASCII.GetBytes("*ABCD"), 1);
            var reader = new BinaryStreamReader(stream, new byte[20]);

            reader.ReadByte();
            reader.ReadFixedZeroFilledAsciiString(20);
        }
Example #2
0
        public void ReadBytes_Gradual_EOF()
        {
            byte[] input  = new byte[10];
            var    stream = new GradualReadMemoryStream(input, 3, 7);
            var    reader = new BinaryStreamReader(stream, new byte[8]);

            byte[] output = new byte[input.Length + 5];
            reader.ReadBytes(output, 0, output.Length);
        }
Example #3
0
        public void ShortThenExtend_ReadFixedZeroFilledString_Alphabet()
        {
            var stream = new GradualReadMemoryStream(Encoding.ASCII.GetBytes("*ABCDEFGHIJKLMNOPQRSTUVWXYZ"), 1);
            var reader = new BinaryStreamReader(stream, new byte[20]);

            reader.ReadByte();
            string str = reader.ReadFixedZeroFilledAsciiString(26);

            Assert.AreEqual("ABCDEFGHIJKLMNOPQRSTUVWXYZ", str);
        }
Example #4
0
        public void ReadBytes_Gradual()
        {
            byte[] input = new byte[10];
            for (int i = 0; i < input.Length; i++)
            {
                input[i] = (byte)i;
            }
            var stream = new GradualReadMemoryStream(input, 3, 7);
            var reader = new BinaryStreamReader(stream, new byte[8]);

            byte[] output = new byte[input.Length];
            reader.ReadBytes(output, 0, output.Length);

            Assert.AreEqual(input.Length, output.Length);
            for (int i = 0; i < output.Length; i++)
            {
                Assert.AreEqual(input[i], output[i], "output[" + i + "]");
            }
        }
        public void ReadBytes_Gradual()
        {
            byte[] input =new byte[10];
            for (int i = 0; i < input.Length; i++)
            {
                input[i] = (byte)i;
            }
            var stream = new GradualReadMemoryStream(input, 3, 7);
            var reader = new BinaryStreamReader(stream, new byte[8]);
            byte[] output = new byte[input.Length];
            reader.ReadBytes(output, 0, output.Length);

            Assert.AreEqual(input.Length, output.Length);
            for (int i = 0; i < output.Length; i++)
            {
                Assert.AreEqual(input[i], output[i], "output[" + i + "]");
            }
        }
 public void ShortThenExtend_ReadFixedZeroFilledString_StreamTooShort()
 {
     var stream = new GradualReadMemoryStream(Encoding.ASCII.GetBytes("*ABCD"), 1);
     var reader = new BinaryStreamReader(stream, new byte[20]);
     reader.ReadByte();
     reader.ReadFixedZeroFilledAsciiString(20);
 }
 public void ShortThenExtend_ReadFixedZeroFilledString_Alphabet()
 {
     var stream = new GradualReadMemoryStream(Encoding.ASCII.GetBytes("*ABCDEFGHIJKLMNOPQRSTUVWXYZ"), 1);
     var reader = new BinaryStreamReader(stream, new byte[20]);
     reader.ReadByte();
     string str = reader.ReadFixedZeroFilledAsciiString(26);
     Assert.AreEqual("ABCDEFGHIJKLMNOPQRSTUVWXYZ", str);
 }
 public void ReadBytes_Gradual_EOF()
 {
     byte[] input = new byte[10];
     var stream = new GradualReadMemoryStream(input, 3, 7);
     var reader = new BinaryStreamReader(stream, new byte[8]);
     byte[] output = new byte[input.Length + 5];
     reader.ReadBytes(output, 0, output.Length);
 }