Example #1
0
        public void TryGetLocalizedModelForLocalizedActionThrowsException()
        {
            ApplicationModel applicationModel = TestApplicationModel.Instance;
            ControllerModel  controller       = applicationModel.Controller1();
            ActionModel      action           = controller.Actions.First();

            ControllerModel translatedController =
                controller.CreateLocalizedControllerModel(GetLocalizedRouteMarker(), ModelExtensionTest.Culture);
            ActionModel translatedAction = translatedController.Actions.First();

            applicationModel.Controllers.Add(translatedController);

            ActionModel translatedAction2 =
                translatedAction.TryGetLocalizedModelFor(GetLocalizedRouteMarker(), ModelExtensionTest.Culture);
        }
Example #2
0
        public void TryGetLocalizedModelForOriginalActionReturnsLocalizedAction()
        {
            ApplicationModel applicationModel = TestApplicationModel.Instance;
            ControllerModel  controller       = applicationModel.Controller1();
            ActionModel      action           = controller.Actions.First();

            ControllerModel translatedController =
                controller.CreateLocalizedControllerModel(GetLocalizedRouteMarker(), ModelExtensionTest.Culture);
            ActionModel translatedAction = translatedController.Actions.First();

            applicationModel.Controllers.Add(translatedController);

            ActionModel translatedAction2 =
                action.TryGetLocalizedModelFor(GetLocalizedRouteMarker(), ModelExtensionTest.Culture);

            Assert.AreSame(translatedAction, translatedAction2);
        }
 public static bool IsPartiallyTranslatedAction(ActionModel action, ICollection <string> cultures, ILocalizer localizer)
 {
     return(action.HasAttributeRoutes() &&
            cultures.All(
                culture => action.TryGetLocalizedModelFor(localizer, culture)?.IsPartiallyTranslated(localizer) == true));
 }
 public static bool IsNotCompletelyTranslatedAction(ActionModel action, string culture, ILocalizer localizer)
 {
     return(action.HasAttributeRoutes() && action.TryGetLocalizedModelFor(localizer, culture)
            ?.IsCompletelyTranslated(localizer) != true);
 }