1

We have the following test:

[TestMethod]
    public void TestSettleOrdersPost()
    {
        // Invoke
        FormCollection form = CreatesettleOrdersPostFormCollection();
        var viewResult = unconfirmedOrderController.SettleOrders(form) as ViewResult;
        var ordersFromView = (IEnumerable<Order>)viewResult.Model;

        // Assert
        Assert.IsInstanceOfType(ordersFromView.ElementAt(0).UnitPrice, typeof(Decimal),
            "Unitprice should be a decimal");
        Assert.AreEqual(4.00M, ordersFromView.ElementAt(0).UnitPrice,
            "The unitprice should be updated to 4.00");
        Assert.AreEqual(true, ordersFromView.ElementAt(1).IsConfirmed,
           "The item should also be set to confirmed");
    }

    private static FormCollection CreatesettleOrdersPostFormCollection()
    {
        FormCollection form = new FormCollection();
        form.Add("item.OrderId", "1");
        form.Add("item.UnitPrice", "2.00");
        form.Add("item.OrderId", "2");
        form.Add("item.UnitPrice", "4.00");
        return form;
    }

This test works like a charm locally, but when we use the Jenkins build server we get the following error message:

MESSAGE:
Assert.AreEqual failed. Expected:<4,00>. Actual:<400>. The unitprice should be updated to 4.00
+++++++++++++++++++

So somehow someway in the UnitPrice the decimal point . is converted to a ,. How can we also make it turn into a . on Jenkins?

user2609980
  • 10,264
  • 15
  • 74
  • 143
  • I guess read about locales: http://stackoverflow.com/questions/2288383/where-is-the-system-locale-culture-set-for-net – doctorlove Dec 12 '13 at 11:39
  • Thanks, how do we use that in this specific case? Initialize the tests in a thread with the specific culture? – user2609980 Dec 12 '13 at 11:45

1 Answers1

1

put this in your TestInitialize method

System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
Ondrej Janacek
  • 12,486
  • 14
  • 59
  • 93
blah
  • 26
  • 2