示例#1
0
        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());
        }
示例#2
0
        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);
        }
示例#3
0
        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));
        }
示例#4
0
 private void btnCancel_Click(object sender, EventArgs e)
 {
     _presenter.Cancel();
 }