Example #1
0
        public async void HandleTraceRequestAsync_ReturnsExpected()
        {
            var opts = new TraceOptions();

            TraceDiagnosticObserver obs = new TraceDiagnosticObserver(opts);
            var ep      = new TestTraceEndpoint(opts, obs);
            var middle  = new TraceEndpointMiddleware(null, ep);
            var context = CreateRequest("GET", "/trace");
            await middle.HandleTraceRequestAsync(context);

            context.Response.Body.Seek(0, SeekOrigin.Begin);
            StreamReader rdr  = new StreamReader(context.Response.Body);
            string       json = await rdr.ReadToEndAsync();

            Assert.Equal("[]", json);
        }
        public async Task HandleTraceRequestAsync_OtherPathReturnsExpected()
        {
            var opts  = new TraceEndpointOptions();
            var mopts = new CloudFoundryManagementOptions();

            mopts.EndpointOptions.Add(opts);

            var obs     = new TraceDiagnosticObserver(opts);
            var ep      = new TestTraceEndpoint(opts, obs);
            var middle  = new TraceEndpointMiddleware(null, ep, mopts);
            var context = CreateRequest("GET", "/cloudfoundryapplication/trace");
            await middle.HandleTraceRequestAsync(context);

            context.Response.Body.Seek(0, SeekOrigin.Begin);
            var rdr  = new StreamReader(context.Response.Body);
            var json = await rdr.ReadToEndAsync();

            Assert.Equal("[]", json);
        }