Created
July 26, 2013 09:33
-
-
Save huseyint/6087575 to your computer and use it in GitHub Desktop.
Dictionary with single item assertion
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
// headers is a Dictionary<string, string> | |
Assert.AreEqual(1, headers.Count); | |
Assert.AreEqual("bar", headers["foo"]); | |
// Do I need both of these? Only first? Only second? | |
// Only 1st: What if the item is different than what I expected? | |
// Only 2nd: If dictionary is empty, this line will throw an exception before assertion is evaluated, is this OK? | |
// Both: Isn't this against "one assert per unit test" rule? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'd do some variation of:
That states what you expect, and what you verify, in a single assertion, so it addresses all your questions in one go.