public async Task ProcessRequest_UnrecognisedPath_Returns404(string requestedPath)
        {
            var testLogger = new TestLogger(logToConsole: true);
            var context    = CreateOwinContext(requestedPath);

            var handler     = CreateHandler("/sonarlint/api/handled");
            var testSubject = new OwinPipelineProcessor(new[] { handler }, testLogger);

            await testSubject.ProcessRequest(context.Environment).ConfigureAwait(false);

            context.Response.StatusCode.Should().Be(404);
            CheckCorsHeader(context);
            testLogger.AssertPartialOutputStringExists(requestedPath);
        }
        public async Task ProcessRequest_RecognisedPath_ReturnsStatusSetByHandler()
        {
            var          testLogger         = new TestLogger(logToConsole: true);
            const int    expectedStatusCode = 12345;
            const string handledRequestPath = "/sonarlint/api/handled";
            var          context            = CreateOwinContext(handledRequestPath);

            var handler     = CreateHandler(handledRequestPath, expectedStatusCode);
            var testSubject = new OwinPipelineProcessor(new[] { handler }, testLogger);

            await testSubject.ProcessRequest(context.Environment).ConfigureAwait(false);

            context.Response.StatusCode.Should().Be(expectedStatusCode);
            CheckCorsHeader(context);
            testLogger.AssertPartialOutputStringExists(handledRequestPath);
        }
        public void ProcessRequest_ExceptionInHandler_IsLoggedAndRethrown()
        {
            var          testLogger         = new TestLogger(logToConsole: true);
            const string handledRequestPath = "/path";
            var          context            = CreateOwinContext(handledRequestPath);

            const string expectedErrorMessage = "exception thrown by test";
            var          handler     = CreateHandler(handledRequestPath, processOp: () => throw new IndexOutOfRangeException(expectedErrorMessage));
            var          testSubject = new OwinPipelineProcessor(new[] { handler }, testLogger);

            Func <Task> act = () => testSubject.ProcessRequest(context.Environment);

            act.Should().ThrowExactly <IndexOutOfRangeException>().And.Message.Should().Be(expectedErrorMessage);
            CheckCorsHeader(context);
            testLogger.AssertPartialOutputStringExists(expectedErrorMessage);
        }