Short problem description: I'm using the App_GlobalResources folder and HttpContext.GetGlobalResourceObject(..) function to access my resources. My unit tests are in a separate project and I use NUnit for testing. The problem is that HttpContext.GetGlobalResourceObject(..) returns null in an offline (i.e. test setting).
DetailsI guess the problem is that there's no HttpContext in the test setting. So I need to figure out how to access the resource file from my test classes. A complicating factor is that I'm not directly calling GetGlobalResourceObject from my web application but a helper function (which amongst others logs missing resources) on a class located in a different assembly.
I guess I need to access the resource file using ResourceManager manually but I can't find out what parameters to pass to the constructor. My resources file is located in the App_GlobalResources file. Using Reflector I found out that that the actual resource location is in the assembly "App_GlobalResources", because this line is used by the auto-generated designer class:
ResourceManager manager1 =
new ResourceManager(
"Resources.MyProject",
Assembly.
Load(
"App_GlobalResources"));
Unfortunately I cannot use the same line when I'm unit testing because it cannot find the assembly "App_GlobalResources".
Has anyone any idea how I can access the resources in a web application in an offline (i.e. unit testing) setting?
BTW I'm using Web Application Projects.