Theory is an xUnit attribute for parameterized tests. It runs one test method repeatedly, using a different argument set each time, so related cases do not require duplicated methods. section 35.5
Supply arguments with one of these data providers:
- [InlineData] places each complete argument set directly above the test method. section 35.5
- [MemberData] reads test data from a static property on the test class. section 35.5
- [ClassData] obtains test data from a separate class. section 35.5
Testing several currency conversions
Decorate ConvertToGbp_ConvertsCorrectly with [Theory] and three [InlineData] attributes: (0, 3, 0), (3, 1.5, 2), and (3.75, 2.5, 1.5). xUnit executes the method three times and reports three separate tests.
