Esempio n. 1
0
        public void HistoryPresenter_ExportClick_Test()
        {
            // Arrange
            _database.Stub(x => x.Fetch(null, 0)).IgnoreArguments().Return(new HistoryEntry[0]);

            var saveFileDialogView = MockRepository.GenerateMock <ISaveFileDialogView>();

            saveFileDialogView.Expect(x => x.FileName).Return("test.csv");
            saveFileDialogView.Expect(x => x.FilterIndex).Return(1);
            saveFileDialogView.Expect(x => x.ShowDialog()).Return(DialogResult.OK);
            _viewFactory.Expect(x => x.GetSaveFileDialogView()).Return(saveFileDialogView);
            _viewFactory.Expect(x => x.Release(saveFileDialogView));

            var serializer = MockRepository.GenerateMock <IFileSerializer <List <HistoryEntry> > >();

            serializer.Expect(x => x.Serialize(null, null)).Constraints(new Equal("test.csv"), new TypeOf(typeof(List <HistoryEntry>)));
            // Act
            _presenter = CreatePresenter();
            _presenter.ExportSerializers = new[] { serializer };
            _presenter.ExportClick();
            // Assert
            _viewFactory.VerifyAllExpectations();
            saveFileDialogView.VerifyAllExpectations();
            serializer.VerifyAllExpectations();
        }
Esempio n. 2
0
        public void HistoryPresenter_EditQueryClick_Test()
        {
            // Arrange
            var parameters = new QueryParameters {
                Name = "Test"
            };

            parameters.Fields.Add(new QueryField {
                Value = 6606
            });
            _model.AddQuery(parameters);

            var queryView = MockRepository.GenerateMock <IQueryView>();

            queryView.Expect(x => x.ShowDialog(_view)).Return(DialogResult.OK);
            var parameters2 = new QueryParameters {
                Name = "Test2"
            };

            parameters2.Fields.Add(new QueryField {
                Value = 6606
            });
            queryView.Stub(x => x.Query).Return(parameters2);
            _viewFactory.Expect(x => x.GetQueryDialog()).Return(queryView);
            // Act
            _presenter = CreatePresenter();
            Assert.AreEqual(2, _model.QueryBindingSource.Count);
            _presenter.EditQueryClick();
            // Assert
            Assert.AreEqual(2, _model.QueryBindingSource.Count);
            Assert.AreEqual("Test2", _model.SelectedQuery.Name);
            queryView.VerifyAllExpectations();
            _viewFactory.VerifyAllExpectations();
        }
Esempio n. 3
0
 public void HistoryPresenter_DeleteWorkUnitClick_NoSelection_Test()
 {
     // Arrange
     _messageBoxView.Expect(x => x.ShowInformation(null, String.Empty, String.Empty)).IgnoreArguments();
     // Act
     _presenter = CreatePresenter();
     _presenter.DeleteWorkUnitClick();
     // Assert
     _messageBoxView.VerifyAllExpectations();
 }
Esempio n. 4
0
 public void HistoryPresenter_DeleteQueryClick_Failed_Test()
 {
     // Arrange
     _messageBoxView.Expect(x => x.AskYesNoQuestion(_view, String.Empty, String.Empty)).IgnoreArguments().Return(DialogResult.Yes);
     _messageBoxView.Expect(x => x.ShowError(_view, String.Empty, String.Empty)).IgnoreArguments();
     // Act
     _presenter = CreatePresenter();
     _presenter.DeleteQueryClick();
     // Assert
     _messageBoxView.VerifyAllExpectations();
 }
Esempio n. 5
0
        public void HistoryPresenter_Close_Test()
        {
            bool presenterClosedFired = false;

            // Act
            _presenter = CreatePresenter();
            _presenter.PresenterClosed += delegate { presenterClosedFired = true; };
            _presenter.Close();
            // Assert
            Assert.AreEqual(true, presenterClosedFired);
        }
Esempio n. 6
0
 public void HistoryPresenter_Show_Test()
 {
     // Arrange
     _view.Expect(x => x.Show());
     _view.Expect(x => x.BringToFront());
     // Act
     _presenter = CreatePresenter();
     _presenter.Show();
     // Assert
     _view.VerifyAllExpectations();
 }
Esempio n. 7
0
 public void HistoryPresenter_Show_FromMinimized_Test()
 {
     // Arrange
     _view.Expect(x => x.Show());
     _view.Expect(x => x.WindowState).Return(FormWindowState.Minimized);
     _view.Expect(x => x.WindowState = FormWindowState.Normal);
     // Act
     _presenter = CreatePresenter();
     _presenter.Show();
     // Assert
     _view.VerifyAllExpectations();
 }
Esempio n. 8
0
        public void HistoryPresenter_EditQueryClick_Cancel_Test()
        {
            // Arrange
            var queryView = MockRepository.GenerateMock <IQueryView>();

            queryView.Expect(x => x.ShowDialog(_view)).Return(DialogResult.Cancel);
            _viewFactory.Expect(x => x.GetQueryDialog()).Return(queryView);
            // Act
            _presenter = CreatePresenter();
            _presenter.EditQueryClick();
            // Assert
            queryView.VerifyAllExpectations();
            _viewFactory.VerifyAllExpectations();
        }
Esempio n. 9
0
        public void HistoryPresenter_DeleteWorkUnitClick_Test()
        {
            // Arrange
            _model.HistoryBindingSource.Add(new HistoryEntry {
                ID = 1
            });
            _model.HistoryBindingSource.ResetBindings(false);

            _messageBoxView.Expect(x => x.AskYesNoQuestion(null, String.Empty, String.Empty)).IgnoreArguments().Return(DialogResult.Yes);
            _database.Expect(x => x.Delete(null)).IgnoreArguments().Return(1);
            // Act
            _presenter = CreatePresenter();
            _presenter.DeleteWorkUnitClick();
            // Assert
            _messageBoxView.VerifyAllExpectations();
            _database.VerifyAllExpectations();
        }
Esempio n. 10
0
        public void HistoryPresenter_EditQueryClick_Failed_Test()
        {
            // Arrange
            var queryView = MockRepository.GenerateMock <IQueryView>();

            queryView.Expect(x => x.ShowDialog(_view)).Return(DialogResult.OK).Repeat.Once();
            //queryView.Stub(x => x.Query).Return(new QueryParameters());
            _viewFactory.Expect(x => x.GetQueryDialog()).Return(queryView);
            _messageBoxView.Expect(x => x.ShowError(_view, String.Empty, String.Empty)).IgnoreArguments();
            // Act
            _presenter = CreatePresenter();
            _presenter.EditQueryClick();
            // Assert
            queryView.VerifyAllExpectations();
            _viewFactory.VerifyAllExpectations();
            _messageBoxView.VerifyAllExpectations();
        }
Esempio n. 11
0
        public void HistoryPresenter_OnClosing_WhileNotNormalWindow_Test()
        {
            // Arrange
            var r       = new Rectangle();
            var columns = new List <string>();

            _view.Expect(x => x.RestoreBounds).Return(r);
            _view.Expect(x => x.GetColumnSettings()).Return(columns);
            _view.Expect(x => x.WindowState).Return(FormWindowState.Minimized);
            // Act
            _presenter = CreatePresenter();
            _presenter.OnViewClosing();
            // Assert
            _view.VerifyAllExpectations();
            Assert.AreEqual(r.Location, _model.FormLocation);
            Assert.AreEqual(r.Size, _model.FormSize);
            Assert.AreEqual(columns, _model.FormColumns);
        }
Esempio n. 12
0
        public void HistoryPresenter_OnClosing_Test()
        {
            // Arrange
            var p       = new Point();
            var s       = new Size();
            var columns = new List <string>();

            _view.Expect(x => x.Location).Return(p);
            _view.Expect(x => x.Size).Return(s);
            _view.Expect(x => x.GetColumnSettings()).Return(columns);
            _view.Expect(x => x.WindowState).Return(FormWindowState.Normal);
            // Act
            _presenter = CreatePresenter();
            _presenter.OnViewClosing();
            // Assert
            _view.VerifyAllExpectations();
            Assert.AreEqual(p, _model.FormLocation);
            Assert.AreEqual(s, _model.FormSize);
            Assert.AreEqual(columns, _model.FormColumns);
        }
Esempio n. 13
0
        public void ToolsHistoryClick()
        {
            Debug.Assert(_view.WorkUnitHistoryMenuEnabled);

            if (_historyPresenter == null)
            {
                _historyPresenter = _presenterFactory.GetHistoryPresenter();
                _historyPresenter.Initialize();
                _historyPresenter.PresenterClosed += (sender, args) =>
                {
                    _presenterFactory.Release(_historyPresenter);
                    _historyPresenter = null;
                };
            }

            if (_historyPresenter != null)
            {
                _historyPresenter.Show();
            }
        }
Esempio n. 14
0
        public void HistoryPresenter_DeleteQueryClick_No_Test()
        {
            // Arrange
            var parameters = new QueryParameters {
                Name = "Test"
            };

            parameters.Fields.Add(new QueryField {
                Value = 6606
            });
            _model.AddQuery(parameters);

            _messageBoxView.Expect(x => x.AskYesNoQuestion(_view, String.Empty, String.Empty)).IgnoreArguments().Return(DialogResult.No);
            // Act
            _presenter = CreatePresenter();
            Assert.AreEqual(2, _model.QueryBindingSource.Count);
            _presenter.DeleteQueryClick();
            // Assert
            Assert.AreEqual(2, _model.QueryBindingSource.Count);
            _messageBoxView.VerifyAllExpectations();
        }
Esempio n. 15
0
        public void HistoryPresenter_NewQueryClick_Test()
        {
            // Arrange
            var queryView = MockRepository.GenerateMock <IQueryView>();

            queryView.Expect(x => x.ShowDialog(_view)).Return(DialogResult.OK);
            var parameters = new QueryParameters {
                Name = "Test"
            };

            parameters.Fields.Add(new QueryField {
                Value = 6606
            });
            queryView.Stub(x => x.Query).Return(parameters);
            _viewFactory.Expect(x => x.GetQueryDialog()).Return(queryView);
            // Act
            _presenter = CreatePresenter();
            _presenter.NewQueryClick();
            // Assert
            queryView.VerifyAllExpectations();
            _viewFactory.VerifyAllExpectations();
        }
Esempio n. 16
0
 public void AttachPresenter(HistoryPresenter presenter)
 {
    _presenter = presenter;
 }
Esempio n. 17
0
        public void ToolsHistoryClick()
        {
            Debug.Assert(_view.WorkUnitHistoryMenuEnabled);

             if (_historyPresenter == null)
             {
            _historyPresenter = ServiceLocator.Resolve<HistoryPresenter>();
            _historyPresenter.Initialize();
            _historyPresenter.PresenterClosed += delegate { _historyPresenter = null; };
             }

             _historyPresenter.Show();
        }
Esempio n. 18
0
      public void ToolsHistoryClick()
      {
         Debug.Assert(_view.WorkUnitHistoryMenuEnabled);

         if (_historyPresenter == null)
         {
            _historyPresenter = _presenterFactory.GetHistoryPresenter();
            _historyPresenter.Initialize();
            _historyPresenter.PresenterClosed += (sender, args) =>
            {
               _presenterFactory.Release(_historyPresenter);
               _historyPresenter = null;
            };
         }

         if (_historyPresenter != null)
         {
            _historyPresenter.Show();
         }
      }
Esempio n. 19
0
 public void AttachPresenter(HistoryPresenter presenter)
 {
     _presenter = presenter;
 }