Ejemplo n.º 1
0
        public void ConfigureTab_Formats_Tab_ContainerSrc_If_Neccessary()
        {
            //Arrange
            var controller = new PortalSettingsController();
            var settings   = new PortalSettings {
                PortalId = ValidPortalId, DefaultPortalContainer = DefaultContainer, CultureCode = Null.NullString
            };
            var validTab = new TabInfo {
                TabID = ValidTabId, PortalID = ValidPortalId, ContainerSrc = GlobalTabContainer
            };

            settings.ActiveTab         = validTab;
            settings.ActiveTab.SkinSrc = TabSkin;

            var mockLocaleController = new Mock <ILocaleController>();

            mockLocaleController.Setup(c => c.GetLocales(It.IsAny <int>())).Returns(new Dictionary <string, Locale>());
            LocaleController.RegisterInstance(mockLocaleController.Object);

            var mockTabController = new Mock <ITabController>();

            mockTabController.Setup(c => c.GetTabsByPortal(ValidPortalId)).Returns(new TabCollection(new List <TabInfo> {
                validTab
            }));
            mockTabController.Setup(c => c.GetTabsByPortal(HostPortalId)).Returns(new TabCollection());
            TabController.SetTestableInstance(mockTabController.Object);

            //Act
            controller.ConfigureActiveTab(settings);

            //Assert
            Assert.AreEqual(SkinController.FormatSkinSrc(GlobalTabContainer, settings), settings.ActiveTab.ContainerSrc);
        }
Ejemplo n.º 2
0
 private string GenerateMarkup(Dictionary <string, string> Attributes)
 {
     try
     {
         PortalSettings ps = PortalController.Instance.GetCurrentSettings() as PortalSettings;
         IDictionary <string, object> Objects = new ExpandoObject() as IDictionary <string, object>;
         if (ps != null && ps.ActiveTab != null && ps.ActiveTab.BreadCrumbs == null)
         {
             PortalSettingsController controller = new PortalSettingsController();
             controller.ConfigureActiveTab(ps);
         }
         if (ps != null && ps.ActiveTab != null && ps.ActiveTab.BreadCrumbs != null && ps.ActiveTab.BreadCrumbs.Count > 0)
         {
             Objects.Add("ActiveTab", ps.ActiveTab);
             Objects.Add("Request", HttpContext.Current.Request);
             string Template = RazorEngineManager.RenderTemplate(ExtensionInfo.GUID, BlockPath, Attributes["data-block-template"], Objects);
             Template = new DNNLocalizationEngine(null, ResouceFilePath, false).Parse(Template);
             return(Template);
         }
         return(string.Empty);
     }
     catch (Exception ex)
     {
         DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
         return(ex.Message);
     }
 }
        public void ConfigureTab_Builds_Breadcrumbs_For_Tab()
        {
            // Arrange
            var controller = new PortalSettingsController();
            var settings   = new PortalSettings {
                PortalId = ValidPortalId, CultureCode = Null.NullString
            };
            var validTab = new TabInfo {
                TabID = ValidTabId, PortalID = ValidPortalId, SkinSrc = GlobalTabSkin
            };

            settings.ActiveTab = validTab;

            var mockLocaleController = new Mock <ILocaleController>();

            mockLocaleController.Setup(c => c.GetLocales(It.IsAny <int>())).Returns(new Dictionary <string, Locale>());
            LocaleController.RegisterInstance(mockLocaleController.Object);

            var mockTabController = new Mock <ITabController>();

            mockTabController.Setup(c => c.GetTabsByPortal(ValidPortalId)).Returns(new TabCollection(new List <TabInfo> {
                validTab
            }));
            mockTabController.Setup(c => c.GetTabsByPortal(HostPortalId)).Returns(new TabCollection());
            TabController.SetTestableInstance(mockTabController.Object);

            this.mockHostController.Setup(c => c.GetString("DefaultPortalContainer")).Returns("DefaultPortalContainer");

            // Act
            controller.ConfigureActiveTab(settings);

            // Assert
            Assert.NotNull(settings.ActiveTab.BreadCrumbs);
            Assert.AreEqual(1, settings.ActiveTab.BreadCrumbs.Count);
        }
        public void ConfigureTab_Uses_PortalSettings_DefaultSkin_If_SkinSrc_Not_Set()
        {
            // Arrange
            var controller = new PortalSettingsController();
            var settings   = new PortalSettings {
                PortalId = ValidPortalId, DefaultPortalSkin = DefaultSkin, DefaultPortalContainer = DefaultContainer, CultureCode = Null.NullString
            };
            var validTab = new TabInfo {
                TabID = ValidTabId, PortalID = ValidPortalId
            };

            settings.ActiveTab = validTab;

            this.mockHostController.Setup(c => c.GetString("DefaultPortalSkin")).Returns(DefaultSkin);
            this.mockHostController.Setup(c => c.GetString("DefaultPortalContainer")).Returns("DefaultPortalContainer");

            var mockLocaleController = new Mock <ILocaleController>();

            mockLocaleController.Setup(c => c.GetLocales(It.IsAny <int>())).Returns(new Dictionary <string, Locale>());
            LocaleController.RegisterInstance(mockLocaleController.Object);

            var mockTabController = new Mock <ITabController>();

            mockTabController.Setup(c => c.GetTabsByPortal(ValidPortalId)).Returns(new TabCollection(new List <TabInfo> {
                validTab
            }));
            mockTabController.Setup(c => c.GetTabsByPortal(HostPortalId)).Returns(new TabCollection());
            TabController.SetTestableInstance(mockTabController.Object);

            // Act
            controller.ConfigureActiveTab(settings);

            // Assert
            Assert.AreEqual(DefaultSkin, settings.ActiveTab.SkinSrc);
        }
        public void ConfigureTab_Uses_Tab_SkinSrc_If_SkinSrc_Set()
        {
            //Arrange
            var controller = new PortalSettingsController();
            var settings   = new PortalSettings {
                PortalId = ValidPortalId, DefaultPortalSkin = DefaultSkin
            };
            var validTab = new TabInfo {
                TabID = ValidTabId, PortalID = ValidPortalId, SkinSrc = TabSkin
            };

            settings.ActiveTab = validTab;

            var mockLocaleController = new Mock <ILocaleController>();

            mockLocaleController.Setup(c => c.GetLocales(It.IsAny <int>())).Returns(new Dictionary <string, Locale>());
            LocaleController.RegisterInstance(mockLocaleController.Object);

            var mockTabController = new Mock <ITabController>();

            mockTabController.Setup(c => c.GetTabsByPortal(ValidPortalId)).Returns(new TabCollection(new List <TabInfo> {
                validTab
            }));
            mockTabController.Setup(c => c.GetTabsByPortal(HostPortalId)).Returns(new TabCollection());
            TabController.SetTestableInstance(mockTabController.Object);

            //Act
            controller.ConfigureActiveTab(settings);

            //Assert
            Assert.AreEqual(TabSkin, settings.ActiveTab.SkinSrc);
        }
