示例#1
0
        public void Constructor_DataGridViewCorrectlyInitialized()
        {
            // Setup & Call
            using (var viewParent = new Form())
                using (var dialog = new MacroStabilityInwardsSurfaceLineSelectionDialog(viewParent, Enumerable.Empty <MacroStabilityInwardsSurfaceLine>()))
                {
                    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];
                    const string expectedLocationCalculateHeaderText = "Gebruik";
                    Assert.AreEqual(expectedLocationCalculateHeaderText, locationCalculateColumn.HeaderText);
                    Assert.AreEqual("Selected", locationCalculateColumn.DataPropertyName);
                    Assert.IsFalse(locationCalculateColumn.ReadOnly);

                    var          nameColumn             = (DataGridViewTextBoxColumn)dataGridView.Columns[nameColumnIndex];
                    const string expectedNameHeaderText = "Profielschematisatie";
                    Assert.AreEqual(expectedNameHeaderText, nameColumn.HeaderText);
                    Assert.AreEqual("Name", nameColumn.DataPropertyName);
                    Assert.AreEqual(DataGridViewAutoSizeColumnMode.Fill, nameColumn.AutoSizeMode);
                    Assert.IsTrue(nameColumn.ReadOnly);
                }
        }
示例#2
0
 public void Constructor_WithParentAndSurfaceLines_DefaultProperties()
 {
     // Setup
     using (var viewParent = new Form())
     {
         // Call
         using (var dialog = new MacroStabilityInwardsSurfaceLineSelectionDialog(viewParent, Enumerable.Empty <MacroStabilityInwardsSurfaceLine>()))
         {
             // Assert
             Assert.IsInstanceOf <SelectionDialogBase <MacroStabilityInwardsSurfaceLine> >(dialog);
             CollectionAssert.IsEmpty(dialog.SelectedItems);
             Assert.AreEqual("Selecteer profielschematisaties", dialog.Text);
         }
     }
 }
示例#3
0
        public void GivenCalculationsView_WhenGenerateScenariosButtonClicked_ThenShowViewWithSurfaceLines()
        {
            // Given
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            ConfigureHydraulicBoundaryDatabase(assessmentSection);
            mocks.ReplayAll();

            const string arbitraryFilePath = "path";
            var          failureMechanism  = new MacroStabilityInwardsFailureMechanism();

            failureMechanism.SurfaceLines.AddRange(new[]
            {
                new MacroStabilityInwardsSurfaceLine("Line A"),
                new MacroStabilityInwardsSurfaceLine("Line B")
            }, arbitraryFilePath);
            failureMechanism.StochasticSoilModels.AddRange(new[]
            {
                MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel()
            }, arbitraryFilePath);

            ShowMacroStabilityInwardsCalculationsView(failureMechanism.CalculationsGroup, failureMechanism, assessmentSection);

            var button = new ButtonTester("generateButton", testForm);

            MacroStabilityInwardsSurfaceLineSelectionDialog selectionDialog = null;
            DataGridViewControl grid = null;
            var rows = 0;

            DialogBoxHandler = (name, wnd) =>
            {
                selectionDialog = (MacroStabilityInwardsSurfaceLineSelectionDialog) new FormTester(name).TheObject;
                grid            = (DataGridViewControl) new ControlTester("DataGridViewControl", selectionDialog).TheObject;
                rows            = grid.Rows.Count;

                new ButtonTester("CustomCancelButton", selectionDialog).Click();
            };

            // When
            button.Click();

            // Then
            Assert.NotNull(selectionDialog);
            Assert.NotNull(grid);
            Assert.AreEqual(failureMechanism.SurfaceLines.Count, rows);
            mocks.VerifyAll();
        }
        protected override void GenerateCalculations()
        {
            var calculationGroup = (CalculationGroup)Data;

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

                if (dialog.SelectedItems.Any())
                {
                    IEnumerable <ICalculationBase> calculationsStructure = MacroStabilityInwardsCalculationConfigurationHelper.GenerateCalculationItemsStructure(
                        dialog.SelectedItems,
                        FailureMechanism.StochasticSoilModels);
                    foreach (ICalculationBase item in calculationsStructure)
                    {
                        calculationGroup.Children.Add(item);
                    }

                    calculationGroup.NotifyObservers();
                }
            }
        }
示例#5
0
        public void Constructor_SurfaceLinesOneEntry_OneRowInGrid()
        {
            // Setup
            const string testname    = "testName";
            var          surfaceLine = new MacroStabilityInwardsSurfaceLine(testname);

            // Call
            using (var viewParent = new Form())
                using (var dialog = new MacroStabilityInwardsSurfaceLineSelectionDialog(viewParent, new[]
                {
                    surfaceLine
                }))
                {
                    // 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);
                }
        }