public void SQSSenderSetsMessageGroupIdWhenSpecifiedInConstructor() { var mockSqs = new Mock <IAmazonSQS>(); using (var sender = new SQSSender(mockSqs.Object, "foo", "http://url.com/foo", "abc")) sender.Send(new SenderMessage("")); mockSqs.Verify(m => m.SendMessageAsync( It.Is <SendMessageRequest>(r => r.MessageGroupId == "abc"), It.IsAny <CancellationToken>())); }
public void SQSSenderSendsMessagesToItsIAmazonSQS() { var mockSqs = new Mock <IAmazonSQS>(); using (var sender = new SQSSender(mockSqs.Object, "foo", "http://url.com/foo")) sender.Send(new SenderMessage("Hello, world!") { Headers = { { "bar", "abc" } } }); mockSqs.Verify(m => m.SendMessageAsync( It.Is <SendMessageRequest>(r => r.MessageBody == "Hello, world!" && r.MessageAttributes[HeaderNames.OriginatingSystem].StringValue == "SQS" && r.MessageAttributes["bar"].StringValue == "abc"), It.IsAny <CancellationToken>())); }
public void SQSSenderSetsMessageDeduplicationIdWhenSpecifiedInHeader() { var mockSqs = new Mock <IAmazonSQS>(); using (var sender = new SQSSender(mockSqs.Object, "foo", "http://url.com/foo")) sender.Send(new SenderMessage("") { Headers = { { "SQS.MessageDeduplicationId", "abc" } } }); mockSqs.Verify(m => m.SendMessageAsync( It.Is <SendMessageRequest>(r => !r.MessageAttributes.ContainsKey("SQS.MessageDeduplicationId") && r.MessageDeduplicationId == "abc"), It.IsAny <CancellationToken>())); }