コード例 #1
0
        public void BenchmarkPresenter_DeleteGraphColorClicked_DeletesColor()
        {
            // Arrange
            var model  = CreateModel();
            var color0 = Color.AliceBlue;
            var color1 = Color.SaddleBrown;
            var color2 = Color.Yellow;
            var color3 = Color.Red;

            model.Preferences.Set(Preference.GraphColors, new List <Color> {
                color0, color1, color2, color3
            });
            var messageBox = new MockMessageBoxPresenter((o, t, c) => DialogResult.Yes);

            using (var presenter = new MockFormBenchmarksPresenter(model, messageBox))
            {
                presenter.Show();
                Assert.AreEqual(4, presenter.Model.GraphColors.Count);
                // Act
                presenter.DeleteGraphColorClicked();
                // Assert
                Assert.AreEqual(3, presenter.Model.GraphColors.Count);
                Assert.AreEqual(0, messageBox.Invocations.Count);
            }
        }
コード例 #2
0
        public void BenchmarkPresenter_Show_ShowsView()
        {
            // Arrange
            var model     = CreateModel();
            var presenter = new MockFormBenchmarksPresenter(model);

            // Act
            presenter.Show();
            // Assert
            Assert.IsTrue(presenter.MockForm.Shown);
        }
コード例 #3
0
        public void BenchmarkPresenter_DescriptionLinkClicked_ShowsMessageBoxWhenLocalProcessFailsToStart()
        {
            // Arrange
            var model      = CreateModel();
            var messageBox = new MockMessageBoxPresenter();

            using (var presenter = new MockFormBenchmarksPresenter(model, messageBox))
            {
                presenter.Show();
                var localProcess = new LocalProcessServiceThrows();
                // Act
                presenter.DescriptionLinkClicked(localProcess);
                // Assert
                Assert.AreEqual(1, messageBox.Invocations.Count);
                Assert.AreEqual(nameof(MessageBoxPresenter.ShowError), messageBox.Invocations.First().Name);
            }
        }
コード例 #4
0
        public void BenchmarkPresenter_DeleteGraphColorClicked_ShowsMessageBoxWhenSelectedGraphColorItemIsNull()
        {
            // Arrange
            var model = CreateModel();

            model.Preferences.Set(Preference.GraphColors, new List <Color>());
            var messageBox = new MockMessageBoxPresenter((o, t, c) => DialogResult.Yes);

            using (var presenter = new MockFormBenchmarksPresenter(model, messageBox))
            {
                presenter.Show();
                Assert.IsNull(presenter.Model.SelectedGraphColorItem);
                // Act
                presenter.DeleteGraphColorClicked();
                // Assert
                Assert.AreEqual(1, messageBox.Invocations.Count);
            }
        }
コード例 #5
0
        public void BenchmarkPresenter_AddGraphColorClicked_AddsNewColorToGraphColors()
        {
            // Arrange
            var model = CreateModel();

            model.Preferences.Set(Preference.GraphColors, new List <Color>());
            using (var presenter = new MockFormBenchmarksPresenter(model))
            {
                presenter.Show();
                var dialog = new MockColorDialogPresenter(window => DialogResult.OK);
                dialog.Color = Color.FromArgb(72, 134, 186);
                // Act
                presenter.AddGraphColorClicked(dialog);
                // Assert
                Assert.AreEqual(1, model.GraphColors.Count);
                Assert.AreEqual(Color.SteelBlue, model.SelectedGraphColorItem.Value);
            }
        }
コード例 #6
0
        public void BenchmarkPresenter_DeleteSlotClicked_AsksYesNoQuestionAndDeletesSlot()
        {
            // Arrange
            var benchmarkService = CreateBenchmarkServiceWithOneSlotAndProject();
            var model            = CreateModel(benchmarkService);
            var messageBox       = new MockMessageBoxPresenter((o, t, c) => DialogResult.Yes);

            using (var presenter = new MockFormBenchmarksPresenter(model, messageBox))
            {
                presenter.Show();
                Assert.AreEqual(2, presenter.Model.SlotIdentifiers.Count);
                presenter.Model.SelectedSlotIdentifier = presenter.Model.SlotIdentifierValueItems.Last();
                // Act
                presenter.DeleteSlotClicked();
                // Assert
                Assert.AreEqual(1, presenter.Model.SlotIdentifiers.Count);
                Assert.AreEqual(1, messageBox.Invocations.Count);
            }
        }
コード例 #7
0
        public void BenchmarkPresenter_DeleteProjectClicked_AsksYesNoQuestionAndExitsAfterNoAnswer()
        {
            // Arrange
            var benchmarkService = CreateBenchmarkServiceWithTwoSlotsAndProjects();
            var model            = CreateModel(benchmarkService);
            var messageBox       = new MockMessageBoxPresenter((o, t, c) => DialogResult.No);

            using (var presenter = new MockFormBenchmarksPresenter(model, messageBox))
            {
                presenter.Show();
                presenter.Model.SelectedSlotIdentifier = presenter.Model.SlotIdentifierValueItems.Last();
                Assert.AreEqual(2, presenter.Model.SlotProjects.Count);
                presenter.Model.SelectedSlotProjectListItems.Clear();
                presenter.Model.SelectedSlotProjectListItems.Add(presenter.Model.SlotProjectListItems.Last());
                // Act
                presenter.DeleteProjectClicked();
                // Assert
                Assert.AreEqual(2, presenter.Model.SlotProjects.Count);
                Assert.AreEqual(1, messageBox.Invocations.Count);
            }
        }
コード例 #8
0
        public void BenchmarkPresenter_AddGraphColorClicked_ShowsMessageBoxAndDoesNotAddExistingColor()
        {
            // Arrange
            var model = CreateModel();
            var color = Color.AliceBlue;

            model.Preferences.Set(Preference.GraphColors, new List <Color> {
                color
            });
            var messageBox = new MockMessageBoxPresenter((o, t, c) => DialogResult.Yes);

            using (var presenter = new MockFormBenchmarksPresenter(model, messageBox))
            {
                presenter.Show();
                var dialog = new MockColorDialogPresenter(window => DialogResult.OK);
                dialog.Color = color;
                // Act
                presenter.AddGraphColorClicked(dialog);
                // Assert
                Assert.AreEqual(1, model.GraphColors.Count);
                Assert.AreEqual(1, messageBox.Invocations.Count);
            }
        }
コード例 #9
0
        public void BenchmarkPresenter_DescriptionLinkClicked_StartsLocalProcess()
        {
            // Arrange
            var dataContainer = new ProteinDataContainer();

            dataContainer.Data.Add(new Protein {
                ProjectNumber = 12345, Description = "http://someurl"
            });
            var proteinService   = new ProteinService(dataContainer, null, null);
            var benchmarkService = CreateBenchmarkServiceWithOneSlotAndProject();
            var model            = CreateModel(proteinService, benchmarkService);

            using (var presenter = new MockFormBenchmarksPresenter(model))
            {
                presenter.Show();
                var localProcess = new MockLocalProcessService();
                // Act
                presenter.DescriptionLinkClicked(localProcess);
                // Assert
                Assert.AreEqual(1, presenter.Model.SlotProjects.Count);
                Assert.IsTrue(localProcess.Invocations.First().FileName == "http://someurl");
            }
        }