Daily Archives: May 2, 2019

Creating dotnet solution, project and test project with cli

This is a good source. https://docs.microsoft.com/en-us/dotnet/core/testing/unit-testing-with-mstest 

mkidr MyConsoleProjectWithUnitTest
cd MyConsoleProjectWithUnitTest/
dotnet new sln
mkdir HelloWorldConsole
cd HelloWorldConsole/
dotnet new console 
(or dotnet new classlib for creating Library instead of console project)
dotnet run
cd ..
mkdir HelloWorldConsole.Tests
cd HelloWorldConsole.Tests/
dotnet new mstest 
dotnet add reference ../HelloWorldConsole/HelloWorldConsole.csproj 
cd ..
dotnet sln add HelloWorldConsole/HelloWorldConsole.csproj 
dotnet sln add HelloWorldConsole.Tests/HelloWorldConsole.Tests.csproj
code . 
# Make modifications to your tests, program. 
Cd HelloWorldConsole.Tests
dotnet test