Tim Huffam

Dotting the I and crossing the T of I.T.

  Home  |   Contact  |   Syndication    |   Login
  153 Posts | 0 Stories | 2415 Comments | 653 Trackbacks

News

Archives

Post Categories

Interesting Blogs/Links

Friday, May 22, 2009 #

When unit testing you sometimes need to test that values are being set to the correct literal/constant value - and this value is often stored in a resources file.

However, for some reason the VS2008 'Create Private Accessor' feature did not work for me for resources (maybe be cause they're all static properties and the generated _Accessor classes need to be instantiated).  So to make these resource available within the unit test project I simply made the Resources class public (by default it's internal).

To do this:

  1. Open the resource file (eg Resources.resx) using the Visual Studio resource editor tool (just double click on the .resx file).
  2. At the top of the editor tab there is a drop down box labelled "Access Modifier" - change this from Internal to Public and save the file.
  3. Rebuild the project.

Your resources will now be accessible in your unit tests.

HTH
Tim