コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        public void IsCompleteShouldExecuteCompleteEventHandlerIfAllPacketsHaveBeenRead()
        {
            // Arrange
            var stream = new MessageBusReadStream { LastPacketNumber = 3, CompleteEventHandler = CompleteEventHandler };
            var bytes = new byte[10];
            stream.Write(bytes, 1);
            stream.Write(bytes, 2);
            stream.Read();
            stream.Read();

            // Act
            stream.IsComplete();

            // Assert
            Assert.True(_complete);
        }