locked
Problem Unit Testing ASP.NET Application RRS feed

  • Question

  • I'm trying to unit test my ASP.NET application. I have two problems:

    1. I need my application's HttpModules and HttpHandlers to have total control over the requests as my ASP.NET application is actually an Atom server. Effectively I have IIS forward all requests to ASP.NET; when I try to run my generated unit tests that have [HostType("ASP.NET")] attributes I get an error when accessing the VSEnterpriseHelper.axd file (information invalid?).
    2. I have code that does internal functions in the ASP.NET app that I need to test without actually invoking URLs at all. So I just removed the [HostType("ASP.NET")] and [UrlToTest("...")] attributes and ran the tests. Now the problem is I need a way to access my web.config from within the unit test project. Is this possible? If so, how?

    Thank you,
    Sammy

     

    Tuesday, November 21, 2006 11:57 AM

Answers

  • Hi Sammy,

    Yes, we test execution automatically changes the web.config file and adds our HTTP handler.

    Regards,

    Boris

    Monday, December 18, 2006 5:07 PM

All replies

  • Hi Sammy,

    Please, take my appologies for the late reply. I believe that you have two choices:

    1. Run non-ASP.NET unit tests, which manually open the web.config file and operate on it. However, this will mean that your tests are not running in the IIS context anymore.

    2. Leave the HostType and UrlToTest attributes, but make sure that your HTTPHanlder handler does not process VSEnterpriseHelper.axd file. This is a non-existent file, which we request only to invoke our own handler and perform the communication with the IIS worker process. As far as that communication takes place (aka our handler is called), you should be good to go.

    Regards,

    Boris

    Monday, December 4, 2006 5:28 PM
  • And the second case handles the web.config file automatically?

    Thank you,
    Sammy

     

    Monday, December 4, 2006 8:22 PM
  • Hi Sammy,

    Yes, we test execution automatically changes the web.config file and adds our HTTP handler.

    Regards,

    Boris

    Monday, December 18, 2006 5:07 PM