public void WaitUntilExistsTimeOutExceptionInnerExceptionSetToLastExceptionThrown() { var domContainerMock = new Mock <DomContainer>(new object[] { }); var finderMock = new Mock <ElementFinder>(null, null); finderMock.Expect(finder => finder.FindFirst()).Throws(new Exception("")); finderMock.Expect(finder => finder.FindFirst()).Throws(new UnauthorizedAccessException("mockUnauthorizedAccessException")).AtMostOnce(); element = new Element(domContainerMock.Object, finderMock.Object); Exceptions.TimeoutException timeoutException = null; try { element.WaitUntilExists(1); } catch (Exceptions.TimeoutException e) { timeoutException = e; } Assert.IsNotNull(timeoutException, "TimeoutException not thrown"); Assert.IsInstanceOfType(typeof(UnauthorizedAccessException), timeoutException.InnerException, "Unexpected innerexception"); Assert.AreEqual("mockUnauthorizedAccessException", timeoutException.InnerException.Message); domContainerMock.VerifyAll(); finderMock.VerifyAll(); }
public void WaitUntilExistsTimeOutExceptionInnerExceptionNotSetToLastExceptionThrown() { var domContainerMock = new Mock <DomContainer>(new object[] { }); var finderMock = new ElementFinderMock(); var counter = 0; finderMock.FindAllElements = () => { counter++; if (counter == 1) { throw new UnauthorizedAccessException(""); } return(new List <Element>()); }; var element1 = new Element(domContainerMock.Object, finderMock); Exceptions.TimeoutException timeoutException = null; try { element1.WaitUntilExists(1); } catch (Exceptions.TimeoutException e) { timeoutException = e; } Assert.IsNotNull(timeoutException, "TimeoutException not thrown"); Assert.IsNull(timeoutException.InnerException, "Unexpected innerexception"); domContainerMock.VerifyAll(); }
public void WaitUntilExistsTimeOutExceptionInnerExceptionNotSetToLastExceptionThrown() { var domContainerMock = new Mock <DomContainer>(new object[] { }); var finderMock = new Mock <ElementFinder> (null, null); finderMock.Expect(finder => finder.FindFirst()).Throws(new UnauthorizedAccessException("")); finderMock.Expect(finder => finder.FindFirst()).Returns((Element)null); //.AtMostOnce(); var element1 = new Element(domContainerMock.Object, finderMock.Object); Exceptions.TimeoutException timeoutException = null; try { element1.WaitUntilExists(1); } catch (Exceptions.TimeoutException e) { timeoutException = e; } Assert.IsNotNull(timeoutException, "TimeoutException not thrown"); Assert.IsNull(timeoutException.InnerException, "Unexpected innerexception"); domContainerMock.VerifyAll(); finderMock.VerifyAll(); }
public void WaitUntilExistsTimeOutExceptionInnerExceptionSetToLastExceptionThrown() { var domContainerMock = new Mock <DomContainer>(new object[] { }); var finderMock = new ElementFinderMock(); var counter = 0; finderMock.FindAllElements = () => { counter++; if (counter == 1) { throw new Exception(""); } throw new UnauthorizedAccessException("mockUnauthorizedAccessException"); }; element = new Element(domContainerMock.Object, finderMock); Exceptions.TimeoutException timeoutException = null; try { element.WaitUntilExists(1); } catch (Exceptions.TimeoutException e) { timeoutException = e; } Assert.IsNotNull(timeoutException, "TimeoutException not thrown"); Assert.IsInstanceOf(typeof(UnauthorizedAccessException), timeoutException.InnerException, "Unexpected innerexception"); Assert.AreEqual("mockUnauthorizedAccessException", timeoutException.InnerException.Message); domContainerMock.VerifyAll(); }