fluentassertions / fluentassertions

A very extensive set of extension methods that allow you to more naturally specify the expected outcome of a TDD or BDD-style unit tests. Targets .NET Framework 4.7, as well as .NET Core 2.1, .NET Core 3.0, .NET 6, .NET Standard 2.0 and 2.1. Supports the unit test frameworks MSTest2, NUnit3, XUnit2, MSpec, and NSpec3.
https://www.fluentassertions.com
Apache License 2.0
3.72k stars 544 forks source link

AssertionScope.FailWith can't be told not to unescape line breaks #913

Open AlexanderSher opened 6 years ago

AlexanderSher commented 6 years ago

Description

In the error message, it is easier to compare strings when they are presented escaped. For example,

Line 1\r\n  \tLine 2

and

Line 1\r\n\tLine 2

will look identical in the VS test result window if they are unescaped.

Right now, there is no way to tell AssertionScope.FailWith to not unescape the whole string or some part of the string because MessageBuilder.Build unconditionally calls Unescape(): https://github.com/fluentassertions/fluentassertions/blob/24fba2074035892b0fc82584a6b3d11d2a42dd8f/Src/FluentAssertions/Execution/MessageBuilder.cs#L42

dennisdoomen commented 6 years ago

@jnyrup maybe we should always display tabs and new-lines in their encoded form?

dennisdoomen commented 10 months ago

@AlexanderSher do you still need this?