.NET

Unit testing C# with MSTest and .NET Core Part 3 – Create a test

Like I said, I’m a big fan of testing so let’s write a test!

Right click on the test project and create a new Class file named PrimeService_IsPrimeShould.cs

Write the code from here to create your first test!

Awespme! This code creates an object from the class PrimeSerivce and calls the method IsPrime with the argument set to 1.

Since our IsPrime method currently throws an exception the test will fail.

In the solution folder run the test and watch what happens!

dotnet test

Ouch! Failed! Now in the final post we’ll rewrite the method so that the test will pass!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: