Example #1
0
        public bool ShouldBeRedirectedToMaintenancePage()
        {
            ApplicationInstance instance = _context.GetCurrent();

            bool downForMaintenance = instance.DownForMaintenance;
            bool isExternalUrl      = _urlChecker.CurrentUrlIsExternal();
            bool redirectableUrl    = _extensionChecker.CurrentUrlCanBeRedirected();

            return(redirectableUrl && downForMaintenance && isExternalUrl);
        }
Example #2
0
        private void performTest(bool isRedirectableExtension, bool isExternalUrl, bool isDownForMaintenance, bool shouldBeRedirected)
        {
            ApplicationInstance instance = new ApplicationInstance();

            instance.DownForMaintenance = isDownForMaintenance;

            MockRepository              mocks            = new MockRepository();
            IFileExtensionChecker       extensionChecker = mocks.CreateMock <IFileExtensionChecker>();
            IExternalUrlChecker         urlChecker       = mocks.CreateMock <IExternalUrlChecker>();
            IApplicationInstanceContext context          = mocks.CreateMock <IApplicationInstanceContext>();

            using (mocks.Record())
            {
                Expect.Call(extensionChecker.CurrentUrlCanBeRedirected()).Return(isRedirectableExtension);
                Expect.Call(urlChecker.CurrentUrlIsExternal()).Return(isExternalUrl);
                Expect.Call(context.GetCurrent()).Return(instance);
            }

            using (mocks.Playback())
            {
                IMaintenanceRedirectionChecker checker = new MaintenanceRedirectionChecker(extensionChecker, urlChecker, context);
                Assert.That(checker.ShouldBeRedirectedToMaintenancePage(), Is.EqualTo(shouldBeRedirected));
            }
        }