Search code examples
testingmvpdialog

MVP : Dialog boxes that return value and testable code


In my MVP pattern (Passive view) based application (.NET), I have separated out the message boxes into the View so that when I test my presenter and model my testing code is not affected by the need to show user some information. But I don't know how to accommodate dialog boxes, when user's input is required to decide on a course of action. So, how do we make dialog boxes work in MVP?


Solution

  • You can make the tests work by mocking the View while testing the presenter. Mocking allows you to return values for a given method of the View and thus simulating the user input.