コード例 #1
0
        public void RedirectToMaintenancePageIfAppropriate()
        {
            try
            {
                bool redirect = _checker.ShouldBeRedirectedToMaintenancePage();

                if (redirect)
                {
                    string maintenancePageUrl = _configurationReader.GetRequiredSetting("TarantinoWebManagementMaintenancePage");
                    _context.ServerTransfer(maintenancePageUrl, false);
                }
            }
            catch
            {
            }
        }
コード例 #2
0
        public void Does_not_redirect_if_its_not_supposed_to()
        {
            MockRepository mocks = new MockRepository();

            IMaintenanceRedirectionChecker checker = mocks.CreateMock <IMaintenanceRedirectionChecker>();

            using (mocks.Record())
            {
                Expect.Call(checker.ShouldBeRedirectedToMaintenancePage()).Return(false);
            }

            using (mocks.Playback())
            {
                IMaintenancePageRedirector redirector = new MaintenancePageRedirector(null, null, checker);
                redirector.RedirectToMaintenancePageIfAppropriate();
            }
        }
コード例 #3
0
        public void Does_not_redirect_if_an_exception_takes_place()
        {
            MockRepository mocks = new MockRepository();

            IConfigurationReader           reader  = mocks.CreateMock <IConfigurationReader>();
            IMaintenanceRedirectionChecker checker = mocks.CreateMock <IMaintenanceRedirectionChecker>();

            using (mocks.Record())
            {
                Expect.Call(checker.ShouldBeRedirectedToMaintenancePage()).Return(true);
                Expect.Call(reader.GetRequiredSetting("TarantinoWebManagementMaintenancePage")).Throw(new Exception());
            }

            using (mocks.Playback())
            {
                IMaintenancePageRedirector redirector = new MaintenancePageRedirector(null, reader, checker);
                redirector.RedirectToMaintenancePageIfAppropriate();
            }
        }
コード例 #4
0
        public void Does_redirect_if_appropriate()
        {
            MockRepository mocks = new MockRepository();

            IWebContext                    context = mocks.CreateMock <IWebContext>();
            IConfigurationReader           reader  = mocks.CreateMock <IConfigurationReader>();
            IMaintenanceRedirectionChecker checker = mocks.CreateMock <IMaintenanceRedirectionChecker>();

            using (mocks.Record())
            {
                Expect.Call(checker.ShouldBeRedirectedToMaintenancePage()).Return(true);
                Expect.Call(reader.GetRequiredSetting("TarantinoWebManagementMaintenancePage")).Return("DownForMaintenance.aspx");
                context.ServerTransfer("DownForMaintenance.aspx", false);
            }

            using (mocks.Playback())
            {
                IMaintenancePageRedirector redirector = new MaintenancePageRedirector(context, reader, checker);
                redirector.RedirectToMaintenancePageIfAppropriate();
            }
        }