Skip to content

Latest commit

 

History

History
75 lines (46 loc) · 2.21 KB

README.md

File metadata and controls

75 lines (46 loc) · 2.21 KB

.Net Unit Test Template

A minimal template for setting up a .Net Console App project with unit tests using NUnit in VSCode.

References

Terminal Commands

Pre-requisites: Have the .Net SDK installed on your local machine.

Run /ConsoleApp/Program.cs

dotnet run --project ConsoleApp

Run all unit tests

dotnet test

Configuration

ConsoleApp and TestProject can be renamed to any other new name by renaming all the files and replacing all occurences of the original names to their new names. See this repository for an example.

Troubleshooting

If you have a different .Net SDK version, change the <TargetFramework> field in AdventOfCode.csproj and UnitTests.csproj to the corresponding version that you have.

Setup Steps

The setup steps used to create this template.

1. Console App Setup

In root directory, using VSCode Command Pallete with C# Dev Kit installed: .Net: New Project > Console App.

Name the project ConsoleApp.

In the ConsoleApp directory, Run the following to create a .gitignore file.

dotnet new gitignore

In the ConsoleApp directory, Run the following command to run the Program.cs file.

dotnet run

2. NUnit Setup

In root directory, using VSCode Command Pallete with C# Dev Kit installed: .Net: New Project > NUnit 3 Test Project.

Name the project TestProject

In the TestProject directory, Run the following to create a .gitignore file.

dotnet new gitignore

In the root directory, run the following command to reference the main project ConsoleApp in the test project TestProject.

dotnet add TestProject/TestProject.csproj reference ConsoleApp/ConsoleApp.csproj