Domanda

I am having difficulty with achieving what I would like to do and am hoping for some advice from others to help me solve my lack of understanding.

I have a series of unit tests.
The application I am testing is munti-lingual, (English and French).

I have created 2 string resource files (StringConstants.resx and StringConstants.fr-CA.resx)

Within each of my unit tests I can validate properties and string values using

String message1 = StringConstants.ERROR_MESSAGE_INVALID_USERID; 
Assert.IsTrue(Something.Contains(message1));

What I would like to be able to do is run the set the suite of tests, once for english (the default), and once for french.

Currently I use one of these lines of code

Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en");
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("fr-CA");

in the MyTestInitialize method to control the language and I would like to be able to pass in a local for the execution to use either on a command line or from a build server (TeamCity).

Any thoughts are appreciated.

È stato utile?

Soluzione

I assume you are using MSTest but this should work with anything: Set an environment variable before you start your test (in a batch file for example or maybe TeamCity parameters would suffice)

Environment.GetEnvironmentVariable("TEST_CULTURE_INFO")
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top