Example #1
0
        public static void AddStopwatchAndRequestKey_Should_Add_Pipelines()
        {
            // arrange
            var pipelines = new Pipelines();
            var context   = NancyContextMock.Create(
                responseContent: "{ \"test\": 1 }",
                responseHeaders: new Dictionary <string, string>
            {
                { "Content-Type", "application/json" }
            });
            TinyIoCContainer container = new TinyIoCContainer();

            // act
            pipelines.AddStopwatchAndRequestKeyPipelines();
            pipelines.BeforeRequest.Invoke(context, new CancellationToken());
            pipelines.AfterRequest.Invoke(context, new CancellationToken());
            context.Response.Headers.Remove("X-Internal-Time");
            context.Response.Headers.Remove("RequestKey");
            pipelines.OnError.Invoke(context, new Exception());

            // assert
            Assert.Single(pipelines.BeforeRequest.PipelineItems);
            Assert.Single(pipelines.AfterRequest.PipelineItems);
            Assert.Single(pipelines.OnError.PipelineItems);
        }