0

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?

rink.attendant.6
  • 44,500
  • 61
  • 101
  • 156
June
  • 974
  • 5
  • 20
  • 34

1 Answers1

1

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.

Community
  • 1
  • 1
Ivan Gerken
  • 914
  • 1
  • 9
  • 21