This article explains how you can set up a unit test method that will retrieve values used in the test method from a data source using the Microsoft unit test framework for managed code. Creating these data-driven unit tests makes it easy to test a multiple inputs with a single method.
Creating a data-driven unit test involves the following steps:
1. Create a data source that contains the values that you use in the test method. The data source can be any type that is registered on the machine that runs the test.
2. Add a private TestContext field and a public TestContext property to the test class.
3. Create a unit test method and add a DataSourceAttribute attribute to it.
4. Use the DataRow indexer property to retrieve the values that you use in a test.
All these steps are described in detail in the article.