I know why this is happening. Compile time string constants always have "\r\n". Runtime uses System.Environment.NewLine which is "\n" on a Mac (and probably Linux as well)
Is there a clean way to write tests that will work on both?
[Fact]
public void StringConst()
{
var expected = """
""";
var actual = new StringBuilder()
.AppendLine()
.ToString();
Assert.Equal(expected, actual); // Fails on Mac
}
I don't really want write;
Assert.Equal(expected, actual.ReplaceLineEndings("\r\n"));
Assert.Equal(expected, actual.Replace(Environment.NewLine, "\r\n"));
UPDATED:
Thank you to @sweeper for pointing me in the right direction. The string constant is dependant on your editor. If your editor is set to use CRLF, then that is what the string constant will hold. If your editor uses LF for line endings, then that is what is used. Silent and invisible problem.