public void GetPageTitleFromResource_HasResourceForOverridePageType()
        {
            var ctrl = Core.Services.Utils.DependencyResolver.Current.Get <MyContentControllerBase>();

            FakeResources.AddString("PageTitle", "PAGETYPE_MyOverride", "my override page type title");

            var res = ctrl.CallGetPageTitleFromResource("MyOverride");

            Assert.Contains("my override page type title", res);
        }
        public void GetPageTitleFromResource_NoResourceForOverridePageType_UsesDefault()
        {
            var ctrl = Core.Services.Utils.DependencyResolver.Current.Get <MyContentControllerBase>();

            FakeResources.AddString("PageTitle", "PAGETYPE_MyOverride", string.Empty);
            FakeResources.AddString("PageTitle", "PAGETYPE_AllOthers", "my all other title");

            var res = ctrl.CallGetPageTitleFromResource("MyOverride");

            Assert.Contains("my all other title", res);
        }
        public void GetPageTitleFromResource_HasResourceForPageType_RemovesPageSuffixFromTypeName()
        {
            var ctrl = Core.Services.Utils.DependencyResolver.Current.Get <MyContentControllerBaseWithSuffix>();

            ctrl.MyCurrentPage = new MyContentItemWithSuffixPage();
            FakeResources.AddString("PageTitle", "PAGETYPE_MyContentItemWithSuffix", "my resource title");

            var res = ctrl.CallGetPageTitleFromResource();

            Assert.Contains("my resource title", res);
        }
        public void SetPageTitleOverrideResKey_CallsGetPageTitleWithOverride()
        {
            var ctrl = Core.Services.Utils.DependencyResolver.Current.Get <MyContentControllerBase>();

            ctrl.MyCurrentPage.PageTitle = string.Empty;
            FakeResources.AddString("PageTitle", "PAGETYPE_MyOverride", "my override type title");

            ctrl.CallSetPageTitleOverrideResKey("MyOverride");

            Assert.Contains("my override type title", ctrl.ViewBag.Title);
        }
        public void GetPageTitle_FallsBackToDefaultResource()
        {
            var ctrl = Core.Services.Utils.DependencyResolver.Current.Get <MyContentControllerBase>();

            ctrl.MyCurrentPage.PageTitle = string.Empty;
            FakeResources.AddString("PageTitle", "PAGETYPE_MyContentItem", string.Empty);
            FakeResources.AddString("PageTitle", "PAGETYPE_AllOthers", "my all other title");

            var res = ctrl.CallGetPageTitle();

            Assert.Contains("my all other title", res);
        }
        public void GetPageTitle_FavorsCurrentItem()
        {
            var ctrl = Core.Services.Utils.DependencyResolver.Current.Get <MyContentControllerBase>();

            ctrl.MyCurrentPage.PageTitle = "my content item title";
            FakeResources.AddString("PageTitle", "PAGETYPE_MyContentItem", "my page type title");
            FakeResources.AddString("PageTitle", "PAGETYPE_AllOthers", "my all other title");

            var res = ctrl.CallGetPageTitle();

            Assert.Contains("my content item title", res);
        }
Esempio n. 7
0
        public void Default_validation_messages_can_be_replaced_in_order_to_add_localization_support()
        {
            var messages = new FakeResources("the-message");

            var command = new Command("the-command")
            {
                new Argument
                {
                    Arity = ArgumentArity.ExactlyOne
                }
            };
            var parser = new Parser(new CommandLineConfiguration(new[] { command }, resources: messages));
            var result = parser.Parse("the-command");

            result.Errors
            .Select(e => e.Message)
            .Should()
            .Contain("the-message");
        }