string

There are 1 entries for the tag string

Comparing Strings in Unit Tests

Suppose you have a test that needs to compare strings. Most test frameworks do a fine job with their default equality assertion. But once in a while, you get a case like this: [Fact] public void SomeTest() { Assert.Equal("Hard \tto\ncompare\r\n", "Hard to\r\ncompare\n"); } Let’s pretend the first value in the above test is the expected value and the second value is the value you obtained by calling some method. Clearly, this test fails. So you look at the output and this is what you see: It’s pretty hard to compare those...