public async Task Require_Single_Handler_In_InPipe()
        {
            const string url = "https://v-mock.org/v2/smoke-testing-company/ver";

#if NETCOREAPP
            var innerHandler1 = new ReturnResponseWithPresetStatusCode(async ctx => await Task.CompletedTask, 200);
            var innerHandler2 = new LogRequestAndResponse(innerHandler1.InvokeAsync);
            var outerHandler  = new LogRequestAndResponse(innerHandler2.InvokeAsync);
            var context       = new DefaultHttpContext();
            SetRequest(context, url);
#else
            var outerHandler = new LogRequestAndResponse()
            {
                InnerHandler = new LogRequestAndResponse()
            };
            var invoker = new HttpMessageInvoker(outerHandler);
            var request = new HttpRequestMessage(HttpMethod.Get, url);
#endif


#if NETCOREAPP
            await outerHandler.InvokeAsync(context);
#else
            await invoker.SendAsync(request, CancellationToken.None);
#endif
        }
        public async Task StatusCode500LogError()
        {
            var highestSeverityLevel = LogSeverityLevel.None;
            var mockLogger           = new Mock <ISyncLogger>();

            mockLogger.Setup(logger =>
                             logger.LogSync(
                                 It.IsAny <LogRecord>()))
            .Callback((LogRecord lr) =>
            {
                if (lr.SeverityLevel > highestSeverityLevel)
                {
                    highestSeverityLevel = lr.SeverityLevel;
                }
            })
            .Verifiable();
            FulcrumApplication.Setup.SynchronousFastLogger = mockLogger.Object;
            const string url = "https://v-mock.org/v2/smoke-testing-company/ver";

#if NETCOREAPP
            var innerHandler = new ReturnResponseWithPresetStatusCode(async ctx => await Task.CompletedTask, 500);
            var outerHandler =
                new LogRequestAndResponse(innerHandler.InvokeAsync);
            var context = new DefaultHttpContext();
            SetRequest(context, url);
#else
            var outerHandler = new LogRequestAndResponse()
            {
                InnerHandler = new ReturnResponseWithPresetStatusCode(HttpStatusCode.InternalServerError)
                {
                    InnerHandler = new Mock <HttpMessageHandler>().Object
                }
            };
            var invoker = new HttpMessageInvoker(outerHandler);
            var request = new HttpRequestMessage(HttpMethod.Get, url);
#endif


#if NETCOREAPP
            await outerHandler.InvokeAsync(context);
#else
            await invoker.SendAsync(request, CancellationToken.None);
#endif

            Assert.AreEqual(LogSeverityLevel.Error, highestSeverityLevel);
        }
        public async Task LogRequestAndResponseMustNotBeBeforeBatchLogs()
        {
            const string url = "https://v-mock.org/v2/smoke-testing-company/ver";

#if NETCOREAPP
            var innerHandler = new BatchLogs(async ctx => await Task.CompletedTask);
            var outerHandler =
                new LogRequestAndResponse(innerHandler.InvokeAsync);
            var context = new DefaultHttpContext();
            SetRequest(context, url);
#else
            var outerHandler = new LogRequestAndResponse()
            {
                InnerHandler = new BatchLogs
                {
                    InnerHandler = new GetContextTestHandler()
                    {
                        InnerHandler = new Mock <HttpMessageHandler>().Object
                    }
                }
            };
            var invoker = new HttpMessageInvoker(outerHandler);
            var request = new HttpRequestMessage(HttpMethod.Get, url);
#endif

            try
            {
#if NETCOREAPP
                await outerHandler.InvokeAsync(context);
#else
                await invoker.SendAsync(request, CancellationToken.None);
#endif
                Assert.Fail("Expected an exception");
            }
            catch (FulcrumContractException e)
            {
                Assert.IsTrue(e.Message.Contains("must not precede"));
            }
            catch (Exception e)
            {
                Assert.Fail(
                    $"Expected an exception of type {nameof(FulcrumContractException)}, but caught exception {e.GetType().FullName}");
            }
        }