I have embedded string resources in my .NET 4.0 project: Strings.resx and Strings.de.resx.
In production code the correct localised strings are retrieved, dependent on the value of Strings.Culture:
Strings.Culture = new Culture("de");
string deString = Strings.Welcome; // 'Willkommen'
Strings.Culture = new Culture("en");
string enString = Strings.Welcome; // 'Welcome'
But in my unit test code (using MSTest) the strings from 'Strings.de.resx' are never returned - I only ever get the strings from Strings.resx, no matter what the values of Strings.Culture
or Threads.CurrentThread.CultureUICulture
.
Can anybody help?
Ok, I was able to reproduce this issue. First of all try to disable deployment. Go to "local.testsettings" and uncheck Deployment -> Enable Deployment. When this flag is checked, VS doesn't seem to be deploying satellite assemblies for me. If you do need some deployment item, use DeploymentItemAttribute:
[DeploymentItem(
@".\YourProject\bin\Debug\de\YourProject.resources.dll", @".\de\")]
or use the same "Deployment" tab to select appropriate satellite assemblies.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With