I am trying to test the "plugin" for ASPNET HttpApplication, which loads on Application_Start .
The code looks something like this:
private HttpApplication application; public void Application_Start(object sender, EventArgs e) { this.application = sender as HttpApplication; StartReportService(); } private void StartReportService() { HandledReports = new SortedList<string, string>(); HandledReports.Add("myindex","myvalue"); } public System.Collections.Generic.SortedList<String, String> HandledReports { get { application.Application.Lock(); var handledReports = (SortedList<String, String>)application.Application["handledReports"]; application.Application.UnLock(); return handledReports; } set { application.Application.Lock(); application.Application["handledReports"] = value; application.Application.UnLock(); } }
The problem is that I cannot find a good way to test HttpApplicationState mainly because the HttpApplication.Application property HttpApplication.Application not HttpApplication.Application there is no HttpApplication.Application class in the System.Web.Abstractions class that would allow this.
I tried the options for the following: always run the road block every time.
[TestMethod()] public void StartReportService_ApplicationStateShouldContainMyIndex() {
Can anyone shed some light on some good approaches for me? This is the first test of a larger number, which will rely on the fact that he will be able to taunt the functioning HttpApplicationState.
Simon francesco
source share