Reputation: 1014
I am trying to do a unit test on an aspx partial class, for example a button_click
event.
I think this task is more suitable for an integration testing using "seleniumhq" or "watin".
The other way that I can think of doing this test is to extract the business logic from within this eventHandler
, put it into a different class and perform unit test on that.
What do you think?
Upvotes: 0
Views: 2117
Reputation: 914
Yes, you're moving in the right direction. Do some googling on "Model-View-Presenter" and "Passive View".
The idea is to move all logic from a code-behind file into a Presenter class that is an easily-instantiated and not platform dependent POCO. That presenter will be easily testable then. The code-behind code will be pretty "dummy", as the name "passive view" suggests.
EDIT: Here is an example for WinForms but the pattern works for ASP.Net and even for Android Java as well.
Upvotes: 1