public void MatchMethod() { it("should return true if an exception of the given type was thrown", () => { exceptionMatcher = new ExceptionMatcher(typeof(InvalidCastException)); Action closure = () => { throw new InvalidCastException(); }; expect(exceptionMatcher.Match(closure)).toEqual(true); }); it("should return false if an exception with the wrong type was thrown", () => { exceptionMatcher = new ExceptionMatcher(typeof(InvalidCastException)); Action closure = () => { throw new IndexOutOfRangeException(); }; expect(exceptionMatcher.Match(closure)).toEqual(false); }); it("should throw an invalid operation exception if a delegate wasn't provided", () => { exceptionMatcher = new ExceptionMatcher(typeof(InvalidCastException)); expect(() => { exceptionMatcher.Match("Trolololol"); }).toThrow <InvalidOperationException>(); }); }
public void ShowStackTraceProperty() { it("should return false", () => { exceptionMatcher = new ExceptionMatcher(null); expect(exceptionMatcher.ShowStackTrace).toEqual(false); }); }
public static AssertionConfiguration GetConfiguration(this int?timeout) { var exceptionMatcher = ExceptionMatcher.FromTypes(typeof(ElementNotFoundException), typeof(WebDriverException), typeof(InvalidOperationException), typeof(PropertyTransformationException)); return(new AssertionConfiguration { ExceptionMatcher = exceptionMatcher, Timeout = timeout ?? DefaultTimeout, Interval = 100 }); }
public static IAssertionResult <T, TSource> That <T, TSource>(this IValueProvider <T, TSource> provider, IResolveConstraint constraint) { var configuration = new AssertionConfiguration <T> { Timeout = 2000, Interval = 100, Assertion = Assertion.FromDelegate <T>(x => NUnit.Framework.Assert.That(x, new ReusableConstraint(constraint))), ExceptionMatcher = ExceptionMatcher.FromTypes(typeof(WebDriverException), typeof(InvalidOperationException), typeof(ElementNotFoundException)) }; return(Kontur.RetryableAssertions.Wait.Assertion(provider, configuration)); }
public void GetFailureMessageMethod() { it("should return the correct message when the match is inverted", () => { exceptionMatcher = new ExceptionMatcher(typeof(InvalidCastException)); expect(exceptionMatcher.GetFailureMessage(true)).toEqual("Expected InvalidCastException to not have been thrown"); }); it("should return the correct message when the match isn't inverted", () => { exceptionMatcher = new ExceptionMatcher(typeof(InvalidCastException)); expect(exceptionMatcher.GetFailureMessage(false)).toEqual("Expected InvalidCastException to have been thrown"); }); }