Example #1
0
 public static void ThrowIfNotPartiallyTranslated(this ControllerModel controllerModel, ILocalizer localizer)
 {
     if (!controllerModel.IsPartiallyTranslated(localizer))
     {
         throw new InvalidOperationException("ControllerModel is not partially translated.");
     }
 }
Example #2
0
        public void IsPartiallyTranslatedForOriginalControllerThrowsException()
        {
            ApplicationModel applicationModel     = TestApplicationModel.Instance;
            ControllerModel  controller           = applicationModel.Controller1();
            ControllerModel  translatedController =
                controller.CreateLocalizedControllerModel(GetLocalizedRouteMarker(), ModelExtensionTest.Culture);

            applicationModel.Controllers.Add(translatedController);

            bool isPartiallyLocalized = controller.IsPartiallyTranslated(GetLocalizedRouteMarker());
        }
Example #3
0
        public void IsPartiallyTranslatedForNotLocalizedControllerReturnsFalse()
        {
            ApplicationModel applicationModel     = TestApplicationModel.Instance;
            ControllerModel  controller           = applicationModel.Controller1();
            ControllerModel  translatedController =
                controller.CreateLocalizedControllerModel(GetLocalizedRouteMarker(), ModelExtensionTest.Culture);

            applicationModel.Controllers.Add(translatedController);

            bool isPartiallyLocalized = translatedController.IsPartiallyTranslated(GetLocalizedRouteMarker());

            Assert.IsFalse(isPartiallyLocalized);
        }
Example #4
0
        public void IsPartiallyTranslatedForPartiallyLocalizedControllerReturnsTrue()
        {
            ApplicationModel applicationModel     = TestApplicationModel.Instance;
            ControllerModel  controller           = applicationModel.Controller1();
            ControllerModel  translatedController =
                controller.CreateLocalizedControllerModel(GetLocalizedRouteMarker(), ModelExtensionTest.Culture);

            applicationModel.Controllers.Add(translatedController);

            foreach (SelectorModel selectorModel in controller.Selectors.Take(1))
            {
                translatedController.Selectors.Add(new SelectorModel(selectorModel));
            }

            bool isPartiallyLocalized = translatedController.IsPartiallyTranslated(GetLocalizedRouteMarker());

            Assert.IsTrue(isPartiallyLocalized);
        }