public void ShouldReadZeroLengthBytes() { var mockInput = IOExtensions.CreateMockStream(PackStream.Bytes8, 0); var reader = new PackStreamReader(mockInput.Object, BoltReader.StructHandlers); var real = reader.ReadBytes(); real.Length.Should().Be(0); }
public void ShouldThrowExceptionIfMarkerByteNotBytes() { var mockInput = IOExtensions.CreateMockStream(PackStream.False); var reader = new PackStreamReader(mockInput.Object, BoltReader.StructHandlers); var ex = Xunit.Record.Exception(() => reader.ReadBytes()); ex.Should().BeOfType <ProtocolException>(); mockInput.Verify(x => x.Read(It.IsAny <byte[]>(), It.IsAny <int>(), It.IsAny <int>()), Times.Once); }
public void ShouldThrowExceptionWhenReadBytes32ReturnsBytesSizeLonggerThanIntMax() { var mockInput = IOExtensions.CreateMockStream(PackStream.Bytes32, PackStreamBitConverter.GetBytes((int)-1)); var reader = new PackStreamReader(mockInput.Object, BoltReader.StructHandlers); var ex = Xunit.Record.Exception(() => reader.ReadBytes()); ex.Should().BeOfType <ProtocolException>(); mockInput.Verify(x => x.Read(It.IsAny <byte[]>(), It.IsAny <int>(), It.IsAny <int>()), Times.Exactly(2)); }
public void ShouldReadBytes8() { var mockInput = IOExtensions.CreateMockStream(PackStream.Bytes8, 1, 0x61); var reader = new PackStreamReader(mockInput.Object, BoltReader.StructHandlers); var real = reader.ReadBytes(); real.Length.Should().Be(1); real.Should().Contain(0x61); mockInput.Verify(x => x.Read(It.IsAny <byte[]>(), It.IsAny <int>(), It.IsAny <int>()), Times.Exactly(3)); }
public void ShouldReadBytes16() { var mockInput = IOExtensions.CreateMockStream(new byte[] { PackStream.Bytes16 }, PackStreamBitConverter.GetBytes((short)1), new byte[] { 0x61 }); var reader = new PackStreamReader(mockInput.Object, BoltReader.StructHandlers); var real = reader.ReadBytes(); real.Length.Should().Be(1); real.Should().Contain(0x61); mockInput.Verify(x => x.Read(It.IsAny <byte[]>(), It.IsAny <int>(), It.IsAny <int>()), Times.Exactly(3)); }