示例#1
0
        public void SelectAction_ReturnsTheActionName_ForSingletonActionBoundToEntity()
        {
            // Arrange
            ActionRoutingConvention actionConvention = new ActionRoutingConvention();
            HttpContext             context          = CreateHttpContext("Post");

            IEdmModel model = new CustomersModelWithInheritance().Model;
            //IODataPathHandler pathHandler = context.RequestServices.GetRequiredService<IODataPathHandler>();
            IODataPathHandler pathHandler = new DefaultODataPathHandler(context.RequestServices);
            ODataPath         odataPath   = pathHandler.Parse(model, _serviceRoot, "VipCustomer/NS.upgrade");

            context.ODataFeature().Path = odataPath;

            ControllerActionDescriptor descriptor = new ControllerActionDescriptor();

            descriptor.ControllerName = "VipCustomer";
            descriptor.ActionName     = "upgrade";

            RouteContext routeContext = new RouteContext(context);
            IEnumerable <ControllerActionDescriptor> actionDescriptors = new[] { descriptor };

            // Act
            ActionDescriptor actionDescriptor = actionConvention.SelectAction(routeContext, actionDescriptors);

            // Assert
            Assert.Same(descriptor, actionDescriptor);
            Assert.Empty(routeContext.RouteData.Values);
        }
示例#2
0
        public void SelectAction_ReturnsTheActionDescriptor_ForEntitySetActionBoundToEntitySet()
        {
            // Arrange
            ActionRoutingConvention actionConvention = new ActionRoutingConvention();

            HttpContext context = CreateHttpContext("Post");
            HttpRequest request = context.Request;

            IEdmModel         model       = ODataRoutingModel.GetModel(null);
            IODataPathHandler pathHandler = context.RequestServices.GetRequiredService <IODataPathHandler>();
            ODataPath         odataPath   = pathHandler.Parse(model, _serviceRoot, "RoutingCustomers/Default.GetVIPs");

            context.ODataFeature().Path = odataPath;

            ControllerActionDescriptor descriptor = new ControllerActionDescriptor();

            descriptor.ControllerName = "RoutingCustomers";
            descriptor.ActionName     = "GetVIPs";

            RouteContext routeContext = new RouteContext(context);
            IEnumerable <ControllerActionDescriptor> actionDescriptors = new [] { descriptor };

            // Act
            ActionDescriptor actionDescriptor = actionConvention.SelectAction(routeContext, actionDescriptors);

            // Assert
            Assert.Same(descriptor, actionDescriptor);
            Assert.Empty(routeContext.RouteData.Values);
        }