Reputation: 10093
I'm working on a web site written using asp.net WebForms. I'd like two wrap test cases around some of the more interesting subroutines. How can I instantiate the class that comes from the .aspx file in my test project so I can manipulate it under nUnit?
Edit: What I really want to do is test the utility methods and event methods that are in the code-behind. I don't want to post to the page and read the response. I want to unit test the Methods, not the Page.
Upvotes: 3
Views: 4589
Reputation: 21180
UPDATE Make sure you have setup your project to be an ASP.NET web project, not an asp.net web site. You can then mark your page class with the appropriate NUnit attributes and test the output dll for your project with NUnit.
Here is a Microsoft article that explains unit testing in asp.net: http://msdn.microsoft.com/en-us/library/ms404696(VS.80).aspx
Upvotes: 3
Reputation: 351728
You can instantiate it just like any other type:
YourPage page = new YourPage();
Now getting the lifecycle to run will be quite another matter.
Upvotes: 0