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)); } }
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)); } }
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)); }
public override void WriteByte(byte value) { writer.WriteByte(value); }