コード例 #1
0
        public async Task ShouldPublishMessagesWithIdsToSQS(
            SNSEvent snsEvent,
            SNSEvent.SNSRecord record1,
            SNSEvent.SNSRecord record2,
            Request request1,
            Request request2,
            [Frozen] IAmazonSQS sqs,
            [Frozen] ISnsRecordMapper mapper,
            [Target] Handler handler,
            CancellationToken cancellationToken
            )
        {
            snsEvent.Records = new List <SNSEvent.SNSRecord> {
                record1, record2
            };

            mapper.MapToRequest(Is(record1)).Returns(request1);
            mapper.MapToRequest(Is(record2)).Returns(request2);

            await handler.Handle(snsEvent, cancellationToken);

            await sqs.Received().SendMessageBatchAsync(Any <SendMessageBatchRequest>(), Is(cancellationToken));

            var request = TestUtils.GetArg <SendMessageBatchRequest>(sqs, nameof(IAmazonSQS.SendMessageBatchAsync), 0);

            request.Entries.Should().Contain(entry => entry.Id == request1.Id.ToString());
            request.Entries.Should().Contain(entry => entry.Id == request2.Id.ToString());
        }
コード例 #2
0
 public Handler(
     IAmazonSQS sqs,
     ISerializer serializer,
     ISnsRecordMapper mapper,
     IOptions <Options> options,
     ILogger <Handler> logger
     )
 {
     this.sqs        = sqs;
     this.serializer = serializer;
     this.mapper     = mapper;
     this.options    = options.Value;
     this.logger     = logger;
 }
コード例 #3
0
        public async Task ShouldPublishMessagesWithQueueUrlToSQS(
            SNSEvent snsEvent,
            [Frozen] Options options,
            [Frozen] IAmazonSQS sqs,
            [Frozen] ISnsRecordMapper mapper,
            [Target] Handler handler,
            CancellationToken cancellationToken
            )
        {
            await handler.Handle(snsEvent, cancellationToken);

            await sqs.Received().SendMessageBatchAsync(Any <SendMessageBatchRequest>(), Is(cancellationToken));

            var request = TestUtils.GetArg <SendMessageBatchRequest>(sqs, nameof(IAmazonSQS.SendMessageBatchAsync), 0);

            request.QueueUrl.Should().Be(options.QueueUrl.ToString());
        }