public void SelectAction_ReturnsNull_IfActionIsMissing(string httpMethod) { ODataPath odataPath = new DefaultODataPathHandler().Parse(ODataRoutingModel.GetModel(), "RoutingCustomers"); ILookup<string, HttpActionDescriptor> emptyActionMap = 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())); string selectedAction = new EntitySetRoutingConvention().SelectAction(odataPath, controllerContext, emptyActionMap); Assert.Null(selectedAction); Assert.Empty(controllerContext.Request.GetRouteData().Values); }
public void SelectAction_ReturnsNull_IfActionIsMissing(string httpMethod) { ODataPath odataPath = new DefaultODataPathHandler().Parse(ODataRoutingModel.GetModel(), "http://any/", "RoutingCustomers"); ILookup <string, HttpActionDescriptor> emptyActionMap = 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())); string selectedAction = new EntitySetRoutingConvention().SelectAction(odataPath, controllerContext, emptyActionMap); Assert.Null(selectedAction); Assert.Empty(controllerContext.Request.GetRouteData().Values); }
public void SelectAction_ReturnsNull_IfActionIsMissing(string httpMethod) { // Arrange CustomersModelWithInheritance model = new CustomersModelWithInheritance(); ODataPath odataPath = new DefaultODataPathHandler().Parse(model.Model, _serviceRoot, "VipCustomer"); ILookup <string, HttpActionDescriptor> emptyActionMap = 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 selectedAction = new EntitySetRoutingConvention().SelectAction(odataPath, controllerContext, emptyActionMap); // Assert Assert.Null(selectedAction); Assert.Empty(controllerContext.Request.GetRouteData().Values); }
public void SelectAction_ReturnsNull_NotSupportedMethodForDollarCount(string method) { // Arrange var model = new CustomersModelWithInheritance(); var odataPath = new ODataPath(new EntitySetPathSegment(model.Customers), new CountPathSegment()); HttpControllerContext controllerContext = new HttpControllerContext() { Request = new HttpRequestMessage(new HttpMethod(method), "http://localhost/"), RouteData = new HttpRouteData(new HttpRoute()) }; ILookup <string, HttpActionDescriptor> actionMap = new HttpActionDescriptor[1].ToLookup(desc => "PostCustomer"); // Act string actionName = new EntitySetRoutingConvention().SelectAction(odataPath, controllerContext, actionMap); // Assert Assert.Null(actionName); }
public void SelectAction_ReturnsExpectedActionName_DollarCount(string method, string expected) { // Arrange var model = new CustomersModelWithInheritance(); var odataPath = new ODataPath(new EntitySetPathSegment(model.Customers), new CountPathSegment()); HttpControllerContext controllerContext = new HttpControllerContext() { Request = new HttpRequestMessage(new HttpMethod(method), "http://localhost/"), RouteData = new HttpRouteData(new HttpRoute()) }; ILookup<string, HttpActionDescriptor> actionMap = new HttpActionDescriptor[1].ToLookup(desc => expected); // Act string actionName = new EntitySetRoutingConvention().SelectAction(odataPath, controllerContext, actionMap); // Assert Assert.Equal(expected, actionName); }
public void SelectAction_ReturnsExpectedActionName_DollarCount(string method, string expected) { // Arrange var model = new CustomersModelWithInheritance(); var odataPath = new ODataPath(new EntitySetSegment(model.Customers), CountSegment.Instance); HttpControllerContext controllerContext = new HttpControllerContext() { Request = new HttpRequestMessage(new HttpMethod(method), "http://localhost/"), RouteData = new HttpRouteData(new HttpRoute()) }; ILookup <string, HttpActionDescriptor> actionMap = new HttpActionDescriptor[1].ToLookup(desc => expected); // Act string actionName = new EntitySetRoutingConvention().SelectAction(odataPath, controllerContext, actionMap); // Assert Assert.Equal(expected, actionName); }
public void SelectAction_WithCast_Returns_ExpectedActionName(string method, string expected) { // Arrange CustomersModelWithInheritance model = new CustomersModelWithInheritance(); IEdmCollectionType collection = new EdmCollectionType(new EdmEntityTypeReference(model.SpecialCustomer, isNullable: false)); ODataPath odataPath = new ODataPath(new EntitySetSegment(model.Customers), new TypeSegment(collection, model.Customers)); var controllerContext = new HttpControllerContext() { Request = new HttpRequestMessage(new HttpMethod(method), "http://localhost/"), RouteData = new HttpRouteData(new HttpRoute()) }; ILookup <string, HttpActionDescriptor> actionMap = new HttpActionDescriptor[1].ToLookup(desc => expected); // Act string actionName = new EntitySetRoutingConvention().SelectAction(odataPath, controllerContext, actionMap); // Assert Assert.Equal(expected, actionName); }
public void SelectAction_ReturnsNull_IfActionIsMissing(string httpMethod) { // Arrange CustomersModelWithInheritance model = new CustomersModelWithInheritance(); ODataPath odataPath = new DefaultODataPathHandler().Parse(model.Model, _serviceRoot, "VipCustomer"); ILookup<string, HttpActionDescriptor> emptyActionMap = 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 selectedAction = new EntitySetRoutingConvention().SelectAction(odataPath, controllerContext, emptyActionMap); // Assert Assert.Null(selectedAction); Assert.Empty(controllerContext.Request.GetRouteData().Values); }