Exemple #1
0
        protected override void GenerateCalculations()
        {
            var calculationGroup = (CalculationGroup)Data;

            using (var dialog = new PipingSurfaceLineSelectionDialog(Parent, FailureMechanism.SurfaceLines))
            {
                dialog.ShowDialog();

                if (dialog.SelectedItems.Any())
                {
                    IEnumerable <ICalculationBase> calculationsStructure = PipingCalculationConfigurationHelper.GenerateCalculationItemsStructure(
                        dialog.SelectedItems,
                        dialog.GenerateSemiProbabilistic,
                        dialog.GenerateProbabilistic,
                        FailureMechanism.StochasticSoilModels);

                    foreach (ICalculationBase item in calculationsStructure)
                    {
                        calculationGroup.Children.Add(item);
                    }

                    calculationGroup.NotifyObservers();
                }
            }
        }
Exemple #2
0
        public void GivenDialog_WhenSurfaceLinesSelectedAndCheckboxChecked_ThenDoForSelectedButtonEnabled(IEnumerable <Func <PipingSurfaceLineSelectionDialog, CheckBoxTester> > getCheckBoxFuncs)
        {
            // Given
            var surfaceLines = new[]
            {
                new PipingSurfaceLine("surface line 1"),
                new PipingSurfaceLine("surface line 2")
            };

            using (var dialog = new PipingSurfaceLineSelectionDialog(testForm, surfaceLines))
            {
                dialog.Show();

                var selectionView = (DataGridViewControl) new ControlTester("DataGridViewControl", dialog).TheObject;
                selectionView.Rows[0].Cells[0].Value = true;

                foreach (Func <PipingSurfaceLineSelectionDialog, CheckBoxTester> getCheckBoxFunc in getCheckBoxFuncs)
                {
                    CheckBoxTester checkBox = getCheckBoxFunc(dialog);
                    checkBox.Check();
                }

                var buttonTester = new ButtonTester("DoForSelectedButton", dialog);

                // When
                var button = (Button)buttonTester.TheObject;

                // Then
                Assert.IsTrue(button.Enabled);
            }
        }
Exemple #3
0
        public void GivenDialogWithSelectedItems_WhenDoForSelectedButtonClicked_ThenReturnsSelectedCollection()
        {
            // Given
            var selectedSurfaceLine = new PipingSurfaceLine("surface line 1");

            PipingSurfaceLine[] surfaceLines =
            {
                selectedSurfaceLine,
                new PipingSurfaceLine("surface line 2")
            };

            using (var dialog = new PipingSurfaceLineSelectionDialog(testForm, surfaceLines))
            {
                dialog.Show();

                var selectionView = (DataGridViewControl) new ControlTester("DataGridViewControl", dialog).TheObject;
                selectionView.Rows[0].Cells[0].Value = true;

                // When
                var generateButton = new ButtonTester("DoForSelectedButton", dialog);
                generateButton.Click();

                // Then
                CollectionAssert.AreEqual(new[]
                {
                    selectedSurfaceLine
                }, dialog.SelectedItems);
            }
        }
Exemple #4
0
        public void GivenDialog_WhenSurfaceLinesSelectedAndNoCheckboxesChecked_ThenDoForSelectedButtonDisabled()
        {
            // Given
            var surfaceLines = new[]
            {
                new PipingSurfaceLine("surface line 1"),
                new PipingSurfaceLine("surface line 2")
            };

            using (var dialog = new PipingSurfaceLineSelectionDialog(testForm, surfaceLines))
            {
                dialog.Show();

                var selectionView = (DataGridViewControl) new ControlTester("DataGridViewControl", dialog).TheObject;
                selectionView.Rows[0].Cells[0].Value = true;

                var semiProbabilisticCheckbox = new CheckBoxTester("SemiProbabilisticCheckBox", dialog);
                semiProbabilisticCheckbox.UnCheck();

                var buttonTester = new ButtonTester("DoForSelectedButton", dialog);

                // When
                var button = (Button)buttonTester.TheObject;

                // Then
                Assert.IsFalse(button.Enabled);
            }
        }
