Пример #1
0
            public void ShouldThrowExceptionWhenTheresNoBytesToPeek()
            {
                var mockInput = IOExtensions.CreateMockStream(new byte[0]);
                var reader    = new PackStreamReader(mockInput.Object, BoltReader.StructHandlers);

                var ex = Record.Exception(() => reader.PeekByte());

                ex.Should().BeOfType <ProtocolException>();
                mockInput.Verify(x => x.Length, Times.Once);
                mockInput.Verify(x => x.Position, Times.Once);
                mockInput.Verify(x => x.Seek(-1, SeekOrigin.Current), Times.Never);
            }
Пример #2
0
            public void ShouldPeekCorrectly()
            {
                const byte expected  = 1;
                var        mockInput = IOExtensions.CreateMockStream(1, 2, 3);
                var        reader    = new PackStreamReader(mockInput.Object, BoltReader.StructHandlers);

                var real = reader.PeekByte();

                real.Should().Be(expected);
                mockInput.Verify(x => x.ReadByte(), Times.Once);
                mockInput.Verify(x => x.Length, Times.Once);
                mockInput.Verify(x => x.Position, Times.Once);
                mockInput.Verify(x => x.Seek(-1, SeekOrigin.Current), Times.Once);
            }