Exemplo n.º 1
0
            public void ReturnMatchingHandler()
            {
                var expectedQueueName      = "TestQueue";
                var expectedErrorQueueName = $"{expectedQueueName}_error";
                var expectedMessage        = new TestMessage {
                    Name = "TestMessage"
                };
                var expectedQueueUrl    = "URL:TestQueue";
                var createQueueResponse = new CreateQueueResponse {
                    QueueUrl = expectedQueueUrl
                };

                queueNamingStrategyMock.Setup(x => x.GetName(typeof(TestMessage))).Returns(expectedQueueName);
                sqsServiceMock.Setup(x => x.GetQueueUrl(expectedQueueName)).Returns(createQueueResponse.QueueUrl);

                var handlerMock = new Mock <IHandlerAsync <TestMessage> >();

                sut.Subscribe <TestMessage, IHandlerAsync <TestMessage> >(handlerMock.Object);

                var actual = sut.GetHandler <TestMessage>();

                actual.Should().NotBeNull();
            }
Exemplo n.º 2
0
            public void AddHandlerResolver()
            {
                var expectedQueueName      = "TestQueue";
                var expectedErrorQueueName = $"{expectedQueueName}_error";
                var expectedMessage        = new TestMessage {
                    Name = "TestMessage"
                };
                var createQueueResponse = new CreateQueueResponse {
                    QueueUrl = "URL:TestQueue"
                };

                queueNamingStrategyMock.Setup(x => x.GetName(typeof(TestMessage))).Returns(expectedQueueName);
                sqsServiceMock.Setup(x => x.GetQueueUrl(expectedQueueName)).Returns(createQueueResponse.QueueUrl);

                sut.Subscribe <TestMessage, IHandlerAsync <TestMessage> >(new TestHandler());

                var expected = sut.GetHandler <TestMessage>();

                expected.Should().NotBeNull();
            }