Ejemplo n.º 6
0
        public void ConfigureTab_Builds_Breadcrumbs_For_Tab_And_Parent()
        {
            //Arrange
            var controller = new PortalSettingsController();
            var settings   = new PortalSettings {
                PortalId = ValidPortalId, CultureCode = Null.NullString
            };
            var validTab = new TabInfo {
                TabID = ValidTabId, PortalID = ValidPortalId, ParentId = ParentTabId
            };
            var parentTab = new TabInfo {
                TabID = ParentTabId, PortalID = ValidPortalId
            };

            settings.ActiveTab         = validTab;
            settings.ActiveTab.SkinSrc = TabSkin;

            var mockLocaleController = new Mock <ILocaleController>();

            mockLocaleController.Setup(c => c.GetLocales(It.IsAny <int>())).Returns(new Dictionary <string, Locale>());
            LocaleController.RegisterInstance(mockLocaleController.Object);

            var mockTabController = new Mock <ITabController>();

            mockTabController.Setup(c => c.GetTabsByPortal(ValidPortalId)).Returns(new TabCollection(new List <TabInfo> {
                validTab, parentTab
            }));
            mockTabController.Setup(c => c.GetTabsByPortal(HostPortalId)).Returns(new TabCollection());
            TabController.SetTestableInstance(mockTabController.Object);

            var mockHostController = new Mock <IHostController>();

            mockHostController.Setup(c => c.GetString("DefaultPortalContainer")).Returns("DefaultPortalContainer");
            HostController.RegisterInstance(mockHostController.Object);

            //Act
            controller.ConfigureActiveTab(settings);

            //Assert
            var actualParent = settings.ActiveTab.BreadCrumbs[0] as TabInfo;
            var actualTab    = settings.ActiveTab.BreadCrumbs[1] as TabInfo;

            Assert.AreEqual(2, settings.ActiveTab.BreadCrumbs.Count);
            Assert.AreEqual(ValidTabId, actualTab.TabID);
            Assert.AreEqual(ParentTabId, actualParent.TabID);
        }