Bookmark Collection: Checking Input Parameters

The tests that I am going to implement this time around have to do with the input parameters to the Add method. Both input parameters in this example cannot be null. If they are null then the Add method should throw ArgumentNullException. Here’s the test: [Test, ExpectedException(typeof(ArgumentNullException))]public void AddNullLabelBookmark(){   collection.Add(null, exampleDotComUri);} When I run this test…


Bookmark Collection: Current progress

When I was thinking about the next test to write I had to go back and look at the test list again. If I can’t keep the thing in my head how hard must it be for everyone else? The purpose of this entry is to identify what has been completed so far and modify…


Bookmark Collection: Retrieving a bookmark that is not in the collection

Let’s see where we were… Retrieve a Bookmark that is not in the collection, return null The test for this looks like this: [Test]public void RetrieveABookmarkNotInCollection(){   Assert.IsNull(collection[exampleDotComLabel]);} When I run this I get the following error: BookmarkCollectionFixture.RetrieveABookmarkNotInCollection : System.Collections.Generic.KeyNotFoundException : The given key was not present in the dictionary. Unfortunately it does not return null like I…


Bookmark Collection: To collect or not to collect (and when)

The next test to implement is as follows: Add a Bookmark, Retrieve using the label All the tests I wrote previously and the resulting implementation focused on whether or not the count was correct as bookmarks were added and removed from the collection. This test demands that the collection return a bookmark using the label….


Why variables in NUnit [TestFixture] classes should be static?

In a previous post Ben Lowery asked the question? Why is the collection in your test fixture class static? Here is the code from the previous post: [TestFixture]public class BookmarkCollectionFixture{   private static BookmarkCollection collection;    [SetUp]   public void BeforeTest()   {      collection = new BookmarkCollection();   }    // …} The reason that I do this is not so subtle, so let me explain. I…


Bookmark Collection: Adding and Removing a Bookmark – Does the Count keep up?

I have given up apologizing for the not so weekly updates to solving this problem – just too much going on. That said; where was I? In the previous step I had refactored out the common initialization code out of each test and put this in the [SetUp] method, named BeforeTest. If I had NUnit…


Refactoring: Introduce SetUp Method

Tests in a TestFixture share common initialization code. Create a method in the TestFixture, move common initialization code to the method, and execute the method prior to each test.    Before: [Test]public void UponCreationCountIsZero(){   BookmarkCollection collection = new BookmarkCollection();   Assert.AreEqual(0, collection.Count);} [Test]public void AddBookmarkCountIsIncremented(){   BookmarkCollection collection = new BookmarkCollection();   collection.Add(“Label”, new Uri(;   Assert.AreEqual(1, collection.Count);} After the Refactoring: [TestFixture]public class BookmarkCollectionFixture{   private…


Bookmark Collection: Implementing the Add Method

The first test I implemented last week turned out to describe an excellent example of the Fake It (‘Til You Make It’) pattern. As we continue with the next test let’s see if we will continue to “Fake It” or do we have enough tests and information to begin formulating a solution. The next test…


Bookmark Collection: Choosing the first test

Sorry for the diversions and the delay. The first thing I need to is choose the first test. It really does not matter which test is chosen first, really it doesn’t. I have to finish all of the tests to finish the task. There are a couple of choices. I could choose the first test,…


Attending Game 4 of the Baseball World Series

I just got home from a whirlwind trip to St. Louis to see the Cardinals play the Boston Red Sox in the World Series. A good friend of mine (thanks Brian) had an extra ticket and asked if I wanted to attend. I jumped at the chance because I have been a St. Louis Cardinal fan…