public void ReceiveOrSend_GivenTheTimeoutExpiresBeforePreparationCompletes_JustThrowsTheException() { // Arrange preparationInlet.Setup(p => p.Send(It.IsAny <string>(), It.IsAny <TimeSpan>())).Throws <TimeoutException>(); // Act TimeoutException exception = null; try { valve.ReceiveOrSend("Not gonna make it...", TimeSpan.FromMilliseconds(1000)); } catch (TimeoutException e) { exception = e; } // Assert preparationInlet.Verify(p => p.Send(It.IsAny <string>(), It.IsAny <TimeSpan>()), Times.Once); resultOutlet.Verify(r => r.Receive(It.IsAny <TimeSpan>()), Times.Never); exception.Should().NotBeNull(); }
public void ReceiveOrSend_GivenTheTimeoutExpiresDuringReceivingAResult_FlushesTheMessageToBeSentAndThrowsTheException() { // Arrange resultOutlet.Setup(r => r.Receive(It.IsAny <TimeSpan>())).Throws <TimeoutException>(); // Act TimeoutException exception = null; try { valve.ReceiveOrSend("Not gonna make it...", TimeSpan.FromMilliseconds(1000)); } catch (TimeoutException e) { exception = e; } // Assert preparationInlet.Verify(p => p.Send(It.IsAny <string>(), It.IsAny <TimeSpan>()), Times.Once); resultOutlet.Verify(r => r.Receive(It.IsAny <TimeSpan>()), Times.Once); flushOutlet.Verify(f => f.ReceiveImmediately(), Times.Once); exception.Should().NotBeNull(); }