In the next few lessons, we'll walk through constructing a more complex application together using test-driven development.
We'll build a to do list application with basic functionality to record Item
s with a description. We'll continue working on this program throughout the course as we explore more advanced topics.
Create a ToDoList.Solution
parent directory with the following project structure:
ToDoList.Solution ├── ToDoList │ ├── Models │ │ └── Item.cs │ └── ToDoList.csproj └── ToDoList.Tests ├── ModelTests │ └── ItemTests.cs └── ToDoList.Tests.csproj
Then add all required code to the .csproj
files and run $ dotnet restore
.
Keep in mind that your .csproj
should only include an OutputType
if you have a Program.cs
file with a Main
method. Attempting to compile your project to test your classes before creating the user interface will throw an error, if you accidentally include an OutputType
, and it might not be clear from the error message what the issue is. Similarly, you must remember to add the OutputType
before attempting to run your project with a user interface!
Let's add boilerplate code to our test file:
using Microsoft.VisualStudio.TestTools.UnitTesting;
using ToDoList.Models;
namespace ToDoList.Tests
{
[TestClass]
public class ItemTests
{
// Test methods will go here.
}
}
Item
ClassLet's also add boilerplate code to our Item
class:
namespace ToDoList.Models
{
public class Item
{
// properties, methods, etc. will go here.
}
}
Notice we use the ToDoList.Models
namespace here.
Now that our project structure, configuration files, packages, and boilerplate code is in place, we can begin developing our To Do List in the next lesson.
Lesson 13 of 20
Last updated April 14, 2022