Click here to Skip to main content
15,887,214 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: It's too complicated to understand Pin
KarstenK16-Mar-17 5:39
mveKarstenK16-Mar-17 5:39 
GeneralRe: It's too complicated to understand Pin
Bernhard Hiller28-Feb-17 21:51
Bernhard Hiller28-Feb-17 21:51 
GeneralRe: It's too complicated to understand Pin
Nathan Minier1-Mar-17 1:24
professionalNathan Minier1-Mar-17 1:24 
GeneralRe: It's too complicated to understand Pin
virang_212-Mar-17 17:13
virang_212-Mar-17 17:13 
GeneralRe: It's too complicated to understand Pin
MarkTJohnson6-Mar-17 4:31
professionalMarkTJohnson6-Mar-17 4:31 
GeneralRe: It's too complicated to understand Pin
Jon McKee6-Mar-17 7:59
professionalJon McKee6-Mar-17 7:59 
GeneralRe: It's too complicated to understand Pin
OriginalGriff6-Mar-17 8:15
mveOriginalGriff6-Mar-17 8:15 
GeneralHow (not) to use mstest Pin
Bernhard Hiller22-Feb-17 2:30
Bernhard Hiller22-Feb-17 2:30 
There are several rants on the functionality of mstest... Yes, it offers a little less than other unit test frameworks.
But there are geniuses using it. What about:
C#
Assert.AreEqual(actual, expected, "Value is wrong: {0}, expected: {1}.", actual, expected);
That guy always wrote a custom message showing both the actual and the expected value. Has he ever read the message of a failing test?
Let's try with int expected = 42; int actual = 7;. The message is:
Assert.AreEqual failed. Expected:<7>. Actual:<42>. Value is wrong: 7, expected: 42.
See: another bug.
Strangely, intellisense shows the signature correctly:
Assert.AreEqual<int>(int expected, int actual, string message, params object[] parameters) (+17 overloads)
Well, even mstest is better than some professionals. Frown | :(

[Edit]
Strange that I need to explain further...
The mstest framework works here absolutely the way it is documented, without any bugs.
A potential source of confusion is the order of arguments to Assert.AreEqual - NUnit does it the other way round. But intellisense shows it correctly, so anyone looking at the screen when writing the test will see where "actual" and "expected" have to go.
For testing your tests, you are expected to show that your test can fail, aren't you? At that moment, you will see the failure message. And now you have another opportunity to see where actual and expected should go: even when you do not provide a custom message mstest will tell you "Assert.AreEqual failed. Expected:<7>. Actual:<42>.", if you provide a custom message that will be appended. And thus you'll see that you do not need to repeat actual and expected in your custom message.
What happened to CodeProject that I need to say that so explicitly? Unsure | :~
[/Edit]

modified 23-Feb-17 3:05am.

GeneralRe: How (not) to use mstest Pin
User 1013254622-Feb-17 4:32
User 1013254622-Feb-17 4:32 
GeneralRe: How (not) to use mstest Pin
Sander Rossel22-Feb-17 5:14
professionalSander Rossel22-Feb-17 5:14 
GeneralRe: How (not) to use mstest Pin
Rob Grainger4-Apr-17 5:26
Rob Grainger4-Apr-17 5:26 
GeneralEnums are for wimps PinPopular
Bernhard Hiller20-Feb-17 20:36
Bernhard Hiller20-Feb-17 20:36 
GeneralRe: Enums are for wimps Pin
Pete O'Hanlon20-Feb-17 22:55
mvePete O'Hanlon20-Feb-17 22:55 
GeneralRe: Enums are for wimps Pin
Bruce Patin22-Feb-17 4:54
Bruce Patin22-Feb-17 4:54 
GeneralRe: Enums are for wimps Pin
David O'Neil21-Feb-17 0:20
professionalDavid O'Neil21-Feb-17 0:20 
JokeRe: Enums are for wimps Pin
Daniel Pfeffer21-Feb-17 2:59
professionalDaniel Pfeffer21-Feb-17 2:59 
JokeRe: Enums are for wimps Pin
David O'Neil21-Feb-17 8:20
professionalDavid O'Neil21-Feb-17 8:20 
GeneralRe: Enums are for wimps Pin
PeejayAdams21-Feb-17 4:45
PeejayAdams21-Feb-17 4:45 
GeneralRe: Enums are for wimps Pin
den2k8821-Feb-17 5:17
professionalden2k8821-Feb-17 5:17 
GeneralRe: Enums are for wimps Pin
Jon McKee21-Feb-17 8:35
professionalJon McKee21-Feb-17 8:35 
GeneralRe: Enums are for wimps Pin
den2k8821-Feb-17 8:59
professionalden2k8821-Feb-17 8:59 
GeneralRe: Enums are for wimps Pin
Leng Vang22-Feb-17 6:22
Leng Vang22-Feb-17 6:22 
GeneralRe: Enums are for wimps Pin
harold aptroot22-Feb-17 6:55
harold aptroot22-Feb-17 6:55 
GeneralRe: Enums are for wimps Pin
Munchies_Matt4-Mar-17 7:36
Munchies_Matt4-Mar-17 7:36 
GeneralRe: Enums are for wimps Pin
Brisingr Aerowing4-Mar-17 8:00
professionalBrisingr Aerowing4-Mar-17 8:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.