Exemple #5
0
        public void DeselectAllButton_AllItemsSelectedDeselectAllButtonClicked_AllItemsNotSelected()
        {
            // Setup
            var surfaceLines = new[]
            {
                new PipingSurfaceLine("surface line 1"),
                new PipingSurfaceLine("surface line 2")
            };

            using (var dialog = new PipingSurfaceLineSelectionDialog(testForm, surfaceLines))
            {
                dialog.Show();

                var dataGridView = (DataGridViewControl) new ControlTester("DataGridViewControl", dialog).TheObject;
                DataGridViewRowCollection rows = dataGridView.Rows;
                var button = new ButtonTester("DeselectAllButton", dialog);

                foreach (DataGridViewRow row in rows)
                {
                    row.Cells[selectItemColumnIndex].Value = true;
                }

                // Precondition
                Assert.IsTrue((bool)rows[0].Cells[selectItemColumnIndex].Value);
                Assert.IsTrue((bool)rows[1].Cells[selectItemColumnIndex].Value);

                // Call
                button.Click();

                // Assert
                Assert.IsFalse((bool)rows[0].Cells[selectItemColumnIndex].Value);
                Assert.IsFalse((bool)rows[1].Cells[selectItemColumnIndex].Value);
            }
        }
Exemple #6
0
        public void Constructor_DataGridViewCorrectlyInitialized()
        {
            // Call
            using (var dialog = new PipingSurfaceLineSelectionDialog(testForm, Enumerable.Empty <PipingSurfaceLine>()))
            {
                dialog.Show();

                // Assert
                CollectionAssert.IsEmpty(dialog.SelectedItems);

                var          dataGridViewControl = (DataGridViewControl) new ControlTester("DataGridViewControl", dialog).TheObject;
                DataGridView dataGridView        = dataGridViewControl.Controls.OfType <DataGridView>().First();
                Assert.AreEqual(2, dataGridView.ColumnCount);

                var locationCalculateColumn = (DataGridViewCheckBoxColumn)dataGridView.Columns[selectItemColumnIndex];
                Assert.AreEqual("Gebruik", locationCalculateColumn.HeaderText);
                Assert.AreEqual("Selected", locationCalculateColumn.DataPropertyName);
                Assert.IsFalse(locationCalculateColumn.ReadOnly);

                var nameColumn = (DataGridViewTextBoxColumn)dataGridView.Columns[nameColumnIndex];
                Assert.AreEqual("Profielschematisatie", nameColumn.HeaderText);
                Assert.AreEqual("Name", nameColumn.DataPropertyName);
                Assert.AreEqual(DataGridViewAutoSizeColumnMode.Fill, nameColumn.AutoSizeMode);
                Assert.IsTrue(nameColumn.ReadOnly);
            }
        }
Exemple #7
0
 public void Constructor_ExpectedValues()
 {
     // Call
     using (var dialog = new PipingSurfaceLineSelectionDialog(testForm, Enumerable.Empty <PipingSurfaceLine>()))
     {
         // Assert
         Assert.IsInstanceOf <DialogBase>(dialog);
         CollectionAssert.IsEmpty(dialog.SelectedItems);
         Assert.AreEqual("Selecteer profielschematisaties", dialog.Text);
         Assert.IsTrue(dialog.GenerateSemiProbabilistic);
         Assert.IsFalse(dialog.GenerateProbabilistic);
     }
 }
Exemple #8
0
        public void Constructor_SurfaceLinesOneEntry_OneRowInGrid()
        {
            // Setup
            const string testName          = "testName";
            var          pipingSurfaceLine = new PipingSurfaceLine(testName);

            // Call
            using (var dialog = new PipingSurfaceLineSelectionDialog(testForm, new[]
            {
                pipingSurfaceLine
            }))
            {
                // Assert
                dialog.Show();

                var dataGridViewControl = (DataGridViewControl) new ControlTester("DataGridViewControl").TheObject;
                Assert.AreEqual(1, dataGridViewControl.Rows.Count);
                Assert.IsFalse((bool)dataGridViewControl.Rows[0].Cells[selectItemColumnIndex].Value);
                Assert.AreEqual(testName, (string)dataGridViewControl.Rows[0].Cells[nameColumnIndex].Value);
            }
        }
