Beispiel #1
0
        public void testWrite_Large()
        {
            const int buflen = SideBandOutputStream.MAX_BUF - SideBandOutputStream.HDR_SIZE;

            byte[] buf = new byte[buflen];
            for (int i = 0; i < buf.Length; i++)
            {
                buf[i] = (byte)i;
            }

            SideBandOutputStream o;

            o = new SideBandOutputStream(SideBandOutputStream.CH_DATA, SideBandOutputStream.MAX_BUF, rawOut);
            o.Write(buf, 0, buf.Length);
            o.Flush();
            byte[] act    = rawOut.ToArray();
            string explen = NB.DecimalToBase(buf.Length + SideBandOutputStream.HDR_SIZE, 16);

            Assert.AreEqual(SideBandOutputStream.HDR_SIZE + buf.Length, act.Length);
            Assert.AreEqual(Charset.forName("UTF-8").GetString(act, 0, 4), explen);
            Assert.AreEqual(1, act[4]);
            for (int i = 0, j = SideBandOutputStream.HDR_SIZE; i < buf.Length; i++, j++)
            {
                Assert.AreEqual(buf[i], act[j]);
            }
        }
 public void testWrite_CH_ERROR()
 {
     SideBandOutputStream o;
     o = new SideBandOutputStream(SideBandOutputStream.CH_ERROR, pckOut);
     byte[] b = new byte[] { (byte)'a', (byte)'b', (byte)'c' };
     o.Write(b, 0, b.Length);
     assertBuffer("0008\x03" + "abc");
 }
Beispiel #3
0
        public void testWrite_SmallBlocks2()
        {
            SideBandOutputStream o;

            o = new SideBandOutputStream(SideBandOutputStream.CH_DATA, 6, rawOut);
            o.Write(new byte[] { (byte)'a', (byte)'b', (byte)'c' }, 0, 3);
            o.Flush();
            assertBuffer("0006\x01" + "a0006\x01" + "b0006\x01" + "c");
        }
        public void testWrite_CH_ERROR()
        {
            SideBandOutputStream o;

            o = new SideBandOutputStream(SideBandOutputStream.CH_ERROR, pckOut);
            byte[] b = new byte[] { (byte)'a', (byte)'b', (byte)'c' };
            o.Write(b, 0, b.Length);
            assertBuffer("0008\x03" + "abc");
        }
Beispiel #5
0
        public void testWrite_CH_PROGRESS()
        {
            SideBandOutputStream o;

            o = new SideBandOutputStream(SideBandOutputStream.CH_PROGRESS, SideBandOutputStream.SMALL_BUF, rawOut);
            byte[] b = new byte[] { (byte)'a', (byte)'b', (byte)'c' };
            o.Write(b, 0, b.Length);
            o.Flush();
            assertBuffer("0008\x02" + "abc");
        }
        public void testWrite_Small()
        {
            SideBandOutputStream o;

            o = new SideBandOutputStream(SideBandOutputStream.CH_DATA, pckOut);
            o.WriteByte((byte)'a');
            o.WriteByte((byte)'b');
            o.WriteByte((byte)'c');
            assertBuffer("0006\x01" + "a0006\x01" + "b0006\x01" + "c");
        }
Beispiel #7
0
        public void testWrite_Small()
        {
            SideBandOutputStream o;

            o = new SideBandOutputStream(SideBandOutputStream.CH_DATA, SideBandOutputStream.SMALL_BUF, rawOut);
            o.WriteByte((byte)'a');
            o.WriteByte((byte)'b');
            o.WriteByte((byte)'c');
            o.Flush();
            assertBuffer("0008\x01" + "abc");
        }
        public void testWrite_Large()
        {
            const int buflen = SideBandOutputStream.MAX_BUF - SideBandOutputStream.HDR_SIZE;
            byte[] buf = new byte[buflen];
            for (int i = 0; i < buf.Length; i++)
                buf[i] = (byte) i;

            SideBandOutputStream o;
            o = new SideBandOutputStream(SideBandOutputStream.CH_DATA, pckOut);
            o.Write(buf, 0, buf.Length);

            byte[] act = rawOut.ToArray();
            string explen = NB.DecimalToBase(buf.Length + 5, 16);
            Assert.AreEqual(5 + buf.Length, act.Length);
            Assert.AreEqual(Constants.CHARSET.GetString(act, 0, 4).ToUpper(), explen.ToUpper());
            Assert.AreEqual(1, act[4]);
            for (int i = 0, j = 5; i < buf.Length; i++, j++)
                Assert.AreEqual(buf[i], act[j]);
        }
 public void testWrite_Small()
 {
     SideBandOutputStream o;
     o = new SideBandOutputStream(SideBandOutputStream.CH_DATA, pckOut);
     o.WriteByte((byte)'a');
     o.WriteByte((byte)'b');
     o.WriteByte((byte)'c');
     assertBuffer("0006\x01" + "a0006\x01" + "b0006\x01" + "c");
 }