Context
When you compare multi-line strings in NUnit test code, you often need to normalize line endings beforehand. A simple .Replace() will do, but:
- it's annoying to put it everywhere.
- the string replacement causes unnecessary memory allocations even when the string doesn't contain any newlines.
Proposal
A more user-friendly option would be handle this at the framework level, similar to the IgnoreCase modifier or the IgnoreWhiteSpace modifier which exist for some constraints.
Example
[Test]
public void TestIgnoringLineEndingFormat(string actual)
{
const string expected = """
multi-line
raw
string
literal
""";
Assert.That(actual, Is.EqualTo(expected).IgnoreLineEndingFormat);
}
Context
When you compare multi-line strings in NUnit test code, you often need to normalize line endings beforehand. A simple
.Replace()will do, but:Proposal
A more user-friendly option would be handle this at the framework level, similar to the
IgnoreCasemodifier or theIgnoreWhiteSpacemodifier which exist for some constraints.Example