Geeks With Blogs

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

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

 

Posted on Friday, May 22, 2009 4:07 PM C# .NET , ASP.NET , Unit Testing | Back to top


Comments on this post: How to unit test against resources (localization) values within Visual Studio 2008

# GAMECLOUD Technologies - Game Testing, Game Development, Customer care services, Spoof Animations, Pune, India
Requesting Gravatar...
it was realy wonderful blog..!
Left by rohini on Jun 14, 2011 6:49 AM

# re: How to unit test against resources (localization) values within Visual Studio 2008
Requesting Gravatar...
Getting stuck brilliant ….. evidently our wife plus my partner and i don’t unique any type of doubtfulness around your articles… that article content and assessments are generally awesome… Rightfully you will be the most beneficial. Regards designed for post such type of with us.
Left by Android Instagram on Apr 10, 2012 4:46 PM

Your comment:
 (will show your gravatar)


Copyright © Tim Huffam | Powered by: GeeksWithBlogs.net