Created
March 9, 2018 09:24
-
-
Save dgg/83a3ed53aac63e3260da861c2a3fd953 to your computer and use it in GitHub Desktop.
They-got-your-back
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Test] | |
[TestCase(2, 1, true)] | |
[TestCase(1, 2, false)] | |
[TestCase(1, 1, false)] | |
[TestCase(null, 1, false)] | |
[TestCase(1, null, false)] | |
[TestCase(null, null, false)] | |
public void Snippets_Are_Equivalent(int? qty1, int? qty2, bool result) | |
{ | |
bool shouldCompare = qty1 != null && qty2 != null; | |
bool snippetOne = shouldCompare && (qty1.Value > qty2.Value); | |
bool snippetTwo = qty1 > qty2; | |
Assert.That(snippetOne, Is.EqualTo(snippetTwo).And.EqualTo(result)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int? qty1, qty2; | |
//... | |
bool shouldCompare = qty1 != null && qty2 != null; | |
if (shouldCompare && (qty1.Value > qty2.Value)) | |
{ | |
// do the thing when one is greater than the other | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int? qty1, qty2; | |
//... | |
if (qty1 > qty2) | |
{ | |
// do the thing when one is greater than the other | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment