I have a unit test method which tests a controller action method. The action method uses resource file to get a static message.
message = Resources.MyResource.MemberNotVerified;
However at this line the exception thrown is :-
“Could not load file or assembly ‘App_GlobalResources’ or one of its dependencies. The system cannot find the file specified.”:”App_GlobalResources” System.IO.IOException {System.IO.FileNotFoundException}
I tried coping the whole resource file in my Test project, but it was unsuccessful.
Any idea friends.
Behind the scenes, App_GlobalResources uses HttpContext.GetGlobalResourceObject
Of course, there is no HttpContext in unit tests (unless your mocking it).
If you were so inclined to mock it, Phil Haack has a decent post on it here.
There is another solution, and that is to move the RESX files out of the regular directory.
Scott Allen has a post on that here.