private static TestServer GetTestServer(
            SelfTestMiddlewareOptions options = null)
        {
            if (options == null)
            {
                ISelfTester selfTester = new FakeSelfTester();
                options = new SelfTestMiddlewareOptions
                {
                    BearerTokenValue = "opensesame",
                    SelfTester = selfTester
                };
            }
            var server = TestServer.Create(app =>
            {
                app.Use<SelfTestMiddleware>(options);

                // "Fall back" on Hello world if the self-test middleware doesn't kick in
                app.Run(context =>
                {
                    return context.Response.WriteAsync("Hello world");
                });
            });
            return server;
        }
 public async Task Usage()
 {
     ISelfTester selfTesterMock = new FakeSelfTester();
     ISelfTestResult result = await selfTesterMock.RunTests();
 }
        public async Task No_token_required_status_code_is_OK()
        {
            ISelfTester selfTester = new FakeSelfTester();
            var options = new SelfTestMiddlewareOptions
            {
                RequireBearerToken = false,
                SelfTester = selfTester
            };

            using (var server = GetTestServer(options))
            {
                var client = server.HttpClient;
                HttpResponseMessage responseFromEndpoint = await client.GetAsync("/.ntc.rs-well-known/selftest");
                Assert.True(responseFromEndpoint.IsSuccessStatusCode);
                Assert.Equal(HttpStatusCode.OK, responseFromEndpoint.StatusCode);
            }
        }
            // ReSharper disable once UnusedMember.Local
            public void Configuration(IAppBuilder app)
            {
                ISelfTester selfTester = new FakeSelfTester();
                var options = new SelfTestMiddlewareOptions
                {
                    BearerTokenValue = "opensesame",
                    SelfTester = selfTester
                };

                app.UseSelfTestMiddleware(options);

                // "Fall back" on Hello world if the self-test middleware doesn't kick in
                app.Run(context =>
                {
                    return context.Response.WriteAsync("Hello world");
                });
            }