I have defined several inbound and outbound rules which I can see work perfectly.
Now I would like to create web unit tests to ensure my rules but I didn't find resources about this topic on this site. So I tried to write my own test but I stumbled onto a problem : since the module is installed in the root web.config, the ASP.NET Development
Server seems to not take it into account and ignores my rules therefore I need to host my site in IIS. So far so good but when I write my test with the following attributes :
I get the following error when executing the test :
"The URL specified ('http://mysite.fr/Default.aspx') does not correspond to a valid directory. Tests configured to run in ASP.NET in IIS require a valid directory to exist for the URL. The URL may be invalid or may not point to a valid Web application.".
I don't know what I'm doing wrong (or maybe I'm not using the right approach) so please enlighten me.
I tried binding the website on localhost:8081 (custom port) but to no avail either.
Finally I tried to make a sub web application of my Default Web Site so it looked like "localhost/MySite" but no luck either.
A hint is that maybe since I'm using VS2010 Premium I am not allowed to make Web Unit Test with a site hosted in IIS. But I was not able to confirm that hypothesis.
Eric Gaspard
2 Posts
Unit testing the rules defined in the Url Rewrite module
Apr 25, 2012 09:50 AM|LINK
Hello,
I have defined several inbound and outbound rules which I can see work perfectly.
Now I would like to create web unit tests to ensure my rules but I didn't find resources about this topic on this site. So I tried to write my own test but I stumbled onto a problem : since the module is installed in the root web.config, the ASP.NET Development Server seems to not take it into account and ignores my rules therefore I need to host my site in IIS. So far so good but when I write my test with the following attributes :
[TestMethod]
[HostType("ASP.NET")]
[UrlToTest("http://mysite.fr/Default.aspx")]
I get the following error when executing the test :
"The URL specified ('http://mysite.fr/Default.aspx') does not correspond to a valid directory. Tests configured to run in ASP.NET in IIS require a valid directory to exist for the URL. The URL may be invalid or may not point to a valid Web application.".
I don't know what I'm doing wrong (or maybe I'm not using the right approach) so please enlighten me.
Thanks and regards,
Eric Gaspard
url rewrite 2.0 unit test
Dalong Zhang...
647 Posts
Microsoft
Re: Unit testing the rules defined in the Url Rewrite module
Apr 27, 2012 08:06 AM|LINK
Hi,
The UrlToTest is expecting the WebSite that is being used, something like this:
[UrlToTest("http://localhost/WebSite")]
You can refer to the following article to check if you have correctlly definded the unit test
How to: Create an ASP.NET Unit Test
http://msdn.microsoft.com/en-us/library/ms182526(v=vs.80).aspx
Hope this helps.
Feedback to us
Develop and promote your apps in Windows Store
Eric Gaspard
2 Posts
Re: Unit testing the rules defined in the Url Rewrite module
Apr 27, 2012 08:34 AM|LINK
Hi Dahong,
I tried using using "mysite.fr" it didn't work.
I tried binding the website on localhost:8081 (custom port) but to no avail either.
Finally I tried to make a sub web application of my Default Web Site so it looked like "localhost/MySite" but no luck either.
A hint is that maybe since I'm using VS2010 Premium I am not allowed to make Web Unit Test with a site hosted in IIS. But I was not able to confirm that hypothesis.
Thanks and regards,
Eric Gaspard.