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…