ProcessRequest() public méthode

Processes an incoming HTTP request.
is null.
public ProcessRequest ( IStumpsHttpContext context ) : Task
context IStumpsHttpContext The representing both the incoming request and the response.
Résultat Task
Exemple #1
0
        public void ProcessRequest_WithNullContext_ThrowsException()
        {
            var pipe = new HttpPipelineHandler();

            Assert.That(
                async() => await pipe.ProcessRequest(null),
                Throws.Exception.TypeOf <ArgumentNullException>().With.Property("ParamName").EqualTo("context"));
        }
Exemple #2
0
        public async Task ProcessRequest_WithoutHandlers_ReturnsContinue()
        {
            var context = Substitute.For <IStumpsHttpContext>();
            var handler = new HttpPipelineHandler();

            var result = await handler.ProcessRequest(context);

            Assert.AreEqual(ProcessHandlerResult.Continue, result, "The process request returned a Terminate.");
        }
Exemple #3
0
        public async Task ProcessRequest_StopsExecutingWhenTerminateReturned()
        {
            var context       = Substitute.For <IStumpsHttpContext>();
            var pipe          = new HttpPipelineHandler();
            var innerHandler1 = new NoOpHandler(ProcessHandlerResult.Terminate);
            var innerHandler2 = new NoOpHandler(ProcessHandlerResult.Continue);

            pipe.Add(innerHandler1);
            pipe.Add(innerHandler2);

            var result = await pipe.ProcessRequest(context);

            Assert.AreEqual(ProcessHandlerResult.Terminate, result, "The process request returned a Continue.");
            Assert.AreEqual(1, innerHandler1.ProcessRequestCalls());
            Assert.AreEqual(0, innerHandler2.ProcessRequestCalls());
        }
Exemple #4
0
        public async Task ProcessRequest_WithValidContext_RaisesContextProcessedEvent()
        {
            var context = Substitute.For <IStumpsHttpContext>();

            var handler = new HttpPipelineHandler();

            var contextProcessedEvent = new AutoResetEvent(false);

            handler.ContextProcessed += (o, e) => contextProcessedEvent.Set();

            var result = await handler.ProcessRequest(context);

            var contextProcessed = contextProcessedEvent.WaitOne(1000);

            Assert.IsTrue(contextProcessed);
        }
        public async void ProcessRequest_StopsExecutingWhenTerminateReturned()
        {

            var context = Substitute.For<IStumpsHttpContext>();
            var pipe = new HttpPipelineHandler();
            var innerHandler1 = new NoOpHandler(ProcessHandlerResult.Terminate);
            var innerHandler2 = new NoOpHandler(ProcessHandlerResult.Continue);

            pipe.Add(innerHandler1);
            pipe.Add(innerHandler2);

            var result = await pipe.ProcessRequest(context);

            Assert.AreEqual(ProcessHandlerResult.Terminate, result, "The process request returned a Continue.");
            Assert.AreEqual(1, innerHandler1.ProcessRequestCalls());
            Assert.AreEqual(0, innerHandler2.ProcessRequestCalls());

        }
        public void ProcessRequest_WithNullContext_ThrowsException()
        {

            var pipe = new HttpPipelineHandler();

            Assert.That(
                async () => await pipe.ProcessRequest(null),
                Throws.Exception.TypeOf<ArgumentNullException>().With.Property("ParamName").EqualTo("context"));

        }
        public void ProcessRequest_WithValidContext_RaisesContextProcessedEvent()
        {

            var context = Substitute.For<IStumpsHttpContext>();

            var handler = new HttpPipelineHandler();
            var hitCount = 0;
            handler.ContextProcessed += (o, e) => hitCount++;

            var result = handler.ProcessRequest(context);

            Assert.AreEqual(1, hitCount);

        }
        public async void ProcessRequest_WithoutHandlers_ReturnsContinue()
        {

            var context = Substitute.For<IStumpsHttpContext>();
            var handler = new HttpPipelineHandler();

            var result = await handler.ProcessRequest(context);
            Assert.AreEqual(ProcessHandlerResult.Continue, result, "The process request returned a Terminate.");

        }