public void GetControllerDirectRoutes_IfDirectRouteProviderReturnsRouteWithHandler_Throws() { // Arrange var action = CreateStubActionDescriptor("IgnoreAction"); HttpRouteValueDictionary dataTokens = new HttpRouteValueDictionary { { RouteDataTokenKeys.Actions, new HttpActionDescriptor[] { action } } }; HttpMessageHandler handler = new Mock <HttpMessageHandler>(MockBehavior.Strict).Object; HttpRoute route = new HttpRoute(null, null, null, dataTokens, handler); RouteEntry entry = new RouteEntry(name: null, route: route); var factories = new[] { CreateStubRouteFactory(entry) }; var constraintResolver = new Mock <IInlineConstraintResolver>(MockBehavior.Strict).Object; var provider = new AccessibleDirectRouteProvider(); // Act & Assert string expectedMessage = "Direct routing does not support per-route message handlers."; Assert.Throws <InvalidOperationException>( () => provider.GetControllerDirectRoutes(action.ControllerDescriptor, new[] { action }, factories, constraintResolver), expectedMessage); }
public void GetControllerDirectRoutes_IfDirectRouteProviderReturnsRouteWithoutActionDescriptors_Throws() { // Arrange IHttpRoute route = new Mock <IHttpRoute>().Object; RouteEntry entry = new RouteEntry(name: null, route: route); var factories = new[] { CreateStubRouteFactory(entry) }; var action = CreateStubActionDescriptor("IgnoreAction"); var constraintResolver = new Mock <IInlineConstraintResolver>(MockBehavior.Strict).Object; var provider = new AccessibleDirectRouteProvider(); // Act & Assert string expectedMessage = "The route does not have any associated action descriptors. Routing requires " + "that each direct route map to a non-empty set of actions."; Assert.Throws <InvalidOperationException>( () => provider.GetControllerDirectRoutes( action.ControllerDescriptor, new[] { action }, factories, constraintResolver ), expectedMessage ); }
public void GetControllerDirectRoutes_IfDirectRouteProviderReturnsNull_Throws() { // Arrange var factories = new[] { CreateStubRouteFactory(null) }; var action = CreateStubActionDescriptor("IgnoreAction"); var constraintResolver = new Mock <IInlineConstraintResolver>(MockBehavior.Strict).Object; var provider = new AccessibleDirectRouteProvider(); // Act & Assert Assert.Throws <InvalidOperationException>( () => provider.GetControllerDirectRoutes(action.ControllerDescriptor, new[] { action }, factories, constraintResolver), "IDirectRouteFactory.CreateRoute must not return null."); }