Practicing TDD with a real-world example
In TDD, everything begins with the specification and a thorough understanding of the intended functionality. It’s essential to grasp the meaning of what we want to accomplish in order to write effective tests. With that in mind, let’s establish a scenario for our example.
We’ll create a ValidateMail
method that will process email verification. Our goal here is to explore the tools available in Visual Studio to enhance our TDD experience.
Now that we have outlined our requirements, our next step is to begin by creating our unit test project. For this, we’ll choose xUnit, as discussed earlier in this chapter. We will create an empty Class Library Project:
- We’ll start by writing a test, in our xUnit project, that specifies the behavior or functionality we want to implement:
[Fact] public void ValidateMail_NewUser_ReturnsTrue() { // Arrange var user ...