jeudi 4 juin 2015

Datadriven test using csv with double fails

I'm new to DDT and I've created a very small test with integer and double values. I can parse the integers without any problems but I can't get use the double.

Here's my C# code:

    [DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", "bounds.csv", "bounds#csv",
        DataAccessMethod.Sequential)]
    [DeploymentItem("bounds.csv")]
    [DeploymentItem("schema.ini")]
    [TestMethod]
    public void GetBestUsingBounds()
    {
        // http://ift.tt/1JnyHbu
        var x1 = Convert.ToDouble(TestContext.DataRow["x1"]);
        var x2 = Convert.ToDouble(TestContext.DataRow["x2"]);
    }

Here's my csv file:

x1;y1
11,1;55.1
-6;50

And my scheme.ini:

[bounds.csv]
Format=Delimited(;)

The second row is read properly, they're just integers, but the first row is either stripped of the decimals: 11.1 becomes 11 or stripped from the decimal point 11.1 becomes 111.

When I add quotes (double or single) the whole row is skipped.

It doesn't matter if I use schema.ini with ; as delimiter or no scheme.ini with the default , as delimiter.

The problems is not with Convert.ToDouble TestContext.DataRow["x1"] is already wrong.

I'm using VS2013 Pro on a Dutch Win8.1. Any suggestion on how to solve this seemingly easy problem?

Aucun commentaire:

Enregistrer un commentaire