public void AppliesToControllerWithLongTemplateWorksAsExpected() { // Arrange ControllerModel controller = ControllerModelHelpers.BuildControllerModel <WithoutPrefixController>("LongAction"); ActionModel action = controller.Actions.First(); ODataControllerActionContext context = new ODataControllerActionContext(string.Empty, EdmModel, controller); AttributeRoutingConvention attributeConvention = CreateConvention(); // Act bool ok = attributeConvention.AppliesToController(context); Assert.False(ok); // Assert Assert.Equal(4, action.Selectors.Count); Assert.Equal(new[] { "/Customers({key})/Orders({relatedKey})/NS.MyOrder/Title", "/Customers({key})/Orders/{relatedKey}/NS.MyOrder/Title", "/Customers/{key}/Orders({relatedKey})/NS.MyOrder/Title", "/Customers/{key}/Orders/{relatedKey}/NS.MyOrder/Title" }, action.Selectors.Select(s => s.AttributeRouteModel.Template)); }
public void AppliesToControllerWithRoutePrefixWorksAsExpected() { // Arrange ControllerModel controller = ControllerModelHelpers.BuildControllerModel <WithPrefixController>("List"); ActionModel action = controller.Actions.First(); ODataControllerActionContext context = new ODataControllerActionContext(string.Empty, EdmModel, controller); AttributeRoutingConvention attributeConvention = CreateConvention(); // Act bool ok = attributeConvention.AppliesToController(context); Assert.False(ok); // Assert Assert.Equal(6, action.Selectors.Count); Assert.Equal(new[] { "Customers({key})", "Customers/{key}", "Customers", "Orders({key})", "Orders/{key}", "Orders", }, action.Selectors.Select(s => s.AttributeRouteModel.Template)); }
public void AppliesToControllerForSingletonWorksAsExpected(string actionName, string expectedTemplate) { // Arrange ControllerModel controller = ControllerModelHelpers.BuildControllerModel <SingletonTestControllerWithPrefix>(actionName); ActionModel action = controller.Actions.First(); ODataControllerActionContext context = new ODataControllerActionContext(string.Empty, EdmModel, controller); AttributeRoutingConvention attributeConvention = CreateConvention(); // Act bool ok = attributeConvention.AppliesToController(context); Assert.False(ok); // Assert SelectorModel selector = Assert.Single(action.Selectors); Assert.NotNull(selector.AttributeRouteModel); Assert.Equal(expectedTemplate, selector.AttributeRouteModel.Template); }