I am trying to read the values from column 3. However, whenever the column data has either a space or a '-' in it then null is returned. If I just have digits such as 12345 then it returns fine. I don't understand why this is happening since if I place the value in a different column it works fine but anything I place in this column with a space or dash it will return null.
Things I've tried:
-
using xlsx file instead.
-
making a new csv file.
-
DataRow[column_name] instead of DataRow[number]
-
having dummy columns before or after it
Snippet of code:
public TestContext TestContext
{
get; set;
}
[TestMethod]
[DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", "test.csv", "test#csv", DataAccessMethod.Sequential)]
public void TestMethod()
{
var ProductName = TestContext.DataRow[0].ToString();
var Stock = TestContext.DataRow[1].ToString();
var location = TestContext.DataRow[2].ToString();
var ProductID = TestContext.DataRow[3].ToString();
Snippet of CSV:
ProductName,Stock,location,ProductID
CALCULATOR 5000,30,CA,59621-9202
Aucun commentaire:
Enregistrer un commentaire