Esempio n. 1
0
        static void TestWriterSeekAndPositon()
        {
            byte[] src = CreateTestArray();

            using (Writer writer = new Writer())
            {
                for (int i = 0; i < src.Length; i++)
                {
                    writer.WriteByte(src[i]);
                }

                for (int i = src.Length / 2; i < src.Length; i++)
                {
                    writer.Seek(i, SeekOrigin.Begin);
                    UnitTest.Test(writer.Position == i);

                    writer.WriteByte(src[i]);
                }
                UnitTest.Test(writer.Position == src.Length);
                UnitTest.Test(ArrayUtils.IsEqual(src, writer.OutData));
            }

        }
Esempio n. 2
0
        static void TestWriter()
        {
            byte[] src = CreateTestArray();

            using (Writer writer = new Writer())
            {
                for (int i = 0; i < src.Length; ++i)
                {
                    UnitTest.Test(writer.Position == i);
                    writer.WriteByte(src[i]);
                }

                UnitTest.Test(writer.UnsynchronizationCounter == 0);
                UnitTest.Test(ArrayUtils.IsEqual(src, writer.OutData));
            }
        }
Esempio n. 3
0
        private static void TestWriterUnsynchronization(byte[] src, byte[] dst, int unsynchronizationCount)
        {
            byte[] result = null;

            using (Writer writer = new Writer())
            {
                writer.Unsynchronization = true;

                for (int i = 0; i < src.Length; ++i)
                {
                    writer.WriteByte(src[i]);
                }
                UnitTest.Test(writer.UnsynchronizationCounter == unsynchronizationCount);
                result = writer.OutData;
            }

            UnitTest.Test(ArrayUtils.IsEqual(result, dst));
        }
Esempio n. 4
0
 public override void WriteByte(byte value)
 {
     writer.WriteByte(value);
 }