Index: Core/Common/src/Core.Common.Gui/Forms/ViewHost/AvalonDockViewHost.xaml =================================================================== diff -u -rfea3ed82dfb6dfcad535eef16efcbaa9c01564ed -r6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a --- Core/Common/src/Core.Common.Gui/Forms/ViewHost/AvalonDockViewHost.xaml (.../AvalonDockViewHost.xaml) (revision fea3ed82dfb6dfcad535eef16efcbaa9c01564ed) +++ Core/Common/src/Core.Common.Gui/Forms/ViewHost/AvalonDockViewHost.xaml (.../AvalonDockViewHost.xaml) (revision 6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a) @@ -49,19 +49,29 @@ - - + + - + - + + + + + + + + + + + Index: Core/Common/src/Core.Common.Gui/Forms/ViewHost/AvalonDockViewHost.xaml.cs =================================================================== diff -u -rd52aa340885d10c5932c381d4283062c8dddd76b -r6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a --- Core/Common/src/Core.Common.Gui/Forms/ViewHost/AvalonDockViewHost.xaml.cs (.../AvalonDockViewHost.xaml.cs) (revision d52aa340885d10c5932c381d4283062c8dddd76b) +++ Core/Common/src/Core.Common.Gui/Forms/ViewHost/AvalonDockViewHost.xaml.cs (.../AvalonDockViewHost.xaml.cs) (revision 6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a) @@ -56,6 +56,8 @@ public AvalonDockViewHost() { InitializeComponent(); + dummyPanelA.Hide(); + dummyPanelB.Hide(); toolViews = new List(); documentViews = new List(); @@ -169,6 +171,7 @@ SetFocusToView(view); layoutAnchorable.Hiding += OnLayoutAnchorableHiding; + layoutAnchorable.Closing += OnLayoutAnchorableClosing; } public void Remove(IView view) @@ -185,12 +188,14 @@ SetFocusToView(view); } - GetLayoutContent(view).Close(); + var layoutDocument = GetLayoutContent(view); + layoutDocument.Close(); UpdateDockingManager(); } else if (toolViews.Contains(view)) { - GetLayoutContent(view).Hide(); + var layoutAnchorable = GetLayoutContent(view); + layoutAnchorable.Hide(); UpdateDockingManager(); } @@ -303,7 +308,7 @@ private void OnLayoutDocumentClosing(object sender, CancelEventArgs e) { - var layoutDocument = (LayoutDocument) sender; + var layoutDocument = (LayoutDocument)sender; var view = GetView(layoutDocument.Content); if (ActiveDocumentView == view) @@ -315,23 +320,34 @@ } } + private void OnLayoutAnchorableHiding(object sender, CancelEventArgs eventArgs) + { + var layoutAnchorable = (LayoutAnchorable)sender; + + layoutAnchorable.Hiding -= OnLayoutAnchorableHiding; + layoutAnchorable.Closing -= OnLayoutAnchorableClosing; + + layoutAnchorable.Close(); + OnViewClosed(GetView(layoutAnchorable.Content)); + + eventArgs.Cancel = true; + } + private void OnLayoutDocumentClosed(object sender, EventArgs e) { - var layoutDocument = (LayoutDocument) sender; + var layoutDocument = (LayoutDocument)sender; layoutDocument.Closing -= OnLayoutDocumentClosing; layoutDocument.Closed -= OnLayoutDocumentClosed; OnViewClosed(GetView(layoutDocument.Content)); } - private void OnLayoutAnchorableHiding(object sender, CancelEventArgs e) + private void OnLayoutAnchorableClosing(object sender, CancelEventArgs e) { - var layoutAnchorable = (LayoutAnchorable) sender; - - layoutAnchorable.Hiding -= OnLayoutAnchorableHiding; - - OnViewClosed(GetView(layoutAnchorable.Content)); + var layoutAnchorable = (LayoutAnchorable)sender; + layoutAnchorable.Hide(); + e.Cancel = true; } private void OnViewClosed(IView view) @@ -388,19 +404,35 @@ private void AddLayoutAnchorable(LayoutAnchorable layoutAnchorable, ToolViewLocation toolViewLocation) { - var layoutAnchorablePaneGroup = new LayoutAnchorablePaneGroup(); - + LayoutAnchorablePaneGroup layoutAnchorablePaneGroup = null; switch (toolViewLocation) { case ToolViewLocation.Left: + if (leftLayoutAnchorablePaneGroup.Parent == null) + { + leftLayoutAnchorablePaneGroup.Children.Add(new LayoutAnchorablePane()); + leftRightLayoutTarget.Children.Insert(0, leftLayoutAnchorablePaneGroup); + } layoutAnchorablePaneGroup = leftLayoutAnchorablePaneGroup; break; case ToolViewLocation.Bottom: + if (bottomLayoutAnchorablePaneGroup.Parent == null) + { + bottomLayoutAnchorablePaneGroup.Children.Add(new LayoutAnchorablePane()); + bottomLayoutTarget.Children.Add(bottomLayoutAnchorablePaneGroup); + } layoutAnchorablePaneGroup = bottomLayoutAnchorablePaneGroup; break; case ToolViewLocation.Right: + if (rightLayoutAnchorablePaneGroup.Parent == null) + { + rightLayoutAnchorablePaneGroup.Children.Add(new LayoutAnchorablePane()); + leftRightLayoutTarget.Children.Add(rightLayoutAnchorablePaneGroup); + } layoutAnchorablePaneGroup = rightLayoutAnchorablePaneGroup; break; + default: + throw new InvalidEnumArgumentException("toolViewLocation", (int)toolViewLocation, typeof(ToolViewLocation)); } layoutAnchorablePaneGroup.Descendents() Index: Core/Components/test/Core.Components.OxyPlot.Forms.Test/LinearPlotViewTest.cs =================================================================== diff -u -red96d38a758365e4c0f117def83a2926c589c18a -r6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a --- Core/Components/test/Core.Components.OxyPlot.Forms.Test/LinearPlotViewTest.cs (.../LinearPlotViewTest.cs) (revision ed96d38a758365e4c0f117def83a2926c589c18a) +++ Core/Components/test/Core.Components.OxyPlot.Forms.Test/LinearPlotViewTest.cs (.../LinearPlotViewTest.cs) (revision 6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a) @@ -88,19 +88,21 @@ public void ZoomToAll_ViewInForm_InvalidatesView() { // Setup - var form = new Form(); - var view = new LinearPlotView(); - form.Controls.Add(view); - var invalidated = 0; - view.Invalidated += (sender, args) => invalidated++; + using (var form = new Form()) + using (var view = new LinearPlotView()) + { + form.Controls.Add(view); + var invalidated = 0; + view.Invalidated += (sender, args) => invalidated++; - form.Show(); + form.Show(); - // Call - view.ZoomToAll(); + // Call + view.ZoomToAll(); - // Assert - Assert.AreEqual(1, invalidated); + // Assert + Assert.AreEqual(1, invalidated); + } } [Test] @@ -110,20 +112,22 @@ public void ModelTitle_Always_SetsNewTitleToModelAndInvalidatesView(string newTitle) { // Setup - var form = new Form(); - var view = new LinearPlotView(); - form.Controls.Add(view); - var invalidated = 0; - view.Invalidated += (sender, args) => invalidated++; + using (var form = new Form()) + using (var view = new LinearPlotView()) + { + form.Controls.Add(view); + var invalidated = 0; + view.Invalidated += (sender, args) => invalidated++; - form.Show(); + form.Show(); - // Call - view.ModelTitle = newTitle; + // Call + view.ModelTitle = newTitle; - // Assert - Assert.AreEqual(view.ModelTitle, newTitle); - Assert.AreEqual(1, invalidated); + // Assert + Assert.AreEqual(view.ModelTitle, newTitle); + Assert.AreEqual(1, invalidated); + } } [Test] @@ -133,20 +137,22 @@ public void BottomAxisTitle_Always_SetsNewTitleToBottomAxisAndInvalidatesView(string newTitle) { // Setup - var form = new Form(); - var view = new LinearPlotView(); - form.Controls.Add(view); - var invalidated = 0; - view.Invalidated += (sender, args) => invalidated++; + using (var form = new Form()) + using (var view = new LinearPlotView()) + { + form.Controls.Add(view); + var invalidated = 0; + view.Invalidated += (sender, args) => invalidated++; - form.Show(); + form.Show(); - // Call - view.BottomAxisTitle = newTitle; + // Call + view.BottomAxisTitle = newTitle; - // Assert - Assert.AreEqual(view.BottomAxisTitle, newTitle); - Assert.AreEqual(1, invalidated); + // Assert + Assert.AreEqual(view.BottomAxisTitle, newTitle); + Assert.AreEqual(1, invalidated); + } } [Test] @@ -156,29 +162,28 @@ public void SetLeftAxisTitle_Always_SetsNewTitleToLeftAxisAndInvalidatesView(string newTitle) { // Setup - var form = new Form(); - var view = new LinearPlotView(); - form.Controls.Add(view); - var invalidated = 0; - view.Invalidated += (sender, args) => invalidated++; + using (var form = new Form()) + using (var view = new LinearPlotView()) + { + form.Controls.Add(view); + var invalidated = 0; + view.Invalidated += (sender, args) => invalidated++; - form.Show(); + form.Show(); - // Call - view.LeftAxisTitle = newTitle; + // Call + view.LeftAxisTitle = newTitle; - // Assert - Assert.AreEqual(view.LeftAxisTitle, newTitle); - Assert.AreEqual(1, invalidated); + // Assert + Assert.AreEqual(view.LeftAxisTitle, newTitle); + Assert.AreEqual(1, invalidated); + } } [Test] public void GivenMultipleAreaSeriesAddedToView_WhenViewOpenedAndUpdated_ThenXYAxisIncludesSeriesValues() { // Given - var form = new Form(); - var view = new LinearPlotView(); - form.Controls.Add(view); var maxY = 100; var minY = -25; var maxX = 50; @@ -198,12 +203,18 @@ } }; - view.Model.Series.Add(series); + using (var form = new Form()) + using (var view = new LinearPlotView()) + { + form.Controls.Add(view); - // When - form.Show(); - view.Update(); + view.Model.Series.Add(series); + // When + form.Show(); + view.Update(); + } + // Then Assert.AreEqual(maxX, series.XAxis.DataMaximum); Assert.AreEqual(minX, series.XAxis.DataMinimum); @@ -215,17 +226,19 @@ public void GivenEmptyMultipleAreaSeriesAddedToView_WhenViewOpenedAndUpdated_ThenXYAxisNotChanged() { // Given - var form = new Form(); - var view = new LinearPlotView(); - form.Controls.Add(view); + var series = new MultipleAreaSeries(); + using (var form = new Form()) + using (var view = new LinearPlotView()) + { + form.Controls.Add(view); + view.Model.Series.Add(series); - view.Model.Series.Add(series); + // When + form.Show(); + view.Update(); + } - // When - form.Show(); - view.Update(); - // Then Assert.AreEqual(double.NaN, series.XAxis.DataMaximum); Assert.AreEqual(double.NaN, series.XAxis.DataMinimum); Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/GrassCoverErosionInwardsDikeProfileSelectionDialogTest.cs =================================================================== diff -u -rce871f8d394d4539208c9ef68372dd9d64ae1941 -r6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/GrassCoverErosionInwardsDikeProfileSelectionDialogTest.cs (.../GrassCoverErosionInwardsDikeProfileSelectionDialogTest.cs) (revision ce871f8d394d4539208c9ef68372dd9d64ae1941) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/GrassCoverErosionInwardsDikeProfileSelectionDialogTest.cs (.../GrassCoverErosionInwardsDikeProfileSelectionDialogTest.cs) (revision 6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a) @@ -47,32 +47,41 @@ [Test] public void Constructor_WithoutDikeProfiles_ThrowsArgumentNullException() { - // Call - TestDelegate test = () => new GrassCoverErosionInwardsDikeProfileSelectionDialog(new Form(), null); + // Setup + using (var viewParent = new Form()) + { + // Call + TestDelegate test = () => new GrassCoverErosionInwardsDikeProfileSelectionDialog(viewParent, null); - // Assert - var parameter = Assert.Throws(test).ParamName; - Assert.AreEqual("dikeProfiles", parameter); + // Assert + var parameter = Assert.Throws(test).ParamName; + Assert.AreEqual("dikeProfiles", parameter); + } } [Test] public void Constructor_WithParentAndDikeProfiles_DefaultProperties() { - // Call - using (var dialog = new GrassCoverErosionInwardsDikeProfileSelectionDialog(new Form(), Enumerable.Empty())) + // Setup + using (var viewParent = new Form()) { - // Assert - Assert.IsEmpty(dialog.SelectedDikeProfiles); - Assert.IsInstanceOf(new ControlTester("GrassCoverErosionInwardsDikeProfileSelectionView", dialog).TheObject); - Assert.AreEqual("Selecteer dijkprofielen", dialog.Text); + // Call + using (var dialog = new GrassCoverErosionInwardsDikeProfileSelectionDialog(viewParent, Enumerable.Empty())) + { + // Assert + Assert.IsEmpty(dialog.SelectedDikeProfiles); + Assert.IsInstanceOf(new ControlTester("GrassCoverErosionInwardsDikeProfileSelectionView", dialog).TheObject); + Assert.AreEqual("Selecteer dijkprofielen", dialog.Text); + } } } [Test] public void OnLoad_Always_SetMinimumSize() { // Setup - using (var dialog = new GrassCoverErosionInwardsDikeProfileSelectionDialog(new Form(), Enumerable.Empty())) + using (var viewParent = new Form()) + using (var dialog = new GrassCoverErosionInwardsDikeProfileSelectionDialog(viewParent, Enumerable.Empty())) { // Call dialog.Show(); @@ -93,17 +102,20 @@ CreateDikeProfile() }; - var dialog = new GrassCoverErosionInwardsDikeProfileSelectionDialog(new Form(), dikeProfiles); - var selectionView = (DataGridView) new ControlTester("DikeProfileDataGrid", dialog).TheObject; + using (var viewParent = new Form()) + using (var dialog = new GrassCoverErosionInwardsDikeProfileSelectionDialog(viewParent, dikeProfiles)) + { + var selectionView = (DataGridView) new ControlTester("DikeProfileDataGrid", dialog).TheObject; - dialog.Show(); - selectionView.Rows[0].Cells[0].Value = true; + dialog.Show(); + selectionView.Rows[0].Cells[0].Value = true; - // When - dialog.Close(); + // When + dialog.Close(); - // Then - Assert.IsEmpty(dialog.SelectedDikeProfiles); + // Then + Assert.IsEmpty(dialog.SelectedDikeProfiles); + } } [Test] @@ -117,18 +129,21 @@ CreateDikeProfile() }; - var dialog = new GrassCoverErosionInwardsDikeProfileSelectionDialog(new Form(), dikeProfiles); - var selectionView = (DataGridView) new ControlTester("DikeProfileDataGrid", dialog).TheObject; + using (var viewParent = new Form()) + using (var dialog = new GrassCoverErosionInwardsDikeProfileSelectionDialog(viewParent, dikeProfiles)) + { + var selectionView = (DataGridView) new ControlTester("DikeProfileDataGrid", dialog).TheObject; - dialog.Show(); - selectionView.Rows[0].Cells[0].Value = true; + dialog.Show(); + selectionView.Rows[0].Cells[0].Value = true; - // When - var cancelButton = new ButtonTester("CustomCancelButton", dialog); - cancelButton.Click(); + // When + var cancelButton = new ButtonTester("CustomCancelButton", dialog); + cancelButton.Click(); - // Then - Assert.IsEmpty(dialog.SelectedDikeProfiles); + // Then + Assert.IsEmpty(dialog.SelectedDikeProfiles); + } } [Test] @@ -142,22 +157,25 @@ CreateDikeProfile() }; - var dialog = new GrassCoverErosionInwardsDikeProfileSelectionDialog(new Form(), dikeProfiles); - var selectionView = (DataGridView) new ControlTester("DikeProfileDataGrid", dialog).TheObject; + using (var viewParent = new Form()) + using (var dialog = new GrassCoverErosionInwardsDikeProfileSelectionDialog(viewParent, dikeProfiles)) + { + var selectionView = (DataGridView) new ControlTester("DikeProfileDataGrid", dialog).TheObject; - dialog.Show(); - selectionView.Rows[0].Cells[0].Value = true; + dialog.Show(); + selectionView.Rows[0].Cells[0].Value = true; - // When - var okButton = new ButtonTester("OkButton", dialog); - okButton.Click(); + // When + var okButton = new ButtonTester("OkButton", dialog); + okButton.Click(); - // Then - var result = dialog.SelectedDikeProfiles; - CollectionAssert.AreEqual(new[] - { - selectedDikeProfile - }, result); + // Then + var result = dialog.SelectedDikeProfiles; + CollectionAssert.AreEqual(new[] + { + selectedDikeProfile + }, result); + } } private DikeProfile CreateDikeProfile() Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelLocationsView.Designer.cs =================================================================== diff -u -r807598022746fc4a110fa6af9038c0896f5a6c0f -r6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelLocationsView.Designer.cs (.../DesignWaterLevelLocationsView.Designer.cs) (revision 807598022746fc4a110fa6af9038c0896f5a6c0f) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelLocationsView.Designer.cs (.../DesignWaterLevelLocationsView.Designer.cs) (revision 6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a) @@ -23,11 +23,6 @@ { partial class DesignWaterLevelLocationsView { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - #region Component Designer generated code /// @@ -36,24 +31,22 @@ /// private void InitializeComponent() { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DesignWaterLevelLocationsView)); this.SuspendLayout(); // // dataGridViewControl // - this.dataGridViewControl.Size = new System.Drawing.Size(523, 344); + resources.ApplyResources(this.dataGridViewControl, "dataGridViewControl"); // // ButtonGroupBox // - this.ButtonGroupBox.Location = new System.Drawing.Point(0, 344); - this.ButtonGroupBox.Size = new System.Drawing.Size(523, 61); - this.ButtonGroupBox.Text = "Toetspeilen berekenen"; + resources.ApplyResources(this.ButtonGroupBox, "ButtonGroupBox"); // // DesignWaterLevelLocationsView // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Name = "DesignWaterLevelLocationsView"; - this.Size = new System.Drawing.Size(523, 405); this.ResumeLayout(false); } Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelLocationsView.cs =================================================================== diff -u -r26bfb24de212c4f4224b773a0cb8fb87a2d7a0f0 -r6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelLocationsView.cs (.../DesignWaterLevelLocationsView.cs) (revision 26bfb24de212c4f4224b773a0cb8fb87a2d7a0f0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelLocationsView.cs (.../DesignWaterLevelLocationsView.cs) (revision 6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a) @@ -39,7 +39,6 @@ public DesignWaterLevelLocationsView() { InitializeComponent(); - InitializeDataGridView(); } protected override void SetDataSource() @@ -56,16 +55,9 @@ CalculationCommandHandler.CalculateDesignWaterLevels(AssessmentSection, locations); } - private void InitializeDataGridView() + protected override void InitializeDataGridView() { - dataGridViewControl.AddCheckBoxColumn(TypeUtils.GetMemberName(row => row.ToCalculate), - Resources.HydraulicBoundaryLocationsView_Calculate); - dataGridViewControl.AddTextBoxColumn(TypeUtils.GetMemberName(row => row.Name), - Resources.HydraulicBoundaryDatabase_Locations_Name_DisplayName); - dataGridViewControl.AddTextBoxColumn(TypeUtils.GetMemberName(row => row.Id), - Resources.HydraulicBoundaryDatabase_Locations_Id_DisplayName); - dataGridViewControl.AddTextBoxColumn(TypeUtils.GetMemberName(row => row.Location), - Resources.HydraulicBoundaryDatabase_Locations_Coordinates_DisplayName); + base.InitializeDataGridView(); dataGridViewControl.AddTextBoxColumn(TypeUtils.GetMemberName(row => row.DesignWaterLevel), Resources.HydraulicBoundaryDatabase_Locations_DesignWaterLevel_DisplayName); } Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelLocationsView.resx =================================================================== diff -u -red0ac171987ec828fb4aebf32493a41d43c7599c -r6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelLocationsView.resx (.../DesignWaterLevelLocationsView.resx) (revision ed0ac171987ec828fb4aebf32493a41d43c7599c) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelLocationsView.resx (.../DesignWaterLevelLocationsView.resx) (revision 6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a) @@ -117,4 +117,56 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 523, 344 + + + dataGridViewControl + + + Core.Common.Controls.DataGrid.DataGridViewControl, Core.Common.Controls, Version=16.1.1.4918, Culture=neutral, PublicKeyToken=null + + + $this + + + 0 + + + 0, 344 + + + 523, 61 + + + Toetspeilen berekenen + + + ButtonGroupBox + + + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 + + + True + + + 6, 13 + + + 523, 405 + + + DesignWaterLevelLocationsView + + + Ringtoets.Integration.Forms.Views.HydraulicBoundaryLocationsView, Ringtoets.Integration.Forms, Version=16.1.1.4918, Culture=neutral, PublicKeyToken=null + \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/HydraulicBoundaryLocationsView.Designer.cs =================================================================== diff -u -r807598022746fc4a110fa6af9038c0896f5a6c0f -r6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/HydraulicBoundaryLocationsView.Designer.cs (.../HydraulicBoundaryLocationsView.Designer.cs) (revision 807598022746fc4a110fa6af9038c0896f5a6c0f) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/HydraulicBoundaryLocationsView.Designer.cs (.../HydraulicBoundaryLocationsView.Designer.cs) (revision 6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a) @@ -36,6 +36,7 @@ /// private void InitializeComponent() { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(HydraulicBoundaryLocationsView)); this.dataGridViewControl = new Core.Common.Controls.DataGrid.DataGridViewControl(); this.CalculateForSelectedButton = new System.Windows.Forms.Button(); this.DeselectAllButton = new System.Windows.Forms.Button(); @@ -46,43 +47,29 @@ // // dataGridViewControl // - this.dataGridViewControl.Dock = System.Windows.Forms.DockStyle.Fill; - this.dataGridViewControl.Location = new System.Drawing.Point(0, 0); + resources.ApplyResources(this.dataGridViewControl, "dataGridViewControl"); this.dataGridViewControl.MultiSelect = true; this.dataGridViewControl.Name = "dataGridViewControl"; - this.dataGridViewControl.Padding = new System.Windows.Forms.Padding(0, 0, 0, 5); this.dataGridViewControl.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.RowHeaderSelect; - this.dataGridViewControl.Size = new System.Drawing.Size(533, 85); - this.dataGridViewControl.TabIndex = 2; // // CalculateForSelectedButton // - this.CalculateForSelectedButton.Enabled = false; - this.CalculateForSelectedButton.Location = new System.Drawing.Point(227, 29); + resources.ApplyResources(this.CalculateForSelectedButton, "CalculateForSelectedButton"); this.CalculateForSelectedButton.Name = "CalculateForSelectedButton"; - this.CalculateForSelectedButton.Size = new System.Drawing.Size(207, 23); - this.CalculateForSelectedButton.TabIndex = 2; - this.CalculateForSelectedButton.Text = "Bereken voor geselecteerde locaties"; this.CalculateForSelectedButton.UseVisualStyleBackColor = true; this.CalculateForSelectedButton.Click += new System.EventHandler(this.CalculateForSelectedButton_Click); // // DeselectAllButton // - this.DeselectAllButton.Location = new System.Drawing.Point(110, 29); + resources.ApplyResources(this.DeselectAllButton, "DeselectAllButton"); this.DeselectAllButton.Name = "DeselectAllButton"; - this.DeselectAllButton.Size = new System.Drawing.Size(111, 23); - this.DeselectAllButton.TabIndex = 1; - this.DeselectAllButton.Text = "Deselecteer alles"; this.DeselectAllButton.UseVisualStyleBackColor = true; this.DeselectAllButton.Click += new System.EventHandler(this.DeselectAllButton_Click); // // SelectAllButton // - this.SelectAllButton.Location = new System.Drawing.Point(6, 29); + resources.ApplyResources(this.SelectAllButton, "SelectAllButton"); this.SelectAllButton.Name = "SelectAllButton"; - this.SelectAllButton.Size = new System.Drawing.Size(98, 23); - this.SelectAllButton.TabIndex = 0; - this.SelectAllButton.Text = "Selecteer alles"; this.SelectAllButton.UseVisualStyleBackColor = true; this.SelectAllButton.Click += new System.EventHandler(this.SelectAllButton_Click); // @@ -91,25 +78,17 @@ this.ButtonGroupBox.Controls.Add(this.CalculateForSelectedButton); this.ButtonGroupBox.Controls.Add(this.DeselectAllButton); this.ButtonGroupBox.Controls.Add(this.SelectAllButton); - this.ButtonGroupBox.Dock = System.Windows.Forms.DockStyle.Bottom; - this.ButtonGroupBox.Location = new System.Drawing.Point(0, 85); - this.ButtonGroupBox.MinimumSize = new System.Drawing.Size(445, 61); + resources.ApplyResources(this.ButtonGroupBox, "ButtonGroupBox"); this.ButtonGroupBox.Name = "ButtonGroupBox"; - this.ButtonGroupBox.Size = new System.Drawing.Size(533, 61); - this.ButtonGroupBox.TabIndex = 3; this.ButtonGroupBox.TabStop = false; - this.ButtonGroupBox.Text = "Berekenen"; // // HydraulicBoundaryLocationsView // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.AutoScroll = true; - this.AutoScrollMinSize = new System.Drawing.Size(516, 85); this.Controls.Add(this.dataGridViewControl); this.Controls.Add(this.ButtonGroupBox); this.Name = "HydraulicBoundaryLocationsView"; - this.Size = new System.Drawing.Size(533, 146); this.ButtonGroupBox.ResumeLayout(false); this.ResumeLayout(false); Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/HydraulicBoundaryLocationsView.cs =================================================================== diff -u -r807598022746fc4a110fa6af9038c0896f5a6c0f -r6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/HydraulicBoundaryLocationsView.cs (.../HydraulicBoundaryLocationsView.cs) (revision 807598022746fc4a110fa6af9038c0896f5a6c0f) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/HydraulicBoundaryLocationsView.cs (.../HydraulicBoundaryLocationsView.cs) (revision 6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a) @@ -27,10 +27,12 @@ using Core.Common.Controls.Views; using Core.Common.Gui.Selection; using Core.Common.Utils.Extensions; +using Core.Common.Utils.Reflection; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.HydraRing.Data; using Ringtoets.Integration.Forms.Commands; using Ringtoets.Integration.Forms.PresentationObjects; +using Ringtoets.Integration.Forms.Properties; namespace Ringtoets.Integration.Forms.Views { @@ -57,6 +59,24 @@ hydraulicBoundaryDatabaseObserver = new Observer(() => dataGridViewControl.RefreshDataGridView()); } + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + InitializeDataGridView(); + } + + protected virtual void InitializeDataGridView() + { + dataGridViewControl.AddCheckBoxColumn(TypeUtils.GetMemberName(row => row.ToCalculate), + Resources.HydraulicBoundaryLocationsView_Calculate); + dataGridViewControl.AddTextBoxColumn(TypeUtils.GetMemberName(row => row.Name), + Resources.HydraulicBoundaryDatabase_Locations_Name_DisplayName); + dataGridViewControl.AddTextBoxColumn(TypeUtils.GetMemberName(row => row.Id), + Resources.HydraulicBoundaryDatabase_Locations_Id_DisplayName); + dataGridViewControl.AddTextBoxColumn(TypeUtils.GetMemberName(row => row.Location), + Resources.HydraulicBoundaryDatabase_Locations_Coordinates_DisplayName); + } + /// /// Gets or sets the . /// Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/HydraulicBoundaryLocationsView.resx =================================================================== diff -u -r807598022746fc4a110fa6af9038c0896f5a6c0f -r6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/HydraulicBoundaryLocationsView.resx (.../HydraulicBoundaryLocationsView.resx) (revision 807598022746fc4a110fa6af9038c0896f5a6c0f) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/HydraulicBoundaryLocationsView.resx (.../HydraulicBoundaryLocationsView.resx) (revision 6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a) @@ -117,4 +117,160 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Fill + + + + 0, 0 + + + 0, 0, 0, 5 + + + 533, 85 + + + + 2 + + + dataGridViewControl + + + Core.Common.Controls.DataGrid.DataGridViewControl, Core.Common.Controls, Version=16.1.1.4918, Culture=neutral, PublicKeyToken=null + + + $this + + + 0 + + + False + + + 227, 29 + + + 207, 23 + + + 2 + + + Bereken voor geselecteerde locaties + + + CalculateForSelectedButton + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ButtonGroupBox + + + 0 + + + 110, 29 + + + 111, 23 + + + 1 + + + Deselecteer alles + + + DeselectAllButton + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ButtonGroupBox + + + 1 + + + 6, 29 + + + 98, 23 + + + 0 + + + Selecteer alles + + + SelectAllButton + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ButtonGroupBox + + + 2 + + + Bottom + + + 0, 85 + + + 445, 61 + + + 533, 61 + + + 3 + + + Berekenen + + + ButtonGroupBox + + + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 + + + True + + + 6, 13 + + + True + + + 516, 85 + + + 533, 146 + + + HydraulicBoundaryLocationsView + + + System.Windows.Forms.UserControl, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/WaveHeightLocationsView.Designer.cs =================================================================== diff -u -r807598022746fc4a110fa6af9038c0896f5a6c0f -r6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/WaveHeightLocationsView.Designer.cs (.../WaveHeightLocationsView.Designer.cs) (revision 807598022746fc4a110fa6af9038c0896f5a6c0f) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/WaveHeightLocationsView.Designer.cs (.../WaveHeightLocationsView.Designer.cs) (revision 6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a) @@ -23,11 +23,6 @@ { partial class WaveHeightLocationsView { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - #region Component Designer generated code /// @@ -36,24 +31,22 @@ /// private void InitializeComponent() { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(WaveHeightLocationsView)); this.SuspendLayout(); // // dataGridViewControl // - this.dataGridViewControl.Size = new System.Drawing.Size(523, 344); + resources.ApplyResources(this.dataGridViewControl, "dataGridViewControl"); // // ButtonGroupBox // - this.ButtonGroupBox.Location = new System.Drawing.Point(0, 344); - this.ButtonGroupBox.Size = new System.Drawing.Size(523, 61); - this.ButtonGroupBox.Text = "Golfhoogtes berekenen"; + resources.ApplyResources(this.ButtonGroupBox, "ButtonGroupBox"); // // WaveHeightLocationsView // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Name = "WaveHeightLocationsView"; - this.Size = new System.Drawing.Size(523, 405); this.ResumeLayout(false); } Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/WaveHeightLocationsView.cs =================================================================== diff -u -r26bfb24de212c4f4224b773a0cb8fb87a2d7a0f0 -r6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/WaveHeightLocationsView.cs (.../WaveHeightLocationsView.cs) (revision 26bfb24de212c4f4224b773a0cb8fb87a2d7a0f0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/WaveHeightLocationsView.cs (.../WaveHeightLocationsView.cs) (revision 6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a) @@ -39,7 +39,6 @@ public WaveHeightLocationsView() { InitializeComponent(); - InitializeDataGridView(); } protected override void SetDataSource() @@ -56,16 +55,9 @@ CalculationCommandHandler.CalculateWaveHeights(AssessmentSection, locations); } - private void InitializeDataGridView() + protected override void InitializeDataGridView() { - dataGridViewControl.AddCheckBoxColumn(TypeUtils.GetMemberName(row => row.ToCalculate), - Resources.HydraulicBoundaryLocationsView_Calculate); - dataGridViewControl.AddTextBoxColumn(TypeUtils.GetMemberName(row => row.Name), - Resources.HydraulicBoundaryDatabase_Locations_Name_DisplayName); - dataGridViewControl.AddTextBoxColumn(TypeUtils.GetMemberName(row => row.Id), - Resources.HydraulicBoundaryDatabase_Locations_Id_DisplayName); - dataGridViewControl.AddTextBoxColumn(TypeUtils.GetMemberName(row => row.Location), - Resources.HydraulicBoundaryDatabase_Locations_Coordinates_DisplayName); + base.InitializeDataGridView(); dataGridViewControl.AddTextBoxColumn(TypeUtils.GetMemberName(row => row.WaveHeight), Resources.HydraulicBoundaryDatabase_Locations_WaveHeight_DisplayName); } Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/WaveHeightLocationsView.resx =================================================================== diff -u -r84afb606e58d67c6342c4f11bf66b042e49f52d6 -r6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/WaveHeightLocationsView.resx (.../WaveHeightLocationsView.resx) (revision 84afb606e58d67c6342c4f11bf66b042e49f52d6) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/WaveHeightLocationsView.resx (.../WaveHeightLocationsView.resx) (revision 6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a) @@ -117,4 +117,56 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 523, 344 + + + dataGridViewControl + + + Core.Common.Controls.DataGrid.DataGridViewControl, Core.Common.Controls, Version=16.1.1.4918, Culture=neutral, PublicKeyToken=null + + + $this + + + 0 + + + 0, 344 + + + 523, 61 + + + Golfhoogtes berekenen + + + ButtonGroupBox + + + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 + + + True + + + 6, 13 + + + 523, 405 + + + WaveHeightLocationsView + + + Ringtoets.Integration.Forms.Views.HydraulicBoundaryLocationsView, Ringtoets.Integration.Forms, Version=16.1.1.4918, Culture=neutral, PublicKeyToken=null + \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs =================================================================== diff -u -re05b8947a4f5a41c2cb8b3f5460daf20ab77b2c8 -r6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision e05b8947a4f5a41c2cb8b3f5460daf20ab77b2c8) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a) @@ -1037,7 +1037,7 @@ RingtoetsCommonFormsResources.CalculateAllIcon, (sender, args) => { - if (hydraulicBoundaryLocationCalculationCommandHandler == null || nodeData.WrappedData.HydraulicBoundaryDatabase == null) + if (hydraulicBoundaryLocationCalculationCommandHandler == null) { return; } @@ -1069,7 +1069,7 @@ RingtoetsCommonFormsResources.CalculateAllIcon, (sender, args) => { - if (hydraulicBoundaryLocationCalculationCommandHandler == null || nodeData.WrappedData.HydraulicBoundaryDatabase == null) + if (hydraulicBoundaryLocationCalculationCommandHandler == null) { return; } Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Commands/HydraulicBoundaryLocationCommandHandlerTest.cs =================================================================== diff -u -r26bfb24de212c4f4224b773a0cb8fb87a2d7a0f0 -r6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Commands/HydraulicBoundaryLocationCommandHandlerTest.cs (.../HydraulicBoundaryLocationCommandHandlerTest.cs) (revision 26bfb24de212c4f4224b773a0cb8fb87a2d7a0f0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Commands/HydraulicBoundaryLocationCommandHandlerTest.cs (.../HydraulicBoundaryLocationCommandHandlerTest.cs) (revision 6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a) @@ -62,28 +62,36 @@ } [Test] - public void DefaultConstructor_DefaultValues() + public void Constructor_DefaultValues() { - // Setup & Call - var commandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(new Form()); + // Setup + using (var viewParent = new Form()) + { + // Call + var commandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(viewParent); - // Assert - Assert.IsInstanceOf(commandHandler); + // Assert + Assert.IsInstanceOf(commandHandler); + } } [Test] public void CalculateDesignWaterLevels_NullIAssessmentSection_ThrowsArgumentNullException() { // Setup - var commandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(new Form()); var locations = Enumerable.Empty(); + using (var viewParent = new Form()) + { + var commandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(viewParent); - TestDelegate test = () => commandHandler.CalculateDesignWaterLevels(null, locations); + // Call + TestDelegate test = () => commandHandler.CalculateDesignWaterLevels(null, locations); - // Assert - string paramName = Assert.Throws(test).ParamName; - const string expectedParamName = "assessmentSection"; - Assert.AreEqual(expectedParamName, paramName); + // Assert + string paramName = Assert.Throws(test).ParamName; + const string expectedParamName = "assessmentSection"; + Assert.AreEqual(expectedParamName, paramName); + } } [Test] @@ -93,14 +101,18 @@ var assessmentSectionMock = mockRepository.StrictMock(); mockRepository.ReplayAll(); - var commandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(new Form()); + using (var viewParent = new Form()) + { + var commandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(viewParent); - TestDelegate test = () => commandHandler.CalculateDesignWaterLevels(assessmentSectionMock, null); + // Call + TestDelegate test = () => commandHandler.CalculateDesignWaterLevels(assessmentSectionMock, null); - // Assert - string paramName = Assert.Throws(test).ParamName; - const string expectedParamName = "locations"; - Assert.AreEqual(expectedParamName, paramName); + // Assert + string paramName = Assert.Throws(test).ParamName; + const string expectedParamName = "locations"; + Assert.AreEqual(expectedParamName, paramName); + } mockRepository.VerifyAll(); } @@ -118,21 +130,25 @@ var observerMock = mockRepository.StrictMock(); mockRepository.ReplayAll(); - var commandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(new Form()); - var locations = Enumerable.Empty(); - hydraulicBoundaryDatabase.Attach(observerMock); - // Call - Action call = () => commandHandler.CalculateDesignWaterLevels(assessmentSectionMock, locations); + var locations = Enumerable.Empty(); - // Assert - TestHelper.AssertLogMessages(call, messages => + using (var viewParent = new Form()) { - var msgs = messages.ToArray(); - Assert.AreEqual(1, msgs.Length); - StringAssert.StartsWith("Berekeningen konden niet worden gestart. ", msgs.First()); - }); + var commandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(viewParent); + + // Call + Action call = () => commandHandler.CalculateDesignWaterLevels(assessmentSectionMock, locations); + + // Assert + TestHelper.AssertLogMessages(call, messages => + { + var msgs = messages.ToArray(); + Assert.AreEqual(1, msgs.Length); + StringAssert.StartsWith("Berekeningen konden niet worden gestart. ", msgs.First()); + }); + } mockRepository.VerifyAll(); } @@ -152,7 +168,6 @@ observerMock.Expect(o => o.UpdateObserver()); mockRepository.ReplayAll(); - var commandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(new Form()); var locations = Enumerable.Empty(); hydraulicBoundaryDatabase.Attach(observerMock); @@ -162,11 +177,16 @@ // Expect an activity dialog which is automatically closed }; - // Call - Action call = () => commandHandler.CalculateDesignWaterLevels(assessmentSectionMock, locations); + using (var viewParent = new Form()) + { + var commandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(viewParent); - // Assert - TestHelper.AssertLogMessagesCount(call, 0); + // Call + Action call = () => commandHandler.CalculateDesignWaterLevels(assessmentSectionMock, locations); + + // Assert + TestHelper.AssertLogMessagesCount(call, 0); + } mockRepository.VerifyAll(); } @@ -204,39 +224,47 @@ // Expect an activity dialog which is automatically closed }; - var commandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(new Form()); + using (var viewParent = new Form()) + { + var commandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(viewParent); - // Call - Action call = () => commandHandler.CalculateDesignWaterLevels(assessmentSectionMock, locations); + // Call + Action call = () => commandHandler.CalculateDesignWaterLevels(assessmentSectionMock, locations); - // Assert - TestHelper.AssertLogMessages(call, messages => - { - var msgs = messages.ToArray(); - Assert.AreEqual(6, msgs.Length); - string expectedName = string.Format("Toetspeil voor locatie {0}", hydraulicLocationName); - StringAssert.StartsWith(string.Format("Validatie van '{0}' gestart om: ", expectedName), msgs.First()); - StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", expectedName), msgs.Skip(1).First()); - StringAssert.StartsWith(string.Format("Berekening van '{0}' gestart om: ", expectedName), msgs.Skip(2).First()); - StringAssert.StartsWith(string.Format("Berekening van '{0}' beëindigd om: ", expectedName), msgs.Skip(3).First()); - StringAssert.AreNotEqualIgnoringCase(string.Format("Uitvoeren van '{0}' is mislukt.", expectedName), msgs.Last()); - }); + // Assert + TestHelper.AssertLogMessages(call, messages => + { + var msgs = messages.ToArray(); + Assert.AreEqual(6, msgs.Length); + string expectedName = string.Format("Toetspeil voor locatie {0}", hydraulicLocationName); + StringAssert.StartsWith(string.Format("Validatie van '{0}' gestart om: ", expectedName), msgs.First()); + StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", expectedName), msgs.Skip(1).First()); + StringAssert.StartsWith(string.Format("Berekening van '{0}' gestart om: ", expectedName), msgs.Skip(2).First()); + StringAssert.StartsWith(string.Format("Berekening van '{0}' beëindigd om: ", expectedName), msgs.Skip(3).First()); + StringAssert.AreNotEqualIgnoringCase(string.Format("Uitvoeren van '{0}' is mislukt.", expectedName), msgs.Last()); + }); + } mockRepository.VerifyAll(); } [Test] public void CalculateWaveHeights_NullIAssessmentSection_ThrowsArgumentNullException() { // Setup - var commandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(new Form()); var locations = Enumerable.Empty(); - TestDelegate test = () => commandHandler.CalculateWaveHeights(null, locations); + using (var viewParent = new Form()) + { + var commandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(viewParent); - // Assert - string paramName = Assert.Throws(test).ParamName; - const string expectedParamName = "assessmentSection"; - Assert.AreEqual(expectedParamName, paramName); + // Call + TestDelegate test = () => commandHandler.CalculateWaveHeights(null, locations); + + // Assert + string paramName = Assert.Throws(test).ParamName; + const string expectedParamName = "assessmentSection"; + Assert.AreEqual(expectedParamName, paramName); + } } [Test] @@ -246,14 +274,18 @@ var assessmentSectionMock = mockRepository.StrictMock(); mockRepository.ReplayAll(); - var commandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(new Form()); + using (var viewParent = new Form()) + { + var commandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(viewParent); - TestDelegate test = () => commandHandler.CalculateWaveHeights(assessmentSectionMock, null); + // Call + TestDelegate test = () => commandHandler.CalculateWaveHeights(assessmentSectionMock, null); - // Assert - string paramName = Assert.Throws(test).ParamName; - const string expectedParamName = "locations"; - Assert.AreEqual(expectedParamName, paramName); + // Assert + string paramName = Assert.Throws(test).ParamName; + const string expectedParamName = "locations"; + Assert.AreEqual(expectedParamName, paramName); + } mockRepository.VerifyAll(); } @@ -271,21 +303,25 @@ var observerMock = mockRepository.StrictMock(); mockRepository.ReplayAll(); - var commandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(new Form()); var locations = Enumerable.Empty(); hydraulicBoundaryDatabase.Attach(observerMock); - // Call - Action call = () => commandHandler.CalculateWaveHeights(assessmentSectionMock, locations); - - // Assert - TestHelper.AssertLogMessages(call, messages => + using (var viewParent = new Form()) { - var msgs = messages.ToArray(); - Assert.AreEqual(1, msgs.Length); - StringAssert.StartsWith("Berekeningen konden niet worden gestart. ", msgs.First()); - }); + var commandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(viewParent); + + // Call + Action call = () => commandHandler.CalculateWaveHeights(assessmentSectionMock, locations); + + // Assert + TestHelper.AssertLogMessages(call, messages => + { + var msgs = messages.ToArray(); + Assert.AreEqual(1, msgs.Length); + StringAssert.StartsWith("Berekeningen konden niet worden gestart. ", msgs.First()); + }); + } mockRepository.VerifyAll(); } @@ -305,21 +341,25 @@ observerMock.Expect(o => o.UpdateObserver()); mockRepository.ReplayAll(); - var commandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(new Form()); - var locations = Enumerable.Empty(); - hydraulicBoundaryDatabase.Attach(observerMock); DialogBoxHandler = (name, wnd) => { // Expect an activity dialog which is automatically closed }; - // Call - Action call = () => commandHandler.CalculateWaveHeights(assessmentSectionMock, locations); + var locations = Enumerable.Empty(); - // Assert - TestHelper.AssertLogMessagesCount(call, 0); + using (var viewParent = new Form()) + { + var commandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(viewParent); + + // Call + Action call = () => commandHandler.CalculateWaveHeights(assessmentSectionMock, locations); + + // Assert + TestHelper.AssertLogMessagesCount(call, 0); + } mockRepository.VerifyAll(); } @@ -345,10 +385,6 @@ mockRepository.ReplayAll(); const string hydraulicLocationName = "name"; - var locations = new List - { - new HydraulicBoundaryLocation(1, hydraulicLocationName, 2, 3) - }; hydraulicBoundaryDatabase.Attach(observerMock); @@ -357,23 +393,30 @@ // Expect an activity dialog which is automatically closed }; - var commandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(new Form()); + var locations = new List + { + new HydraulicBoundaryLocation(1, hydraulicLocationName, 2, 3) + }; + using (var viewParent = new Form()) + { + var commandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(viewParent); - // Call - Action call = () => commandHandler.CalculateWaveHeights(assessmentSectionMock, locations); + // Call + Action call = () => commandHandler.CalculateWaveHeights(assessmentSectionMock, locations); - // Assert - TestHelper.AssertLogMessages(call, messages => - { - var msgs = messages.ToArray(); - Assert.AreEqual(6, msgs.Length); - string expectedName = string.Format("Golfhoogte voor locatie {0}", hydraulicLocationName); - StringAssert.StartsWith(string.Format("Validatie van '{0}' gestart om: ", expectedName), msgs.First()); - StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", expectedName), msgs.Skip(1).First()); - StringAssert.StartsWith(string.Format("Berekening van '{0}' gestart om: ", expectedName), msgs.Skip(2).First()); - StringAssert.StartsWith(string.Format("Berekening van '{0}' beëindigd om: ", expectedName), msgs.Skip(3).First()); - StringAssert.AreNotEqualIgnoringCase(string.Format("Uitvoeren van '{0}' is mislukt.", expectedName), msgs.Last()); - }); + // Assert + TestHelper.AssertLogMessages(call, messages => + { + var msgs = messages.ToArray(); + Assert.AreEqual(6, msgs.Length); + string expectedName = string.Format("Golfhoogte voor locatie {0}", hydraulicLocationName); + StringAssert.StartsWith(string.Format("Validatie van '{0}' gestart om: ", expectedName), msgs.First()); + StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", expectedName), msgs.Skip(1).First()); + StringAssert.StartsWith(string.Format("Berekening van '{0}' gestart om: ", expectedName), msgs.Skip(2).First()); + StringAssert.StartsWith(string.Format("Berekening van '{0}' beëindigd om: ", expectedName), msgs.Skip(3).First()); + StringAssert.AreNotEqualIgnoringCase(string.Format("Uitvoeren van '{0}' is mislukt.", expectedName), msgs.Last()); + }); + } mockRepository.VerifyAll(); } } Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/ReferenceLineMetaSelectionDialogTest.cs =================================================================== diff -u -rf1bf048f691ca575f22e8807911ace0338fa425d -r6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/ReferenceLineMetaSelectionDialogTest.cs (.../ReferenceLineMetaSelectionDialogTest.cs) (revision f1bf048f691ca575f22e8807911ace0338fa425d) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/ReferenceLineMetaSelectionDialogTest.cs (.../ReferenceLineMetaSelectionDialogTest.cs) (revision 6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a) @@ -48,26 +48,34 @@ [Test] public void Constructor_WithoutReferenceLineMetas_ThrowsArgumentNullException() { - // Call - TestDelegate test = () => new ReferenceLineMetaSelectionDialog(new Form(), null); + // Setup + using (var viewParent = new Form()) + { + // Call + TestDelegate test = () => new ReferenceLineMetaSelectionDialog(viewParent, null); - // Assert - var parameter = Assert.Throws(test).ParamName; - Assert.AreEqual("referenceLineMetas", parameter); + // Assert + var parameter = Assert.Throws(test).ParamName; + Assert.AreEqual("referenceLineMetas", parameter); + } } [Test] public void Constructor_WithParentAndReferenceLineMeta_DefaultProperties() { - // Call - using (var dialog = new ReferenceLineMetaSelectionDialog(new Form(), Enumerable.Empty())) + // Setup + using (var viewParent = new Form()) { - // Assert - Assert.IsInstanceOf(dialog); - Assert.IsNull(dialog.SelectedReferenceLineMeta); - Assert.AreEqual(@"Stel een traject samen", dialog.Text); + // Call + using (var dialog = new ReferenceLineMetaSelectionDialog(viewParent, Enumerable.Empty())) + { + // Assert + Assert.IsInstanceOf(dialog); + Assert.IsNull(dialog.SelectedReferenceLineMeta); + Assert.AreEqual(@"Stel een traject samen", dialog.Text); - AssertReferenceLineMetaDataGridViewControl(dialog); + AssertReferenceLineMetaDataGridViewControl(dialog); + } } } @@ -108,42 +116,46 @@ } }; - // Call - using (var dialog = new ReferenceLineMetaSelectionDialog(new Form(), referenceLineMetas)) + using (var viewParent = new Form()) { - // Assert - DataGridViewControl grid = (DataGridViewControl) new ControlTester("ReferenceLineMetaDataGridViewControl", dialog).TheObject; - DataGridView dataGridView = grid.Controls.OfType().First(); - - var assessmentIdValuesInGrid = new List(); - for (var i = 0; i < dataGridView.Rows.Count; i++) + // Call + using (var dialog = new ReferenceLineMetaSelectionDialog(viewParent, referenceLineMetas)) { - object currentIdValue = dataGridView[0, i].FormattedValue; - if (currentIdValue != null) + // Assert + DataGridViewControl grid = (DataGridViewControl) new ControlTester("ReferenceLineMetaDataGridViewControl", dialog).TheObject; + DataGridView dataGridView = grid.Controls.OfType().First(); + + var assessmentIdValuesInGrid = new List(); + for (var i = 0; i < dataGridView.Rows.Count; i++) { - assessmentIdValuesInGrid.Add(currentIdValue.ToString()); + object currentIdValue = dataGridView[0, i].FormattedValue; + if (currentIdValue != null) + { + assessmentIdValuesInGrid.Add(currentIdValue.ToString()); + } } - } - CollectionAssert.AreEqual(new[] - { - "", - "10", - "101-1", - "101-2", - "101-10", - "101a-1", - "101b-1", - "102-1" - }, assessmentIdValuesInGrid); + CollectionAssert.AreEqual(new[] + { + "", + "10", + "101-1", + "101-2", + "101-10", + "101a-1", + "101b-1", + "102-1" + }, assessmentIdValuesInGrid); + } } } [Test] public void OnLoad_Always_SetMinimumSize() { // Setup - using (var dialog = new ReferenceLineMetaSelectionDialog(new Form(), Enumerable.Empty())) + using (var viewParent = new Form()) + using (var dialog = new ReferenceLineMetaSelectionDialog(viewParent, Enumerable.Empty())) { // Call dialog.Show(); Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelLocationsViewTest.cs =================================================================== diff -u -r26bfb24de212c4f4224b773a0cb8fb87a2d7a0f0 -r6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelLocationsViewTest.cs (.../DesignWaterLevelLocationsViewTest.cs) (revision 26bfb24de212c4f4224b773a0cb8fb87a2d7a0f0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelLocationsViewTest.cs (.../DesignWaterLevelLocationsViewTest.cs) (revision 6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a) @@ -27,7 +27,6 @@ using Core.Common.Base; using Core.Common.Base.Data; using Core.Common.Base.Geometry; -using Core.Common.Gui.Selection; using NUnit.Extensions.Forms; using NUnit.Framework; using Rhino.Mocks; @@ -36,7 +35,6 @@ using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.HydraRing.Data; using Ringtoets.Integration.Forms.Commands; -using Ringtoets.Integration.Forms.PresentationObjects; using Ringtoets.Integration.Forms.Views; namespace Ringtoets.Integration.Forms.Test.Views @@ -106,38 +104,6 @@ } [Test] - public void Data_IAssessmentSection_DataSet() - { - // Setup - using (var view = new DesignWaterLevelLocationsView()) - { - var assessmentSection = new TestAssessmentSection(); - - // Call - view.Data = assessmentSection; - - // Assert - Assert.AreSame(assessmentSection, view.Data); - } - } - - [Test] - public void Data_OtherThanIAssessmentSection_DataNull() - { - // Setup - using (var view = new DesignWaterLevelLocationsView()) - { - var data = new object(); - - // Call - view.Data = data; - - // Assert - Assert.IsNull(view.Data); - } - } - - [Test] public void DesignWaterLevelLocationsView_AssessmentSectionWithData_DataGridViewCorrectlyInitialized() { // Setup & Call @@ -233,149 +199,6 @@ } [Test] - public void DesignWaterLevelLocationsView_SelectingCellInRow_ApplicationSelectionCorrectlySynced() - { - // Setup - var view = ShowFullyConfiguredDesignWaterLevelLocationsView(); - IAssessmentSection assessmentSection = (IAssessmentSection) view.Data; - var secondHydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.Skip(1).First(); - - var mocks = new MockRepository(); - var applicationSelectionMock = mocks.StrictMock(); - applicationSelectionMock.Stub(asm => asm.Selection).Return(null); - applicationSelectionMock.Expect(asm => asm.Selection = new DesignWaterLevelLocationContext( - assessmentSection.HydraulicBoundaryDatabase, - secondHydraulicBoundaryLocation)); - mocks.ReplayAll(); - - view.ApplicationSelection = applicationSelectionMock; - - var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; - - // Call - dataGridView.CurrentCell = dataGridView.Rows[1].Cells[locationNameColumnIndex]; - EventHelper.RaiseEvent(dataGridView, "CellClick", new DataGridViewCellEventArgs(1, 0)); - - // Assert - mocks.VerifyAll(); - } - - [Test] - public void DesignWaterLevelLocationsView_SelectingCellInAlreadySelectedRow_ApplicationSelectionNotSyncedRedundantly() - { - // Setup - var view = ShowFullyConfiguredDesignWaterLevelLocationsView(); - - var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; - dataGridView.CurrentCell = dataGridView.Rows[1].Cells[locationNameColumnIndex]; - - var mocks = new MockRepository(); - var applicationSelectionMock = mocks.StrictMock(); - applicationSelectionMock.Stub(asm => asm.Selection).Return(view.Selection); - mocks.ReplayAll(); - - view.ApplicationSelection = applicationSelectionMock; - - // Call - dataGridView.CurrentCell = dataGridView.Rows[1].Cells[locationNameColumnIndex]; - EventHelper.RaiseEvent(dataGridView, "CellClick", new DataGridViewCellEventArgs(locationNameColumnIndex, 0)); - - // Assert - mocks.VerifyAll(); - } - - [Test] - [TestCase(0)] - [TestCase(1)] - [TestCase(2)] - public void Selection_Always_ReturnsTheSelectedRowObject(int selectedRow) - { - // Setup - var view = ShowFullyConfiguredDesignWaterLevelLocationsView(); - var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; - dataGridView.CurrentCell = dataGridView.Rows[selectedRow].Cells[locationNameColumnIndex]; - - // Call - var selection = view.Selection; - - // Assert - Assert.IsInstanceOf(selection); - HydraulicBoundaryDatabase hydraulicBoundaryDatabase = ((IAssessmentSection) view.Data).HydraulicBoundaryDatabase; - Assert.AreSame(hydraulicBoundaryDatabase, ((DesignWaterLevelLocationContext) selection).WrappedData); - } - - [Test] - public void SelectAllButton_SelectAllButtonClicked_AllLocationsSelected() - { - // Setup - ShowFullyConfiguredDesignWaterLevelLocationsView(); - - var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; - var rows = dataGridView.Rows; - var button = new ButtonTester("SelectAllButton", testForm); - - // Precondition - Assert.IsFalse((bool) rows[0].Cells[locationCalculateColumnIndex].Value); - Assert.IsFalse((bool) rows[1].Cells[locationCalculateColumnIndex].Value); - Assert.IsFalse((bool) rows[2].Cells[locationCalculateColumnIndex].Value); - - // Call - button.Click(); - - // Assert - Assert.IsTrue((bool) rows[0].Cells[locationCalculateColumnIndex].Value); - Assert.IsTrue((bool) rows[1].Cells[locationCalculateColumnIndex].Value); - Assert.IsTrue((bool) rows[2].Cells[locationCalculateColumnIndex].Value); - } - - [Test] - public void DeselectAllButton_AllLocationsSelectedDeselectAllButtonClicked_AllLocationsNotSelected() - { - // Setup - ShowFullyConfiguredDesignWaterLevelLocationsView(); - - var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; - var rows = dataGridView.Rows; - var button = new ButtonTester("DeselectAllButton", testForm); - - foreach (DataGridViewRow row in rows) - { - row.Cells[locationCalculateColumnIndex].Value = true; - } - - // Precondition - Assert.IsTrue((bool) rows[0].Cells[locationCalculateColumnIndex].Value); - Assert.IsTrue((bool) rows[1].Cells[locationCalculateColumnIndex].Value); - Assert.IsTrue((bool) rows[2].Cells[locationCalculateColumnIndex].Value); - - // Call - button.Click(); - - // Assert - Assert.IsFalse((bool) rows[0].Cells[locationCalculateColumnIndex].Value); - Assert.IsFalse((bool) rows[1].Cells[locationCalculateColumnIndex].Value); - Assert.IsFalse((bool) rows[2].Cells[locationCalculateColumnIndex].Value); - } - - [Test] - public void CalculateForSelectedButton_NoneSelected_CalculateForSelectedButtonDisabled() - { - // Setup - var mockRepository = new MockRepository(); - var commandHandlerMock = mockRepository.StrictMock(); - mockRepository.ReplayAll(); - - DesignWaterLevelLocationsView view = ShowFullyConfiguredDesignWaterLevelLocationsView(); - view.CalculationCommandHandler = commandHandlerMock; - - // Assert - var buttonTester = new ButtonTester("CalculateForSelectedButton", testForm); - var button = (Button) buttonTester.TheObject; - Assert.IsFalse(button.Enabled); - mockRepository.VerifyAll(); - } - - [Test] public void CalculateForSelectedButton_OneSelected_CallsCalculateDesignWaterLevels() { // Setup Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/FailureMechanismContributionItemRowTest.cs =================================================================== diff -u -rf1bf048f691ca575f22e8807911ace0338fa425d -r6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/FailureMechanismContributionItemRowTest.cs (.../FailureMechanismContributionItemRowTest.cs) (revision f1bf048f691ca575f22e8807911ace0338fa425d) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/FailureMechanismContributionItemRowTest.cs (.../FailureMechanismContributionItemRowTest.cs) (revision 6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a) @@ -44,7 +44,7 @@ } [Test] - public void Constructor_WithFailureMechanismContributionItem_PropertiesFromFailureMechanismContributionItemn() + public void Constructor_WithFailureMechanismContributionItem_PropertiesFromFailureMechanismContributionItem() { // Setup var pipingFailureMechanism = new PipingFailureMechanism(); Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/HydraulicBoundaryLocationContextRowTest.cs =================================================================== diff -u -r84afb606e58d67c6342c4f11bf66b042e49f52d6 -r6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/HydraulicBoundaryLocationContextRowTest.cs (.../HydraulicBoundaryLocationContextRowTest.cs) (revision 84afb606e58d67c6342c4f11bf66b042e49f52d6) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/HydraulicBoundaryLocationContextRowTest.cs (.../HydraulicBoundaryLocationContextRowTest.cs) (revision 6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a) @@ -64,6 +64,7 @@ Assert.AreEqual(locationname, row.Name); var expectedPoint2D = new Point2D(coordinateX, coordinateY); Assert.AreEqual(expectedPoint2D, row.Location); + Assert.AreSame(context, row.HydraulicBoundaryLocationContext); Assert.IsFalse(row.ToCalculate); } Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/HydraulicBoundaryLocationsViewTest.cs =================================================================== diff -u -r807598022746fc4a110fa6af9038c0896f5a6c0f -r6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/HydraulicBoundaryLocationsViewTest.cs (.../HydraulicBoundaryLocationsViewTest.cs) (revision 807598022746fc4a110fa6af9038c0896f5a6c0f) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/HydraulicBoundaryLocationsViewTest.cs (.../HydraulicBoundaryLocationsViewTest.cs) (revision 6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a) @@ -25,9 +25,9 @@ using System.Windows.Forms; using Core.Common.Base; using Core.Common.Base.Data; +using Core.Common.Base.Geometry; using Core.Common.Controls.Views; using Core.Common.Gui.Selection; -using Core.Common.Utils.Reflection; using NUnit.Extensions.Forms; using NUnit.Framework; using Rhino.Mocks; @@ -67,6 +67,7 @@ // Assert Assert.IsInstanceOf(view); Assert.IsInstanceOf(view); + Assert.IsInstanceOf(view); Assert.IsNull(view.Data); } } @@ -83,6 +84,37 @@ } [Test] + public void Constructor_DataGridViewCorrectlyInitialized() + { + // Setup & Call + ShowTestHydraulicBoundaryLocationsView(); + + // Assert + var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + Assert.AreEqual(4, dataGridView.ColumnCount); + + var locationCalculateColumn = (DataGridViewCheckBoxColumn) dataGridView.Columns[locationCalculateColumnIndex]; + const string expectedLocationCalculateHeaderText = "Berekenen"; + Assert.AreEqual(expectedLocationCalculateHeaderText, locationCalculateColumn.HeaderText); + + var locationNameColumn = (DataGridViewTextBoxColumn) dataGridView.Columns[locationNameColumnIndex]; + const string expectedLocationNameHeaderText = "Naam"; + Assert.AreEqual(expectedLocationNameHeaderText, locationNameColumn.HeaderText); + + var locationIdColumn = (DataGridViewTextBoxColumn) dataGridView.Columns[locationIdColumnIndex]; + const string expectedLocationIdHeaderText = "ID"; + Assert.AreEqual(expectedLocationIdHeaderText, locationIdColumn.HeaderText); + + var locationColumn = (DataGridViewTextBoxColumn) dataGridView.Columns[locationColumnIndex]; + const string expectedLocationHeaderText = "Coördinaten [m]"; + Assert.AreEqual(expectedLocationHeaderText, locationColumn.HeaderText); + + var buttonTester = new ButtonTester("CalculateForSelectedButton", testForm); + var button = (Button) buttonTester.TheObject; + Assert.IsFalse(button.Enabled); + } + + [Test] public void Data_IAssessmentSection_DataSet() { // Setup @@ -115,11 +147,76 @@ } [Test] - public void TestHydraulicBoundaryLocationsView_SelectingCellInRow_ApplicationSelectionCorrectlySynced() + public void HydraulicBoundaryLocationsView_AssessmentSectionWithData_DataGridViewCorrectlyInitialized() { + // Setup & Call + ShowFullyConfiguredTestHydraulicBoundaryLocationsView(); + + // Assert + var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + var rows = dataGridView.Rows; + Assert.AreEqual(3, rows.Count); + + var cells = rows[0].Cells; + Assert.AreEqual(4, cells.Count); + Assert.AreEqual(false, cells[locationCalculateColumnIndex].FormattedValue); + Assert.AreEqual("1", cells[locationNameColumnIndex].FormattedValue); + Assert.AreEqual("1", cells[locationIdColumnIndex].FormattedValue); + Assert.AreEqual(new Point2D(1, 1).ToString(), cells[locationColumnIndex].FormattedValue); + + cells = rows[1].Cells; + Assert.AreEqual(4, cells.Count); + Assert.AreEqual(false, cells[locationCalculateColumnIndex].FormattedValue); + Assert.AreEqual("2", cells[locationNameColumnIndex].FormattedValue); + Assert.AreEqual("2", cells[locationIdColumnIndex].FormattedValue); + Assert.AreEqual(new Point2D(2, 2).ToString(), cells[locationColumnIndex].FormattedValue); + + cells = rows[2].Cells; + Assert.AreEqual(4, cells.Count); + Assert.AreEqual(false, cells[locationCalculateColumnIndex].FormattedValue); + Assert.AreEqual("3", cells[locationNameColumnIndex].FormattedValue); + Assert.AreEqual("3", cells[locationIdColumnIndex].FormattedValue); + Assert.AreEqual(new Point2D(3, 3).ToString(), cells[locationColumnIndex].FormattedValue); + } + + [Test] + public void HydraulicBoundaryLocationsView_HydraulicBoundaryDatabaseUpdated_DataGridViewCorrectlyUpdated() + { // Setup var view = ShowFullyConfiguredTestHydraulicBoundaryLocationsView(); IAssessmentSection assessmentSection = (IAssessmentSection) view.Data; + HydraulicBoundaryDatabase newHydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(10, "10", 10.0, 10.0) + { + DesignWaterLevel = (RoundedDouble) 10.23 + }; + newHydraulicBoundaryDatabase.Locations.Add(hydraulicBoundaryLocation); + + // Precondition + var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + var rows = dataGridView.Rows; + Assert.AreEqual(3, rows.Count); + + // Call + assessmentSection.HydraulicBoundaryDatabase = newHydraulicBoundaryDatabase; + assessmentSection.NotifyObservers(); + + // Assert + Assert.AreEqual(1, rows.Count); + var cells = rows[0].Cells; + Assert.AreEqual(4, cells.Count); + Assert.AreEqual(false, cells[locationCalculateColumnIndex].FormattedValue); + Assert.AreEqual("10", cells[locationNameColumnIndex].FormattedValue); + Assert.AreEqual("10", cells[locationIdColumnIndex].FormattedValue); + Assert.AreEqual(new Point2D(10, 10).ToString(), cells[locationColumnIndex].FormattedValue); + } + + [Test] + public void HydraulicBoundaryLocationsView_SelectingCellInRow_ApplicationSelectionCorrectlySynced() + { + // Setup + var view = ShowFullyConfiguredTestHydraulicBoundaryLocationsView(); + IAssessmentSection assessmentSection = (IAssessmentSection) view.Data; var secondHydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.Skip(1).First(); var mocks = new MockRepository(); @@ -143,7 +240,7 @@ } [Test] - public void TestHydraulicBoundaryLocationsView_SelectingCellInAlreadySelectedRow_ApplicationSelectionNotSyncedRedundantly() + public void HydraulicBoundaryLocationsView_SelectingCellInAlreadySelectedRow_ApplicationSelectionNotSyncedRedundantly() { // Setup var view = ShowFullyConfiguredTestHydraulicBoundaryLocationsView(); @@ -307,6 +404,9 @@ } private const int locationCalculateColumnIndex = 0; + private const int locationNameColumnIndex = 1; + private const int locationIdColumnIndex = 2; + private const int locationColumnIndex = 3; private TestHydraulicBoundaryLocationsView ShowTestHydraulicBoundaryLocationsView() { @@ -381,11 +481,10 @@ : base(hydraulicBoundaryLocationContext) {} } - private class TestHydraulicBoundaryLocationsView : HydraulicBoundaryLocationsView + private sealed class TestHydraulicBoundaryLocationsView : HydraulicBoundaryLocationsView { public TestHydraulicBoundaryLocationsView() { - dataGridViewControl.AddCheckBoxColumn(TypeUtils.GetMemberName(row => row.ToCalculate), ""); LocationsToCalculate = new List(); } Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/WaveHeightLocationsViewTest.cs =================================================================== diff -u -r26bfb24de212c4f4224b773a0cb8fb87a2d7a0f0 -r6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/WaveHeightLocationsViewTest.cs (.../WaveHeightLocationsViewTest.cs) (revision 26bfb24de212c4f4224b773a0cb8fb87a2d7a0f0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/WaveHeightLocationsViewTest.cs (.../WaveHeightLocationsViewTest.cs) (revision 6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a) @@ -27,7 +27,6 @@ using Core.Common.Base; using Core.Common.Base.Data; using Core.Common.Base.Geometry; -using Core.Common.Gui.Selection; using NUnit.Extensions.Forms; using NUnit.Framework; using Rhino.Mocks; @@ -36,7 +35,6 @@ using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.HydraRing.Data; using Ringtoets.Integration.Forms.Commands; -using Ringtoets.Integration.Forms.PresentationObjects; using Ringtoets.Integration.Forms.Views; namespace Ringtoets.Integration.Forms.Test.Views @@ -102,38 +100,6 @@ } [Test] - public void Data_IAssessmentSection_DataSet() - { - // Setup - using (var view = new WaveHeightLocationsView()) - { - var assessmentSection = new TestAssessmentSection(); - - // Call - view.Data = assessmentSection; - - // Assert - Assert.AreSame(assessmentSection, view.Data); - } - } - - [Test] - public void Data_OtherThanIAssessmentSection_DataNull() - { - // Setup - using (var view = new WaveHeightLocationsView()) - { - var data = new object(); - - // Call - view.Data = data; - - // Assert - Assert.IsNull(view.Data); - } - } - - [Test] public void WaveHeightLocationsView_AssessmentSectionWithData_DataGridViewCorrectlyInitialized() { // Setup & Call @@ -229,149 +195,6 @@ } [Test] - public void WaveHeightLocationsView_SelectingCellInRow_ApplicationSelectionCorrectlySynced() - { - // Setup - var view = ShowFullyConfiguredWaveHeightLocationsView(); - IAssessmentSection assessmentSection = (IAssessmentSection) view.Data; - var secondHydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.Skip(1).First(); - - var mocks = new MockRepository(); - var applicationSelectionMock = mocks.StrictMock(); - applicationSelectionMock.Stub(asm => asm.Selection).Return(null); - applicationSelectionMock.Expect(asm => asm.Selection = new WaveHeightLocationContext( - assessmentSection.HydraulicBoundaryDatabase, - secondHydraulicBoundaryLocation)); - mocks.ReplayAll(); - - view.ApplicationSelection = applicationSelectionMock; - - var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; - - // Call - dataGridView.CurrentCell = dataGridView.Rows[1].Cells[locationNameColumnIndex]; - EventHelper.RaiseEvent(dataGridView, "CellClick", new DataGridViewCellEventArgs(1, 0)); - - // Assert - mocks.VerifyAll(); - } - - [Test] - public void WaveHeightLocationsView_SelectingCellInAlreadySelectedRow_ApplicationSelectionNotSyncedRedundantly() - { - // Setup - var view = ShowFullyConfiguredWaveHeightLocationsView(); - - var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; - dataGridView.CurrentCell = dataGridView.Rows[1].Cells[locationNameColumnIndex]; - - var mocks = new MockRepository(); - var applicationSelectionMock = mocks.StrictMock(); - applicationSelectionMock.Stub(asm => asm.Selection).Return(view.Selection); - mocks.ReplayAll(); - - view.ApplicationSelection = applicationSelectionMock; - - // Call - dataGridView.CurrentCell = dataGridView.Rows[1].Cells[locationNameColumnIndex]; - EventHelper.RaiseEvent(dataGridView, "CellClick", new DataGridViewCellEventArgs(locationNameColumnIndex, 0)); - - // Assert - mocks.VerifyAll(); - } - - [Test] - [TestCase(0)] - [TestCase(1)] - [TestCase(2)] - public void Selection_Always_ReturnsTheSelectedRowObject(int selectedRow) - { - // Setup - var view = ShowFullyConfiguredWaveHeightLocationsView(); - var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; - dataGridView.CurrentCell = dataGridView.Rows[selectedRow].Cells[locationNameColumnIndex]; - - // Call - var selection = view.Selection; - - // Assert - Assert.IsInstanceOf(selection); - HydraulicBoundaryDatabase hydraulicBoundaryDatabase = ((IAssessmentSection) view.Data).HydraulicBoundaryDatabase; - Assert.AreSame(hydraulicBoundaryDatabase, ((WaveHeightLocationContext) selection).WrappedData); - } - - [Test] - public void SelectAllButton_SelectAllButtonClicked_AllLocationsSelected() - { - // Setup - ShowFullyConfiguredWaveHeightLocationsView(); - - var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; - var rows = dataGridView.Rows; - var button = new ButtonTester("SelectAllButton", testForm); - - // Precondition - Assert.IsFalse((bool) rows[0].Cells[locationCalculateColumnIndex].Value); - Assert.IsFalse((bool) rows[1].Cells[locationCalculateColumnIndex].Value); - Assert.IsFalse((bool) rows[2].Cells[locationCalculateColumnIndex].Value); - - // Call - button.Click(); - - // Assert - Assert.IsTrue((bool) rows[0].Cells[locationCalculateColumnIndex].Value); - Assert.IsTrue((bool) rows[1].Cells[locationCalculateColumnIndex].Value); - Assert.IsTrue((bool) rows[2].Cells[locationCalculateColumnIndex].Value); - } - - [Test] - public void DeselectAllButton_AllLocationsSelectedDeselectAllButtonClicked_AllLocationsNotSelected() - { - // Setup - ShowFullyConfiguredWaveHeightLocationsView(); - - var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; - var rows = dataGridView.Rows; - var button = new ButtonTester("DeselectAllButton", testForm); - - foreach (DataGridViewRow row in rows) - { - row.Cells[locationCalculateColumnIndex].Value = true; - } - - // Precondition - Assert.IsTrue((bool) rows[0].Cells[locationCalculateColumnIndex].Value); - Assert.IsTrue((bool) rows[1].Cells[locationCalculateColumnIndex].Value); - Assert.IsTrue((bool) rows[2].Cells[locationCalculateColumnIndex].Value); - - // Call - button.Click(); - - // Assert - Assert.IsFalse((bool) rows[0].Cells[locationCalculateColumnIndex].Value); - Assert.IsFalse((bool) rows[1].Cells[locationCalculateColumnIndex].Value); - Assert.IsFalse((bool) rows[2].Cells[locationCalculateColumnIndex].Value); - } - - [Test] - public void CalculateForSelectedButton_NoneSelected_CalculateForSelectedButtonDisabled() - { - // Setup - var mockRepository = new MockRepository(); - var commandHandlerMock = mockRepository.StrictMock(); - mockRepository.ReplayAll(); - - WaveHeightLocationsView view = ShowFullyConfiguredWaveHeightLocationsView(); - view.CalculationCommandHandler = commandHandlerMock; - - // Assert - var buttonTester = new ButtonTester("CalculateForSelectedButton", testForm); - var button = (Button) buttonTester.TheObject; - Assert.IsFalse(button.Enabled); - mockRepository.VerifyAll(); - } - - [Test] public void CalculateForSelectedButton_OneSelected_CallsCalculateWaveHeights() { // Setup Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/DesignWaterLevelLocationsViewInfoTest.cs =================================================================== diff -u -r26bfb24de212c4f4224b773a0cb8fb87a2d7a0f0 -r6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/DesignWaterLevelLocationsViewInfoTest.cs (.../DesignWaterLevelLocationsViewInfoTest.cs) (revision 26bfb24de212c4f4224b773a0cb8fb87a2d7a0f0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/DesignWaterLevelLocationsViewInfoTest.cs (.../DesignWaterLevelLocationsViewInfoTest.cs) (revision 6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a) @@ -64,13 +64,15 @@ // Setup var assessmentSection = mocks.Stub(); mocks.ReplayAll(); - var view = new DesignWaterLevelLocationsView(); - // Call - var viewName = info.GetViewName(view, assessmentSection); + using (var view = new DesignWaterLevelLocationsView()) + { + // Call + var viewName = info.GetViewName(view, assessmentSection); - // Assert - Assert.AreEqual("Toetspeilen", viewName); + // Assert + Assert.AreEqual("Toetspeilen", viewName); + } mocks.VerifyAll(); } @@ -137,13 +139,11 @@ guiStub.Stub(g => g.ViewCommands).Return(mocks.Stub()); guiStub.Stub(g => g.MainWindow).Return(mocks.Stub()); guiStub.Stub(g => g.DocumentViewController).Return(mocks.Stub()); - mocks.ReplayAll(); var context = new DesignWaterLevelLocationsContext(assessmentSection); - var view = new DesignWaterLevelLocationsView(); - + using (var view = new DesignWaterLevelLocationsView()) using (var ringtoetsPlugin = new RingtoetsPlugin()) { info = ringtoetsPlugin.GetViewInfos().First(tni => tni.ViewType == typeof(DesignWaterLevelLocationsView)); @@ -157,6 +157,7 @@ Assert.IsInstanceOf(view.CalculationCommandHandler); Assert.AreSame(view.ApplicationSelection, guiStub); } + mocks.VerifyAll(); } } Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaveHeightLocationsViewInfoTest.cs =================================================================== diff -u -r26bfb24de212c4f4224b773a0cb8fb87a2d7a0f0 -r6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaveHeightLocationsViewInfoTest.cs (.../WaveHeightLocationsViewInfoTest.cs) (revision 26bfb24de212c4f4224b773a0cb8fb87a2d7a0f0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaveHeightLocationsViewInfoTest.cs (.../WaveHeightLocationsViewInfoTest.cs) (revision 6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a) @@ -64,13 +64,15 @@ // Setup var assessmentSection = mocks.Stub(); mocks.ReplayAll(); - var view = new WaveHeightLocationsView(); - // Call - var viewName = info.GetViewName(view, assessmentSection); + using (var view = new WaveHeightLocationsView()) + { + // Call + var viewName = info.GetViewName(view, assessmentSection); - // Assert - Assert.AreEqual("Golfhoogtes", viewName); + // Assert + Assert.AreEqual("Golfhoogtes", viewName); + } mocks.VerifyAll(); } @@ -142,8 +144,7 @@ var context = new WaveHeightLocationsContext(assessmentSection); - var view = new WaveHeightLocationsView(); - + using (var view = new WaveHeightLocationsView()) using (var ringtoetsPlugin = new RingtoetsPlugin()) { info = ringtoetsPlugin.GetViewInfos().First(tni => tni.ViewType == typeof(WaveHeightLocationsView)); Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PipingSurfaceLineSelectionDialogTest.cs =================================================================== diff -u -rac2a8327f9ce8b42d2e2740a0cda030385c5c63c -r6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PipingSurfaceLineSelectionDialogTest.cs (.../PipingSurfaceLineSelectionDialogTest.cs) (revision ac2a8327f9ce8b42d2e2740a0cda030385c5c63c) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PipingSurfaceLineSelectionDialogTest.cs (.../PipingSurfaceLineSelectionDialogTest.cs) (revision 6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a) @@ -46,32 +46,41 @@ [Test] public void Constructor_WithoutSurfaceLines_ThrowsArgumentNullException() { - // Call - TestDelegate test = () => new PipingSurfaceLineSelectionDialog(new Form(), null); + // Setup + using (var viewParent = new Form()) + { + // Call + TestDelegate test = () => new PipingSurfaceLineSelectionDialog(viewParent, null); - // Assert - string parameter = Assert.Throws(test).ParamName; - Assert.AreEqual("surfaceLines", parameter); + // Assert + string parameter = Assert.Throws(test).ParamName; + Assert.AreEqual("surfaceLines", parameter); + } } [Test] public void Constructor_WithParentAndSurfaceLines_DefaultProperties() { - // Call - using (var dialog = new PipingSurfaceLineSelectionDialog(new Form(), Enumerable.Empty())) + // Setup + using (var viewParent = new Form()) { - // Assert - Assert.IsEmpty(dialog.SelectedSurfaceLines); - Assert.IsInstanceOf(new ControlTester("PipingSurfaceLineSelectionView", dialog).TheObject); - Assert.AreEqual("Selecteer profielschematisaties", dialog.Text); + // Call + using (var dialog = new PipingSurfaceLineSelectionDialog(viewParent, Enumerable.Empty())) + { + // Assert + Assert.IsEmpty(dialog.SelectedSurfaceLines); + Assert.IsInstanceOf(new ControlTester("PipingSurfaceLineSelectionView", dialog).TheObject); + Assert.AreEqual("Selecteer profielschematisaties", dialog.Text); + } } } [Test] public void OnLoad_Always_SetMinimumSize() { // Setup - using (var dialog = new PipingSurfaceLineSelectionDialog(new Form(), Enumerable.Empty())) + using (var viewParent = new Form()) + using (var dialog = new PipingSurfaceLineSelectionDialog(viewParent, Enumerable.Empty())) { // Call dialog.Show(); @@ -92,17 +101,20 @@ new RingtoetsPipingSurfaceLine() }; - var dialog = new PipingSurfaceLineSelectionDialog(new Form(), surfaceLines); - var selectionView = (DataGridView) new ControlTester("SurfaceLineDataGrid", dialog).TheObject; + using (var viewParent = new Form()) + using (var dialog = new PipingSurfaceLineSelectionDialog(viewParent, surfaceLines)) + { + var selectionView = (DataGridView) new ControlTester("SurfaceLineDataGrid", dialog).TheObject; - dialog.Show(); - selectionView.Rows[0].Cells[0].Value = true; + dialog.Show(); + selectionView.Rows[0].Cells[0].Value = true; - // When - dialog.Close(); + // When + dialog.Close(); - // Then - Assert.IsEmpty(dialog.SelectedSurfaceLines); + // Then + Assert.IsEmpty(dialog.SelectedSurfaceLines); + } } [Test] @@ -116,18 +128,21 @@ new RingtoetsPipingSurfaceLine() }; - var dialog = new PipingSurfaceLineSelectionDialog(new Form(), surfaceLines); - var selectionView = (DataGridView) new ControlTester("SurfaceLineDataGrid", dialog).TheObject; + using (var viewParent = new Form()) + using (var dialog = new PipingSurfaceLineSelectionDialog(viewParent, surfaceLines)) + { + var selectionView = (DataGridView) new ControlTester("SurfaceLineDataGrid", dialog).TheObject; - dialog.Show(); - selectionView.Rows[0].Cells[0].Value = true; + dialog.Show(); + selectionView.Rows[0].Cells[0].Value = true; - // When - var cancelButton = new ButtonTester("CustomCancelButton", dialog); - cancelButton.Click(); + // When + var cancelButton = new ButtonTester("CustomCancelButton", dialog); + cancelButton.Click(); - // Then - Assert.IsEmpty(dialog.SelectedSurfaceLines); + // Then + Assert.IsEmpty(dialog.SelectedSurfaceLines); + } } [Test] @@ -141,22 +156,26 @@ new RingtoetsPipingSurfaceLine() }; - var dialog = new PipingSurfaceLineSelectionDialog(new Form(), surfaceLines); - var selectionView = (DataGridView) new ControlTester("SurfaceLineDataGrid", dialog).TheObject; + using (var viewParent = new Form()) + using (var dialog = new PipingSurfaceLineSelectionDialog(viewParent, surfaceLines)) + { + var selectionView = (DataGridView) new ControlTester("SurfaceLineDataGrid", dialog).TheObject; - dialog.Show(); - selectionView.Rows[0].Cells[0].Value = true; + dialog.Show(); + selectionView.Rows[0].Cells[0].Value = true; - // When - var okButton = new ButtonTester("OkButton", dialog); - okButton.Click(); + // When + var okButton = new ButtonTester("OkButton", dialog); + okButton.Click(); - // Then - var result = dialog.SelectedSurfaceLines; - CollectionAssert.AreEqual(new[] - { - selectedSurfaceLine - }, result); + // Then + var result = dialog.SelectedSurfaceLines; + + CollectionAssert.AreEqual(new[] + { + selectedSurfaceLine + }, result); + } } } } \ No newline at end of file