-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Testing business logic inside button event #5
Comments
That's exactly the point of MVP - all the event handler inside the view should do is to invoke the corresponding presenter method. The view should be as "dumb" as possible, there should be no other logic in the event handler. If this is so, testing the presenter method is enough and testing the view code adds no value, only complicates things. |
Just a preface, I am still learning how to unit test and still learning the MVP pattern and its different flavors, so apologies in advanced.
I noticed you have a unit test around saving a customer, which is ultimately called by the button event (editButton_Click). This becomes awkward because you can't test all the code in the button click, just the save customer. I realize this is a basic example, but lets say I want test that edit logic.
I noticed other implementations may wrap an event around the button click in the interface to expose the event:
ICustomerView
CustomerForm
CustomerPresenter
However exposing the editmode property and the readonly property of the textboxes feels messy...
So without going to far down this rabbit hole, what do you think is the best way to go about refactoring so you could unit test this?
The text was updated successfully, but these errors were encountered: