示例#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);
        }
示例#2
0
        public void GetActiveTab_Gets_Splash_Tab_If_InValid_TabId_And_Both_HomeTab_And_SplashTab_Set()
        {
            //Arrange
            var controller = new PortalSettingsController();
            var settings   = new PortalSettings {
                PortalId = ValidPortalId, SplashTabId = SplashTabId, HomeTabId = HomeTabId, CultureCode = Null.NullString
            };
            var splashTabId = new TabInfo {
                TabID = SplashTabId, PortalID = ValidPortalId
            };
            var homeTabId = new TabInfo {
                TabID = HomeTabId, PortalID = ValidPortalId
            };

            var mockLocaleController = new Mock <ILocaleController>();

            mockLocaleController.Setup(c => c.GetLocales(ValidPortalId)).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> {
                splashTabId, homeTabId
            }));
            TabController.SetTestableInstance(mockTabController.Object);

            //Act
            var tab = controller.GetActiveTab(InValidTabId, settings);

            //Assert
            Assert.AreEqual(SplashTabId, tab.TabID);
        }
示例#3
0
        public void GetActiveTab_Sets_StartDate_And_EndDate_Of_Tab_If_Not_Set()
        {
            //Arrange
            var controller = new PortalSettingsController();
            var settings   = new PortalSettings {
                PortalId = ValidPortalId, CultureCode = Null.NullString
            };
            var validTab = new TabInfo {
                TabID = ValidTabId, PortalID = ValidPortalId
            };

            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
            var tab = controller.GetActiveTab(ValidTabId, settings);

            //Assert
            Assert.AreEqual(DateTime.MinValue, tab.StartDate);
            Assert.AreEqual(DateTime.MaxValue, tab.EndDate);
        }
示例#4
0
        public void GetActiveTab_Gets_Correct_Tab_If_Valid_Host_TabId()
        {
            //Arrange
            var controller = new PortalSettingsController();
            var settings   = new PortalSettings {
                PortalId = ValidPortalId, CultureCode = Null.NullString
            };
            var validTab = new TabInfo {
                TabID = HostTabId, PortalID = HostPortalId
            };

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

            //Act
            var tab = controller.GetActiveTab(HostTabId, settings);

            //Assert
            Assert.AreEqual(validTab.TabID, tab.TabID);
        }
示例#5
0
        public void Setup()
        {
            _sfp                  = new StandardFolderProvider();
            _folderInfo           = new Mock <IFolderInfo>();
            _fileInfo             = new Mock <IFileInfo>();
            _fileWrapper          = new Mock <IFile>();
            _directoryWrapper     = new Mock <IDirectory>();
            _folderManager        = new Mock <IFolderManager>();
            _fileManager          = new Mock <IFileManager>();
            _pathUtils            = new Mock <IPathUtils>();
            _portalControllerMock = new Mock <IPortalController>();
            _portalControllerMock.Setup(p => p.GetPortalSettings(Constants.CONTENT_ValidPortalId))
            .Returns(GetPortalSettingsDictionaryMock());
            _portalControllerMock.Setup(p => p.GetCurrentPortalSettings()).Returns(GetPortalSettingsMock());
            _cryptographyProviderMock = new Mock <CryptographyProvider>();
            _cryptographyProviderMock.Setup(c => c.EncryptParameter(It.IsAny <string>(), It.IsAny <string>()))
            .Returns(Guid.NewGuid().ToString("N"));
            _localeControllerMock = new Mock <ILocaleController>();
            _localeControllerMock.Setup(l => l.GetLocales(Constants.CONTENT_ValidPortalId)).Returns(new Dictionary <string, Locale>
            {
                { "en-us", new Locale() }
            });

            FileWrapper.RegisterInstance(_fileWrapper.Object);
            DirectoryWrapper.RegisterInstance(_directoryWrapper.Object);
            FolderManager.RegisterInstance(_folderManager.Object);
            FileManager.RegisterInstance(_fileManager.Object);
            PathUtils.RegisterInstance(_pathUtils.Object);
            PortalController.SetTestableInstance(_portalControllerMock.Object);
            ComponentFactory.RegisterComponentInstance <CryptographyProvider>("CryptographyProviderMock", _cryptographyProviderMock.Object);
            LocaleController.RegisterInstance(_localeControllerMock.Object);
        }
        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);
        }
示例#9
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);
        }