Hello,
What are some ideas or guidance for the best practice when doing things that require user input in the below example.
Say you have a RemoveCommand on the presenter that needed to ask the user "Are you sure you want to do this?" (Ok, Cancel...) With the view's xaml RemoveButton bound directly to the presentation class's RemoveCommand. You can't put a MessageBox.Show("Are You Sure") in the Presentaion.RemovComand because the testability of the remove command will become difficult.
Does this mean all presentation classes that need this functionality should take a dependency on something like...
public interface IMessageBoxService
{
MessageBoxResult Show(string messageBoxText);
MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button);
}
Where during test you can mock the message box functionality? What is the guidance in this scenario?
OR
Is it not the responsibility of the Presentation class to ask the user for this input, it should be asked before the command executes, meaning the xaml binds to a view level method that does the validatoin and then calls the model's command?
Some issues I see with that option are:
1. the interaction isn't very testable
2. what if you had mounds of business logic before the question was asked? You'd be forced to put that logic in the code behind which violates the benifit of the seperation of concerns to begin with.
Any thoughts?