public void Consumer_RejectDeliveredMessage_ShouldCallMerQureRejectDeliveredMessagee() { //Arrange TestMessage testMessage = TestMessage.GetFilledTestMessage(); //Act _consumer.RejectDeliveredMessage(new Channel(""), testMessage); //Assert _mockMerQureConsumer.Verify(m => m.RejectDeliveredMessage(testMessage)); }
public void Consumer_AcknowlegdeDeliveredMessage_ShouldCallMerQureAcknowledgdeDelivredMessage() { //Arrange TestMessage testMessage = TestMessage.GetFilledTestMessage(); //Act _consumer.AcknowlegdeDeliveredMessage(new Channel(""), testMessage); //Assert _mockMerQureConsumer.Verify(m => m.AcknowlegdeDeliveredMessage(testMessage)); }
private static RetryMessage <TestMessage> GetFilledRetryMessage(int numberOfRetry) { return(new RetryMessage <TestMessage> { OriginalMessage = TestMessage.GetFilledTestMessage(), RetryInformations = new RetryInformations { NumberOfRetry = numberOfRetry } }); }
public void Publisher_Publish_ShouldThrow_WhenPublishFailed() { //Arrange Channel channel = new Channel("testChannel"); TestMessage message = TestMessage.GetFilledTestMessage(); _mockMessagingService.Setup(m => m.GetPublisher(It.IsAny <string>(), true)).Returns(_mockMerQurePublisher.Object); _mockMerQurePublisher.Setup(p => p.PublishWithAcknowledgement(It.IsAny <string>(), It.IsAny <string>())).Returns(false); //Act && Assert Assert.Throws <MerqureToolsException>(() => _publisher.Publish(channel, message, false)); }
public void Publisher_PublishWithTransaction_ShouldThrow_WhenPublishWithTransactionFailed() { //Arrange Channel channel = new Channel("testChannel"); var messages = new List <TestMessage> { TestMessage.GetFilledTestMessage() }; _mockMessagingService.Setup(m => m.GetPublisher(It.IsAny <string>(), false)).Returns(_mockMerQurePublisher.Object); _mockMerQurePublisher.Setup(p => p.PublishWithTransaction(It.IsAny <string>(), It.IsAny <List <string> >())).Throws <Exception>(); //Act && Assert Assert.Throws <MerqureToolsException>(() => _publisher.PublishWithTransaction(channel, messages, false)); }
public void Publisher_Publish_MessageShouldBePublishedOnRightBusAndChannel() { //Arrange Channel channel = new Channel("testChannel"); TestMessage message = TestMessage.GetFilledTestMessage(); _mockMessagingService.Setup(m => m.GetPublisher(It.IsAny <string>(), true)).Returns(_mockMerQurePublisher.Object); _mockMerQurePublisher.Setup(p => p.PublishWithAcknowledgement(It.IsAny <string>(), It.IsAny <string>())).Returns(true); //Act _publisher.Publish(channel, message, false); //Assert _mockMessagingService.Verify(p => p.GetPublisher(It.Is <string>(busName => busName.Contains(_retryStrategy.BusName)), true)); _mockMerQurePublisher.Verify(p => p.PublishWithAcknowledgement(It.Is <string>(channelName => channelName.Contains(channel.Value)), It.IsAny <string>()), Times.Once); }
public void Publisher_PublishOnRetryExchange_MessageShouldBePublishedOnRightBusAndChannel() { Channel channel = new Channel("testChannel"); TestMessage message = TestMessage.GetFilledTestMessage(); _mockMessagingService.Setup(m => m.GetPublisher(It.IsAny <string>(), true)).Returns(_mockMerQurePublisher.Object); _mockMerQurePublisher.Setup(p => p.PublishWithAcknowledgement(It.IsAny <string>(), It.IsAny <string>())).Returns(true); _publisher.PublishOnRetryExchange(channel, message, new RetryInformations { NumberOfRetry = 0 }); _mockMessagingService.Verify(p => p.GetPublisher(It.Is <string>(busName => busName.Contains(_retryStrategy.BusName)), true)); _mockMerQurePublisher.Verify(p => p.PublishWithAcknowledgement(It.Is <string>(channelName => channelName.Contains(channel.Value)), It.IsAny <string>()), Times.Once); }
public void Publisher_PublishOnRetryExchange_QueueNameShouldContainsFirstDelay_WhenItsTheFirstRetry() { Channel channel = new Channel("testChannel"); TestMessage message = TestMessage.GetFilledTestMessage(); _mockMessagingService.Setup(m => m.GetPublisher(It.IsAny <string>(), true)).Returns(_mockMerQurePublisher.Object); _mockMerQurePublisher.Setup(p => p.PublishWithAcknowledgement(It.IsAny <string>(), It.IsAny <string>())).Returns(true); _publisher.PublishOnRetryExchange(channel, message, new RetryInformations { NumberOfRetry = 0 }); _mockMessagingService.Verify(p => p.GetPublisher(It.Is <string>(busName => busName.Contains(_retryStrategy.BusName)), true)); _mockMerQurePublisher.Verify(p => p.PublishWithAcknowledgement(It.Is <string>(channelName => channelName.Contains(_retryStrategy.DelaysInMsBetweenEachRetry.First().ToString())), It.IsAny <string>()), Times.Once); }
public void Publisher_PublishWithTransaction_MessageShouldBePublishedOnRightBusAndChannel() { //Arrange Channel channel = new Channel("testChannel"); var messages = new List <TestMessage> { TestMessage.GetFilledTestMessage() }; _mockMessagingService.Setup(m => m.GetPublisher(It.IsAny <string>(), false)).Returns(_mockMerQurePublisher.Object); //Act _publisher.PublishWithTransaction(channel, messages, false); //Assert _mockMessagingService.Verify(p => p.GetPublisher(It.Is <string>(busName => busName.Contains(_retryStrategy.BusName)), false)); _mockMerQurePublisher.Verify(p => p.PublishWithTransaction(It.Is <string>(channelName => channelName.Contains(channel.Value)), It.IsAny <List <string> >()), Times.Once); }