You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
This becomes awkward because you can't test all the code in the button click, just the save customer.
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: