public void SelectAction_ThrowsArgumentNull_IfODataPathIsNull() { // Arrange FunctionRoutingConvention functionConvention = new FunctionRoutingConvention(); // Act & Assert ExceptionAssert.ThrowsArgumentNull( () => functionConvention.SelectAction(odataPath: null, controllerContext: null, actionMap: null), "odataPath"); }
public void SelectAction_ThrowsArgumentNull_IfMissRouteContext() { // Arrange FunctionRoutingConvention functionConvention = new FunctionRoutingConvention(); // Act & Assert ExceptionAssert.ThrowsArgumentNull( () => functionConvention.SelectAction(null), "routeContext"); }
public void SelectAction_ThrowsArgumentNull_IfActionMapIsNull() { // Arrange FunctionRoutingConvention functionConvention = new FunctionRoutingConvention(); ODataPath odataPath = new ODataPath(); HttpControllerContext controllerContext = new HttpControllerContext(); // Act & Assert ExceptionAssert.ThrowsArgumentNull( () => functionConvention.SelectAction(odataPath, controllerContext, actionMap: null), "actionMap"); }
public void SelectAction_ThrowsArgumentNull_IfMissOdataPath() { // Arrange var request = RequestFactory.Create(); var routeContext = new RouteContext(request.HttpContext); FunctionRoutingConvention functionConvention = new FunctionRoutingConvention(); // Act & Assert ExceptionAssert.ThrowsArgumentNull( () => functionConvention.SelectAction(routeContext), "odataPath"); }
public void SelectAction_ReturnsNull_RequestMethodIsNotGet(string requestMethod) { // Arrange FunctionRoutingConvention functionConvention = new FunctionRoutingConvention(); ODataPath odataPath = new ODataPath(); var request = RequestFactory.Create(new HttpMethod(requestMethod), "http://localhost/"); var emptyActionMap = SelectActionHelper.CreateActionMap(); // Act string selectedAction = SelectActionHelper.SelectAction(functionConvention, odataPath, request, emptyActionMap); // Assert Assert.Null(selectedAction); }
public void SelectAction_ReturnsFunctionName_ForFunctionOnEntityCollection() { // Arrange FunctionRoutingConvention functionConvention = new FunctionRoutingConvention(); CustomersModelWithInheritance model = new CustomersModelWithInheritance(); ODataPath odataPath = new DefaultODataPathHandler().Parse(model.Model, _serviceRoot, "Customers/NS.IsAnyUpgraded"); var request = RequestFactory.Create(HttpMethod.Get, "http://localhost/"); var actionMap = SelectActionHelper.CreateActionMap("IsAnyUpgraded"); // Act string selectedAction = SelectActionHelper.SelectAction(functionConvention, odataPath, request, actionMap); // Assert Assert.Equal("IsAnyUpgraded", selectedAction); Assert.Empty(SelectActionHelper.GetRouteData(request).Values); }
public void SelectAction_UpdatesRouteData_ForSingletonFunctionWithParameters() { // Arrange FunctionRoutingConvention functionConvention = new FunctionRoutingConvention(); CustomersModelWithInheritance model = new CustomersModelWithInheritance(); ODataPath odataPath = new DefaultODataPathHandler().Parse(model.Model, _serviceRoot, "VipCustomer/NS.IsUpgradedWithParam(city='any')"); var request = RequestFactory.Create(HttpMethod.Get, "http://localhost/"); var actionMap = SelectActionHelper.CreateActionMap("IsUpgradedWithParam"); // Act string selectedAction = SelectActionHelper.SelectAction(functionConvention, odataPath, request, actionMap); // Assert Assert.Equal("IsUpgradedWithParam", selectedAction); Assert.Single(SelectActionHelper.GetRouteData(request).Values); Assert.Equal("any", SelectActionHelper.GetRouteData(request).Values["city"]); }