Let's see where we were...

  • Retrieve a Bookmark that is not in the collection, return null

The test for this looks like this:

public void

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 want it to. I guess I will have to write some code. I need to modify the Indexer to check to see if the label is in the collection. If not it should return null. Here's the code: 

public Uri this[string label]
      if (!dictionary.ContainsKey(label)) return null

      return dictionary[label]; 

I compile and run and the tests pass. Let's move on. The next post will address the following tests:

  • Add a Bookmark with a null label, expect ArgumentNullException
  • Add a Bookmark with a null URL, expect ArgumentNullException  

Surveying the rest of the tests in the test list indicates that there is not much left so I should be able to finish up the task in the next couple of posts.