Using Theory in xUnit for unit tests

xUnit is one of the unit test frameworks available for .NET Core applications.

When writing a test, you can use the Theory attribute to create parameterised unit tests.

The parameters can be passed in using the InlineData attribute.

Take this code:

public static class AdditionHelper
{
	public static int Addition(int number1, int number2)
	{
		return number1 + number2;
	}
}

public class AdditionTests
{
	
	public void Addition_TwoNumbers_Equals9(int number1, int number2)
	{
		Assert.Equal(9, number1 + number2);
	}
}

We are wanting to test the static Addition method in the AdditionHelper class. We want to add the Addition_TwoNumbers_Equals9 method as a test in our xUnit project.

However, this unit test will not run. What changes would we need to make for this test to run?