3.2. Design

Since we are using TDD, we can probably think of our tests as our design. We start by creating a test for a specific feature/requirement, and then we write the code needed to satisfy the test. In essence, we are designing our application by writing tests. For example, if we want to accept only usernames that contain only letters and that are three or more characters long, then we will write a test for that followed by code to satisfy the test.

As mentioned in the previous chapter, the registration process involves the following steps:

  1. Collect name, email, password, security question and answer.

  2. Ensure username is unique.

  3. Ensure username is valid:

    • It is 4 characters or more.

    • It starts with a letter.

    • It contains only letters, numbers, and underscore.

  4. Ensure email is unique and valid.

  5. Create the user account and log the user in.

Get ASP.NET MVC 1.0 Test Driven Development: Problem - Design - Solution now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.