Red/Green/Refactor

The following is the implementation of each test in the test list.

Test 1: Create a Stack and verify that IsEmpty is true.

This test requires creating a Stack and then calling the IsEmpty property. The IsEmpty property should return true because we haven’t put any elements into the Stack. Let’s create a file called StackFixture.cs, in which we write a test fixture class, called StackFixture, to hold the tests.

using System;
using NUnit.Framework;

[TestFixture]
public class StackFixture
{ /* ... */ }

There are a few things of interest about this class. The line using NUnit.Framework; is needed to reference the custom attributes defined in NUnit that are used to mark the test fixture. The [TestFixture] attribute can be associated ...

Get Test-Driven Development in Microsoft® .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.