Exemplo n.º 1
0
        public void ProcessRequestInternal_ContentNotFound()
        {
            // Arrange
            var requestProcessor = Mocks.Create<IRequestProcessor>();
            requestProcessor.Setup(p => p.Process(ItemId)).Returns(new ResponseState { StatusCode = HttpStatusCode.NotFound });

            var notFoundProcessor = Mocks.Create<IRequestProcessor>();
            notFoundProcessor.Setup(p => p.Process(null)).Returns(new ResponseState { StatusCode = HttpStatusCode.NotFound, Content = "404" });

            RequestProcessorFactory.Setup(f => f.Create(MethodName)).Returns(requestProcessor.Object);
            RequestProcessorFactory.Setup(f => f.Create(RequestTypes.NotFound)).Returns(notFoundProcessor.Object);

            var handler = new HttpHandler(Container.Object);

            // Act
            handler.ProcessRequestInternal(HttpContext.Object);

            // Assert
            Mocks.VerifyAll();
        }
Exemplo n.º 2
0
        public void ProcessRequestInternal_EditAuthorizationFails()
        {
            // Arrange
            var processor = new EditAuthorizedProcessor();

            var unauthorizedProcessor = Mocks.Create<IRequestProcessor>();
            unauthorizedProcessor.Setup(p => p.Process(ItemId)).Returns(new ResponseState());

            RequestProcessorFactory.Setup(f => f.Create(MethodName)).Returns(processor);
            RequestProcessorFactory.Setup(c => c.Create(RequestTypes.Unauthorized)).Returns(unauthorizedProcessor.Object);

            EditAuthorizer.Setup(a => a.Authorize()).Returns(false);

            var handler = new HttpHandler(Container.Object);

            // Act
            handler.ProcessRequestInternal(HttpContext.Object);

            // Assert
            Mocks.VerifyAll();
        }
Exemplo n.º 3
0
        public void ProcessRequestInternal_InvalidRequestType()
        {
            // Arrange
            var requestProcessor = Mocks.Create<IRequestProcessor>();
            requestProcessor.Setup(p => p.Process(ItemId)).Returns(new ResponseState());

            RequestProcessorFactory.Setup(f => f.Create(MethodName)).Throws(new InvalidOperationException("Dependency creator not registered"));
            RequestProcessorFactory.Setup(f => f.Create(RequestTypes.NotFound)).Returns(requestProcessor.Object);

            var handler = new HttpHandler(Container.Object);

            // Act
            handler.ProcessRequestInternal(HttpContext.Object);

            // Assert
            Mocks.VerifyAll();
        }
Exemplo n.º 4
0
        public void ProcessRequestInternal_NoAuthorization()
        {
            // Arrange
            var requestProcessor = Mocks.Create<IRequestProcessor>();
            requestProcessor.Setup(p => p.Process(ItemId)).Returns(new ResponseState());

            RequestProcessorFactory.Setup(f => f.Create(MethodName)).Returns(requestProcessor.Object);

            var handler = new HttpHandler(Container.Object);

            // Act
            handler.ProcessRequestInternal(HttpContext.Object);

            // Assert
            Mocks.VerifyAll();
        }