示例#1
0
            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);
            }
示例#2
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);
            }
示例#3
0
            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));
            }
示例#4
0
            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));
            }
示例#5
0
            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));
            }