public void SelectWithFilteredNoTranslatedOptionReturnsCorrectSelection2() { ApplicationModel applicationModel = TestApplicationModel.Instance; StaticRouteSelector routeSelector = new StaticRouteSelector(); routeSelector.RouteSelection.Add(new RouteSelection() { ControllerModel = applicationModel.Controller4(), ActionModels = applicationModel.Controller4().Actions, }); routeSelector.RouteSelection.Add(new RouteSelection() { ControllerModel = applicationModel.Controller2(), ActionModels = applicationModel.Controller2().Actions, }); ControllerModel translatedController = applicationModel.Controller4() .CreateLocalizedControllerModel(GetLocalizer(), TranslatedRoutesRouteSelectorBuilderTest.Culture); foreach (SelectorModel selectorModel in translatedController.GetOriginalModel(GetLocalizer()).Selectors) { translatedController.Selectors.Add(selectorModel); } applicationModel.Controllers.Add(translatedController); ControllerModel translatedController2 = applicationModel.Controller2() .CreateLocalizedControllerModel(GetLocalizer(), FilterRouteSelectorTest.Culture); for (int i = 0; i < translatedController2.Actions.Count; i++) { foreach (SelectorModel selectorModel in translatedController2.GetOriginalModel(GetLocalizer()).Actions[i].Selectors) { translatedController2.Actions[i].Selectors.Add(selectorModel); } } applicationModel.Controllers.Add(translatedController2); FilterRouteSelector filterRouteSelector = new FilterRouteSelector(routeSelector) { Controller = "Controller4", Action = "Action1", Localizer = GetLocalizer(), Cultures = new[] { FilterRouteSelectorTest.Culture }, FilterControllerOrActionWhenNoTranslatedRouteLeft = true, }; ICollection <RouteSelection> routeSelections = filterRouteSelector.Select(applicationModel); Assert.IsTrue(routeSelections.Count == 2); Assert.IsTrue(routeSelections.First().ActionModels.Count == 0); Assert.IsTrue(routeSelections.Last().ControllerModel.ControllerName == "Controller2"); Assert.IsTrue(routeSelections.Last().ActionModels.Count == 2); Assert.IsTrue(routeSelections.Last().ActionModels.First().ActionName == "Action1"); Assert.IsTrue(routeSelections.Last().ActionModels.Last().ActionName == "Action2"); }
public void SelectWithFilteredNoUntranslatedOptionReturnsCorrectSelection1() { ApplicationModel applicationModel = TestApplicationModel.Instance; StaticRouteSelector routeSelector = new StaticRouteSelector(); routeSelector.RouteSelection.Add(new RouteSelection() { ControllerModel = applicationModel.Controller4(), ActionModels = applicationModel.Controller4().Actions, }); routeSelector.RouteSelection.Add(new RouteSelection() { ControllerModel = applicationModel.Controller2(), ActionModels = applicationModel.Controller2().Actions, }); FilterRouteSelector filterRouteSelector = new FilterRouteSelector(routeSelector) { Controller = "Controller4", Action = "Action1", ActionArguments = new[] { typeof(int) }, Localizer = GetLocalizer(), Cultures = new[] { FilterRouteSelectorTest.Culture }, FilterControllerOrActionWhenNoUntranslatedRouteLeft = true, }; ICollection <RouteSelection> routeSelections = filterRouteSelector.Select(applicationModel); Assert.IsTrue(routeSelections.Count == 2); Assert.IsTrue(routeSelections.First().ActionModels.Count == 1); Assert.IsTrue(routeSelections.First().ActionModels.Single().Parameters.Count == 0); Assert.IsTrue(routeSelections.Last().ControllerModel.ControllerName == "Controller2"); Assert.IsTrue(routeSelections.Last().ActionModels.Count == 2); Assert.IsTrue(routeSelections.Last().ActionModels.First().ActionName == "Action1"); Assert.IsTrue(routeSelections.Last().ActionModels.Last().ActionName == "Action2"); }