Beispiel #1
0
        public async Task TransformsAndSendsToQueue()
        {
            var subscription = new Mock <IEventSubscription>();
            var queue        = new Mock <IQueue>();
            var handler      = new QueueHandler(subscription.Object, 99, queue.Object);
            var decodedLog   = DecodedEvent.Empty();

            EventLogQueueMessage actualQueueMessage = null;

            queue
            .Setup(q => q.AddMessageAsync(It.IsAny <object>()))
            .Callback <object>((msg) => actualQueueMessage = msg as EventLogQueueMessage)
            .Returns(Task.CompletedTask);

            var result = await handler.HandleAsync(decodedLog);

            Assert.True(result);
            Assert.NotNull(actualQueueMessage);
        }
Beispiel #2
0
        public async Task CanUseCustomMessageMapper()
        {
            var subscription   = new Mock <IEventSubscription>();
            var queue          = new Mock <IQueue>();
            var messageToQueue = new object();
            var customMapper   = new QueueMessageMapper(decodedEvent => messageToQueue);
            var handler        = new QueueHandler(subscription.Object, 99, queue.Object, customMapper);
            var decodedLog     = DecodedEvent.Empty();

            object actualQueueMessage = null;

            queue
            .Setup(q => q.AddMessageAsync(It.IsAny <object>()))
            .Callback <object>((msg) => actualQueueMessage = msg)
            .Returns(Task.CompletedTask);

            var result = await handler.HandleAsync(decodedLog);

            Assert.True(result);
            Assert.Same(messageToQueue, actualQueueMessage);
        }