|
Ravi Bhavnani wrote: But shouldn't it be "Token received" if token isn't Guid.Empty ?
A perfect illustration of the mental gymnastics involved here.
Assert.IsTrue displays the message if the assumption isn't met.
Assert.IsTrue(token != Guid.Empty, ... displays the message if token == Guid.Empty , meaning that "token not received" is the correct message.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Gaaah!
I'm going to blame it on lack of caffeine, even though the real reason is sheer stupidity.
/ravi
|
|
|
|
|
Richard Deeming wrote: perfect illustration of the mental gymnastic Or, perfect illustration of the twisted minds that defined 'Assert semantics
«Where is the Life we have lost in living? Where is the wisdom we have lost in knowledge? Where is the knowledge we have lost in information?» T. S. Elliot
|
|
|
|
|
I understand Option 1 easier and faster Thats my style
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
One
#SupportHeForShe
Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson
You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
|
|
|
|
|
Always go for what is, not what is not, if possible.
Less mental boggling, that way.
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|
|
I always prefer a positive comparison rather than negative so I prefer the first. Except the "IsFalse" kinda does my head in.
How about
Assert.IsNotTrue(token == Guid.Empty, "Token not received.");
*head explodes*
cheers
Chris Maunder
|
|
|
|
|
Just thinking outside of the box here...
Assert.NotEqual(token, Guid.Empty, "Token not received");
|
|
|
|
|
I prefer the second... I often find myself doing (in C++ unit tests)
ASSERT(!some_condition);
or
ASSERT(some_condition == false);
rather than
ASSERT_FALSE(some_condition);
Same thing, really, but as you say, there's an unconscious desire to be positive, I guess.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
If you prefer to compare a logical expression to a logical constant (true, false), then I beg to disagree!
Do you ask someone: Is it true that you want a cup of coffee? Or do you ask: Do you want a cup of coffee?
You reserve the "Is is true that" form to very special cases, like: Is is true that you love me?
So "== true" or "== false" is completely banned from any code that I handle!
|
|
|
|
|
I always chose "!=" over "==", as an habit of the embedded world where == is forbidden by implicit rules due to the possible mistake with =.
|
|
|
|
|
Your compiler needs better warning detection.
"They have a consciousness, they have a life, they have a soul! Damn you! Let the rabbits wear glasses! Save our brothers! Can I get an amen?"
|
|
|
|
|
Warnings are for sissies. That's what my compiler told me.
|
|
|
|
|
I would prefer something that rings true and has an explanation when it fails.
Assert.IsTrue(TokenIsValid(token), "Invalid Token: "+ TokenCheck(token));
TokenCheck would say "Empty", "Wrong Length...must be 4 bytes" (or whatever), "Exceeds limits of 0-100"...etc....
Mike
|
|
|
|
|
Marc Clifton wrote:
Assert.IsTrue(token != Guid.Empty, "Token not received.");
Assert.IsTrue(token != Guid.Empty, "Token is empty (not received).");
The sense of the description now matches that of the assertion.
Software Zen: delete this;
|
|
|
|
|
Since there is a negation in the statement, I'd rather use option 2 in this case. The negation is clearer to me.
|
|
|
|
|
For me, it depends.
From my "programming childhood" I was brought up to write every funcition as a (1) verify all arguments and preconditions, (2) do the work, (3) prepare the results.
If in step 1 any precondition is not satisfied, then you prepare an error return and get out of there, making no changes. Don't even look at the work and result stages.
If anything in step 2 prevents you from creating a complete result, then you prepare an error return and get out of there, without any side effects or other kinds of results.
In step 3, with all preconditons met and all work successfully completed, you do whatever possible to preserve the results (e.g. wait for locks to be released). If all functions are written in this orderly manner, you very rarely run into problems in this step.
These "Get out of there" tests are usually semantically negative, even though they may be syntactically positive ("if (parameter outside legal range) ..."). The essential part is: Don't bother the clean work with debris (I count "n" levels of extra indentation due to validity checks as "debris"!). If there is nothing more you can do, then leave!
Any test that ends up in an abort/termination is placed as early as possible - and then there is no "else" and no extra indentation.
Within step 2, and sometimes even in step 1, the "if" selects one of two equally valid actions, or they are elseif-alternatives. In such cases, I write the test so that the most likely case comes first (even when that requieres negation of the logical expression). An elseif-sequence is ordered in decreasing likelyhood. The final else is the least likely one - like a default at the end of a switch case statement.
|
|
|
|
|
Option 1. Option 2, one could type token = guid.Empty. Or rewrite option 2 to guid.Empty == token.
|
|
|
|
|
Do we know that reincarnation is real for Italians, because of all the pasta lives they have?
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Not sure. Let me noodle on it for a while...
“The palest ink is better than the best memory.” - Chinese Proverb
|
|
|
|
|
...and they always have a good view on things: Pasta la Vista!
- I would love to change the world, but they won’t give me the source code.
|
|
|
|
|
Country folk, yes, but not so much for ziti dwellers. I rotini check on this information in my ditalini base and it seems true (orzo I imagined).
It may also explain the liking for Angel Hair.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
I thought it had to something to do with flowers. All righty then.
"They have a consciousness, they have a life, they have a soul! Damn you! Let the rabbits wear glasses! Save our brothers! Can I get an amen?"
|
|
|
|
|
That's-a pizza cake!
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
I though it was about (RE) an extinct native American (INCA) population (NATION)
|
|
|
|