public void CreateControllerWithFactoryThatThrowsDoesNothingSpecial() { // Arrange ControllerBuilder cb = new ControllerBuilder(); cb.SetControllerFactory(typeof(ControllerFactoryThrows)); // Act Assert.Throws <Exception>( delegate { RequestContext reqContext = new RequestContext( new Mock <HttpContextBase>().Object, new RouteData() ); reqContext.RouteData.Values["controller"] = "foo"; MvcHandlerWithNoVersionHeader handler = new MvcHandlerWithNoVersionHeader( reqContext ) { ControllerBuilder = cb }; handler.ProcessRequest(reqContext.HttpContext); }, "ControllerFactoryThrows" ); }
public void CreateControllerWithFactoryThatReturnsNullThrows() { // Arrange ControllerBuilder cb = new ControllerBuilder(); cb.SetControllerFactory(typeof(ControllerFactoryReturnsNull)); // Act Assert.Throws <InvalidOperationException>( delegate { RequestContext reqContext = new RequestContext( new Mock <HttpContextBase>().Object, new RouteData() ); reqContext.RouteData.Values["controller"] = "boo"; MvcHandlerWithNoVersionHeader handler = new MvcHandlerWithNoVersionHeader( reqContext ) { ControllerBuilder = cb }; handler.ProcessRequest(reqContext.HttpContext); }, "The IControllerFactory 'System.Web.Mvc.Test.ControllerBuilderTest+ControllerFactoryReturnsNull' did not return a controller for the name 'boo'." ); }
public void CreateControllerWithFactoryThatCannotBeCreatedThrows() { // Arrange ControllerBuilder cb = new ControllerBuilder(); cb.SetControllerFactory(typeof(ControllerFactoryThrowsFromConstructor)); // Act Assert.Throws <InvalidOperationException>( delegate { RequestContext reqContext = new RequestContext( new Mock <HttpContextBase>().Object, new RouteData() ); reqContext.RouteData.Values["controller"] = "foo"; MvcHandlerWithNoVersionHeader handler = new MvcHandlerWithNoVersionHeader( reqContext ) { ControllerBuilder = cb }; handler.ProcessRequest(reqContext.HttpContext); }, "An error occurred when trying to create the IControllerFactory 'System.Web.Mvc.Test.ControllerBuilderTest+ControllerFactoryThrowsFromConstructor'. Make sure that the controller factory has a public parameterless constructor." ); }
public void CreateControllerWithFactoryThatThrowsDoesNothingSpecial() { // Arrange ControllerBuilder cb = new ControllerBuilder(); cb.SetControllerFactory(typeof(ControllerFactoryThrows)); // Act ExceptionHelper.ExpectException<Exception>( delegate { RequestContext reqContext = new RequestContext(new Mock<HttpContextBase>().Object, new RouteData()); reqContext.RouteData.Values["controller"] = "foo"; MvcHandlerWithNoVersionHeader handler = new MvcHandlerWithNoVersionHeader(reqContext) { ControllerBuilder = cb }; handler.ProcessRequest(reqContext.HttpContext); }, "ControllerFactoryThrows"); }
public void CreateControllerWithFactoryThatReturnsNullThrows() { // Arrange ControllerBuilder cb = new ControllerBuilder(); cb.SetControllerFactory(typeof(ControllerFactoryReturnsNull)); // Act ExceptionHelper.ExpectException<InvalidOperationException>( delegate { RequestContext reqContext = new RequestContext(new Mock<HttpContextBase>().Object, new RouteData()); reqContext.RouteData.Values["controller"] = "boo"; MvcHandlerWithNoVersionHeader handler = new MvcHandlerWithNoVersionHeader(reqContext) { ControllerBuilder = cb }; handler.ProcessRequest(reqContext.HttpContext); }, "The IControllerFactory 'System.Web.Mvc.Test.ControllerBuilderTest+ControllerFactoryReturnsNull' did not return a controller for the name 'boo'."); }
public void CreateControllerWithFactoryThatCannotBeCreatedThrows() { // Arrange ControllerBuilder cb = new ControllerBuilder(); cb.SetControllerFactory(typeof(ControllerFactoryThrowsFromConstructor)); // Act ExceptionHelper.ExpectException<InvalidOperationException>( delegate { RequestContext reqContext = new RequestContext(new Mock<HttpContextBase>().Object, new RouteData()); reqContext.RouteData.Values["controller"] = "foo"; MvcHandlerWithNoVersionHeader handler = new MvcHandlerWithNoVersionHeader(reqContext) { ControllerBuilder = cb }; handler.ProcessRequest(reqContext.HttpContext); }, "An error occurred when trying to create the IControllerFactory 'System.Web.Mvc.Test.ControllerBuilderTest+ControllerFactoryThrowsFromConstructor'. Make sure that the controller factory has a public parameterless constructor."); }