Пример #1
0
 public static void ThrowIfNotPartiallyTranslated(this ControllerModel controllerModel, ILocalizer localizer)
 {
     if (!controllerModel.IsPartiallyTranslated(localizer))
     {
         throw new InvalidOperationException("ControllerModel is not partially translated.");
     }
 }
Пример #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());
        }
Пример #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);
        }
Пример #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);
        }