# Unit testing

# Adding MSTest unit testing project to an existing solution

  • Right click on the solution, Add new project
  • From the Test section, select an Unit Test Project
  • Pick a name for the assembly - if you are testing project Foo, the name can be Foo.Tests
  • Add a reference to the tested project in the unit test project references

# Creating a sample test method

MSTest (the default testing framework) requires you to have your test classes decorated by a [TestClass] attribute, and the test methods with a [TestMethod] attribute, and to be public.

public class FizzBuzzFixture
    public void Test1()
        var solver = new FizzBuzzSolver();
        var result = solver.FizzBuzz(1);