public void GetStreamData_Test() { MemoryStream ms = new MemoryStream(); PDFIndirectObject indobj = new PDFIndirectObject(this); PDFStream target = new StreamProxy(ms, _usefilters, indobj, false); byte[] expected = new byte[] {}; byte[] actual; actual = target.GetStreamData(); Assert.AreEqual(expected.Length, actual.Length); expected = new byte[] { 1, 2, 3, 4, 5 }; target.Write(expected); target.Flush(); actual = target.GetStreamData(); Assert.AreEqual(expected.Length, actual.Length); for (int i = 0; i < expected.Length; i++) { Assert.AreEqual(expected[i], actual[i]); } target.Dispose(); ms.Dispose(); indobj.Dispose(); }
public void Write() { var bytes = new byte[] { 0, 1, 2, 3, 4, 5, }; var src = new MemoryStream(bytes); var dest = new StreamProxy(src); Assert.That(dest.Seek(1, SeekOrigin.Begin), Is.EqualTo(1L)); dest.SetLength(4); dest.Write(new byte[] { 9, 9, 9 }, 0, 3); dest.Flush(); Assert.That(bytes[0], Is.EqualTo((byte)0)); Assert.That(bytes[1], Is.EqualTo((byte)9)); Assert.That(bytes[2], Is.EqualTo((byte)9)); Assert.That(bytes[3], Is.EqualTo((byte)9)); Assert.That(bytes[4], Is.EqualTo((byte)4)); dest.Dispose(); Assert.That(() => dest.Write(new byte[] { 1 }, 0, 1), Throws.TypeOf <NullReferenceException>()); }
public void Write_Test1() { PDFIndirectObject indobj = new PDFIndirectObject(this); PDFStream target = new StreamProxy(_usefilters, indobj); byte[] expected = new byte[] { 1, 2, 3, 4, 5 }; target.Write(expected); target.Flush(); byte[] actual = target.GetStreamData(); CompareByteArray(expected, actual); target.Dispose(); indobj.Dispose(); }
public void Write_Test2() { PDFIndirectObject indobj = new PDFIndirectObject(this); PDFStream target = new StreamProxy(_usefilters, indobj); string source = "Hello world"; target.Write(source); target.Flush(); byte[] actual = target.GetStreamData(); byte[] expected = System.Text.Encoding.ASCII.GetBytes(source); CompareByteArray(expected, actual); target.Dispose(); indobj.Dispose(); }
public void Write_Test() { PDFIndirectObject indobj = new PDFIndirectObject(this); PDFStream target = new StreamProxy(_usefilters, indobj); byte[] expected = new byte[] { 0, 10, 1, 2, 3, 4, 5, 34, 35 }; target.Write(expected, 2, 5); target.Flush(); byte[] actual = target.GetStreamData(); byte[] copied = new byte[5]; Array.Copy(expected, 2, copied, 0, 5); CompareByteArray(copied, actual); target.Dispose(); indobj.Dispose(); }
public void Length_Test() { MemoryStream ms = new MemoryStream(); PDFIndirectObject indobj = new PDFIndirectObject(this); PDFStream target = new StreamProxy(ms, _usefilters, indobj, false); long expected = ms.Length; long actual = target.Length; Assert.AreEqual(expected, actual); target.WriteLine("This is a test of the length"); target.Write(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }); target.Flush(); expected = ms.Length; actual = target.Length; Assert.AreEqual(expected, actual); target.Dispose(); indobj.Dispose(); }