public void IsCompleteShouldReturnFalseIfAllPacketsHaveBeenRead()
        {
            // Arrange
            var stream = new MessageBusReadStream {
                LastPacketNumber = 3, CompleteEventHandler = CompleteEventHandler
            };
            var bytes = new byte[10];

            stream.Write(bytes, 1);
            stream.Write(bytes, 2);

            // Act
            var result = stream.IsComplete();

            // Assert
            Assert.False(result);
        }
        public void IsCompleteShouldNotExecuteCompleteEventHandlerIfAllPacketsHaveBeenRead()
        {
            // Arrange
            var stream = new MessageBusReadStream {
                LastPacketNumber = 3, CompleteEventHandler = CompleteEventHandler
            };
            var bytes = new byte[10];

            stream.Write(bytes, 1);
            stream.Write(bytes, 2);
            stream.Read();

            // Act
            stream.IsComplete();

            // Assert
            Assert.False(_complete);
        }
        public void ShouldReadPacketAfterWritingToStream()
        {
            // Arrange
            var stream = new MessageBusReadStream();
            var bytes  = new byte[10];

            stream.Write(bytes, 1);

            // Act
            var result = stream.Read();

            // Assert
            Assert.Equal(bytes, result);
        }
        public void ShouldNotReadFromStreamIfPacketNumberHasntYetBeenWritten()
        {
            // Arrange
            var stream = new MessageBusReadStream();
            var bytes  = new byte[10];

            stream.Write(bytes, 2);

            // Act
            var result = stream.Read();

            // Assert
            Assert.Empty(result);
            Assert.NotEqual(bytes, result);
        }