Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.Designer.cs =================================================================== diff -u -r37213b379dafd60f815fce7cb7fd70e8b85d0ec5 -r1dc89167ccdfcc4069e7bceb1db90dba570daba9 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 37213b379dafd60f815fce7cb7fd70e8b85d0ec5) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 1dc89167ccdfcc4069e7bceb1db90dba570daba9) @@ -1467,6 +1467,15 @@ } /// + /// Looks up a localized string similar to Gebruik. + /// + public static string SelectionDialogBase_ColumnSelect_DisplayName { + get { + return ResourceManager.GetString("SelectionDialogBase_ColumnSelect_DisplayName", resourceCulture); + } + } + + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// public static System.Drawing.Bitmap SelectionDialogIcon { Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.resx =================================================================== diff -u -r37213b379dafd60f815fce7cb7fd70e8b85d0ec5 -r1dc89167ccdfcc4069e7bceb1db90dba570daba9 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.resx (.../Resources.resx) (revision 37213b379dafd60f815fce7cb7fd70e8b85d0ec5) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.resx (.../Resources.resx) (revision 1dc89167ccdfcc4069e7bceb1db90dba570daba9) @@ -598,4 +598,7 @@ Modelinstellingen + + Gebruik + \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj =================================================================== diff -u -r3e5a3e2990566fe86caaaa87136d0f57543a9666 -r1dc89167ccdfcc4069e7bceb1db90dba570daba9 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision 3e5a3e2990566fe86caaaa87136d0f57543a9666) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision 1dc89167ccdfcc4069e7bceb1db90dba570daba9) @@ -79,6 +79,12 @@ + + Form + + + SelectionDialogBase.cs + @@ -99,13 +105,17 @@ FailureMechanismResultView.cs + PublicResXFileCodeGenerator Resources.Designer.cs Designer + + SelectionDialogBase.cs + CommentView.cs Index: Ringtoets/Common/src/Ringtoets.Common.Forms/SelectionDialogBase.Designer.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.Forms/SelectionDialogBase.Designer.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/SelectionDialogBase.Designer.cs (revision 1dc89167ccdfcc4069e7bceb1db90dba570daba9) @@ -0,0 +1,170 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +namespace Ringtoets.Common.Forms +{ + partial class SelectionDialogBase + { + /// + /// Required designer variable. + /// + protected System.ComponentModel.IContainer components = null; + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + 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.DoForSelectedButton = 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 + // + this.DataGridViewControl.Dock = System.Windows.Forms.DockStyle.Fill; + this.DataGridViewControl.Location = new System.Drawing.Point(3, 16); + 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(261, 66); + this.DataGridViewControl.TabIndex = 0; + // + // ButtonGroupBox + // + this.ButtonGroupBox.Controls.Add(this.DataGridViewControl); + this.ButtonGroupBox.Controls.Add(this.panel2); + this.ButtonGroupBox.Dock = System.Windows.Forms.DockStyle.Fill; + this.ButtonGroupBox.Location = new System.Drawing.Point(0, 0); + this.ButtonGroupBox.Name = "ButtonGroupBox"; + this.ButtonGroupBox.Size = new System.Drawing.Size(267, 124); + this.ButtonGroupBox.TabIndex = 7; + this.ButtonGroupBox.TabStop = false; + // + // panel2 + // + this.panel2.Controls.Add(this.SelectAllButton); + this.panel2.Controls.Add(this.DeselectAllButton); + this.panel2.Dock = System.Windows.Forms.DockStyle.Bottom; + this.panel2.Location = new System.Drawing.Point(3, 82); + this.panel2.Name = "panel2"; + this.panel2.Size = new System.Drawing.Size(261, 39); + this.panel2.TabIndex = 6; + // + // SelectAllButton + // + this.SelectAllButton.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.SelectAllButton.Location = new System.Drawing.Point(9, 6); + this.SelectAllButton.Name = "SelectAllButton"; + this.SelectAllButton.Size = new System.Drawing.Size(111, 23); + this.SelectAllButton.TabIndex = 5; + this.SelectAllButton.Text = "Selecteer alles"; + this.SelectAllButton.UseVisualStyleBackColor = true; + this.SelectAllButton.Click += new System.EventHandler(this.SelectAllButton_Click); + // + // DeselectAllButton + // + this.DeselectAllButton.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.DeselectAllButton.Location = new System.Drawing.Point(126, 6); + this.DeselectAllButton.Name = "DeselectAllButton"; + this.DeselectAllButton.Size = new System.Drawing.Size(111, 23); + this.DeselectAllButton.TabIndex = 4; + this.DeselectAllButton.Text = "Deselecteer alles"; + this.DeselectAllButton.UseVisualStyleBackColor = true; + this.DeselectAllButton.Click += new System.EventHandler(this.DeselectAllButton_Click); + // + // DoForSelectedButton + // + this.DoForSelectedButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.DoForSelectedButton.Enabled = false; + this.DoForSelectedButton.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.DoForSelectedButton.Location = new System.Drawing.Point(80, 6); + this.DoForSelectedButton.Name = "DoForSelectedButton"; + this.DoForSelectedButton.Size = new System.Drawing.Size(86, 23); + this.DoForSelectedButton.TabIndex = 3; + this.DoForSelectedButton.Text = "Genereren"; + this.DoForSelectedButton.UseVisualStyleBackColor = true; + this.DoForSelectedButton.Click += new System.EventHandler(this.DoForSelectedButton_Click); + // + // CustomCancelButton + // + this.CustomCancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.CustomCancelButton.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.CustomCancelButton.Location = new System.Drawing.Point(172, 6); + this.CustomCancelButton.Name = "CustomCancelButton"; + this.CustomCancelButton.Size = new System.Drawing.Size(86, 23); + this.CustomCancelButton.TabIndex = 6; + this.CustomCancelButton.Text = "Annuleren"; + this.CustomCancelButton.UseVisualStyleBackColor = true; + this.CustomCancelButton.Click += new System.EventHandler(this.CustomCancelButton_Click); + // + // panel1 + // + this.panel1.Controls.Add(this.DoForSelectedButton); + this.panel1.Controls.Add(this.CustomCancelButton); + this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom; + this.panel1.Location = new System.Drawing.Point(0, 124); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(267, 35); + this.panel1.TabIndex = 8; + // + // SelectionDialogBase + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.AutoScroll = true; + this.AutoScrollMinSize = new System.Drawing.Size(240, 90); + this.ClientSize = new System.Drawing.Size(267, 159); + this.Controls.Add(this.ButtonGroupBox); + this.Controls.Add(this.panel1); + this.Name = "SelectionDialogBase"; + this.Text = "SelectionDialogBase"; + this.ButtonGroupBox.ResumeLayout(false); + this.panel2.ResumeLayout(false); + this.panel1.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + protected Core.Common.Controls.DataGrid.DataGridViewControl DataGridViewControl; + private System.Windows.Forms.GroupBox ButtonGroupBox; + private System.Windows.Forms.Panel panel2; + private System.Windows.Forms.Button SelectAllButton; + private System.Windows.Forms.Button DeselectAllButton; + protected System.Windows.Forms.Button DoForSelectedButton; + protected System.Windows.Forms.Button CustomCancelButton; + private System.Windows.Forms.Panel panel1; + } +} \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Forms/SelectionDialogBase.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.Forms/SelectionDialogBase.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/SelectionDialogBase.cs (revision 1dc89167ccdfcc4069e7bceb1db90dba570daba9) @@ -0,0 +1,159 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Windows.Forms; +using Core.Common.Controls.Dialogs; +using Core.Common.Utils.Extensions; +using Core.Common.Utils.Reflection; +using Ringtoets.Common.Forms.Properties; +using Ringtoets.Common.Forms.Views; + +namespace Ringtoets.Common.Forms +{ + /// + /// Base class for selection dialogs which should be derived in order to get a consistent look and feel. + /// + public abstract partial class SelectionDialogBase : DialogBase where T : class + { + private const int selectItemColumnIndex = 0; + + /// + /// Creates a new instance of . + /// + /// The owner of the dialog. + /// Thrown when is null. + protected SelectionDialogBase(IWin32Window dialogParent) : base(dialogParent, Resources.GenerateScenariosIcon, 370, 550) + { + InitializeComponent(); + InitializeEventHandlers(); + + SelectedItems = new List(); + } + + /// + /// 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, then an empty collection is returned. + /// + public IEnumerable SelectedItems { get; private set; } + + /// + /// Sets the datasource on the . + /// + protected void SetDataSource(object data) + { + DataGridViewControl.SetDataSource(data); + } + + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + protected override Button GetCancelButton() + { + return CustomCancelButton; + } + + private void SetSelectedItems() + { + SelectedItems = GetSelectedItems(); + } + + private IEnumerable> GetSelectableRow() + { + return DataGridViewControl.Rows.Cast().Select(row => row.DataBoundItem).Cast>(); + } + + private IEnumerable GetSelectedItems() + { + return GetSelectableRow().Where(row => row.Selected).Select(row => row.Item).ToArray(); + } + + /// + /// Initializes the . + /// + protected void InitializeDataGridView(string nameColumnHeader) + { + DataGridViewControl.AddCheckBoxColumn(TypeUtils.GetMemberName>(row => row.Selected), + Resources.SelectionDialogBase_ColumnSelect_DisplayName); + DataGridViewControl.AddTextBoxColumn(TypeUtils.GetMemberName>(row => row.Name), + nameColumnHeader, true, DataGridViewAutoSizeColumnMode.Fill); + + } + + #region Event handling + + private void SelectAllButton_Click(object sender, EventArgs e) + { + GetSelectableRow().ForEachElementDo(row => row.Selected = true); + DataGridViewControl.RefreshDataGridView(); + UpdateDoForSelectedButton(); + } + + private void DeselectAllButton_Click(object sender, EventArgs e) + { + GetSelectableRow().ForEachElementDo(row => row.Selected = false); + DataGridViewControl.RefreshDataGridView(); + UpdateDoForSelectedButton(); + } + + private void InitializeEventHandlers() + { + DataGridViewControl.AddCellValueChangedHandler(DataGridViewCellValueChanged); + } + + private void DataGridViewCellValueChanged(object sender, DataGridViewCellEventArgs e) + { + if (e.ColumnIndex != selectItemColumnIndex) + { + return; + } + UpdateDoForSelectedButton(); + } + + private void DoForSelectedButton_Click(object sender, EventArgs e) + { + SetSelectedItems(); + Close(); + } + + private void CustomCancelButton_Click(object sender, EventArgs e) + { + Close(); + } + + private void UpdateDoForSelectedButton() + { + DoForSelectedButton.Enabled = GetSelectableRow().Any(row => row.Selected); + } + + #endregion + } +} \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Forms/SelectionDialogBase.resx =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.Forms/SelectionDialogBase.resx (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/SelectionDialogBase.resx (revision 1dc89167ccdfcc4069e7bceb1db90dba570daba9) @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/SelectableRow.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/SelectableRow.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/SelectableRow.cs (revision 1dc89167ccdfcc4069e7bceb1db90dba570daba9) @@ -0,0 +1,66 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; + +namespace Ringtoets.Common.Forms.Views +{ + /// + /// This class represents a row of that can be selected. + /// + public class SelectableRow + { + /// + /// Creates a new instance of . + /// + /// The this row contains. + /// The name representation of . + /// Thrown when any input parameter is null. + public SelectableRow(T item, string name) + { + if (item == null) + { + throw new ArgumentNullException("item"); + } + if (name == null) + { + throw new ArgumentNullException("name"); + } + Name = name; + Item = item; + } + + /// + /// Gets or sets whether the is selected. + /// + public bool Selected { get; set; } + + /// + /// Gets the name of the . + /// + public string Name { get; private set; } + + /// + /// Gets the item. + /// + public T Item { get; private set; } + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj =================================================================== diff -u -r06b2840a2bb64c0960c8ac29322b5a0971c73c77 -r1dc89167ccdfcc4069e7bceb1db90dba570daba9 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision 06b2840a2bb64c0960c8ac29322b5a0971c73c77) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision 1dc89167ccdfcc4069e7bceb1db90dba570daba9) @@ -84,6 +84,7 @@ + @@ -96,6 +97,7 @@ + Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/SelectionDialogBaseTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/SelectionDialogBaseTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/SelectionDialogBaseTest.cs (revision 1dc89167ccdfcc4069e7bceb1db90dba570daba9) @@ -0,0 +1,351 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.Generic; +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 Ringtoets.Common.Forms.Views; + +namespace Ringtoets.Common.Forms.Test +{ + [TestFixture] + public class SelectionDialogBaseTest + { + private const int selectItemColumnIndex = 0; + private const int nameColumnIndex = 1; + private Form testForm; + + [SetUp] + public void Setup() + { + testForm = new Form(); + } + + [TearDown] + public void TearDown() + { + testForm.Dispose(); + } + + [Test] + public void DefaultConstructor_DefaultValues() + { + // Call + using (var dialog = new TestSelectionDialogBase(testForm)) + { + // Assert + Assert.IsInstanceOf(dialog); + } + } + + [Test] + public void Constructor_DialogParentIsNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new TestSelectionDialogBase(null); + + // Assert + var paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("dialogParent", paramName); + } + + [Test] + public void Constructor_DataGridViewCorrectlyInitialized() + { + // Setup & Call + using (var dialog = new TestFullyConfiguredSelectionDialogBase(testForm)) + { + dialog.Show(); + + // Assert + Assert.IsEmpty(dialog.SelectedItems); + + var dataGridViewControl = (DataGridViewControl)new ControlTester("DataGridViewControl", dialog).TheObject; + var dataGridView = dataGridViewControl.Controls.OfType().First(); + Assert.AreEqual(2, dataGridView.ColumnCount); + + var locationCalculateColumn = (DataGridViewCheckBoxColumn)dataGridView.Columns[selectItemColumnIndex]; + const string expectedLocationCalculateHeaderText = "Gebruik"; + Assert.AreEqual(expectedLocationCalculateHeaderText, locationCalculateColumn.HeaderText); + Assert.AreEqual("Selected", locationCalculateColumn.DataPropertyName); + Assert.IsFalse(locationCalculateColumn.ReadOnly); + + var nameColumn = (DataGridViewTextBoxColumn)dataGridView.Columns[nameColumnIndex]; + Assert.AreEqual(string.Empty, nameColumn.HeaderText); + Assert.AreEqual("Name", nameColumn.DataPropertyName); + Assert.AreEqual(DataGridViewAutoSizeColumnMode.Fill, nameColumn.AutoSizeMode); + Assert.IsTrue(nameColumn.ReadOnly); + + var buttonTester = new ButtonTester("DoForSelectedButton", dialog); + var button = (Button)buttonTester.TheObject; + Assert.IsFalse(button.Enabled); + } + } + + [Test] + public void Constructor_Always_SetMinimumSize() + { + // Setup + using (var dialog = new TestSelectionDialogBase(testForm)) + { + // Call + dialog.Show(); + + // Assert + Assert.AreEqual(370, dialog.MinimumSize.Width); + Assert.AreEqual(550, dialog.MinimumSize.Height); + } + } + + [Test] + public void GivenDialogWithSelectedItems_WhenCloseWithoutConfirmation_ThenReturnsEmptyCollection() + { + // Given + var items = new[] + { + new object(), + new object() + }; + + using (var dialog = new TestFullyConfiguredSelectionDialogBase(testForm)) + { + var selectionView = (DataGridViewControl)new ControlTester("DataGridViewControl", dialog).TheObject; + dialog.SetDataSource(items); + + dialog.Show(); + selectionView.Rows[0].Cells[0].Value = true; + + // When + dialog.Close(); + + // Then + Assert.IsEmpty(dialog.SelectedItems); + } + } + + [Test] + public void GivenDialogWithSelectedItems_WhenCancelButtonClicked_ThenReturnsSelectedCollection() + { + // Given + var selectedItem = new object(); + var items = new[] + { + selectedItem, + new object() + }; + + using (var dialog = new TestFullyConfiguredSelectionDialogBase(testForm)) + { + var selectionView = (DataGridViewControl)new ControlTester("DataGridViewControl", dialog).TheObject; + dialog.SetDataSource(items); + + dialog.Show(); + selectionView.Rows[0].Cells[0].Value = true; + + // When + var cancelButton = new ButtonTester("CustomCancelButton", dialog); + cancelButton.Click(); + + // Then + Assert.IsEmpty(dialog.SelectedItems); + } + } + + [Test] + public void GivenDialogWithSelectedItems_WhenDoForSelectedButton_ThenReturnsSelectedCollection() + { + // Given + var selectedItem = new object(); + var items = new[] + { + selectedItem, + new object() + }; + + using (var dialog = new TestFullyConfiguredSelectionDialogBase(testForm)) + { + var selectionView = (DataGridViewControl)new ControlTester("DataGridViewControl", dialog).TheObject; + dialog.SetDataSource(items); + + dialog.Show(); + selectionView.Rows[0].Cells[0].Value = true; + + // When + var generateButton = new ButtonTester("DoForSelectedButton", dialog); + generateButton.Click(); + + // Then + var result = dialog.SelectedItems; + + CollectionAssert.AreEqual(new[] + { + selectedItem + }, result); + } + } + + [Test] + public void SelectAllButton_SelectAllButtonClicked_AllItemsSelected() + { + // Setup + var items = new[] + { + new object(), + new object() + }; + + using (var dialog = new TestFullyConfiguredSelectionDialogBase(testForm)) + { + dialog.SetDataSource(items); + 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[selectItemColumnIndex].Value); + Assert.IsFalse((bool)rows[1].Cells[selectItemColumnIndex].Value); + + // Call + button.Click(); + + // Assert + Assert.IsTrue((bool)rows[0].Cells[selectItemColumnIndex].Value); + Assert.IsTrue((bool)rows[1].Cells[selectItemColumnIndex].Value); + } + } + + [Test] + public void DeselectAllButton_AllItemsSelectedDeselectAllButtonClicked_AllItemsNotSelected() + { + // Setup + var items = new[] + { + new object(), + new object() + }; + + using (var dialog = new TestFullyConfiguredSelectionDialogBase(testForm)) + { + dialog.SetDataSource(items); + 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[selectItemColumnIndex].Value = true; + } + + // Precondition + Assert.IsTrue((bool)rows[0].Cells[selectItemColumnIndex].Value); + Assert.IsTrue((bool)rows[1].Cells[selectItemColumnIndex].Value); + + // Call + button.Click(); + + // Assert + Assert.IsFalse((bool)rows[0].Cells[selectItemColumnIndex].Value); + Assert.IsFalse((bool)rows[1].Cells[selectItemColumnIndex].Value); + } + } + + [Test] + public void DoForSelectedButton_NoneSelected_DoForSelectedButtonDisabled() + { + // Setup + var items = new[] + { + new object(), + new object() + }; + + using (var dialog = new TestFullyConfiguredSelectionDialogBase(testForm)) + { + dialog.SetDataSource(items); + dialog.Show(); + var buttonTester = new ButtonTester("DoForSelectedButton", dialog); + + // Call + var button = (Button)buttonTester.TheObject; + + // Assert + Assert.IsFalse(button.Enabled); + Assert.IsEmpty(dialog.SelectedItems); + } + } + + [Test] + public void DoForSelectedButton_OneSelected_ReturnsSelectedItems() + { + // Setup + var selectedItem = new object(); + var items = new[] + { + selectedItem, + new object() + }; + + using (var dialog = new TestFullyConfiguredSelectionDialogBase(testForm)) + { + dialog.SetDataSource(items); + dialog.Show(); + var dataGridView = (DataGridViewControl)new ControlTester("DataGridViewControl", dialog).TheObject; + var rows = dataGridView.Rows; + rows[0].Cells[selectItemColumnIndex].Value = true; + var buttonTester = new ButtonTester("DoForSelectedButton", dialog); + + // Call + buttonTester.Click(); + + // Assert + Assert.AreEqual(1, dialog.SelectedItems.Count()); + Assert.AreEqual(selectedItem, dialog.SelectedItems.First()); + } + } + + private class TestSelectionDialogBase : SelectionDialogBase + { + public TestSelectionDialogBase(IWin32Window dialogParent) : base(dialogParent) {} + } + + private class TestFullyConfiguredSelectionDialogBase : SelectionDialogBase + { + public TestFullyConfiguredSelectionDialogBase(IWin32Window dialogParent) : base(dialogParent) + { + InitializeDataGridView(""); + } + + public void SetDataSource(IEnumerable items) + { + base.SetDataSource(items.Select(o => new SelectableRow(o, o.ToString())).ToArray()); + } + } + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/SelectableRowTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/SelectableRowTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/SelectableRowTest.cs (revision 1dc89167ccdfcc4069e7bceb1db90dba570daba9) @@ -0,0 +1,72 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using NUnit.Framework; +using Ringtoets.Common.Forms.Views; + +namespace Ringtoets.Common.Forms.Test.Views +{ + [TestFixture] + public class SelectableRowTest + { + [Test] + public void Constructor_WithoutItem_ThrowsArgumentNullException() + { + // Setup + const string name = "name"; + + // Call + TestDelegate test = () => new SelectableRow(null, name); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("item", paramName); + } + + [Test] + public void Constructor_WithoutName_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new SelectableRow(new object(), null); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("name", paramName); + } + + [Test] + public void Constructor_ValidParameters_SetPropertyAsExpected() + { + // Setup + const string name = "name"; + var item = new object(); + + // Call + var row = new SelectableRow(item, name); + + // Assert + Assert.IsFalse(row.Selected); + Assert.AreEqual(name, row.Name); + Assert.AreSame(item, row.Item); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PipingSurfaceLineSelectionDialog.Designer.cs =================================================================== diff -u -rfea3ed82dfb6dfcad535eef16efcbaa9c01564ed -r1dc89167ccdfcc4069e7bceb1db90dba570daba9 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PipingSurfaceLineSelectionDialog.Designer.cs (.../PipingSurfaceLineSelectionDialog.Designer.cs) (revision fea3ed82dfb6dfcad535eef16efcbaa9c01564ed) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PipingSurfaceLineSelectionDialog.Designer.cs (.../PipingSurfaceLineSelectionDialog.Designer.cs) (revision 1dc89167ccdfcc4069e7bceb1db90dba570daba9) @@ -23,24 +23,6 @@ { partial class PipingSurfaceLineSelectionDialog { - /// - /// 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,48 +32,22 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PipingSurfaceLineSelectionDialog)); - this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); - this.OkButton = new System.Windows.Forms.Button(); - this.CustomCancelButton = new System.Windows.Forms.Button(); - this.flowLayoutPanel1.SuspendLayout(); this.SuspendLayout(); // - // flowLayoutPanel1 + // dataGridViewControl // - this.flowLayoutPanel1.Controls.Add(this.CustomCancelButton); - this.flowLayoutPanel1.Controls.Add(this.OkButton); - resources.ApplyResources(this.flowLayoutPanel1, "flowLayoutPanel1"); - this.flowLayoutPanel1.Name = "flowLayoutPanel1"; + resources.ApplyResources(this.DataGridViewControl, "DataGridViewControl"); // - // OkButton - // - resources.ApplyResources(this.OkButton, "OkButton"); - this.OkButton.Name = "OkButton"; - this.OkButton.UseVisualStyleBackColor = true; - this.OkButton.Click += new System.EventHandler(this.OkButtonOnClick); - // - // CancelButton - // - resources.ApplyResources(this.CustomCancelButton, "CustomCancelButton"); - this.CustomCancelButton.Name = "CustomCancelButton"; - this.CustomCancelButton.UseVisualStyleBackColor = true; - this.CustomCancelButton.Click += new System.EventHandler(this.CancelButtonOnClick); - // // PipingSurfaceLineSelectionDialog // resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.flowLayoutPanel1); + this.CancelButton = this.CustomCancelButton; this.Name = "PipingSurfaceLineSelectionDialog"; - this.flowLayoutPanel1.ResumeLayout(false); this.ResumeLayout(false); } #endregion - - private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; - private System.Windows.Forms.Button CustomCancelButton; - private System.Windows.Forms.Button OkButton; } } \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PipingSurfaceLineSelectionDialog.cs =================================================================== diff -u -r9a196c8bc554a2e97ff094d7ffb2e99c42eb04fd -r1dc89167ccdfcc4069e7bceb1db90dba570daba9 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PipingSurfaceLineSelectionDialog.cs (.../PipingSurfaceLineSelectionDialog.cs) (revision 9a196c8bc554a2e97ff094d7ffb2e99c42eb04fd) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PipingSurfaceLineSelectionDialog.cs (.../PipingSurfaceLineSelectionDialog.cs) (revision 1dc89167ccdfcc4069e7bceb1db90dba570daba9) @@ -21,61 +21,37 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Windows.Forms; -using Core.Common.Controls.Dialogs; -using Ringtoets.Piping.Forms.Views; +using Ringtoets.Common.Forms; +using Ringtoets.Common.Forms.Views; +using Ringtoets.Piping.Forms.Properties; using Ringtoets.Piping.Primitives; -using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; namespace Ringtoets.Piping.Forms { /// /// 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 PipingSurfaceLineSelectionDialog : DialogBase + public partial class PipingSurfaceLineSelectionDialog : SelectionDialogBase { /// /// Creates a new instance of . /// /// The parent of the dialog. /// The collection of to show in the dialog. + /// Thrown when any parameter is null. public PipingSurfaceLineSelectionDialog(IWin32Window dialogParent, IEnumerable surfaceLines) - : base(dialogParent, RingtoetsCommonFormsResources.GenerateScenariosIcon, 300, 400) + : base(dialogParent) { - InitializeComponent(); - - PipingSurfaceLineSelectionView = new PipingSurfaceLineSelectionView(surfaceLines) + if (surfaceLines == null) { - Dock = DockStyle.Fill - }; - Controls.Add(PipingSurfaceLineSelectionView); - SelectedSurfaceLines = new List(); + throw new ArgumentNullException("surfaceLines"); + } + InitializeComponent(); + InitializeDataGridView(Resources.RingtoetsPipingSurfaceLine_DisplayName); + SetDataSource(surfaceLines.Select(sl => new SelectableRow(sl, sl.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, then an empty collection is returned. - /// - public IEnumerable SelectedSurfaceLines { get; private set; } - - protected override Button GetCancelButton() - { - return CustomCancelButton; - } - - private PipingSurfaceLineSelectionView PipingSurfaceLineSelectionView { get; set; } - - private void OkButtonOnClick(object sender, EventArgs e) - { - SelectedSurfaceLines = PipingSurfaceLineSelectionView.GetSelectedSurfaceLines(); - Close(); - } - - private void CancelButtonOnClick(object sender, EventArgs eventArgs) - { - Close(); - } } } \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PipingSurfaceLineSelectionDialog.resx =================================================================== diff -u -rfc38d18fc6ff1749476da0ea43281d5d80568283 -r1dc89167ccdfcc4069e7bceb1db90dba570daba9 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PipingSurfaceLineSelectionDialog.resx (.../PipingSurfaceLineSelectionDialog.resx) (revision fc38d18fc6ff1749476da0ea43281d5d80568283) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PipingSurfaceLineSelectionDialog.resx (.../PipingSurfaceLineSelectionDialog.resx) (revision 1dc89167ccdfcc4069e7bceb1db90dba570daba9) @@ -118,91 +118,33 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 293, 3 + + 278, 169 - - 75, 23 + + DataGridViewControl - - - 1 + + Core.Common.Controls.DataGrid.DataGridViewControl, Core.Common.Controls, Version=16.2.1.5236, Culture=neutral, PublicKeyToken=null - - Annuleren + + ButtonGroupBox - - CustomCancelButton - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - flowLayoutPanel1 - - + 0 - - 212, 3 + + 97, 6 - - 75, 23 - - - 0 - - - Genereren - - - OkButton - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - flowLayoutPanel1 - - - 1 - - - - Bottom - - - 0, 297 - - - Yes - - - 371, 30 - - - 0 - - - flowLayoutPanel1 - - - System.Windows.Forms.FlowLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 0 - - + + True - + 6, 13 - 371, 327 + 284, 262 Selecteer profielschematisaties @@ -211,6 +153,6 @@ PipingSurfaceLineSelectionDialog - System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + Ringtoets.Common.Forms.SelectionDialogBase, Ringtoets.Common.Forms, Version=16.2.1.5236, Culture=neutral, PublicKeyToken=null \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingCalculationsView.cs =================================================================== diff -u -r9a196c8bc554a2e97ff094d7ffb2e99c42eb04fd -r1dc89167ccdfcc4069e7bceb1db90dba570daba9 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingCalculationsView.cs (.../PipingCalculationsView.cs) (revision 9a196c8bc554a2e97ff094d7ffb2e99c42eb04fd) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingCalculationsView.cs (.../PipingCalculationsView.cs) (revision 1dc89167ccdfcc4069e7bceb1db90dba570daba9) @@ -522,7 +522,7 @@ var dialog = new PipingSurfaceLineSelectionDialog(Parent, pipingFailureMechanism.SurfaceLines); dialog.ShowDialog(); var calculationsStructure = PipingCalculationConfigurationHelper.GenerateCalculationItemsStructure( - dialog.SelectedSurfaceLines, + dialog.SelectedItems, pipingFailureMechanism.StochasticSoilModels, pipingFailureMechanism.GeneralInput); foreach (var item in calculationsStructure) Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs =================================================================== diff -u -r0d98073e4ba2bdc6b69b7f875508488d1fa0148a -r1dc89167ccdfcc4069e7bceb1db90dba570daba9 --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision 0d98073e4ba2bdc6b69b7f875508488d1fa0148a) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision 1dc89167ccdfcc4069e7bceb1db90dba570daba9) @@ -294,7 +294,7 @@ var assessmentSection = o as IAssessmentSection; var pipingFailureMechanism = o as PipingFailureMechanism; - var viewPipingFailureMechanismContext = (PipingFailureMechanismContext) view.Data; + var viewPipingFailureMechanismContext = (PipingFailureMechanismContext)view.Data; var viewPipingFailureMechanism = viewPipingFailureMechanismContext.WrappedData; return assessmentSection != null @@ -732,7 +732,7 @@ using (var view = new PipingSurfaceLineSelectionDialog(Gui.MainWindow, nodeData.AvailablePipingSurfaceLines)) { view.ShowDialog(); - GeneratePipingCalculations(nodeData.WrappedData, view.SelectedSurfaceLines, nodeData.AvailableStochasticSoilModels, nodeData.FailureMechanism.GeneralInput); + GeneratePipingCalculations(nodeData.WrappedData, view.SelectedItems, nodeData.AvailableStochasticSoilModels, nodeData.FailureMechanism.GeneralInput); } nodeData.NotifyObservers(); } @@ -747,7 +747,7 @@ private void PipingCalculationGroupContextOnNodeRemoved(PipingCalculationGroupContext nodeData, object parentNodeData) { - var parentGroupContext = (PipingCalculationGroupContext) parentNodeData; + var parentGroupContext = (PipingCalculationGroupContext)parentNodeData; parentGroupContext.WrappedData.Children.Remove(nodeData.WrappedData); Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PipingSurfaceLineSelectionDialogTest.cs =================================================================== diff -u -r6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a -r1dc89167ccdfcc4069e7bceb1db90dba570daba9 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PipingSurfaceLineSelectionDialogTest.cs (.../PipingSurfaceLineSelectionDialogTest.cs) (revision 6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PipingSurfaceLineSelectionDialogTest.cs (.../PipingSurfaceLineSelectionDialogTest.cs) (revision 1dc89167ccdfcc4069e7bceb1db90dba570daba9) @@ -22,16 +22,20 @@ using System; using System.Linq; using System.Windows.Forms; +using Core.Common.Controls.DataGrid; using NUnit.Extensions.Forms; using NUnit.Framework; -using Ringtoets.Piping.Forms.Views; +using Ringtoets.Common.Forms; using Ringtoets.Piping.Primitives; namespace Ringtoets.Piping.Forms.Test { [TestFixture] public class PipingSurfaceLineSelectionDialogTest { + private const int selectItemColumnIndex = 0; + private const int nameColumnIndex = 1; + [Test] public void Constructor_WithoutParent_ThrowsArgumentNullException() { @@ -68,113 +72,66 @@ using (var dialog = new PipingSurfaceLineSelectionDialog(viewParent, Enumerable.Empty())) { // Assert - Assert.IsEmpty(dialog.SelectedSurfaceLines); - Assert.IsInstanceOf(new ControlTester("PipingSurfaceLineSelectionView", dialog).TheObject); + Assert.IsInstanceOf>(dialog); + Assert.IsEmpty(dialog.SelectedItems); Assert.AreEqual("Selecteer profielschematisaties", dialog.Text); } } } [Test] - public void OnLoad_Always_SetMinimumSize() + public void Constructor_DataGridViewCorrectlyInitialized() { - // Setup + // Setup & Call using (var viewParent = new Form()) using (var dialog = new PipingSurfaceLineSelectionDialog(viewParent, Enumerable.Empty())) { - // Call dialog.Show(); // Assert - Assert.AreEqual(300, dialog.MinimumSize.Width); - Assert.AreEqual(400, dialog.MinimumSize.Height); - } - } + Assert.IsEmpty(dialog.SelectedItems); - [Test] - public void GivenDialogWithSelectedSurfaceLines_WhenCloseWithoutConfirmation_ThenReturnsEmptyCollection() - { - // Given - var surfaceLines = new[] - { - new RingtoetsPipingSurfaceLine(), - new RingtoetsPipingSurfaceLine() - }; + 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 PipingSurfaceLineSelectionDialog(viewParent, surfaceLines)) - { - var selectionView = (DataGridView) new ControlTester("SurfaceLineDataGrid", dialog).TheObject; + var locationCalculateColumn = (DataGridViewCheckBoxColumn)dataGridView.Columns[selectItemColumnIndex]; + 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.SelectedSurfaceLines); + var nameColumn = (DataGridViewTextBoxColumn)dataGridView.Columns[nameColumnIndex]; + const string expectedNameHeaderText = "Profielschematisatie"; + Assert.AreEqual(expectedNameHeaderText, nameColumn.HeaderText); + Assert.AreEqual("Name", nameColumn.DataPropertyName); + Assert.AreEqual(DataGridViewAutoSizeColumnMode.Fill, nameColumn.AutoSizeMode); + Assert.IsTrue(nameColumn.ReadOnly); } } [Test] - public void GivenDialogWithSelectedSurfaceLines_WhenCancelButtonClicked_ThenReturnsSelectedCollection() + public void Constructor_SurfaceLinesOneEntry_OneRowInGrid() { - // Given - var selectedSurfaceLine = new RingtoetsPipingSurfaceLine(); - var surfaceLines = new[] - { - selectedSurfaceLine, - new RingtoetsPipingSurfaceLine() - }; + // Setup + var testname = "testName"; + var ringtoetsPipingSurfaceLine = new RingtoetsPipingSurfaceLine(); + ringtoetsPipingSurfaceLine.Name = testname; + // Call using (var viewParent = new Form()) - using (var dialog = new PipingSurfaceLineSelectionDialog(viewParent, surfaceLines)) + using (var dialog = new PipingSurfaceLineSelectionDialog(viewParent, new[] { - var selectionView = (DataGridView) new ControlTester("SurfaceLineDataGrid", dialog).TheObject; - - dialog.Show(); - selectionView.Rows[0].Cells[0].Value = true; - - // When - var cancelButton = new ButtonTester("CustomCancelButton", dialog); - cancelButton.Click(); - - // Then - Assert.IsEmpty(dialog.SelectedSurfaceLines); - } - } - - [Test] - public void GivenDialogWithSelectedSurfaceLines_WhenGenerateButtonClicked_ThenReturnsSelectedCollection() - { - // Given - var selectedSurfaceLine = new RingtoetsPipingSurfaceLine(); - var surfaceLines = new[] + ringtoetsPipingSurfaceLine + })) { - selectedSurfaceLine, - new RingtoetsPipingSurfaceLine() - }; - - using (var viewParent = new Form()) - using (var dialog = new PipingSurfaceLineSelectionDialog(viewParent, surfaceLines)) - { - var selectionView = (DataGridView) new ControlTester("SurfaceLineDataGrid", dialog).TheObject; - + // Assert dialog.Show(); - selectionView.Rows[0].Cells[0].Value = true; - // When - var okButton = new ButtonTester("OkButton", dialog); - okButton.Click(); - - // Then - var result = dialog.SelectedSurfaceLines; - - CollectionAssert.AreEqual(new[] - { - selectedSurfaceLine - }, result); + var dataGridViewControl = (DataGridViewControl)new ControlTester("DataGridViewControl").TheObject; + Assert.AreEqual(1, dataGridViewControl.Rows.Count); + Assert.IsFalse((bool)dataGridViewControl.Rows[0].Cells[selectItemColumnIndex].Value); + Assert.AreEqual(testname, (string)dataGridViewControl.Rows[0].Cells[nameColumnIndex].Value); } } } Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -rff8a088931e6af2e46f6f4f09b633bcdd0b84ecd -r1dc89167ccdfcc4069e7bceb1db90dba570daba9 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationGroupContextTreeNodeInfoTest.cs (.../PipingCalculationGroupContextTreeNodeInfoTest.cs) (revision ff8a088931e6af2e46f6f4f09b633bcdd0b84ecd) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationGroupContextTreeNodeInfoTest.cs (.../PipingCalculationGroupContextTreeNodeInfoTest.cs) (revision 1dc89167ccdfcc4069e7bceb1db90dba570daba9) @@ -25,6 +25,7 @@ using System.Windows.Forms; using Core.Common.Base; using Core.Common.Base.Geometry; +using Core.Common.Controls.DataGrid; using Core.Common.Controls.TreeView; using Core.Common.Gui; using Core.Common.Gui.Commands; @@ -152,10 +153,10 @@ // Assert Assert.AreEqual(group.Children.Count, children.Length); Assert.AreSame(calculationItem, children[0]); - var returnedCalculationContext = (PipingCalculationScenarioContext) children[1]; + var returnedCalculationContext = (PipingCalculationScenarioContext)children[1]; Assert.AreSame(childCalculation, returnedCalculationContext.WrappedData); Assert.AreSame(pipingFailureMechanism, returnedCalculationContext.FailureMechanism); - var returnedCalculationGroupContext = (PipingCalculationGroupContext) children[2]; + var returnedCalculationGroupContext = (PipingCalculationGroupContext)children[2]; Assert.AreSame(childGroup, returnedCalculationGroupContext.WrappedData); Assert.AreSame(pipingFailureMechanism, returnedCalculationGroupContext.FailureMechanism); Assert.AreSame(assessmentSectionMock, returnedCalculationGroupContext.AssessmentSection); @@ -1026,13 +1027,13 @@ plugin.Gui = gui; PipingSurfaceLineSelectionDialog selectionDialog = null; - DataGridView grid = null; + DataGridViewControl grid = null; int rowCount = 0; DialogBoxHandler = (name, wnd) => { - selectionDialog = (PipingSurfaceLineSelectionDialog) new FormTester(name).TheObject; - grid = (DataGridView) new ControlTester("SurfaceLineDataGrid", selectionDialog).TheObject; - rowCount = grid.RowCount; + selectionDialog = (PipingSurfaceLineSelectionDialog)new FormTester(name).TheObject; + grid = (DataGridViewControl)new ControlTester("DataGridViewControl", selectionDialog).TheObject; + rowCount = grid.Rows.Count; new ButtonTester("CustomCancelButton", selectionDialog).Click(); }; @@ -1182,12 +1183,12 @@ DialogBoxHandler = (name, wnd) => { - var selectionDialog = (PipingSurfaceLineSelectionDialog) new FormTester(name).TheObject; - var grid = (DataGridView) new ControlTester("SurfaceLineDataGrid", selectionDialog).TheObject; + var selectionDialog = (PipingSurfaceLineSelectionDialog)new FormTester(name).TheObject; + var grid = (DataGridViewControl)new ControlTester("DataGridViewControl", selectionDialog).TheObject; grid.Rows[0].Cells[0].Value = true; - new ButtonTester("OkButton", selectionDialog).Click(); + new ButtonTester("DoForSelectedButton", selectionDialog).Click(); }; using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) @@ -1301,8 +1302,8 @@ DialogBoxHandler = (name, wnd) => { - var selectionDialog = (PipingSurfaceLineSelectionDialog) new FormTester(name).TheObject; - var grid = (DataGridView) new ControlTester("SurfaceLineDataGrid", selectionDialog).TheObject; + var selectionDialog = (PipingSurfaceLineSelectionDialog)new FormTester(name).TheObject; + var grid = (DataGridViewControl)new ControlTester("DataGridViewControl", selectionDialog).TheObject; grid.Rows[0].Cells[0].Value = true; Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationsViewTest.cs =================================================================== diff -u -r24da3aa72ccc0776599628c9f971081694048d9a -r1dc89167ccdfcc4069e7bceb1db90dba570daba9 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationsViewTest.cs (.../PipingCalculationsViewTest.cs) (revision 24da3aa72ccc0776599628c9f971081694048d9a) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationsViewTest.cs (.../PipingCalculationsViewTest.cs) (revision 1dc89167ccdfcc4069e7bceb1db90dba570daba9) @@ -26,6 +26,7 @@ using Core.Common.Base; using Core.Common.Base.Data; using Core.Common.Base.Geometry; +using Core.Common.Controls.DataGrid; using Core.Common.Controls.Views; using Core.Common.Gui.Selection; using NUnit.Extensions.Forms; @@ -96,7 +97,7 @@ // Setup & Call ShowPipingCalculationsView(); - var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject; // Assert Assert.IsFalse(dataGridView.AutoGenerateColumns); @@ -108,11 +109,11 @@ Assert.AreEqual("DisplayName", column.DisplayMember); } - var soilProfilesCombobox = (DataGridViewComboBoxColumn) dataGridView.Columns[stochasticSoilProfilesColumnIndex]; + var soilProfilesCombobox = (DataGridViewComboBoxColumn)dataGridView.Columns[stochasticSoilProfilesColumnIndex]; var soilProfilesComboboxItems = soilProfilesCombobox.Items; Assert.AreEqual(0, soilProfilesComboboxItems.Count); // Row dependend - var hydraulicBoundaryLocationCombobox = (DataGridViewComboBoxColumn) dataGridView.Columns[hydraulicBoundaryLocationsColumnIndex]; + var hydraulicBoundaryLocationCombobox = (DataGridViewComboBoxColumn)dataGridView.Columns[hydraulicBoundaryLocationsColumnIndex]; var hydraulicBoundaryLocationComboboxItems = hydraulicBoundaryLocationCombobox.Items; Assert.AreEqual(1, hydraulicBoundaryLocationComboboxItems.Count); Assert.AreEqual("", hydraulicBoundaryLocationComboboxItems[0].ToString()); @@ -124,7 +125,7 @@ // Setup & Call ShowPipingCalculationsView(); - var listBox = (ListBox) new ControlTester("listBox").TheObject; + var listBox = (ListBox)new ControlTester("listBox").TheObject; // Assert Assert.AreEqual(0, listBox.Items.Count); @@ -157,8 +158,8 @@ pipingCalculationsView.AssessmentSection = assessmentSection; // Assert - var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; - var hydraulicBoundaryLocationCombobox = (DataGridViewComboBoxColumn) dataGridView.Columns[hydraulicBoundaryLocationsColumnIndex]; + var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject; + var hydraulicBoundaryLocationCombobox = (DataGridViewComboBoxColumn)dataGridView.Columns[hydraulicBoundaryLocationsColumnIndex]; var hydraulicBoundaryLocationComboboxItems = hydraulicBoundaryLocationCombobox.Items; Assert.AreEqual(1, hydraulicBoundaryLocationComboboxItems.Count); Assert.AreEqual("", hydraulicBoundaryLocationComboboxItems[0].ToString()); @@ -185,8 +186,8 @@ pipingCalculationsView.AssessmentSection = assessmentSection; // Assert - var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; - var hydraulicBoundaryLocationCombobox = (DataGridViewComboBoxColumn) dataGridView.Columns[hydraulicBoundaryLocationsColumnIndex]; + var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject; + var hydraulicBoundaryLocationCombobox = (DataGridViewComboBoxColumn)dataGridView.Columns[hydraulicBoundaryLocationsColumnIndex]; var hydraulicBoundaryLocationComboboxItems = hydraulicBoundaryLocationCombobox.Items; Assert.AreEqual(3, hydraulicBoundaryLocationComboboxItems.Count); Assert.AreEqual("", hydraulicBoundaryLocationComboboxItems[0].ToString()); @@ -226,7 +227,7 @@ pipingCalculationsView.PipingFailureMechanism = pipingFailureMechanism; // Assert - var listBox = (ListBox) new ControlTester("listBox").TheObject; + var listBox = (ListBox)new ControlTester("listBox").TheObject; Assert.AreEqual(3, listBox.Items.Count); Assert.AreSame(failureMechanismSection1, listBox.Items[0]); Assert.AreSame(failureMechanismSection2, listBox.Items[1]); @@ -244,14 +245,14 @@ mocks.ReplayAll(); - var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject; // Assert - var stochasticSoilModelsComboboxItems = ((DataGridViewComboBoxCell) dataGridView.Rows[0].Cells[stochasticSoilModelsColumnIndex]).Items; + var stochasticSoilModelsComboboxItems = ((DataGridViewComboBoxCell)dataGridView.Rows[0].Cells[stochasticSoilModelsColumnIndex]).Items; Assert.AreEqual(1, stochasticSoilModelsComboboxItems.Count); Assert.AreEqual("Model A", stochasticSoilModelsComboboxItems[0].ToString()); - stochasticSoilModelsComboboxItems = ((DataGridViewComboBoxCell) dataGridView.Rows[1].Cells[stochasticSoilModelsColumnIndex]).Items; + stochasticSoilModelsComboboxItems = ((DataGridViewComboBoxCell)dataGridView.Rows[1].Cells[stochasticSoilModelsColumnIndex]).Items; Assert.AreEqual(3, stochasticSoilModelsComboboxItems.Count); Assert.AreEqual("", stochasticSoilModelsComboboxItems[0].ToString()); Assert.AreEqual("Model A", stochasticSoilModelsComboboxItems[1].ToString()); @@ -271,16 +272,16 @@ mocks.ReplayAll(); - var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject; // Assert - var soilProfilesComboboxItems = ((DataGridViewComboBoxCell) dataGridView.Rows[0].Cells[stochasticSoilProfilesColumnIndex]).Items; + var soilProfilesComboboxItems = ((DataGridViewComboBoxCell)dataGridView.Rows[0].Cells[stochasticSoilProfilesColumnIndex]).Items; Assert.AreEqual(3, soilProfilesComboboxItems.Count); Assert.AreEqual("", soilProfilesComboboxItems[0].ToString()); Assert.AreEqual("Profile 1", soilProfilesComboboxItems[1].ToString()); Assert.AreEqual("Profile 2", soilProfilesComboboxItems[2].ToString()); - soilProfilesComboboxItems = ((DataGridViewComboBoxCell) dataGridView.Rows[1].Cells[stochasticSoilProfilesColumnIndex]).Items; + soilProfilesComboboxItems = ((DataGridViewComboBoxCell)dataGridView.Rows[1].Cells[stochasticSoilProfilesColumnIndex]).Items; Assert.AreEqual(1, soilProfilesComboboxItems.Count); Assert.AreEqual("Profile 5", soilProfilesComboboxItems[0].ToString()); @@ -298,7 +299,7 @@ mocks.ReplayAll(); - var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject; // Assert var rows = dataGridView.Rows; @@ -340,7 +341,7 @@ var hydraulicBoundaryDatabase = mocks.StrictMock(); var pipingCalculationsView = ShowFullyConfiguredPipingCalculationsView(assessmentSection, hydraulicBoundaryDatabase); - var secondPipingCalculationItem = ((PipingCalculationScenario) ((CalculationGroup) pipingCalculationsView.Data).Children[1]); + var secondPipingCalculationItem = ((PipingCalculationScenario)((CalculationGroup)pipingCalculationsView.Data).Children[1]); var secondPipingInputItem = secondPipingCalculationItem.InputParameters; var applicationSelectionMock = mocks.StrictMock(); @@ -355,7 +356,7 @@ pipingCalculationsView.ApplicationSelection = applicationSelectionMock; - var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject; // Call dataGridView.CurrentCell = dataGridView.Rows[1].Cells[0]; @@ -375,7 +376,7 @@ var hydraulicBoundaryDatabase = mocks.StrictMock(); var pipingCalculationsView = ShowFullyConfiguredPipingCalculationsView(assessmentSection, hydraulicBoundaryDatabase); - var secondPipingCalculationItem = ((PipingCalculationScenario) ((CalculationGroup) pipingCalculationsView.Data).Children[1]); + var secondPipingCalculationItem = ((PipingCalculationScenario)((CalculationGroup)pipingCalculationsView.Data).Children[1]); var secondPipingInputItem = secondPipingCalculationItem.InputParameters; applicationSelectionMock.Stub(asm => asm.Selection) @@ -390,7 +391,7 @@ pipingCalculationsView.ApplicationSelection = applicationSelectionMock; - var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject; // Call dataGridView.CurrentCell = dataGridView.Rows[1].Cells[0]; @@ -416,8 +417,8 @@ pipingCalculationsView.ApplicationSelection = applicationSelectionMock; - var listBox = (ListBox) new ControlTester("listBox").TheObject; - var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + var listBox = (ListBox)new ControlTester("listBox").TheObject; + var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject; // Precondition Assert.AreEqual(2, dataGridView.Rows.Count); @@ -453,7 +454,7 @@ mocks.ReplayAll(); - var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject; // Call dataGridView.Rows[0].Cells[cellIndex].Value = newValue; @@ -488,10 +489,10 @@ mocks.ReplayAll(); - var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject; // Call - dataGridView.Rows[0].Cells[cellIndex].Value = (RoundedDouble) newValue; + dataGridView.Rows[0].Cells[cellIndex].Value = (RoundedDouble)newValue; // Assert Assert.IsEmpty(dataGridView.Rows[0].ErrorText); @@ -510,7 +511,7 @@ new TestStochasticSoilModel() } }; - var button = (Button) new ButtonTester("buttonGenerateScenarios", testForm).TheObject; + var button = (Button)new ButtonTester("buttonGenerateScenarios", testForm).TheObject; // Call var state = button.Enabled; @@ -531,7 +532,7 @@ new RingtoetsPipingSurfaceLine() }, }; - var button = (Button) new ButtonTester("buttonGenerateScenarios", testForm).TheObject; + var button = (Button)new ButtonTester("buttonGenerateScenarios", testForm).TheObject; // Call var state = button.Enabled; @@ -556,7 +557,7 @@ new TestStochasticSoilModel() } }; - var button = (Button) new ButtonTester("buttonGenerateScenarios", testForm).TheObject; + var button = (Button)new ButtonTester("buttonGenerateScenarios", testForm).TheObject; // Call var state = button.Enabled; @@ -589,7 +590,7 @@ var pipingScenarioView = ShowPipingCalculationsView(); pipingScenarioView.PipingFailureMechanism = pipingFailureMechanismWithSections; - var listBox = (ListBox) new ControlTester("listBox").TheObject; + var listBox = (ListBox)new ControlTester("listBox").TheObject; // Precondition Assert.AreEqual(0, listBox.Items.Count); @@ -630,11 +631,11 @@ var button = new ButtonTester("buttonGenerateScenarios", testForm); PipingSurfaceLineSelectionDialog selectionDialog = null; - DataGridView grid = null; + DataGridViewControl grid = null; DialogBoxHandler = (name, wnd) => { - selectionDialog = (PipingSurfaceLineSelectionDialog) new FormTester(name).TheObject; - grid = (DataGridView) new ControlTester("SurfaceLineDataGrid", selectionDialog).TheObject; + selectionDialog = (PipingSurfaceLineSelectionDialog)new FormTester(name).TheObject; + grid = (DataGridViewControl)new ControlTester("DataGridViewControl", selectionDialog).TheObject; new ButtonTester("CustomCancelButton", selectionDialog).Click(); }; @@ -645,7 +646,7 @@ // Then Assert.NotNull(selectionDialog); Assert.NotNull(grid); - Assert.AreEqual(2, grid.RowCount); + Assert.AreEqual(2, grid.Rows.Count); } [Test] @@ -681,7 +682,7 @@ } [Test] - [TestCase("OkButton")] + [TestCase("DoForSelectedButton")] [TestCase("CustomCancelButton")] public void GivenPipingCalculationsViewGenerateScenariosButtonClicked_WhenDialogClosed_ThenNotifyCalculationGroup(string buttonName) { @@ -711,7 +712,9 @@ DialogBoxHandler = (name, wnd) => { - var selectionDialog = (PipingSurfaceLineSelectionDialog) new FormTester(name).TheObject; + var selectionDialog = (PipingSurfaceLineSelectionDialog)new FormTester(name).TheObject; + var selectionView = (DataGridViewControl)new ControlTester("DataGridViewControl", selectionDialog).TheObject; + selectionView.Rows[0].Cells[0].Value = true; // When new ButtonTester(buttonName, selectionDialog).Click(); @@ -734,19 +737,16 @@ pipingCalculationsView.Data = pipingFailureMechanism.CalculationsGroup; // Precondition - var button = new ButtonTester("buttonGenerateScenarios", testForm); DialogBoxHandler = (name, wnd) => { - var selectionDialog = (PipingSurfaceLineSelectionDialog) new FormTester(name).TheObject; - - var selectionView = (DataGridView) new ControlTester("SurfaceLineDataGrid", selectionDialog).TheObject; - + var selectionDialog = (PipingSurfaceLineSelectionDialog)new FormTester(name).TheObject; + var selectionView = (DataGridViewControl)new ControlTester("DataGridViewControl", selectionDialog).TheObject; selectionView.Rows[0].Cells[0].Value = true; // When - new ButtonTester("OkButton", selectionDialog).Click(); + new ButtonTester("DoForSelectedButton", selectionDialog).Click(); }; button.Click(); @@ -780,10 +780,8 @@ DialogBoxHandler = (name, wnd) => { - var selectionDialog = (PipingSurfaceLineSelectionDialog) new FormTester(name).TheObject; - - var selectionView = (DataGridView) new ControlTester("SurfaceLineDataGrid", selectionDialog).TheObject; - + var selectionDialog = (PipingSurfaceLineSelectionDialog)new FormTester(name).TheObject; + var selectionView = (DataGridViewControl)new ControlTester("DataGridViewControl", selectionDialog).TheObject; selectionView.Rows[0].Cells[0].Value = true; // When @@ -809,7 +807,7 @@ pipingFailureMechanism.NotifyObservers(); // Then - var button = (Button) new ButtonTester("buttonGenerateScenarios", testForm).TheObject; + var button = (Button)new ButtonTester("buttonGenerateScenarios", testForm).TheObject; Assert.IsFalse(button.Enabled); } @@ -826,7 +824,7 @@ pipingFailureMechanism.NotifyObservers(); // Then - var button = (Button) new ButtonTester("buttonGenerateScenarios", testForm).TheObject; + var button = (Button)new ButtonTester("buttonGenerateScenarios", testForm).TheObject; Assert.IsFalse(button.Enabled); } @@ -843,7 +841,7 @@ pipingFailureMechanism.StochasticSoilModels.Add(new TestStochasticSoilModel()); // Then - var button = (Button) new ButtonTester("buttonGenerateScenarios", testForm).TheObject; + var button = (Button)new ButtonTester("buttonGenerateScenarios", testForm).TheObject; Assert.IsFalse(button.Enabled); } @@ -861,7 +859,7 @@ pipingCalculationsView.PipingFailureMechanism.NotifyObservers(); // Then - var button = (Button) new ButtonTester("buttonGenerateScenarios", testForm).TheObject; + var button = (Button)new ButtonTester("buttonGenerateScenarios", testForm).TheObject; Assert.IsTrue(button.Enabled); } @@ -889,7 +887,7 @@ pipingCalculationsView.PipingFailureMechanism.NotifyObservers(); // Then - var button = (Button) new ButtonTester("buttonGenerateScenarios", testForm).TheObject; + var button = (Button)new ButtonTester("buttonGenerateScenarios", testForm).TheObject; Assert.IsFalse(button.Enabled); } @@ -910,16 +908,16 @@ mocks.ReplayAll(); - var data = (CalculationGroup) pipingCalculationView.Data; - var pipingCalculation = (PipingCalculationScenario) data.Children.First(); + var data = (CalculationGroup)pipingCalculationView.Data; + var pipingCalculation = (PipingCalculationScenario)data.Children.First(); pipingCalculation.Attach(pipingCalculationObserver); pipingCalculation.InputParameters.Attach(pipingCalculationInputObserver); - var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject; // Call - dataGridView.Rows[0].Cells[cellIndex].Value = (RoundedDouble) newValue; + dataGridView.Rows[0].Cells[cellIndex].Value = (RoundedDouble)newValue; // Assert Assert.AreEqual(RingtoetsPipingDataResources.PipingInput_EntryPointL_greater_or_equal_to_ExitPointL, dataGridView.Rows[0].ErrorText); @@ -943,16 +941,16 @@ mocks.ReplayAll(); - var data = (CalculationGroup) pipingCalculationView.Data; - var pipingCalculation = (PipingCalculationScenario) data.Children.First(); + var data = (CalculationGroup)pipingCalculationView.Data; + var pipingCalculation = (PipingCalculationScenario)data.Children.First(); pipingCalculation.Attach(pipingCalculationObserver); pipingCalculation.InputParameters.Attach(pipingCalculationInputObserver); - var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject; // Call - dataGridView.Rows[0].Cells[cellIndex].Value = (RoundedDouble) newValue; + dataGridView.Rows[0].Cells[cellIndex].Value = (RoundedDouble)newValue; // Assert var expectedMessage = "Het gespecificeerde punt moet op het profiel liggen (bereik [0, 10])."; @@ -973,7 +971,7 @@ mocks.ReplayAll(); - var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject; dataGridView.CurrentCell = dataGridView.Rows[selectedRow].Cells[0]; @@ -982,8 +980,8 @@ // Assert Assert.IsInstanceOf(selection); - var dataRow = (PipingCalculationRow) dataGridView.Rows[selectedRow].DataBoundItem; - Assert.AreSame(dataRow.PipingCalculation, ((PipingInputContext) selection).PipingCalculation); + var dataRow = (PipingCalculationRow)dataGridView.Rows[selectedRow].DataBoundItem; + Assert.AreSame(dataRow.PipingCalculation, ((PipingInputContext)selection).PipingCalculation); mocks.VerifyAll(); } @@ -1017,16 +1015,16 @@ mocks.ReplayAll(); - var data = (CalculationGroup) pipingCalculationView.Data; - var pipingCalculation = (PipingCalculationScenario) data.Children.First(); + var data = (CalculationGroup)pipingCalculationView.Data; + var pipingCalculation = (PipingCalculationScenario)data.Children.First(); pipingCalculation.Attach(pipingCalculationObserver); pipingCalculation.InputParameters.Attach(pipingCalculationInputObserver); - var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject; // Call - dataGridView.Rows[0].Cells[cellIndex].Value = newValue is double ? (RoundedDouble) (double) newValue : newValue; + dataGridView.Rows[0].Cells[cellIndex].Value = newValue is double ? (RoundedDouble)(double)newValue : newValue; // Assert mocks.VerifyAll(); @@ -1183,14 +1181,14 @@ HydraulicBoundaryLocation = hydraulicBoundaryLocation1, DampingFactorExit = { - Mean = (RoundedDouble) 1.1111 + Mean = (RoundedDouble)1.1111 }, PhreaticLevelExit = { - Mean = (RoundedDouble) 2.2222 + Mean = (RoundedDouble)2.2222 }, - EntryPointL = (RoundedDouble) 3.3333, - ExitPointL = (RoundedDouble) 4.4444 + EntryPointL = (RoundedDouble)3.3333, + ExitPointL = (RoundedDouble)4.4444 } }, new PipingCalculationScenario(new GeneralPipingInput()) @@ -1204,14 +1202,14 @@ HydraulicBoundaryLocation = hydraulicBoundaryLocation2, DampingFactorExit = { - Mean = (RoundedDouble) 5.5555 + Mean = (RoundedDouble)5.5555 }, PhreaticLevelExit = { - Mean = (RoundedDouble) 6.6666 + Mean = (RoundedDouble)6.6666 }, - EntryPointL = (RoundedDouble) 7.7777, - ExitPointL = (RoundedDouble) 8.8888 + EntryPointL = (RoundedDouble)7.7777, + ExitPointL = (RoundedDouble)8.8888 } } }