Background and motivation
Split of from #2496 to ease review.
Some operating systems (Windows) use \r\n as newlines while others (Unix-based) use \n.
In some text-based protocol it's well-defined which type of newline should be used and one would explicitly test that.
var subject = GetValue("a", "b");
subject.Should().Be("a\r\nb");
Manually specifying newlines in tests is cumbersome and easily becomes less readable.
So in all remaining tests we simply wants to test that some newline is used.
Instead of explicitly specifying the newline character
var subject = GetValue();
subject.Should().Be("some\r\nvalue");
it would be a nice to write the tests using verbatim string literals
var subject = GetValue();
subject.Should().BeEquivalentTo(@"some
value");
or even more readable with the C# 11 raw string literals
var subject = GetValue();
subject.Should().BeEquivalentTo("""
some
value
""");
API Proposal
public EquivalencyAssertionOptions<T> IgnoringNewlineStyle()
{
// This will replace "\r\n" with "\n" in actual and expected before comparison
return this;
}
API Usage
var windows = "a\r\nb";
var linux = "a\nb"
windows.Should().BeEquivalentTo(linux, o => o.IgnoringNewlineStyle());
Alternative Designs
No response
Risks
No response
Are you willing to help with a proof-of-concept (as PR in that or a separate repo) first and as pull-request later on?
No
Background and motivation
Split of from #2496 to ease review.
Some operating systems (Windows) use
\r\nas newlines while others (Unix-based) use\n.In some text-based protocol it's well-defined which type of newline should be used and one would explicitly test that.
Manually specifying newlines in tests is cumbersome and easily becomes less readable.
So in all remaining tests we simply wants to test that some newline is used.
Instead of explicitly specifying the newline character
it would be a nice to write the tests using verbatim string literals
or even more readable with the C# 11 raw string literals
API Proposal
API Usage
Alternative Designs
No response
Risks
No response
Are you willing to help with a proof-of-concept (as PR in that or a separate repo) first and as pull-request later on?
No