Search code examples
c#.netcoded-ui-tests

Prevent TestContext data from being automagically converted


I am parameterising my test cases by using data read from .csv files. One of the columns in the csv file has simple date values (as regular strings) in US format, eg mm/dd/yyyy. When the data is actually read and populated into a TestContext however, TestContext.DataRow["MyDateColumn"] actually returns a converted System.DateTime object, complete with a timestamp of 12:00:00 AM. I absolutely do not require or want this automatic conversion. How do I stop this from happening?


Solution

  • If the type of the MyDateColumn is set to datetime, then it would/should return a datetime object.

    Try changing the type of MyDateColumn to be string and see if that does the trick.

    UPDATE

    Change dates in the CSV so that they are "mm/dd/yyyy" instead of mm/dd/yyyy.