Comparing Strings in Unit Tests

Posted by: youve been HAACKED, on 14 Jan 2012 | View original | Bookmarked: 0 time(s)

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"); } Lets 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...

Advertisement
Free Agile Project Management Tool from Telerik
TeamPulse Community Edition helps your team effectively capture requirements, manage project plans, assign and track work, and most importantly, be continually connected with each other.
Category: C# | Other Posts: View all posts by this blogger | Report as irrelevant | View bloggers stats | Views: 400 | Hits: 52

News Categories

.NET | Agile | Ajax | Architecture | ASP.NET | BizTalk | C# | Certification | Data | DataGrid | DataSet | Debugger | DotNetNuke | Events | GridView | IIS | Indigo | JavaScript | Mobile | Mono | Patterns and Practices | Performance | Podcast | Refactor | Regex | Security | Sharepoint | Silverlight | Smart Client Applications | Software | SQL | VB.NET | Visual Studio | W3 | WCF | WinFx | WPF | WSE | XAML | XLinq | XML | XSD