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.
You should add Reference to your test project to fix this issue. I don't know why VS2013 doesn't add it automatically.
right click your test project, Add->Reference...->Assemblies->Framework->System.Data, check it.
Done!
I had the same problem as you with the this.TestContext.DataRow["PathFile_Original"], what I was doing wrong was so simple, I didn't add the reference to System.Data, that was all.
It's quite easy to fix, be sure that you already have library.
Cheers
To fix your issue, as others have said, you should add a reference to System.Data
in your project.
If you are still having an issue after that reference has been added, you may need to restart Visual Studio, and remove any redundant references or using
headers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With