Skip to content

Instantly share code, notes, and snippets.

@rpbeukes
Last active October 30, 2018 02:00
Show Gist options
  • Save rpbeukes/dd9405514c15293ff1b9486c15882fe6 to your computer and use it in GitHub Desktop.
Save rpbeukes/dd9405514c15293ff1b9486c15882fe6 to your computer and use it in GitHub Desktop.
dotNetShouldlyShouldThrow
public static TException ShouldThrow<TException>(Action action, string customMessage = null) where TException : Exception
{
var ex = Should.Throw<Exception>(action, customMessage);
ex.ShouldBeOfType<TException>($"{ex.Message}{Environment.NewLine}StackTrace:{Environment.NewLine}{ex.StackTrace}");
return (TException)ex;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment