diff --git a/SafeExamBrowser.Browser.UnitTests/Handlers/RequestHandlerTests.cs b/SafeExamBrowser.Browser.UnitTests/Handlers/RequestHandlerTests.cs index d024edbe..f09bdc81 100644 --- a/SafeExamBrowser.Browser.UnitTests/Handlers/RequestHandlerTests.cs +++ b/SafeExamBrowser.Browser.UnitTests/Handlers/RequestHandlerTests.cs @@ -6,6 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +using CefSharp; using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; using SafeExamBrowser.Browser.Contracts.Filters; @@ -13,7 +14,10 @@ using SafeExamBrowser.Browser.Handlers; using SafeExamBrowser.Configuration.Contracts; using SafeExamBrowser.I18n.Contracts; using SafeExamBrowser.Logging.Contracts; -using SafeExamBrowser.Settings.Browser; +using SafeExamBrowser.Settings.Browser.Filter; +using SafeExamBrowser.Settings.Browser.Proxy; +using BrowserSettings = SafeExamBrowser.Settings.Browser.BrowserSettings; +using Request = SafeExamBrowser.Browser.Contracts.Filters.Request; namespace SafeExamBrowser.Browser.UnitTests.Handlers { @@ -25,7 +29,7 @@ namespace SafeExamBrowser.Browser.UnitTests.Handlers private Mock logger; private BrowserSettings settings; private Mock text; - private RequestHandler sut; + private TestableRequestHandler sut; [TestInitialize] public void Initialize() @@ -36,13 +40,173 @@ namespace SafeExamBrowser.Browser.UnitTests.Handlers settings = new BrowserSettings(); text = new Mock(); - sut = new RequestHandler(appConfig, filter.Object, logger.Object, settings, text.Object); + sut = new TestableRequestHandler(appConfig, filter.Object, logger.Object, settings, text.Object); } [TestMethod] - public void TODO() + public void MustDetectQuitUrl() { - // Use inheritance to test functionality! + var eventFired = false; + var quitUrl = "http://www.byebye.com"; + var request = new Mock(); + + request.SetupGet(r => r.Url).Returns(quitUrl); + settings.QuitUrl = quitUrl; + sut.QuitUrlVisited += (url) => eventFired = true; + + var blocked = sut.OnBeforeBrowse(Mock.Of(), Mock.Of(), Mock.Of