c# - Datadriven test using csv with double fails -
i'm new ddt , i've created small test integer , double values. can parse integers without problems can't use double.
here's c# code:
[datasource("microsoft.visualstudio.testtools.datasource.csv", "bounds.csv", "bounds#csv", dataaccessmethod.sequential)] [deploymentitem("bounds.csv")] [deploymentitem("schema.ini")] [testmethod] public void getbestusingbounds() { // https://msdn.microsoft.com/en-us/library/ee624082.aspx var x1 = convert.todouble(testcontext.datarow["x1"]); var x2 = convert.todouble(testcontext.datarow["x2"]); }
here's csv file:
x1;y1 11,1;55.1 -6;50
and scheme.ini:
[bounds.csv] format=delimited(;)
the second row read properly, they're integers, first row either stripped of decimals: 11.1 becomes 11 or stripped decimal point 11.1 becomes 111.
when add quotes (double or single) whole row skipped.
it doesn't matter if use schema.ini ; delimiter or no scheme.ini default , delimiter.
the problems not convert.todouble testcontext.datarow["x1"] wrong.
i'm using vs2013 pro on dutch win8.1. suggestion on how solve seemingly easy problem?
it possible (at least in vs2015) quote value, so:
x1;y1 "11.1";"55.1" -6;50
it considered string literal, , can converted double so:
convert.todouble(testcontext.datarow["x1"], cultureinfo.invariantculture);
Comments
Post a Comment