public void Cancel_ShouldCloseView() { // arrange EditPresenter presenter = new EditPresenter(_viewMock.Object, _modelMock.Object); var editedConfiguration = new EConfiguration(0, "test", "Test"); _viewMock.Setup(vm => vm.Configuration).Returns(editedConfiguration).Verifiable(); _viewMock.Setup(vm => vm.IsDirty).Returns(false); // act presenter.Cancel(); // assert _viewMock.VerifySet(vm => vm.DialogResult = DialogResult.Cancel); _viewMock.Verify(vm => vm.Close()); }
public void Cancel_WhenNoIsSelected_ShouldDoNothing() { // arrange EditPresenter presenter = new EditPresenter(_viewMock.Object, _modelMock.Object); var editedConfiguration = new EConfiguration(0, "test", "Test"); _viewMock.Setup(vm => vm.Configuration).Returns(editedConfiguration).Verifiable(); _viewMock.Setup(vm => vm.IsDirty).Returns(true); _viewMock.Setup(vm => vm.ShowMessage(It.IsAny <MessageType>(), It.IsAny <string>(), It.IsAny <string>())) .Returns(DialogResult.No); // act presenter.Cancel(); // assert _viewMock.VerifySet(vm => vm.DialogResult = DialogResult.Cancel, Times.Never); _viewMock.Verify(vm => vm.Close(), Times.Never); }
public void Cancel_WhenChangesAreMade_ShouldShowAConfirmationMessage() { // arrange EditPresenter presenter = new EditPresenter(_viewMock.Object, _modelMock.Object); var editedConfiguration = new EConfiguration(0, "test", "Test"); _viewMock.Setup(vm => vm.Configuration).Returns(editedConfiguration).Verifiable(); _viewMock.Setup(vm => vm.IsDirty).Returns(true); // act presenter.Cancel(); // assert _viewMock.Verify( vm => vm.ShowMessage( MessageType.YesNo, Language.Warning_Tittle, Language.EditCancel_Confirmation)); }
private void btnCancel_Click(object sender, EventArgs e) { _presenter.Cancel(); }