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(http://example.com));   Assert.AreEqual(1, collection.Count);} After the Refactoring: [TestFixture]public class BookmarkCollectionFixture{   private…

16

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…

6

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,…

7