Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'TestContext' does not contain a definition for 'DataRow'

I have UWP project. Using VS Community 2017 I added a unit test to my solution (Add project-> Windows Universal -> Unit Test App (Windows Universal)),

I added reference to my project, I added .csv file with test data, I added DataSource Attribute

using System; 
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace UnitTestProject1
{
 [TestClass]
 public class UnitTest1
 {
  private TestContext testContextInstance;
  public TestContext TestContext
  {
   get { return testContextInstance; }
   set { testContextInstance = value; }
  }

  [TestMethod()]
  [DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", 
  @".\TestData.csv", "TestData#csv", DataAccessMethod.Sequential)]

  public void ParameterizedTest()
  {  
   int value = Convert.ToInt32(TestContext.DataRow["Row1"]); 

But still I can't use TestContext.DataRow

Error CS1061 'TestContext' does not contain a definition for 'DataRow' and no accessible extension method 'DataRow' accepting a first argument of type 'TestContext' could be found (are you missing a using directive or an assembly reference?)

Do I miss something?

like image 299
A G Avatar asked Sep 03 '25 15:09

A G


1 Answers

Are you using .NET Core?

The .Net Core version of the adapter does not support DataSource yet as specified here https://github.com/Microsoft/testfx/issues/233

like image 93
rinomau Avatar answered Sep 05 '25 07:09

rinomau