public OnResourceResponse ( IWebBrowser browser, string url, int status, string statusText, string mimeType, |
||
browser | IWebBrowser | |
url | string | |
status | int | |
statusText | string | |
mimeType | string | |
headers | ||
return | void |
public void BrowserHandler_OnResourceResponse_IsPoppingTrue_InvokesConfigurePopupAndResetsIsPopping() { var browser = new Mock<IWebBrowser>(); var popupController = new Mock<IBrowserPopupController>(); popupController.Setup(p => p.ShowPopup(It.IsAny<string>())).Returns(false); popupController.Setup(c => c.ConfigurePopup()).Verifiable(); var x = int.MinValue; var y = int.MinValue; var width = int.MinValue; var height = int.MinValue; var handler = new BrowserHandler(popupController.Object); handler.OnBeforePopup(browser.Object, "myfake.url", ref x, ref y, ref width, ref height); Assert.IsTrue(handler.IsPopping); handler.OnResourceResponse(browser.Object, string.Empty, 0, string.Empty, string.Empty, new WebHeaderCollection()); Assert.IsFalse(handler.IsPopping); popupController.Verify(c => c.ConfigurePopup(), Times.Once()); }
void Verify_OnResourceResponse_RedirectsToPageUnauthorized(HttpStatusCode statusCode, bool redirects) { var hitCount = redirects ? 1 : 0; //------------Setup for test-------------------------- var browser = new Mock<IWebBrowser>(); browser.Setup(b => b.Load(It.Is<string>(s => s.EndsWith(StringResources.Uri_Studio_PageRestrictedAccess)))).Verifiable(); var handler = new BrowserHandler(new Mock<IBrowserPopupController>().Object); //------------Execute Test--------------------------- handler.OnResourceResponse(browser.Object, string.Empty, (int)statusCode, statusCode.ToString(), string.Empty, new WebHeaderCollection()); //------------Assert Results------------------------- browser.Verify(b => b.Load(It.Is<string>(s => s.EndsWith(StringResources.Uri_Studio_PageRestrictedAccess))), Times.Exactly(hitCount)); }
public void BrowserHandler_OnResourceResponse_IsPoppingFalse_DoesNotInvokeConfigurePopup() { var browser = new Mock<IWebBrowser>(); var popupController = new Mock<IBrowserPopupController>(); popupController.Setup(c => c.ConfigurePopup()).Verifiable(); var handler = new BrowserHandler(popupController.Object); Assert.IsFalse(handler.IsPopping); handler.OnResourceResponse(browser.Object, string.Empty, 0, string.Empty, string.Empty, new WebHeaderCollection()); Assert.IsFalse(handler.IsPopping); popupController.Verify(c => c.ConfigurePopup(), Times.Never()); }