Beispiel #1
0
        public void WorkUnitHistoryPresenter_NewQueryClick_CancelsNewQueryAndExits()
        {
            // Arrange
            var presenter      = CreatePresenter();
            var queryPresenter = new MockDialogWorkUnitQueryPresenter(_ => DialogResult.Cancel);

            // Act
            presenter.NewQueryClick(queryPresenter);
            // Assert
            Assert.AreEqual(1, presenter.Model.QueryBindingSource.Count);
        }
Beispiel #2
0
        public void WorkUnitHistoryPresenter_NewQueryClick_AddsNewQuery()
        {
            // Arrange
            var presenter      = CreatePresenter();
            var queryPresenter = new MockDialogWorkUnitQueryPresenter(p =>
            {
                p.Query.Name = "Test";
                p.Query.Parameters[0].Value = 6606;
            }, _ => DialogResult.OK);

            // Act
            presenter.NewQueryClick(queryPresenter);
            // Assert
            Assert.AreEqual(2, presenter.Model.QueryBindingSource.Count);
            Assert.AreEqual("Test", presenter.Model.SelectedWorkUnitQuery.Name);
        }
Beispiel #3
0
        public void WorkUnitHistoryPresenter_EditQueryClick_EditsExistingQuery()
        {
            // Arrange
            var presenter = CreatePresenter();

            presenter.Model.AddQuery(new WorkUnitQuery("Test")
                                     .AddParameter(new WorkUnitQueryParameter {
                Value = 6606
            }));
            Assert.AreEqual(2, presenter.Model.QueryBindingSource.Count);

            var queryPresenter = new MockDialogWorkUnitQueryPresenter(p =>
            {
                p.Query.Name = "Test2";
            }, _ => DialogResult.OK);

            // Act
            presenter.EditQueryClick(queryPresenter);
            // Assert
            Assert.AreEqual(2, presenter.Model.QueryBindingSource.Count);
            Assert.AreEqual("Test2", presenter.Model.SelectedWorkUnitQuery.Name);
        }
Beispiel #4
0
        public void WorkUnitHistoryPresenter_EditQueryClick_ShowsMessageBoxWhenAttemptingToEditSelectAllQuery()
        {
            // Arrange
            var presenter      = CreatePresenter();
            int invocations    = 0;
            var queryPresenter = new MockDialogWorkUnitQueryPresenter(_ =>
            {
                switch (invocations++)
                {
                case 0:
                    return(DialogResult.OK);

                default:
                    return(DialogResult.Cancel);
                }
            });

            // Act
            presenter.EditQueryClick(queryPresenter);
            // Assert
            var mockMessageBox = (MockMessageBoxPresenter)presenter.MessageBox;

            Assert.AreEqual(1, mockMessageBox.Invocations.Count);
        }