views:

83

answers:

1

We have a small wrapper class that uses ResourceManager to load string resources from assemblies.

We also have some unit tests that check it loads the correct details from the correct assemblies for different cultures, assemblies etc. Our tests are therefore currently dependant upon resources we have constructed for the test.

Is there an easy way of mocking the ResourceManager class, other than coming up with our own interface which is then implemented by forwarding calls to the propert ResourceManager (and feels somewhat convoluted). Mocking the interface would be easy, but the overall solution just doesn't feed right.

We are currently using Moq.

+1  A: 

I think you answered your own question. If you really need to test the business logic concerning how to choose which culture, assembly, etc is chosen, then you should use an adaptor interface that removes the direct dependency on ResourceManager and can be mocked with Moq.

Pete
+1. You might consider contributing the code to http://systemwrapper.codeplex.com/ as well.
TrueWill
Nice link TrueWill. A project that seeks to make the .NET Framework testable for everyone is great.
Anderson Imes