What is the replacement TestContext.DataRow ["MyColumnName"]

Using MSTest in a .Net Core Unit test project. I am trying to use a csv data source to provide data for a test method.

Previously, I would use something like below in a .NET Framework project:

[DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", @"data.csv", "data#csv", DataAccessMethod.Sequential),
     DeploymentItem("data.csv"),
     TestMethod]
    public void ValuesController_Post()
    {
        _controller.Post(TestContext.DataRow["body"]);
        _valuesRepository.Verify(_ => _.Post(It.IsAny<string>()), Times.Once);
    }

The key here is the DataRow property found in TestContext. This does not seem to exist in the .Net Core version of TestContext.

How can I do this in .Net Core?

+4
source share

Source: https://habr.com/ru/post/1680902/


All Articles