c# - How can I get correct string localization when running my unit tests? -


I have a project that needs to support French and English, I have kept all the stars in resource files when I debug the program in Visual Studio, then I can successfully see the program in French. However, when I run a trial for the program, the program turns into English, I added the French resource DLL file in the deployment. This allows me to debug individual unit tests in French, but when I test -> Debug - & gt; All tests in the solution, the program runs in English

I also add [DeploymentItem (@ ".. \ bin \ x86 \ release \ fr", "fr-FR")] in one of the tests Tried, but did not get help from Does anyone have any suggestions for deciding this? Thanks!

There are two possible issues:

  1. When your test is run , CurrentUICulture can not be set for the language you want to test
  2. The Satellite Assembly (French only in your example) was not deployed in the testing environment. Can be done when the resource manager does not get a Milan satellite assembly for UI culture, then this project will be DLL Default for the original language embedded in (and therefore you get English, assuming it is your native language)

    for 1. You System.Threading.CurrentThread.CurrentUICulture = New Culture Info ("FR-FR"); In your testing or at the beginning of your test class, be sure to determine.

    2. For the use of a DeploymentItemAttribute , you should work as you mentioned. Verify that when your app is successfully launched in the franc, the satellite assembly is deployed, then with the same name and your test deployment is copied to the same subfolder. This is probably something like [DeploymentItem (@ "bin \ fr-FR", "fr-FR")]

Comments