The Artima Developer Community
Sponsored Link

.NET Buzz Forum
NUnit Assert.AreEquals Parameter Ordering

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Peter G Provost

Posts: 849
Nickname: pprovost
Registered: Aug, 2003

Peter G Provost is a Solution Architect for Interlink Group in Denver, CO.
NUnit Assert.AreEquals Parameter Ordering Posted: Jan 27, 2005 12:00 PM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Peter G Provost.
Original Post: NUnit Assert.AreEquals Parameter Ordering
Feed Title: Peter Provost's Geek Noise
Feed URL: /error.aspx?aspxerrorpath=/Rss.aspx
Feed Description: Technology news, development articles, Microsoft .NET, and other stuff...
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Peter G Provost
Latest Posts From Peter Provost's Geek Noise

Advertisement

I regularly take jabs at my boss Jim Newkirk (original author of NUnit 2.x), telling him, “I think you put the parameters to AreEqual in the wrong order. It should be actual, expected and not the other way ‘round.”

To which he consistently replies, “Well, you would be wrong.”

But all kidding aside, I still find myself writing code that assumes the AreEqual method has the opposite ordering.

It comes from the way I write if() statements. I write them like this:

if( myVariable == 4 )
{
  // Do something
}

 I have seen C/C++ programmers do this…

if( 4 == MyVariable )
{
  // Do something
}

…as a way to protect themselved from forgetting the second = symbol (in fact I used to do it too). But as the C# compiler won’t let me make that mistake, I don’t do it anymore.

Which is why I want to write…

Assert.AreEqual( myVariable, 4 );

...instead of...

Assert.AreEqual( 4, myVariable );

But apparently, I'm wrong. But I still type it the other way more often than not.

Now playing: Bob Marley & The Wailers - Misty Morning

Read: NUnit Assert.AreEquals Parameter Ordering

Topic: Thank you, JetBrains! Previous Topic   Next Topic Topic: Visual Studio Hacks Book

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use