public static CellResult Error(string cell, Exception ex) { ErrorDisplay display = ErrorDisplay.text; var text = ExceptionFormatting.ToDisplayMessage(ex, out display); return(Error(cell, text, display)); }
public void render_the_message_of_an_unknown_exception() { var exception = new DivideByZeroException(); ExceptionFormatting.ToDisplayMessage(exception, out display) .ShouldBe(exception.ToString()); display.ShouldBe(ErrorDisplay.text); }
public void render_the_message_of_a_failure_exception_as_text() { var exception = new TextFailureException("Boom!"); ExceptionFormatting.ToDisplayMessage(exception, out display) .ShouldBe(exception.FormattedMessage()); display.ShouldBe(ErrorDisplay.text); }
public void renders_the_message_of_StorytellerAssertionException() { var exception = new StorytellerAssertionException("It failed!"); ExceptionFormatting.ToDisplayMessage(exception, out display) .ShouldBe("It failed!"); display.ShouldBe(ErrorDisplay.markdown); }
public void render_with_custom_markdown_formatting() { var message = "**Dude, you're trying to divide by zero!**"; // This is registering a conversion to markdown text from any // exception of type DivideByZeroException ExceptionFormatting.AsMarkdown <DivideByZeroException>(ex => message); var exception = new DivideByZeroException(); ExceptionFormatting.ToDisplayMessage(exception, out display) .ShouldBe(message); display.ShouldBe(ErrorDisplay.markdown); }
public void render_with_custom_text_formatting() { var message = "**Dude, you're trying to divide by zero!**"; // Register a purely textual representation of the exception // that maintains whitespace ExceptionFormatting.AsText <DivideByZeroException>(ex => message); var exception = new DivideByZeroException(); ExceptionFormatting.ToDisplayMessage(exception, out display) .ShouldBe(message); display.ShouldBe(ErrorDisplay.text); }
public MartenSystem() { ExceptionFormatting.AsText <ShouldAssertException>(x => x.Message); }
public ExceptionFormattingTests() { ExceptionFormatting.ClearAll(); }
public void ExternallyFormattedException() { ExceptionFormatting.AsMarkdown <InvalidTimeZoneException>(ex => "Invalid timezone, see [valid timezones](https://msdn.microsoft.com/en-us/library/system.timezone(v=vs.110).aspx)"); throw new InvalidTimeZoneException(); }
public StepResult(string id, Exception ex) : this(id, ResultStatus.error) { error = ExceptionFormatting.ToDisplayMessage(ex, out errorDisplay); }