コード例 #1
0
        public void ErrorPageProcessor_CreateController_WhenControllerNotFound_ReturnsNull()
        {
            var processor = new ErrorPageProcessor();
            var mockControllerFactory = new Mock<IControllerFactory>();
            mockControllerFactory
                .Setup(m => m.CreateController(It.IsAny<RequestContext>(), It.IsAny<string>()))
                .Throws(new HttpException(404, "Not Found"));

            var result = processor.CreateController(mockControllerFactory.Object, new RequestContext(), "no-controller");

            Assert.That(result, Is.Null);
        }
コード例 #2
0
        public void ErrorPageProcessor_CreateController_WhenFactoryThrows_Throws()
        {
            var processor = new ErrorPageProcessor();
            var exception = new HttpException(500, "Error");
            var mockControllerFactory = new Mock<IControllerFactory>();
            mockControllerFactory
                .Setup(m => m.CreateController(It.IsAny<RequestContext>(), It.IsAny<string>()))
                .Throws(exception);

            TestDelegate act = () =>
            {
                processor.CreateController(mockControllerFactory.Object, new RequestContext(), "no-controller");
            };

            Assert.That(act, Throws.Exception.EqualTo(exception));
        }