Localisation issue with Unit Test for SmartDateTest.cs

Localisation issue with Unit Test for SmartDateTest.cs

Old forum URL: forums.lhotka.net/forums/t/7112.aspx


CraigLittlewood posted on Tuesday, June 16, 2009

After installing NUnit (albeit version 2.5), I was able to successfully compile CslaTest project.  However, on running the tests, I get a failure with SmartDate -> TestConverters tests.

Csla.Test.SmartDate.SmartDateTests.TestConverters:
  Expected string length 8 but was 10. Strings differ at index 0.
  Expected: "1/1/2005"
  But was:  "01/01/2005"
  -----------^

Looking at the code, it appears that CurrentUICulture is being set to en-US, as opposed to CurrentCulture.  As I am running in the UK, this causes a problem.  If I amend all CurrentUICulture references in this module to CurrentCulture, it appears to work.

Is this a known issue, or is there something else I should be doing.

Thanks and regards

Craig Littlewood

RockfordLhotka replied on Wednesday, June 17, 2009

I think the culture is set explicitly to fix a previous culture problem with this (and maybe other) tests.

Obviously things have changed over time that created another problem - probably because we actually spin up other appdomains and threads for certain tests now.

If you have a solution please let me know and we can work it in.

CraigLittlewood replied on Thursday, June 18, 2009

Rocky

All I did to make it work was change all references to ".CurrentUICulture" to ".CurrentCulture" in SmartDateTest.cs.  From what I make of the documentation on these properties, ".CurrentUICulture" only affects the loading of the resource files.  ".CurrentCulture" is the one that changes operation of date time formatting functions.  However, I am no expert on this - hence the reason for my question.  I have attached my modified source module from version 3.6.

Regards

Craig

Copyright (c) Marimer LLC