I'm creating a WinForms application using the MVP Passive View pattern. My Views fire events, which are then handled by their respective Presenters. I've attempted to ensure that events are handled in the Presenter with both RhinoMocks and Moq to no avail. I couldn't find a way to force RhinoMocks to ignore the behavior of my Presenter's event handler, nor could I find a way to make Moq actually call the event handler.
Any advice would be appreciated. For reference, here's a simplified version of my code:
Presenter:
public class FilesTabPresenter {
private readonly IFilesTabView mainView;
public FilesTabPresenter(IFilesTabView inView) {
mainView = inView;
mainView.FileCellClicked += FileCellClickedAsync;
}
public async void FileCellClickedAsync(object sender, GridViewCellEventArgs e) {
//...logic...
}
View:
public partial class FilesTab : UserControl, IFilesTabView {
public FilesTab() {
InitializeComponent();
}
private void radGridViewFiles_CellClick(object sender, GridViewCellEventArgs e) {
OnFileCellClicked(sender, e);
}
private void OnFileCellClicked(object sender, GridViewCellEventArgs args) {
var eventHandler = this.FileCellClicked;
if (eventHandler != null) {
eventHandler.Invoke(sender, args);
}
}
View Interface:
public interface IFilesTabView {
event GridViewCellEventHandler FileCellClicked;
}
Aucun commentaire:
Enregistrer un commentaire