3.3. Solution

Before we can start cranking out tests, we need to create a test class. Let's add a new test class for the AccountController and name it AccountControllerTest. In order for it to be a test class, you decorate it with MbUnit's [TestFixture] attribute. Here is the class:

[TestFixture]
class AccountControllerTest
{
}

Convention

Test classes will be named as follows: [class name]Tests. For example, if we are testing the PayController class, then the test fixture will be named PayControllerTests.

Test methods will be named using clear and descriptive names that clearly identify the test and its outcome. You can separate the name either using uppercase letters or using underscores. For example: CallbackShouldReturnNull or callback_should_return_null.

I personally prefer the underscore method, but there will be a mix of both in the code. I settle on using lowercases and underscores toward the end of the book.

There are two Register actions that we need to accommodate. One action just displays the view that would happen with a GET request, and the other will submit the form to the server to perform the registration that would happen with a POST request.

Let's ensure that the user can actually view the Register page. We start by creating a simple test that would simply need to show whether a user can navigate to the Register view, that is, http://evencontact.com/account/register.

I know you are twitching to write your first test. Simmer down and let's think about what we ...

Get ASP.NET MVC 1.0 Test Driven Development: Problem - Design - Solution 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.