Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog.Designer.cs
===================================================================
diff -u -rd4f6782b27a8e239562812f1482c1e8cb4843e64 -r0f0d4ea78f79ab702bc3c28c78e83daa02c320b1
--- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog.Designer.cs (.../StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog.Designer.cs) (revision d4f6782b27a8e239562812f1482c1e8cb4843e64)
+++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog.Designer.cs (.../StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog.Designer.cs) (revision 0f0d4ea78f79ab702bc3c28c78e83daa02c320b1)
@@ -23,24 +23,6 @@
{
partial class StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog
{
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
#region Windows Form Designer generated code
///
@@ -50,99 +32,22 @@
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog));
- this.dataGridViewControl = new Core.Common.Controls.DataGrid.DataGridViewControl();
- this.ButtonGroupBox = new System.Windows.Forms.GroupBox();
- this.panel2 = new System.Windows.Forms.Panel();
- this.SelectAllButton = new System.Windows.Forms.Button();
- this.DeselectAllButton = new System.Windows.Forms.Button();
- this.GenerateForSelectedButton = new System.Windows.Forms.Button();
- this.CustomCancelButton = new System.Windows.Forms.Button();
- this.panel1 = new System.Windows.Forms.Panel();
- this.ButtonGroupBox.SuspendLayout();
- this.panel2.SuspendLayout();
- this.panel1.SuspendLayout();
this.SuspendLayout();
//
// dataGridViewControl
//
- resources.ApplyResources(this.dataGridViewControl, "dataGridViewControl");
- this.dataGridViewControl.MultiSelect = true;
- this.dataGridViewControl.Name = "dataGridViewControl";
- this.dataGridViewControl.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.RowHeaderSelect;
+ resources.ApplyResources(this.DataGridViewControl, "dataGridViewControl");
//
- // ButtonGroupBox
- //
- this.ButtonGroupBox.Controls.Add(this.dataGridViewControl);
- this.ButtonGroupBox.Controls.Add(this.panel2);
- resources.ApplyResources(this.ButtonGroupBox, "ButtonGroupBox");
- this.ButtonGroupBox.Name = "ButtonGroupBox";
- this.ButtonGroupBox.TabStop = false;
- //
- // panel2
- //
- this.panel2.Controls.Add(this.SelectAllButton);
- this.panel2.Controls.Add(this.DeselectAllButton);
- resources.ApplyResources(this.panel2, "panel2");
- this.panel2.Name = "panel2";
- //
- // SelectAllButton
- //
- resources.ApplyResources(this.SelectAllButton, "SelectAllButton");
- this.SelectAllButton.Name = "SelectAllButton";
- this.SelectAllButton.UseVisualStyleBackColor = true;
- this.SelectAllButton.Click += new System.EventHandler(this.SelectAllButton_Click);
- //
- // DeselectAllButton
- //
- resources.ApplyResources(this.DeselectAllButton, "DeselectAllButton");
- this.DeselectAllButton.Name = "DeselectAllButton";
- this.DeselectAllButton.UseVisualStyleBackColor = true;
- this.DeselectAllButton.Click += new System.EventHandler(this.DeselectAllButton_Click);
- //
- // GenerateForSelectedButton
- //
- resources.ApplyResources(this.GenerateForSelectedButton, "GenerateForSelectedButton");
- this.GenerateForSelectedButton.Name = "GenerateForSelectedButton";
- this.GenerateForSelectedButton.UseVisualStyleBackColor = true;
- this.GenerateForSelectedButton.Click += new System.EventHandler(this.GenerateForSelectedButton_Click);
- //
- // CustomCancelButton
- //
- resources.ApplyResources(this.CustomCancelButton, "CustomCancelButton");
- this.CustomCancelButton.Name = "CustomCancelButton";
- this.CustomCancelButton.UseVisualStyleBackColor = true;
- this.CustomCancelButton.Click += new System.EventHandler(this.CancelButton_Click);
- //
- // panel1
- //
- this.panel1.Controls.Add(this.GenerateForSelectedButton);
- this.panel1.Controls.Add(this.CustomCancelButton);
- resources.ApplyResources(this.panel1, "panel1");
- this.panel1.Name = "panel1";
- //
// StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog
//
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.Controls.Add(this.ButtonGroupBox);
- this.Controls.Add(this.panel1);
+ this.CancelButton = this.CustomCancelButton;
this.Name = "StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog";
- this.ButtonGroupBox.ResumeLayout(false);
- this.panel2.ResumeLayout(false);
- this.panel1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
-
- private Core.Common.Controls.DataGrid.DataGridViewControl dataGridViewControl;
- private System.Windows.Forms.GroupBox ButtonGroupBox;
- private System.Windows.Forms.Button GenerateForSelectedButton;
- private System.Windows.Forms.Button DeselectAllButton;
- private System.Windows.Forms.Button CustomCancelButton;
- private System.Windows.Forms.Button SelectAllButton;
- private System.Windows.Forms.Panel panel1;
- private System.Windows.Forms.Panel panel2;
}
}
\ No newline at end of file
Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog.cs
===================================================================
diff -u -rd4f6782b27a8e239562812f1482c1e8cb4843e64 -r0f0d4ea78f79ab702bc3c28c78e83daa02c320b1
--- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog.cs (.../StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog.cs) (revision d4f6782b27a8e239562812f1482c1e8cb4843e64)
+++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog.cs (.../StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog.cs) (revision 0f0d4ea78f79ab702bc3c28c78e83daa02c320b1)
@@ -26,6 +26,8 @@
using Core.Common.Controls.Dialogs;
using Core.Common.Utils.Extensions;
using Core.Common.Utils.Reflection;
+using Ringtoets.Common.Forms;
+using Ringtoets.Common.Forms.Views;
using Ringtoets.HydraRing.Data;
using Ringtoets.StabilityStoneCover.Forms.Properties;
using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
@@ -36,136 +38,26 @@
/// A dialog which allows the user to make a selection form a given set of . Upon
/// closing of the dialog, the selected can be obtained.
///
- public partial class StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog : DialogBase
+ public partial class StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog : SelectionDialogBase
{
- private const int locationCalculateColumnIndex = 0;
-
///
/// Creates a new instance of .
///
/// The parent of the dialog.
/// The collection of to show in the dialog.
public StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog(IWin32Window dialogParent,
IEnumerable hydraulicBoundaryLocations)
- : base(dialogParent, RingtoetsCommonFormsResources.GenerateScenariosIcon, 370, 550)
+ : base(dialogParent)
{
if (hydraulicBoundaryLocations == null)
{
throw new ArgumentNullException("hydraulicBoundaryLocations");
}
InitializeComponent();
- InitializeEventHandlers();
- InitializeDataGridView();
+ InitializeDataGridView(Resources.StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog_Location_Name);
- SetDataSource(hydraulicBoundaryLocations);
- SelectedLocations = new List();
+ SetDataSource(hydraulicBoundaryLocations.Select(loc => new SelectableRow(loc, loc.Name)).ToArray());
}
-
- ///
- /// Gets a collection of selected if they were selected
- /// in the dialog and a confirmation was given. If no confirmation was given or no
- /// was selected an empty collection is returned.
- ///
- public IEnumerable SelectedLocations { get; private set; }
-
- protected override Button GetCancelButton()
- {
- return CustomCancelButton;
- }
-
- ///
- /// Gets the currently selected hydraulic boundary locations from the data grid view.
- ///
- /// A of
- /// which were selected in the view.
- private IEnumerable GetSelectedLocations()
- {
- return GetHydraulicBoundaryLocationContextRows().Where(row => row.Selected).Select(row => row.Location).ToArray();
- }
-
- private void SetDataSource(IEnumerable hydraulicBoundaryLocations)
- {
- dataGridViewControl.SetDataSource(hydraulicBoundaryLocations.Select(loc => new HydraulicBoundaryLocationContextRow(loc)).ToArray());
- }
-
- ///
- /// Initializes the .
- ///
- private void InitializeDataGridView()
- {
- dataGridViewControl.AddCheckBoxColumn(TypeUtils.GetMemberName(row => row.Selected),
- Resources.StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog_Select_Location);
- dataGridViewControl.AddTextBoxColumn(TypeUtils.GetMemberName(row => row.Name),
- Resources.StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog_Location_Name,
- false, DataGridViewAutoSizeColumnMode.Fill);
- }
-
- private IEnumerable GetHydraulicBoundaryLocationContextRows()
- {
- return dataGridViewControl.Rows.Cast().Select(row => (HydraulicBoundaryLocationContextRow) row.DataBoundItem);
- }
-
- private void UpdateGenerateForSelectedButton()
- {
- GenerateForSelectedButton.Enabled = GetHydraulicBoundaryLocationContextRows().Any(r => r.Selected);
- }
-
- private class HydraulicBoundaryLocationContextRow
- {
- public HydraulicBoundaryLocationContextRow(IHydraulicBoundaryLocation location)
- {
- Selected = false;
- Name = location.Name;
- Location = location;
- }
-
- public bool Selected { get; set; }
- public string Name { get; private set; }
- public IHydraulicBoundaryLocation Location { get; private set; }
- }
-
- #region Event handling
-
- private void SelectAllButton_Click(object sender, EventArgs e)
- {
- GetHydraulicBoundaryLocationContextRows().ForEachElementDo(row => row.Selected = true);
- dataGridViewControl.RefreshDataGridView();
- UpdateGenerateForSelectedButton();
- }
-
- private void DeselectAllButton_Click(object sender, EventArgs e)
- {
- GetHydraulicBoundaryLocationContextRows().ForEachElementDo(row => row.Selected = false);
- dataGridViewControl.RefreshDataGridView();
- UpdateGenerateForSelectedButton();
- }
-
- private void InitializeEventHandlers()
- {
- dataGridViewControl.AddCellValueChangedHandler(DataGridViewCellValueChanged);
- }
-
- private void DataGridViewCellValueChanged(object sender, DataGridViewCellEventArgs e)
- {
- if (e.ColumnIndex != locationCalculateColumnIndex)
- {
- return;
- }
- UpdateGenerateForSelectedButton();
- }
-
- private void GenerateForSelectedButton_Click(object sender, EventArgs e)
- {
- SelectedLocations = GetSelectedLocations();
- Close();
- }
-
- private void CancelButton_Click(object sender, EventArgs e)
- {
- Close();
- }
-
- #endregion
}
}
\ No newline at end of file
Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog.resx
===================================================================
diff -u -rd4f6782b27a8e239562812f1482c1e8cb4843e64 -r0f0d4ea78f79ab702bc3c28c78e83daa02c320b1
--- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog.resx (.../StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog.resx) (revision d4f6782b27a8e239562812f1482c1e8cb4843e64)
+++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog.resx (.../StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog.resx) (revision 0f0d4ea78f79ab702bc3c28c78e83daa02c320b1)
@@ -159,21 +159,6 @@
5
-
- Selecteer alles
-
-
- SelectAllButton
-
-
- System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- panel2
-
-
- 0
-
NoControl
@@ -186,21 +171,6 @@
4
-
- Deselecteer alles
-
-
- DeselectAllButton
-
-
- System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- panel2
-
-
- 1
-
Bottom
@@ -213,18 +183,6 @@
6
-
- panel2
-
-
- System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- ButtonGroupBox
-
-
- 1
-
Fill
@@ -237,18 +195,6 @@
1
-
- ButtonGroupBox
-
-
- System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- $this
-
-
- 0
-
Top, Right
@@ -267,21 +213,6 @@
3
-
- Genereren
-
-
- GenerateForSelectedButton
-
-
- System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- panel1
-
-
- 0
-
Top, Right
@@ -297,21 +228,6 @@
6
-
- Annuleren
-
-
- CustomCancelButton
-
-
- System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- panel1
-
-
- 1
-
Bottom
@@ -324,21 +240,9 @@
6
-
- panel1
-
-
- System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- $this
-
-
- 1
-
-
+
True
-
+
6, 13
@@ -358,6 +262,6 @@
StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog
- Core.Common.Controls.Dialogs.DialogBase, Core.Common.Controls, Version=16.2.1.5098, Culture=neutral, PublicKeyToken=null
+ Ringtoets.Common.Forms.SelectionDialogBase, Ringtoets.Common.Forms, Version=16.2.1.5236, Culture=neutral, PublicKeyToken=null
\ No newline at end of file
Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Plugin/StabilityStoneCoverPlugin.cs
===================================================================
diff -u -r9bb8d5dab740264ba9f3e50181e310ee2c9525f8 -r0f0d4ea78f79ab702bc3c28c78e83daa02c320b1
--- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Plugin/StabilityStoneCoverPlugin.cs (.../StabilityStoneCoverPlugin.cs) (revision 9bb8d5dab740264ba9f3e50181e310ee2c9525f8)
+++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Plugin/StabilityStoneCoverPlugin.cs (.../StabilityStoneCoverPlugin.cs) (revision 0f0d4ea78f79ab702bc3c28c78e83daa02c320b1)
@@ -412,9 +412,9 @@
nodeData.AssessmentSection.HydraulicBoundaryDatabase.Locations))
{
dialog.ShowDialog();
- GenerateStabilityStoneCoverCalculations(nodeData.WrappedData, dialog.SelectedLocations);
+ GenerateStabilityStoneCoverCalculations(nodeData.WrappedData, dialog.SelectedItems);
- if (dialog.SelectedLocations.Any())
+ if (dialog.SelectedItems.Any())
{
nodeData.NotifyObservers();
}
Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/StabilityStoneCoverHydraulicBoundaryLocationSelectionDialogTest.cs
===================================================================
diff -u -rd4f6782b27a8e239562812f1482c1e8cb4843e64 -r0f0d4ea78f79ab702bc3c28c78e83daa02c320b1
--- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/StabilityStoneCoverHydraulicBoundaryLocationSelectionDialogTest.cs (.../StabilityStoneCoverHydraulicBoundaryLocationSelectionDialogTest.cs) (revision d4f6782b27a8e239562812f1482c1e8cb4843e64)
+++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/StabilityStoneCoverHydraulicBoundaryLocationSelectionDialogTest.cs (.../StabilityStoneCoverHydraulicBoundaryLocationSelectionDialogTest.cs) (revision 0f0d4ea78f79ab702bc3c28c78e83daa02c320b1)
@@ -23,9 +23,10 @@
using System.Linq;
using System.Windows.Forms;
using Core.Common.Controls.DataGrid;
-using Core.Common.Controls.Dialogs;
using NUnit.Extensions.Forms;
using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Forms;
using Ringtoets.HydraRing.Data;
using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
@@ -36,7 +37,7 @@
{
private const int locationSelectionColumnIndex = 0;
private const int locationColumnIndex = 1;
-
+
[Test]
public void Constructor_WithoutParent_ThrowsArgumentNullException()
{
@@ -73,260 +74,71 @@
using (var dialog = new StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog(viewParent, Enumerable.Empty()))
{
// Assert
- Assert.IsInstanceOf(dialog);
- Assert.IsEmpty(dialog.SelectedLocations);
+ Assert.IsInstanceOf>(dialog);
+ Assert.IsEmpty(dialog.SelectedItems);
Assert.AreEqual("Selecteer hydraulische randvoorwaardenlocaties", dialog.Text);
-
- var dataGridViewControl = (DataGridViewControl) new ControlTester("dataGridViewControl", dialog).TheObject;
- var dataGridView = dataGridViewControl.Controls.OfType().First();
- Assert.AreEqual(2, dataGridView.ColumnCount);
-
- var locationCalculateColumn = (DataGridViewCheckBoxColumn) dataGridView.Columns[locationSelectionColumnIndex];
- const string expectedLocationCalculateHeaderText = "Gebruik";
- Assert.AreEqual(expectedLocationCalculateHeaderText, locationCalculateColumn.HeaderText);
- Assert.AreEqual("Selected", locationCalculateColumn.DataPropertyName);
- Assert.IsFalse(locationCalculateColumn.ReadOnly);
-
- var locationColumn = (DataGridViewTextBoxColumn) dataGridView.Columns[locationColumnIndex];
- const string expectedLocationHeaderText = "Hydraulische randvoorwaardenlocatie";
- Assert.AreEqual(expectedLocationHeaderText, locationColumn.HeaderText);
- Assert.AreEqual("Name", locationColumn.DataPropertyName);
- Assert.AreEqual(DataGridViewAutoSizeColumnMode.Fill, locationColumn.AutoSizeMode);
- Assert.IsTrue(locationColumn.ReadOnly);
-
- var buttonTester = new ButtonTester("GenerateForSelectedButton", dialog);
- var button = (Button) buttonTester.TheObject;
- Assert.IsFalse(button.Enabled);
}
}
}
[Test]
- public void OnLoad_Always_SetMinimumSize()
+ public void Constructor_DataGridViewCorrectlyInitialized()
{
- // Setup
+ // Setup & Call
using (var viewParent = new Form())
using (var dialog = new StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog(viewParent, Enumerable.Empty()))
{
- // Call
dialog.Show();
// Assert
- Assert.AreEqual(370, dialog.MinimumSize.Width);
- Assert.AreEqual(550, dialog.MinimumSize.Height);
- }
- }
+ Assert.IsEmpty(dialog.SelectedItems);
- [Test]
- public void GivenDialogWithSelectedLocations_WhenCloseWithoutConfirmation_ThenReturnsEmptyCollection()
- {
- // Given
- var locations = new[]
- {
- new HydraulicBoundaryLocation(1, "1", 1, 1),
- new HydraulicBoundaryLocation(2, "2", 2, 2)
- };
+ var dataGridViewControl = (DataGridViewControl)new ControlTester("DataGridViewControl", dialog).TheObject;
+ var dataGridView = dataGridViewControl.Controls.OfType().First();
+ Assert.AreEqual(2, dataGridView.ColumnCount);
- using (var viewParent = new Form())
- using (var dialog = new StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog(viewParent, locations))
- {
- var selectionView = (DataGridViewControl) new ControlTester("dataGridViewControl", dialog).TheObject;
+ var locationCalculateColumn = (DataGridViewCheckBoxColumn)dataGridView.Columns[locationSelectionColumnIndex];
+ const string expectedLocationCalculateHeaderText = "Gebruik";
+ Assert.AreEqual(expectedLocationCalculateHeaderText, locationCalculateColumn.HeaderText);
+ Assert.AreEqual("Selected", locationCalculateColumn.DataPropertyName);
+ Assert.IsFalse(locationCalculateColumn.ReadOnly);
- dialog.Show();
- selectionView.Rows[0].Cells[0].Value = true;
-
- // When
- dialog.Close();
-
- // Then
- Assert.IsEmpty(dialog.SelectedLocations);
+ var nameColumn = (DataGridViewTextBoxColumn)dataGridView.Columns[locationColumnIndex];
+ const string expectedNameHeaderText = "Hydraulische randvoorwaardenlocatie";
+ Assert.AreEqual(expectedNameHeaderText, nameColumn.HeaderText);
+ Assert.AreEqual("Name", nameColumn.DataPropertyName);
+ Assert.AreEqual(DataGridViewAutoSizeColumnMode.Fill, nameColumn.AutoSizeMode);
+ Assert.IsTrue(nameColumn.ReadOnly);
}
}
[Test]
- public void GivenDialogWithSelectedLocations_WhenCancelButtonClicked_ThenReturnsSelectedCollection()
+ public void Constructor_HydraulicBoundaryLocationOneEntry_OneRowInGrid()
{
- // Given
- var selectedLocation = new HydraulicBoundaryLocation(1, "1", 1, 1);
- var locations = new[]
- {
- selectedLocation,
- new HydraulicBoundaryLocation(2, "2", 2, 2)
- };
-
- using (var viewParent = new Form())
- {
- using (var dialog = new StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog(viewParent, locations))
- {
- var selectionView = (DataGridViewControl) new ControlTester("dataGridViewControl", dialog).TheObject;
-
- dialog.Show();
- selectionView.Rows[0].Cells[0].Value = true;
-
- // When
- var cancelButton = new ButtonTester("CustomCancelButton", dialog);
- cancelButton.Click();
-
- // Then
- Assert.IsEmpty(dialog.SelectedLocations);
- }
- }
- }
-
- [Test]
- public void GivenDialogWithSelectedLocations_WhenGenerateButtonClicked_ThenReturnsSelectedCollection()
- {
- // Given
- var selectedLocation = new HydraulicBoundaryLocation(1, "1", 1, 1);
- var locations = new[]
- {
- selectedLocation,
- new HydraulicBoundaryLocation(2, "2", 2, 2)
- };
-
- using (var viewParent = new Form())
- using (var dialog = new StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog(viewParent, locations))
- {
- var selectionView = (DataGridViewControl) new ControlTester("dataGridViewControl", dialog).TheObject;
-
- dialog.Show();
- selectionView.Rows[0].Cells[0].Value = true;
-
- // When
- var generateButton = new ButtonTester("GenerateForSelectedButton", dialog);
- generateButton.Click();
-
- // Then
- var result = dialog.SelectedLocations;
-
- CollectionAssert.AreEqual(new[]
- {
- selectedLocation
- }, result);
- }
- }
-
- [Test]
- public void SelectAllButton_SelectAllButtonClicked_AllLocationsSelected()
- {
// Setup
- var locations = new[]
- {
- new HydraulicBoundaryLocation(1, "1", 1, 1),
- new HydraulicBoundaryLocation(2, "2", 2, 2)
- };
+ const string testname = "testName";
+
+ var mock = new MockRepository();
+ var hydraulicBoundaryLocationMock = mock.Stub();
+ hydraulicBoundaryLocationMock.Expect(h => h.Name).Return(testname);
+ mock.ReplayAll();
+ // Call
using (var viewParent = new Form())
- using (var dialog = new StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog(viewParent, locations))
+ using (var dialog = new StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog(viewParent, new[]
{
- dialog.Show();
-
- var dataGridView = (DataGridViewControl) new ControlTester("dataGridViewControl", dialog).TheObject;
- var rows = dataGridView.Rows;
- var button = new ButtonTester("SelectAllButton", dialog);
-
- // Precondition
- Assert.IsFalse((bool) rows[0].Cells[locationSelectionColumnIndex].Value);
- Assert.IsFalse((bool) rows[1].Cells[locationSelectionColumnIndex].Value);
-
- // Call
- button.Click();
-
- // Assert
- Assert.IsTrue((bool) rows[0].Cells[locationSelectionColumnIndex].Value);
- Assert.IsTrue((bool) rows[1].Cells[locationSelectionColumnIndex].Value);
- }
- }
-
- [Test]
- public void DeselectAllButton_AllLocationsSelectedDeselectAllButtonClicked_AllLocationsNotSelected()
- {
- // Setup
- var locations = new[]
+ hydraulicBoundaryLocationMock
+ }))
{
- new HydraulicBoundaryLocation(1, "1", 1, 1),
- new HydraulicBoundaryLocation(2, "2", 2, 2)
- };
-
- using (var viewParent = new Form())
- using (var dialog = new StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog(viewParent, locations))
- {
- dialog.Show();
-
- var dataGridView = (DataGridViewControl) new ControlTester("dataGridViewControl", dialog).TheObject;
- var rows = dataGridView.Rows;
- var button = new ButtonTester("DeselectAllButton", dialog);
-
- foreach (DataGridViewRow row in rows)
- {
- row.Cells[locationSelectionColumnIndex].Value = true;
- }
-
- // Precondition
- Assert.IsTrue((bool) rows[0].Cells[locationSelectionColumnIndex].Value);
- Assert.IsTrue((bool) rows[1].Cells[locationSelectionColumnIndex].Value);
-
- // Call
- button.Click();
-
// Assert
- Assert.IsFalse((bool) rows[0].Cells[locationSelectionColumnIndex].Value);
- Assert.IsFalse((bool) rows[1].Cells[locationSelectionColumnIndex].Value);
- }
- }
-
- [Test]
- public void GenerateForSelectedButton_NoneSelected_GenerateForSelectedButtonDisabled()
- {
- // Setup
- var locations = new[]
- {
- new HydraulicBoundaryLocation(1, "1", 1, 1),
- new HydraulicBoundaryLocation(2, "2", 2, 2)
- };
-
- using (var viewParent = new Form())
- using (var dialog = new StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog(viewParent, locations))
- {
dialog.Show();
- var buttonTester = new ButtonTester("GenerateForSelectedButton", dialog);
- // Call
- var button = (Button) buttonTester.TheObject;
-
- // Assert
- Assert.IsFalse(button.Enabled);
- Assert.IsEmpty(dialog.SelectedLocations);
+ var dataGridViewControl = (DataGridViewControl)new ControlTester("DataGridViewControl").TheObject;
+ Assert.AreEqual(1, dataGridViewControl.Rows.Count);
+ Assert.IsFalse((bool)dataGridViewControl.Rows[0].Cells[locationSelectionColumnIndex].Value);
+ Assert.AreEqual(testname, (string)dataGridViewControl.Rows[0].Cells[locationColumnIndex].Value);
}
+ mock.VerifyAll();
}
-
- [Test]
- public void GenerateForSelectedButton_OneSelected_ReturnsSelectedLocations()
- {
- // Setup
- var selectedLocation = new HydraulicBoundaryLocation(1, "1", 1, 1);
- var locations = new[]
- {
- selectedLocation,
- new HydraulicBoundaryLocation(2, "2", 2, 2)
- };
-
- using (var viewParent = new Form())
- using (var dialog = new StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog(viewParent, locations))
- {
- dialog.Show();
- var dataGridView = (DataGridViewControl) new ControlTester("dataGridViewControl", dialog).TheObject;
- var rows = dataGridView.Rows;
- rows[0].Cells[locationSelectionColumnIndex].Value = true;
- var buttonTester = new ButtonTester("GenerateForSelectedButton", dialog);
-
- // Call
- buttonTester.Click();
-
- // Assert
- Assert.AreEqual(1, dialog.SelectedLocations.Count());
- Assert.AreEqual(selectedLocation, dialog.SelectedLocations.First());
- }
- }
}
}
\ No newline at end of file
Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs
===================================================================
diff -u -rae04c23f970bb96e54adbfb8c2fe1aaf95d13326 -r0f0d4ea78f79ab702bc3c28c78e83daa02c320b1
--- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs (.../StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs) (revision ae04c23f970bb96e54adbfb8c2fe1aaf95d13326)
+++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs (.../StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs) (revision 0f0d4ea78f79ab702bc3c28c78e83daa02c320b1)
@@ -1314,7 +1314,7 @@
DialogBoxHandler = (name, wnd) =>
{
dialog = (StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog) new FormTester(name).TheObject;
- grid = (DataGridViewControl) new ControlTester("dataGridViewControl", dialog).TheObject;
+ grid = (DataGridViewControl) new ControlTester("DataGridViewControl", dialog).TheObject;
rowCount = grid.Rows.Count;
new ButtonTester("CustomCancelButton", dialog).Click();
};
@@ -1375,10 +1375,10 @@
DialogBoxHandler = (name, wnd) =>
{
dialog = (StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog) new FormTester(name).TheObject;
- grid = (DataGridViewControl) new ControlTester("dataGridViewControl", dialog).TheObject;
+ grid = (DataGridViewControl) new ControlTester("DataGridViewControl", dialog).TheObject;
grid.Rows[0].Cells[0].Value = true;
grid.Rows[1].Cells[0].Value = true;
- new ButtonTester("GenerateForSelectedButton", dialog).Click();
+ new ButtonTester("DoForSelectedButton", dialog).Click();
};
using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl))
@@ -1435,7 +1435,7 @@
DialogBoxHandler = (name, wnd) =>
{
dialog = (StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog) new FormTester(name).TheObject;
- grid = (DataGridViewControl) new ControlTester("dataGridViewControl", dialog).TheObject;
+ grid = (DataGridViewControl) new ControlTester("DataGridViewControl", dialog).TheObject;
grid.Rows[0].Cells[0].Value = true;
new ButtonTester("CustomCancelButton", dialog).Click();
};