public void Configure(
            IApplicationBuilder app
            //#if (AddSqsPublisher || AddSqsConsumer)
            , ISqsClient sqsClient
            //#endif
            //#if (AddSqsConsumer)
            , ISqsConsumerService sqsConsumerService
            //#endif
            )
        {
            //#if (AddSerilog)
            app.UseSerilogRequestLogging();
            //#endif
            app.UseMiddleware <HttpExceptionMiddleware>();
            app.UseRouting();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
                //#if (AddHealthChecks)
                endpoints.MapCustomHealthChecks("PROJECT_NAME service");
                //#endif
            });
            //#if (AddSqsPublisher || AddSqsConsumer)

            if (_appConfig.AwsSettings.AutomaticallyCreateQueue)
            {
                sqsClient.CreateQueueAsync().Wait();
            }
            //#endif
            //#if (AddSqsConsumer)
            sqsConsumerService.StartConsuming();
            //#endif
        }
Exemple #2
0
        public async void Configure(
            IApplicationBuilder app,
            ISqsClient sqsClient,
            ISqsConsumerService sqsConsumerService,
            IActorsRepository actorsRepository,
            IMoviesRepository moviesRepository)
        {
            app.UseSerilogRequestLogging();
            app.UseRouting();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
                endpoints.MapCustomHealthChecks("SqsReader service");
            });

            if (_appConfig.AwsQueueAutomaticallyCreate)
            {
                await sqsClient.CreateQueueAsync();
            }

            sqsConsumerService.StartConsuming();
            await actorsRepository.CreateTableAsync();

            await moviesRepository.CreateTableAsync();
        }
Exemple #3
0
        public void Stop_ReturnsCorrectResult_AndCallsCorrectMethod(
            [Frozen] ISqsConsumerService consumerServiceMock,
            ConsumerController controllerUnderTest)
        {
            var result         = controllerUnderTest.Stop();
            var asObjectResult = (StatusCodeResult)result;

            Assert.Equal(200, asObjectResult.StatusCode);
            consumerServiceMock.Received().StopConsuming();
        }
Exemple #4
0
        public async Task Reprocess_ReturnsCorrectResult_AndCallsCorrectMethod(
            [Frozen] ISqsConsumerService consumerServiceMock,
            ConsumerController controllerUnderTest)
        {
            var result = await controllerUnderTest.Reprocess();

            var asObjectResult = (StatusCodeResult)result;

            Assert.Equal(200, asObjectResult.StatusCode);
            await consumerServiceMock.Received().ReprocessMessagesAsync();
        }
Exemple #5
0
        public async Task Status_ReturnsCorrectResult_AndCallsCorrectMethod(
            [Frozen] ISqsConsumerService consumerServiceMock,
            ConsumerController controllerUnderTest)
        {
            var sqsStatus = new SqsStatus();

            consumerServiceMock.GetStatusAsync().Returns(sqsStatus);

            var result = await controllerUnderTest.Status();

            var asObjectResult = (ObjectResult)result;
            var asObjectValue  = (SqsStatus)asObjectResult.Value;

            Assert.Equal(200, asObjectResult.StatusCode);
            Assert.Equal(sqsStatus, asObjectValue);
            await consumerServiceMock.Received().GetStatusAsync();
        }
 public ConsumerController(ISqsConsumerService sqsConsumerService)
 {
     _sqsConsumerService = sqsConsumerService;
 }