public void Throws_ThrowsException_WhenDerivedException() { var sut = new AClassWithExceptions(); Assert.Throws <ThrowsException>(() => Assert.Throws <BaseException>( () => sut.Throw(new DerivedException("DerivedException"))) ); }
public void ThrowsAny_ThrowsException_WhenNoExceptiontThrown() { var sut = new AClassWithExceptions(); Assert.Throws <ThrowsException>(() => Assert.ThrowsAny <BaseException>( () => sut.Throw(null)) ); }
public void ThrowsAny_DerivedException() { var sut = new AClassWithExceptions(); var ex = Assert.ThrowsAny <BaseException>( () => sut.Throw(new DerivedException("DerivedMessage"))); Assert.NotNull(ex); Assert.IsType <DerivedException>(ex); Assert.Equal("DerivedMessage", ex.Message); }
public void Throws() { var sut = new AClassWithExceptions(); var ex = Assert.Throws <BaseException>( () => sut.Throw(new BaseException("BaseMessage"))); Assert.NotNull(ex); Assert.IsType <BaseException>(ex); Assert.Equal("BaseMessage", ex.Message); }