I'm having essentially the same problem as the question linked below, but I cannot seem to get it to work. I'm getting "cannot apply indexing [] to an expression of type System.Data.DataRow". As far as I can tell, I have implemented the solution correctly.
Problems with data driven testing in MSTest
[TestClass]
public class UnitTest1
{
private TestContext testContextInstance;
public TestContext TestContext
{
get
{
return testContextInstance;
}
set
{
testContextInstance = value;
}
}
private ServiceReference1.ProductCatalogClient client = new ServiceReference1.ProductCatalogClient("BasicHttpBinding_IProductCatalog");
[DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", "|DataDirectory|\\CountList.csv", "CountList#csv", DataAccessMethod.Sequential), DeploymentItem("..\\ServiceTest\\CountList.csv"), TestMethod]
public void AreCountsCorrect()
{
int id = TestContext.DataRow["Id"] as int;
int count = client.GetProductCount(id);
Assert.IsTrue(count == TestContext.DataRow["Count"] as int);
}
}
Add a reference to System.Data
to the test project. No idea why that would not be automatically included since DataRow is used for data driven tests.