Re: Exception message mismatch
"Charlie Poole" <[email protected]>
| Newsgroups | gmane.comp.windows.dotnet.nunit.user |
|---|---|
| Message-ID | <000001c8cb14$2d9b5c40$1400000a@ferrari> |
Hi Eric, Assuming you have copied exactly, the actual exception message seems to have a leading space or tab. There doesn't seem to be a problem with the escape sequences. In my own experience, I have found that tests requiring an exact match on messages created by .NET are not very robust from version to version, so I now use either substrings or regular expressions to leave a bit of room for variation. Charlie _____ From: [email protected] [mailto:[email protected]] On Behalf Of Eric Sent: Sunday, June 08, 2008 6:04 PM To: [email protected] Subject: [Nunit-users] Exception message mismatch I'm testing for an ArgumentNullException message, so there will be info about the parameter name in the message. When I look at the chars in the message via the debugger, it shows the embedded escape sequences to be \r\n, yet the code below fails. Why? TIA, Eric ---------- TEST ------------- [Test, ExpectedException(typeof(ArgumentNullException), ExpectedMessage = "'Group Name' may not be null.\r\nParameter name: String")] public void Add_ErrorIfNullGroupKey() { var unit = new Unit("USD"); Assert.That(Registrar.Exists(unit), Is.False); Registrar.Fetch(null, unit.Name); } ---------- RESULT ------------- RegistrarTest.Add_ErrorIfNullGroupKey : Failed Expected exception message: 'Group Name' may not be null. Parameter name: String got: 'Group Name' may not be null. Parameter name: String ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Nunit-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/nunit-users