I am using a CSV file to inject data into my test.
[TestMethod] [DataSource( CsvData, CsvDir + "TC177023.csv", "TC177023#csv", SEQ )]
The file looks somethings like this: (other strings removed)
something,something,Value,something,something,something ,,0xDEADBEEF,, ,,-12,, ,,0,, ,,0,, ,,0,,
I have one column that I have integers in and I wanted to extend this to hexadecimals. So I took the value from the column "Value" and instead of casting it to an int
int value = (int)TestContext["Value"];
I tried to access the string representing the integer
string text = TestContext.DataRow["Value"].ToString();
But all I got was a empty string. I wont bother you with all I tried to find out what the problem was. I could at least see from inspecting the TestContext object while debugging that the type of the column indeed vas Int32.
In the end I tried to replace the integer values in the column with strings and, lo and behold, I got my hexadecimal value. My conclusion is that, when loading the values, the test framework is "helping" me and sets the type of the column by look on values.
now to my question:
Can I set something somewhere to inhibit this behavour so the MS unit test framework does not help me with this ? I cannot change the framework, I cannot change the int values in that column to something recognised as strings. I am not the end user of the solution so any workarounds would probably make things worse. I just want to get the "raw value" of the "cell" for further processing.
I have investigated it further and for whose who would have the same question, I write it down here.
And the short answer to my question here is no, I cannot within my limitations.
The long answer is: The test framework is using oledb connection to read from excel and csv files. There is a way to make oledb to accept "mixed values", sending the string "IMEX = 1" as Extended Properties in the connection string.
Unfortunatly the connection string is set inside the framework code, at least in the open source version, that is accessable on githug and I haven't found a way smuggle in the string.
User contributions licensed under CC BY-SA 3.0