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, "Count == 0". This test is very simple to implement and would get me started quickly. I could choose "Add a Bookmark, Retrieve using the label". This test also would not be hard to implement and really represents the essance of the problem. For this example, I am going to choose the "Count == 0" test because I want the simplest test to just get started. By the way, I am going to implement the BookmarkCollection in VS 2005. Here is the first test:

using

System;
using NUnit.Framework;

[

TestFixture]
public class BookmarkCollectionFixture
{
[Test]
public void UponCreationCountIsZero()
{
BookmarkCollection collection = new BookmarkCollection();
Assert.AreEqual(0, collection.Count);
}
}

In order to get the test to fail here is the implementation:

using

System;

public class BookmarkCollection
{
public int Count
{
get { return -1; }
}
}

When I run this test in NUnit I get the following result:

BookmarkCollectionFixture.UponCreationCountIsZero :
expected:<0>
but was:<-1>

Now let's choose an implementation to get the test to pass:

using

System;

public class BookmarkCollection
{
public int Count
{
get { return 0; }
}
}

When I run NUnit again the test passes. This implementation may seem ridculous but it really is the simplest design that is needed to pass the test. This is an example of a technique Kent Beck calls: "Fake It ('Til You Make It)". This technique helps us pass the test until we know of a better solution. That's all for the first test.