public void GotExpectedException() { var accessor = new StubAccessor(); var ex = Assert.Throws <InvalidOperationException>(() => accessor.FailingProperty); Assert.NotNull(ex); }
public void NoException() { StubAccessor accessor = new StubAccessor(); Exception ex = Record.Exception(() => accessor.SuccessfulProperty); Assert.Null(ex); }
public void GotDerivedException() { var accessor = new StubAccessor(); var ex = Assert.ThrowsAny <Exception>(() => accessor.FailingProperty); Assert.NotNull(ex); }
public void Exception() { StubAccessor accessor = new StubAccessor(); Exception ex = Record.Exception(() => accessor.FailingProperty); Assert.NotNull(ex); Assert.IsType <InvalidOperationException>(ex); }
public void Exception() { StubAccessor accessor = new StubAccessor(); Exception ex = Record.Exception(() => accessor.FailingProperty); Assert.NotNull(ex); Assert.IsType<InvalidOperationException>(ex); }
public void GotExpectedException() { StubAccessor accessor = new StubAccessor(); Exception ex = Assert.Throws(typeof(InvalidOperationException), () => accessor.FailingProperty); Assert.NotNull(ex); Assert.IsType <InvalidOperationException>(ex); }
public void ExpectExceptionButCodeDoesNotThrow() { StubAccessor accessor = new StubAccessor(); try { Assert.Throws<ArgumentException>(() => accessor.SuccessfulProperty); } catch (AssertActualExpectedException exception) { Assert.Equal("(No exception was thrown)", exception.Actual); } }
public void ExpectExceptionButCodeThrowsDerivedException() { StubAccessor accessor = new StubAccessor(); try { Assert.Throws(typeof(Exception), () => accessor.FailingProperty); } catch (AssertException exception) { Assert.Equal("Assert.Throws() Failure", exception.UserMessage); } }
public static void ExpectExceptionButCodeThrowsDerivedException() { var accessor = new StubAccessor(); try { Assert.Throws <Exception>(() => accessor.FailingProperty); } catch (XunitException exception) { Assert.Equal("Assert.Throws() Failure", exception.UserMessage); } }
public void ExpectExceptionButCodeDoesNotThrow() { StubAccessor accessor = new StubAccessor(); try { Assert.Throws <ArgumentException>(() => accessor.SuccessfulProperty); } catch (AssertActualExpectedException exception) { Assert.Equal("(No exception was thrown)", exception.Actual); } }
public void StackTraceForThrowsIsOriginalThrowNotAssertThrows() { var accessor = new StubAccessor(); try { Assert.Throws <InvalidCastException>(() => accessor.FailingProperty); } catch (AssertActualExpectedException exception) { Assert.Contains("StubAccessor.get_FailingProperty", exception.StackTrace); Assert.DoesNotContain("Xunit.Assert", exception.StackTrace); } }
public void StackTraceForThrowsIsOriginalThrowNotAssertThrows() { var wasFilterStackTraceAssemblyPrefix = AssertException.FilterStackTraceAssemblyPrefix; AssertException.FilterStackTraceAssemblyPrefix = "Should.Core"; StubAccessor accessor = new StubAccessor(); Assert.ThrowsDelegateWithReturn throwsDelegateWithReturn = () => accessor.FailingProperty; try { Assert.Throws <InvalidCastException>(throwsDelegateWithReturn); } catch (AssertActualExpectedException exception) { Assert.Contains(GetMethodFullName(throwsDelegateWithReturn), exception.StackTrace); Assert.DoesNotContain("Should.Core", exception.StackTrace); } finally { AssertException.FilterStackTraceAssemblyPrefix = wasFilterStackTraceAssemblyPrefix; } }
public void GotExpectedException() { StubAccessor accessor = new StubAccessor(); Exception ex = Assert.Throws(typeof(InvalidOperationException), () => accessor.FailingProperty); Assert.NotNull(ex); Assert.IsType<InvalidOperationException>(ex); }
public void StackTraceForThrowsIsOriginalThrowNotAssertThrows() { StubAccessor accessor = new StubAccessor(); try { Assert.Throws<InvalidCastException>(() => accessor.FailingProperty); } catch (AssertActualExpectedException exception) { Assert.Contains("StubAccessor.get_FailingProperty", exception.StackTrace); Assert.DoesNotContain("Xunit.Assert", exception.StackTrace); } }
public void GotDerivedException() { var accessor = new StubAccessor(); var ex = Assert.ThrowsAny<Exception>(() => accessor.FailingProperty); Assert.NotNull(ex); }
public void GotExpectedException() { var accessor = new StubAccessor(); var ex = Assert.ThrowsAny<InvalidOperationException>(() => accessor.FailingProperty); Assert.NotNull(ex); }
public static void ExpectExceptionButCodeThrowsDerivedException() { var accessor = new StubAccessor(); try { Assert.Throws(typeof(Exception), () => accessor.FailingProperty); } catch (XunitException exception) { Assert.Equal("Assert.Throws() Failure", exception.UserMessage); } }
public void ExpectExceptionButCodeThrowsDerivedException() { StubAccessor accessor = new StubAccessor(); try { Assert.Throws<Exception>(() => accessor.FailingProperty); } catch (AssertException exception) { Assert.Equal("Assert.Throws() Failure", exception.UserMessage); } }
public void StackTraceForThrowsIsOriginalThrowNotAssertThrows() { var wasFilterStackTraceAssemblyPrefix = AssertException.FilterStackTraceAssemblyPrefix; AssertException.FilterStackTraceAssemblyPrefix = "Should.Core"; StubAccessor accessor = new StubAccessor(); Assert.ThrowsDelegateWithReturn throwsDelegateWithReturn = () => accessor.FailingProperty; try { Assert.Throws<InvalidCastException>(throwsDelegateWithReturn); } catch (AssertActualExpectedException exception) { Assert.Contains(GetMethodFullName(throwsDelegateWithReturn), exception.StackTrace); Assert.DoesNotContain("Should.Core", exception.StackTrace); } finally { AssertException.FilterStackTraceAssemblyPrefix = wasFilterStackTraceAssemblyPrefix; } }