Exemple #9
0
        public void GivenDialog_WhenChangingProbabilisticCheckBoxValue_ThenGenerateProbabilisticExpectedValue(bool checkBoxChecked)
        {
            // Given
            using (var dialog = new PipingSurfaceLineSelectionDialog(testForm, Enumerable.Empty <PipingSurfaceLine>()))
            {
                dialog.Show();

                // When
                var probabilisticCheckBox = new CheckBoxTester("ProbabilisticCheckBox", dialog);
                if (checkBoxChecked)
                {
                    probabilisticCheckBox.Check();
                }
                else
                {
                    probabilisticCheckBox.UnCheck();
                }

                // Then
                Assert.AreEqual(checkBoxChecked, dialog.GenerateProbabilistic);
            }
        }
Exemple #10
0
        public void GivenDialog_WhenNoSurfaceLinesSelected_ThenDoForSelectedButtonDisabled()
        {
            // Given
            var surfaceLines = new[]
            {
                new PipingSurfaceLine("surface line 1"),
                new PipingSurfaceLine("surface line 2")
            };

            using (var dialog = new PipingSurfaceLineSelectionDialog(testForm, surfaceLines))
            {
                dialog.Show();

                var buttonTester = new ButtonTester("DoForSelectedButton", dialog);

                // When
                var button = (Button)buttonTester.TheObject;

                // Then
                Assert.IsFalse(button.Enabled);
            }
        }
Exemple #11
0
        public void GivenDialogWithSelectedItems_WhenCloseWithoutConfirmation_ThenReturnsEmptyCollection()
        {
            // Given
            var surfaceLines = new[]
            {
                new PipingSurfaceLine("surface line 1"),
                new PipingSurfaceLine("surface line 2")
            };

            using (var dialog = new PipingSurfaceLineSelectionDialog(testForm, surfaceLines))
            {
                dialog.Show();

                var selectionView = (DataGridViewControl) new ControlTester("DataGridViewControl", dialog).TheObject;
                selectionView.Rows[0].Cells[0].Value = true;

                // When
                dialog.Close();

                // Then
                CollectionAssert.IsEmpty(dialog.SelectedItems);
            }
        }
Exemple #12
0
        public void Constructor_ControlsCorrectlyInitialized()
        {
            // Call
            using (var dialog = new PipingSurfaceLineSelectionDialog(testForm, Enumerable.Empty <PipingSurfaceLine>()))
            {
                // Assert
                var selectAllButton   = new ButtonTester("SelectAllButton", dialog);
                var deselectAllButton = new ButtonTester("DeselectAllButton", dialog);
                var generateButton    = new ButtonTester("DoForSelectedButton", dialog);
                var cancelButton      = new ButtonTester("CustomCancelButton", dialog);
                Assert.AreEqual("Selecteer alles", selectAllButton.Text);
                Assert.AreEqual("Deselecteer alles", deselectAllButton.Text);
                Assert.AreEqual("Genereren", generateButton.Text);
                Assert.AreEqual("Annuleren", cancelButton.Text);

                var semiProbabilisticCheckBox = new CheckBoxTester("SemiProbabilisticCheckBox", dialog);
                var probabilisticCheckBox     = new CheckBoxTester("ProbabilisticCheckBox", dialog);
                Assert.AreEqual("Semi-probabilistische toets", semiProbabilisticCheckBox.Text);
                Assert.IsTrue(semiProbabilisticCheckBox.Checked);
                Assert.AreEqual("Probabilistische toets", probabilisticCheckBox.Text);
                Assert.IsFalse(probabilisticCheckBox.Checked);
            }
        }