public void SelectAction_ReturnsNull_ForInvalidHttpMethods(string httpMethod) { // Arrange CustomersModelWithInheritance model = new CustomersModelWithInheritance(); ODataPath odataPath = new DefaultODataPathHandler().Parse(model.Model, _serviceRoot, "VipCustomer"); ILookup <string, HttpActionDescriptor> actionMap = new HttpActionDescriptor[0].ToLookup(desc => (string)null); HttpControllerContext controllerContext = new HttpControllerContext(); controllerContext.Request = new HttpRequestMessage(new HttpMethod(httpMethod), "http://localhost/"); controllerContext.Request.SetRouteData(new HttpRouteData(new HttpRoute())); // Act string actionName = new SingletonRoutingConvention().SelectAction(odataPath, controllerContext, actionMap); // Act & Assert Assert.Null(actionName); }
public void SelectAction_ReturnsTheActionName_ForValidHttpMethods(string httpMethod, string httpMethodNamePrefix) { // Arrange const string SingletonName = "VipCustomer"; string actionName = httpMethodNamePrefix + SingletonName; CustomersModelWithInheritance model = new CustomersModelWithInheritance(); ODataPath odataPath = new DefaultODataPathHandler().Parse(model.Model, _serviceRoot, SingletonName); ILookup<string, HttpActionDescriptor> actionMap = new HttpActionDescriptor[1].ToLookup(desc => actionName); HttpControllerContext controllerContext = new HttpControllerContext(); controllerContext.Request = new HttpRequestMessage(new HttpMethod(httpMethod), "http://localhost/"); controllerContext.Request.SetRouteData(new HttpRouteData(new HttpRoute())); // Act string selectedAction = new SingletonRoutingConvention().SelectAction(odataPath, controllerContext, actionMap); // Assert Assert.NotNull(selectedAction); Assert.Equal(actionName, selectedAction); Assert.Empty(controllerContext.Request.GetRouteData().Values); }
public void SelectAction_ReturnsTheActionName_ForValidHttpMethods(string httpMethod, string httpMethodNamePrefix) { // Arrange const string SingletonName = "VipCustomer"; string actionName = httpMethodNamePrefix + SingletonName; CustomersModelWithInheritance model = new CustomersModelWithInheritance(); ODataPath odataPath = new DefaultODataPathHandler().Parse(model.Model, _serviceRoot, SingletonName); ILookup <string, HttpActionDescriptor> actionMap = new HttpActionDescriptor[1].ToLookup(desc => actionName); HttpControllerContext controllerContext = new HttpControllerContext(); controllerContext.Request = new HttpRequestMessage(new HttpMethod(httpMethod), "http://localhost/"); controllerContext.Request.SetRouteData(new HttpRouteData(new HttpRoute())); // Act string selectedAction = new SingletonRoutingConvention().SelectAction(odataPath, controllerContext, actionMap); // Assert Assert.NotNull(selectedAction); Assert.Equal(actionName, selectedAction); Assert.Empty(controllerContext.Request.GetRouteData().Values); }
public void SelectAction_ReturnsNull_ForInvalidHttpMethods(string httpMethod) { // Arrange CustomersModelWithInheritance model = new CustomersModelWithInheritance(); ODataPath odataPath = new DefaultODataPathHandler().Parse(model.Model, _serviceRoot, "VipCustomer"); ILookup<string, HttpActionDescriptor> actionMap = new HttpActionDescriptor[0].ToLookup(desc => (string)null); HttpControllerContext controllerContext = new HttpControllerContext(); controllerContext.Request = new HttpRequestMessage(new HttpMethod(httpMethod), "http://localhost/"); controllerContext.Request.SetRouteData(new HttpRouteData(new HttpRoute())); // Act string actionName = new SingletonRoutingConvention().SelectAction(odataPath, controllerContext, actionMap); // Act & Assert Assert.Null(actionName); }