public void StartsAtBeginningReturnsFirstByte() { var buffer = new byte[] { 0x01, 0x02, 0x03 }; using (var memoryStream = new MemoryStream(buffer)) { var reader = new PdfStreamReader(memoryStream, 512); Assert.Equal(0, reader.Position); var expected = 1; var actual = reader.Read(); Assert.Equal(expected, actual); Assert.Equal(1, reader.Position); } }
public void ReadsLastByte() { var buffer = new byte[] { 0x01, 0x02, 0x03 }; using (var memoryStream = new MemoryStream(buffer)) { var reader = new PdfStreamReader(memoryStream, 512); reader.Seek(2, SeekOrigin.Begin); Assert.Equal(2, reader.Position); var expected = 3; var actual = reader.Read(); Assert.Equal(expected, actual); Assert.Equal(3, reader.Position); } }
public void StartsAtMiddleReturnsMiddle() { var buffer = new byte[] { 0x01, 0x02, 0x03 }; using (var memoryStream = new MemoryStream(buffer)) { var reader = new PdfStreamReader(memoryStream, 512); reader.Seek(1, SeekOrigin.Begin); Assert.Equal(1, reader.Position); var expected = 2; var actual = reader.Read(); Assert.Equal(expected, actual); Assert.Equal(2, reader.Position); } }
public void StartsAtEndReturnsNegativeOne() { var buffer = new byte[] { 0x01, 0x02, 0x03 }; using (var memoryStream = new MemoryStream(buffer)) { var reader = new PdfStreamReader(memoryStream, 512); reader.Seek(3, SeekOrigin.Begin); Assert.Equal(3, reader.Position); var expected = -1; var actual = reader.Read(); Assert.Equal(expected, actual); Assert.Equal(3, reader.Position); } }
public void StartsAtBeginningReturnsFullBuffer() { var buffer = new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05 }; using (var memoryStream = new MemoryStream(buffer)) { var reader = new PdfStreamReader(memoryStream, 512); var readBuffer = new byte[2]; Assert.Equal(0, reader.Position); var bytesRead = reader.Read(readBuffer, 0, readBuffer.Length); Assert.Equal(2, reader.Position); Assert.Equal(2, bytesRead); Assert.Equal(new byte[] { 0x01, 0x02 }, readBuffer); } }
public void ReadsPartialAtEnd() { var buffer = new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05 }; using (var memoryStream = new MemoryStream(buffer)) { var reader = new PdfStreamReader(memoryStream, 512); var readBuffer = new byte[2]; reader.Seek(4, SeekOrigin.Begin); Assert.Equal(4, reader.Position); var bytesRead = reader.Read(readBuffer, 0, readBuffer.Length); Assert.Equal(5, reader.Position); Assert.Equal(1, bytesRead); Assert.Equal(new byte[] { 0x05, 0x00 }, readBuffer); } }
public void StartsAtEndReturnsNegativeOne() { var buffer = new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05 }; using (var memoryStream = new MemoryStream(buffer)) { var reader = new PdfStreamReader(memoryStream, 512); var readBuffer = new byte[2]; reader.Seek(5, SeekOrigin.Begin); Assert.Equal(5, reader.Position); var bytesRead = reader.Read(readBuffer, 0, readBuffer.Length); Assert.Equal(5, reader.Position); Assert.Equal(-1, bytesRead); Assert.Equal(new byte[] { 0x00, 0x00 }, readBuffer); } }