public async Task Invoke_WhenLoggingIsEnabled_MustSucceed()
        {
            try
            {
                var requestDelegateMock = new Mock <RequestDelegate>();

                var httpContextLoggingHandlerMock = new Mock <IHttpContextLoggingHandler>();
                httpContextLoggingHandlerMock.Setup(x => x.ShouldLog(It.IsAny <HttpContext>()))
                .Returns(true);

                var httpObjectConverterMock = new Mock <IHttpObjectConverter>();
                var loggerMock = new Mock <ILogger <LoggingMiddleware> >();

                var loggingMiddleware = new LoggingMiddleware(requestDelegateMock.Object
                                                              , httpContextLoggingHandlerMock.Object
                                                              , httpObjectConverterMock.Object
                                                              , loggerMock.Object);

                await loggingMiddleware.Invoke(new DefaultHttpContext()).ConfigureAwait(false);
            }
            catch (Exception exception)
            {
                Assert.Fail($"Invoke method shouldn't have failed, but alas: {exception.Message}\n{exception.StackTrace}");
            }
        }
        public void Constructor_WhenInvokedWithValidParameters_MustSucceed()
        {
            var requestDelegateMock           = new Mock <RequestDelegate>();
            var httpContextLoggingHandlerMock = new Mock <IHttpContextLoggingHandler>();
            var httpObjectConverterMock       = new Mock <IHttpObjectConverter>();
            var loggerMock = new Mock <ILogger <LoggingMiddleware> >();

            var loggingMiddleware = new LoggingMiddleware(requestDelegateMock.Object
                                                          , httpContextLoggingHandlerMock.Object
                                                          , httpObjectConverterMock.Object
                                                          , loggerMock.Object);

            loggingMiddleware.Should().NotBeNull();
        }
        public void Invoke_WhenLoggingIsEnabled_MustSucceed()
        {
            // Arrange
            var requestDelegateMock = new Mock <RequestDelegate>();

            var httpContextLoggingHandlerMock = new Mock <IHttpContextLoggingHandler>();

            httpContextLoggingHandlerMock.Setup(x => x.ShouldLog(It.IsAny <HttpContext>()))
            .Returns(true);

            var httpObjectConverterMock = new Mock <IHttpObjectConverter>();
            var loggerMock = new Mock <ILogger <LoggingMiddleware> >();

            var loggingMiddleware = new LoggingMiddleware(requestDelegateMock.Object
                                                          , httpContextLoggingHandlerMock.Object
                                                          , httpObjectConverterMock.Object
                                                          , loggerMock.Object);

            // Act
            Func <Task> invoke = async() => await loggingMiddleware.Invoke(new DefaultHttpContext());

            // Assert
            invoke.Should().NotThrow("logging middleware was built using correct values");
        }