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};
            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);
        }
        public void GetActiveTab_Sets_StartDate_And_EndDate_Of_Tab_If_Not_Set()
        {
            //Arrange
            var controller = new PortalSettingsController();
            var settings = new PortalSettings { PortalId = ValidPortalId };
            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);
        }
        public void GetActiveTab_Gets_Correct_Tab_If_Valid_Host_TabId()
        {
            //Arrange
            var controller = new PortalSettingsController();
            var settings = new PortalSettings { PortalId = ValidPortalId };
            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);
        }