Jürgen Steinblock
Jürgen Steinblock

Reputation: 31743

Include Resource dll in Microsoft Test project

I have a Visual Studio 2010 Solution with a dll and a test project. The dll has a resource file Strings.resx and a Strings.en-us.resx

If I reference the dll from a project the output directory normaly contains a subdirectory en-us with a MyDll.resources.dll this is even true for the output directory of my test project.

However this Test does not pass

[TestMethod]
public void TestMethod1()
{
    var manager = String.ResourceManager;
    var culture = CultureInfo.GetCultureInfo("en-US");
    var resourceSet = manager.GetResourceSet(culture, true, false);

    Assert.IsNotNull(resourceSet);
}

this is because my assembly is loaded from

file:///C:/Users/me/Projects/SampleProject/TestResults/me_myhost 2014-08-06 08_03_33/Out/

this folder does not contain a subdirectory en-us

On a side note: The same test runs fine with ncrunch.

Is it possible to tell microsoft testing tools to include the satellite assemblys in the build process?

Upvotes: 2

Views: 237

Answers (1)

Major
Major

Reputation: 6658

Try this: select all resource files in the Solution Explorer, right click -> Properties and change the value of Copy to Output Directory to: "Copy if newer" or "Always copy".

Upvotes: 2

Related Questions