Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Merge/AssessmentSectionMergeDataProviderDialog.Designer.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Merge/AssessmentSectionMergeDataProviderDialog.Designer.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Merge/AssessmentSectionMergeDataProviderDialog.Designer.cs (revision e1fa673058810802afec7e0c661f16a13bf0e1a3) @@ -0,0 +1,124 @@ +using System.Windows.Forms; + +namespace Ringtoets.Integration.Forms.Merge +{ + partial class AssessmentSectionMergeDataProviderDialog + { + /// + /// 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 + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AssessmentSectionMergeDataProviderDialog)); + this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); + this.assessmentSectionSelectLabel = new System.Windows.Forms.Label(); + this.assessmentSectionComboBox = new System.Windows.Forms.ComboBox(); + this.failureMechanismsSelectLabel = new System.Windows.Forms.Label(); + this.dataGridViewControl = new Core.Common.Controls.DataGrid.DataGridViewControl(); + this.flowLayoutPanelButtons = new System.Windows.Forms.FlowLayoutPanel(); + this.cancelButton = new System.Windows.Forms.Button(); + this.importButton = new System.Windows.Forms.Button(); + this.tableLayoutPanel.SuspendLayout(); + this.flowLayoutPanelButtons.SuspendLayout(); + this.SuspendLayout(); + // + // tableLayoutPanel + // + resources.ApplyResources(this.tableLayoutPanel, "tableLayoutPanel"); + this.tableLayoutPanel.Controls.Add(this.assessmentSectionSelectLabel, 0, 0); + this.tableLayoutPanel.Controls.Add(this.assessmentSectionComboBox, 0, 1); + this.tableLayoutPanel.Controls.Add(this.failureMechanismsSelectLabel, 0, 2); + this.tableLayoutPanel.Controls.Add(this.dataGridViewControl, 0, 3); + this.tableLayoutPanel.Controls.Add(this.flowLayoutPanelButtons, 0, 4); + this.tableLayoutPanel.Name = "tableLayoutPanel"; + // + // assessmentSectionSelectLabel + // + resources.ApplyResources(this.assessmentSectionSelectLabel, "assessmentSectionSelectLabel"); + this.assessmentSectionSelectLabel.Name = "assessmentSectionSelectLabel"; + // + // assessmentSectionComboBox + // + resources.ApplyResources(this.assessmentSectionComboBox, "assessmentSectionComboBox"); + this.assessmentSectionComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.assessmentSectionComboBox.Name = "assessmentSectionComboBox"; + this.assessmentSectionComboBox.SelectedIndexChanged += new System.EventHandler(this.AssessmentSectionComboBox_OnSelectedIndexChanged); + // + // failureMechanismsSelectLabel + // + resources.ApplyResources(this.failureMechanismsSelectLabel, "failureMechanismsSelectLabel"); + this.failureMechanismsSelectLabel.Name = "failureMechanismsSelectLabel"; + // + // dataGridViewControl + // + resources.ApplyResources(this.dataGridViewControl, "dataGridViewControl"); + this.dataGridViewControl.MultiSelect = true; + this.dataGridViewControl.Name = "dataGridViewControl"; + // + // flowLayoutPanelButtons + // + resources.ApplyResources(this.flowLayoutPanelButtons, "flowLayoutPanelButtons"); + this.flowLayoutPanelButtons.Controls.Add(this.cancelButton); + this.flowLayoutPanelButtons.Controls.Add(this.importButton); + this.flowLayoutPanelButtons.Name = "flowLayoutPanelButtons"; + // + // cancelButton + // + resources.ApplyResources(this.cancelButton, "cancelButton"); + this.cancelButton.Name = "cancelButton"; + this.cancelButton.UseVisualStyleBackColor = true; + // + // importButton + // + resources.ApplyResources(this.importButton, "importButton"); + this.importButton.Name = "importButton"; + this.importButton.UseVisualStyleBackColor = true; + this.importButton.Click += new System.EventHandler(this.OnImportButtonClick); + // + // AssessmentSectionProviderDialog + // + resources.ApplyResources(this, "$this"); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.tableLayoutPanel); + this.Name = "AssessmentSectionMergeDataProviderDialog"; + this.tableLayoutPanel.ResumeLayout(false); + this.tableLayoutPanel.PerformLayout(); + this.flowLayoutPanelButtons.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel; + private System.Windows.Forms.Label assessmentSectionSelectLabel; + private System.Windows.Forms.Label failureMechanismsSelectLabel; + private System.Windows.Forms.FlowLayoutPanel flowLayoutPanelButtons; + private System.Windows.Forms.Button cancelButton; + private System.Windows.Forms.Button importButton; + private Core.Common.Controls.DataGrid.DataGridViewControl dataGridViewControl; + private System.Windows.Forms.ComboBox assessmentSectionComboBox; + } +} \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Merge/AssessmentSectionMergeDataProviderDialog.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Merge/AssessmentSectionMergeDataProviderDialog.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Merge/AssessmentSectionMergeDataProviderDialog.cs (revision e1fa673058810802afec7e0c661f16a13bf0e1a3) @@ -0,0 +1,135 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Windows.Forms; +using Core.Common.Controls.Dialogs; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Integration.Data; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.Integration.Forms.Merge +{ + /// + /// A dialog which allows the user to make a selection of which + /// and its to use for merging the data. The selections + /// can be obtained upon closing the dialog. + /// + public partial class AssessmentSectionMergeDataProviderDialog : DialogBase, IMergeDataProvider + { + private FailureMechanismMergeDataRow[] failureMechanismMergeDataRows; + private bool assessmentSectionComboBoxUpdating; + private bool isDataSelected; + + /// + /// Creates a new instance of the . + /// + /// The parent of the dialog. + public AssessmentSectionMergeDataProviderDialog(IWin32Window dialogParent) + : base(dialogParent, RingtoetsCommonFormsResources.SelectionDialogIcon, 500, 350) + { + InitializeComponent(); + InitializeDataGridView(); + } + + public AssessmentSection SelectedAssessmentSection { get; private set; } + public IEnumerable SelectedFailureMechanisms { get; private set; } + + public bool SelectData(IEnumerable assessmentSections) + { + if (assessmentSections == null) + { + throw new ArgumentNullException(nameof(assessmentSections)); + } + + SetComboBoxData(assessmentSections); + ShowDialog(); + + return isDataSelected; + } + + protected override Button GetCancelButton() + { + return cancelButton; + } + + private void InitializeDataGridView() + { + dataGridViewControl.AddCheckBoxColumn(nameof(FailureMechanismMergeDataRow.IsSelected), "Selecteer"); + dataGridViewControl.AddTextBoxColumn(nameof(FailureMechanismMergeDataRow.Name), "Toetsspoor", true); + dataGridViewControl.AddCheckBoxColumn(nameof(FailureMechanismMergeDataRow.IsRelevant), "Is relevant", true); + dataGridViewControl.AddCheckBoxColumn(nameof(FailureMechanismMergeDataRow.HasSections), "Heeft vakindeling", true); + dataGridViewControl.AddTextBoxColumn(nameof(FailureMechanismMergeDataRow.NumberOfCalculations), "Aantal berekeningen", true); + } + + #region Data Setters + + private void SetComboBoxData(IEnumerable assessmentSections) + { + assessmentSectionComboBox.BeginUpdate(); + + assessmentSectionComboBoxUpdating = true; + assessmentSectionComboBox.DataSource = assessmentSections.ToArray(); + assessmentSectionComboBox.DisplayMember = nameof(AssessmentSection.Name); + assessmentSectionComboBox.SelectedItem = null; + assessmentSectionComboBoxUpdating = false; + + assessmentSectionComboBox.SelectedItem = assessmentSections.FirstOrDefault(); + + assessmentSectionComboBox.EndUpdate(); + } + + private void SetDataGridViewData(AssessmentSection assessmentSection) + { + failureMechanismMergeDataRows = new[] + { + new FailureMechanismMergeDataRow(assessmentSection.Piping), + new FailureMechanismMergeDataRow(assessmentSection.GrassCoverErosionInwards), + new FailureMechanismMergeDataRow(assessmentSection.MacroStabilityInwards), + new FailureMechanismMergeDataRow(assessmentSection.MacroStabilityOutwards), + new FailureMechanismMergeDataRow(assessmentSection.Microstability), + new FailureMechanismMergeDataRow(assessmentSection.StabilityStoneCover), + new FailureMechanismMergeDataRow(assessmentSection.WaveImpactAsphaltCover), + new FailureMechanismMergeDataRow(assessmentSection.WaterPressureAsphaltCover), + new FailureMechanismMergeDataRow(assessmentSection.GrassCoverErosionOutwards), + new FailureMechanismMergeDataRow(assessmentSection.GrassCoverSlipOffOutwards), + new FailureMechanismMergeDataRow(assessmentSection.GrassCoverSlipOffInwards), + new FailureMechanismMergeDataRow(assessmentSection.HeightStructures), + new FailureMechanismMergeDataRow(assessmentSection.ClosingStructures), + new FailureMechanismMergeDataRow(assessmentSection.PipingStructure), + new FailureMechanismMergeDataRow(assessmentSection.StabilityPointStructures), + new FailureMechanismMergeDataRow(assessmentSection.StrengthStabilityLengthwiseConstruction), + new FailureMechanismMergeDataRow(assessmentSection.DuneErosion), + new FailureMechanismMergeDataRow(assessmentSection.TechnicalInnovation) + }; + + dataGridViewControl.SetDataSource(failureMechanismMergeDataRows); + } + + #endregion + + #region Event Handling + + private void AssessmentSectionComboBox_OnSelectedIndexChanged(object sender, EventArgs eventArgs) + { + if (assessmentSectionComboBoxUpdating || assessmentSectionComboBox.SelectedIndex == -1) + { + return; + } + + SetDataGridViewData((AssessmentSection) assessmentSectionComboBox.SelectedItem); + } + + private void OnImportButtonClick(object sender, EventArgs eventArgs) + { + SelectedAssessmentSection = (AssessmentSection) assessmentSectionComboBox.SelectedItem; + SelectedFailureMechanisms = failureMechanismMergeDataRows?.Where(row => row.IsSelected) + .Select(row => row.FailureMechanism) + .ToArray(); + + isDataSelected = true; + Close(); + } + + #endregion + } +} \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Merge/AssessmentSectionMergeDataProviderDialog.resx =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Merge/AssessmentSectionMergeDataProviderDialog.resx (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Merge/AssessmentSectionMergeDataProviderDialog.resx (revision e1fa673058810802afec7e0c661f16a13bf0e1a3) @@ -0,0 +1,366 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + True + + + 1 + + + + Bottom + + + + 3, 0 + + + 478, 16 + + + 0 + + + Selecteer traject: + + + BottomLeft + + + assessmentSectionSelectLabel + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tableLayoutPanel + + + 0 + + + Fill + + + 3, 19 + + + 478, 21 + + + 0 + + + assessmentSectionComboBox + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tableLayoutPanel + + + 1 + + + Fill + + + 3, 43 + + + 478, 23 + + + 1 + + + Selecteer toetssporen: + + + BottomLeft + + + failureMechanismsSelectLabel + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tableLayoutPanel + + + 2 + + + Fill + + + 3, 69 + + + 478, 205 + + + 2 + + + dataGridViewControl + + + Core.Common.Controls.DataGrid.DataGridViewControl, Core.Common.Controls, Version=18.1.1.1, Culture=neutral, PublicKeyToken=null + + + tableLayoutPanel + + + 3 + + + True + + + 400, 3 + + + 75, 23 + + + 0 + + + Annuleren + + + cancelButton + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + flowLayoutPanelButtons + + + 0 + + + 319, 3 + + + 75, 23 + + + 1 + + + Importeren + + + importButton + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + flowLayoutPanelButtons + + + 1 + + + Bottom + + + RightToLeft + + + 3, 280 + + + 478, 29 + + + 3 + + + flowLayoutPanelButtons + + + System.Windows.Forms.FlowLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tableLayoutPanel + + + 4 + + + Fill + + + 0, 0 + + + 5 + + + 484, 312 + + + 0 + + + tableLayoutPanel + + + System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 0 + + + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="assessmentSectionSelectLabel" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="assessmentSectionComboBox" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="failureMechanismsSelectLabel" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="dataGridViewControl" Row="3" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="flowLayoutPanelButtons" Row="4" RowSpan="1" Column="0" ColumnSpan="1" /></Controls><Columns Styles="Percent,100" /><Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0,Percent,100,AutoSize,0" /></TableLayoutSettings> + + + True + + + 6, 13 + + + 484, 312 + + + 500, 350 + + + Selecteer trajectinformatie + + + AssessmentSectionMergeDataProviderDialog + + + System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file Fisheye: Tag e1fa673058810802afec7e0c661f16a13bf0e1a3 refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Forms/Merge/AssessmentSectionProviderDialog.Designer.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e1fa673058810802afec7e0c661f16a13bf0e1a3 refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Forms/Merge/AssessmentSectionProviderDialog.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e1fa673058810802afec7e0c661f16a13bf0e1a3 refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Forms/Merge/AssessmentSectionProviderDialog.resx'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj =================================================================== diff -u -r283277d753eec15fec834e7e24a0bf83342a5c09 -re1fa673058810802afec7e0c661f16a13bf0e1a3 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision 283277d753eec15fec834e7e24a0bf83342a5c09) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision e1fa673058810802afec7e0c661f16a13bf0e1a3) @@ -20,11 +20,11 @@ - + Form - - AssessmentSectionProviderDialog.cs + + AssessmentSectionMergeDataProviderDialog.cs Form @@ -319,8 +319,8 @@ MergeDataProviderStub.cs - - AssessmentSectionProviderDialog.cs + + AssessmentSectionMergeDataProviderDialog.cs PublicResXFileCodeGenerator Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Merge/AssessmentSectionMergeDataProviderDialogTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Merge/AssessmentSectionMergeDataProviderDialogTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Merge/AssessmentSectionMergeDataProviderDialogTest.cs (revision e1fa673058810802afec7e0c661f16a13bf0e1a3) @@ -0,0 +1,379 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Windows.Forms; +using Core.Common.Controls.DataGrid; +using Core.Common.Controls.Dialogs; +using Core.Common.TestUtil; +using NUnit.Extensions.Forms; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Forms.Properties; +using Ringtoets.Integration.Data; +using Ringtoets.Integration.Forms.Merge; +using Ringtoets.Integration.TestUtil; + +namespace Ringtoets.Integration.Forms.Test.Merge +{ + [TestFixture] + public class AssessmentSectionMergeDataProviderDialogTest : NUnitFormTest + { + private const int isSelectedIndex = 0; + private const int failureMechanismNameIndex = 1; + private const int isRelevantIndex = 2; + private const int hasSectionsIndex = 3; + private const int numberOfCalculationsIndex = 4; + private const int columnCount = 5; + + [Test] + public void Constructor_DialogParentNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new AssessmentSectionMergeDataProviderDialog(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("dialogParent", exception.ParamName); + } + + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var mocks = new MockRepository(); + var dialogParent = mocks.Stub(); + mocks.ReplayAll(); + + // Call + using (var dialog = new AssessmentSectionMergeDataProviderDialog(dialogParent)) + { + // Assert + Assert.IsInstanceOf(dialog); + Assert.IsInstanceOf(dialog); + + Assert.AreEqual("Selecteer trajectinformatie", dialog.Text); + + Icon icon = BitmapToIcon(Resources.SelectionDialogIcon); + Bitmap expectedImage = icon.ToBitmap(); + Bitmap actualImage = dialog.Icon.ToBitmap(); + TestHelper.AssertImagesAreEqual(expectedImage, actualImage); + } + + mocks.VerifyAll(); + } + + [Test] + public void Show_Always_DefaultProperties() + { + // Setup + using (var dialogParent = new Form()) + using (var dialog = new AssessmentSectionMergeDataProviderDialog(dialogParent)) + { + // Call + dialog.Show(); + + // Assert + Assert.AreEqual(1, dialog.Controls.Count); + + var tableLayoutPanel = (TableLayoutPanel) new ControlTester("tableLayoutPanel").TheObject; + Assert.AreEqual(1, tableLayoutPanel.ColumnCount); + Assert.AreEqual(5, tableLayoutPanel.RowCount); + + var assessmentSectionSelectLabel = (Label) tableLayoutPanel.GetControlFromPosition(0, 0); + Assert.AreEqual("Selecteer traject:", assessmentSectionSelectLabel.Text); + + var assessmentSectionComboBox = (ComboBox) tableLayoutPanel.GetControlFromPosition(0, 1); + Assert.IsTrue(assessmentSectionComboBox.Enabled); + Assert.AreEqual(ComboBoxStyle.DropDownList, assessmentSectionComboBox.DropDownStyle); + CollectionAssert.IsEmpty(assessmentSectionComboBox.Items); + + var failureMechanismSelectionLabel = (Label) tableLayoutPanel.GetControlFromPosition(0, 2); + Assert.AreEqual("Selecteer toetssporen:", failureMechanismSelectionLabel.Text); + + Assert.IsInstanceOf(tableLayoutPanel.GetControlFromPosition(0, 3)); + + var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + Assert.AreEqual(columnCount, dataGridView.ColumnCount); + Assert.AreEqual(0, dataGridView.RowCount); + Assert.IsInstanceOf(dataGridView.Columns[isSelectedIndex]); + Assert.IsInstanceOf(dataGridView.Columns[failureMechanismNameIndex]); + Assert.IsInstanceOf(dataGridView.Columns[isRelevantIndex]); + Assert.IsInstanceOf(dataGridView.Columns[hasSectionsIndex]); + Assert.IsInstanceOf(dataGridView.Columns[numberOfCalculationsIndex]); + + Assert.AreEqual("Selecteer", dataGridView.Columns[isSelectedIndex].HeaderText); + Assert.AreEqual("Toetsspoor", dataGridView.Columns[failureMechanismNameIndex].HeaderText); + Assert.AreEqual("Is relevant", dataGridView.Columns[isRelevantIndex].HeaderText); + Assert.AreEqual("Heeft vakindeling", dataGridView.Columns[hasSectionsIndex].HeaderText); + Assert.AreEqual("Aantal berekeningen", dataGridView.Columns[numberOfCalculationsIndex].HeaderText); + + Assert.IsFalse(dataGridView.Columns[isSelectedIndex].ReadOnly); + Assert.IsTrue(dataGridView.Columns[failureMechanismNameIndex].ReadOnly); + Assert.IsTrue(dataGridView.Columns[isRelevantIndex].ReadOnly); + Assert.IsTrue(dataGridView.Columns[hasSectionsIndex].ReadOnly); + Assert.IsTrue(dataGridView.Columns[numberOfCalculationsIndex].ReadOnly); + + Assert.AreEqual(DataGridViewAutoSizeColumnsMode.AllCells, dataGridView.AutoSizeColumnsMode); + Assert.AreEqual(DataGridViewContentAlignment.MiddleCenter, dataGridView.ColumnHeadersDefaultCellStyle.Alignment); + + var flowLayoutPanel = (FlowLayoutPanel) tableLayoutPanel.GetControlFromPosition(0, 4); + Control.ControlCollection flowLayoutPanelControls = flowLayoutPanel.Controls; + Assert.AreEqual(2, flowLayoutPanelControls.Count); + CollectionAssert.AllItemsAreInstancesOfType(flowLayoutPanelControls, typeof(Button)); + + var buttonSelect = (Button) new ButtonTester("importButton", dialog).TheObject; + Assert.AreEqual("Importeren", buttonSelect.Text); + Assert.IsTrue(buttonSelect.Enabled); + + var buttonCancel = (Button) new ButtonTester("cancelButton", dialog).TheObject; + Assert.AreEqual("Annuleren", buttonCancel.Text); + Assert.AreEqual(dialog.CancelButton, buttonCancel); + + Assert.AreEqual(500, dialog.MinimumSize.Width); + Assert.AreEqual(350, dialog.MinimumSize.Height); + } + } + + [Test] + public void SelectData_AssessmentSectionsNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var dialogParent = mocks.Stub(); + mocks.ReplayAll(); + + using (var dialog = new AssessmentSectionMergeDataProviderDialog(dialogParent)) + { + // Call + TestDelegate call = () => dialog.SelectData(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentSections", exception.ParamName); + } + + mocks.VerifyAll(); + } + + [Test] + public void SelectData_WithEmptyAssessmentSections_SetsDataOnDialog() + { + // Setup + DialogBoxHandler = (formName, wnd) => + { + using (new FormTester(formName)) {} + }; + + using (var dialogParent = new Form()) + using (var dialog = new AssessmentSectionMergeDataProviderDialog(dialogParent)) + { + // Call + dialog.SelectData(Enumerable.Empty()); + + // Assert + var comboBox = (ComboBox) new ComboBoxTester("assessmentSectionComboBox", dialog).TheObject; + Assert.IsNull(comboBox.SelectedItem); + CollectionAssert.IsEmpty(comboBox.Items); + + var dataGridView = (DataGridView) new ControlTester("dataGridView", dialog).TheObject; + DataGridViewRowCollection rows = dataGridView.Rows; + Assert.AreEqual(0, rows.Count); + } + } + + [Test] + public void SelectData_WithAssessmentSections_SetsDataOnDialog() + { + // Setup + DialogBoxHandler = (formName, wnd) => + { + using (new FormTester(formName)) {} + }; + + var random = new Random(21); + AssessmentSection[] assessmentSections = + { + TestDataGenerator.GetAssessmentSectionWithAllCalculationConfigurations(), + new AssessmentSection(random.NextEnumValue()) + }; + + using (var dialogParent = new Form()) + using (var dialog = new AssessmentSectionMergeDataProviderDialog(dialogParent)) + { + // Call + dialog.SelectData(assessmentSections); + + // Assert + AssessmentSection expectedDefaultSelectedAssessmentSection = assessmentSections[0]; + + var comboBox = (ComboBox) new ComboBoxTester("assessmentSectionComboBox", dialog).TheObject; + Assert.AreSame(expectedDefaultSelectedAssessmentSection, comboBox.SelectedItem); + CollectionAssert.AreEqual(assessmentSections, comboBox.Items); + + var dataGridView = (DataGridView) new ControlTester("dataGridView", dialog).TheObject; + DataGridViewRowCollection rows = dataGridView.Rows; + AssertFailureMechanismRows(expectedDefaultSelectedAssessmentSection, rows); + } + } + + [Test] + public void GivenValidDialog_WhenSelectDataCalledAndCancelPressed_ThenSelectedDataNullAndReturnsFalse() + { + // Given + DialogBoxHandler = (formName, wnd) => + { + using (new FormTester(formName)) + { + var button = new ButtonTester("cancelButton", formName); + button.Click(); + } + }; + + using (var dialogParent = new Form()) + using (var dialog = new AssessmentSectionMergeDataProviderDialog(dialogParent)) + { + // When + bool result = dialog.SelectData(new[] + { + TestDataGenerator.GetAssessmentSectionWithAllCalculationConfigurations() + }); + + // Then + Assert.IsFalse(result); + Assert.IsNull(dialog.SelectedAssessmentSection); + Assert.IsNull(dialog.SelectedFailureMechanisms); + } + } + + [Test] + public void GivenValidDialog_WhenSelectDataCalledAndDataSelectedAndImportPressed_ThenSelectedDataSetAndReturnsTrue() + { + // Given + var random = new Random(21); + AssessmentSection selectedAssessmentSection = TestDataGenerator.GetAssessmentSectionWithAllCalculationConfigurations(); + const int selectedFailureMechanismOne = 5; + const int selectedFailureMechanismTwo = 8; + + DialogBoxHandler = (formName, wnd) => + { + using (var formTester = new FormTester(formName)) + { + var dialog = (AssessmentSectionMergeDataProviderDialog) formTester.TheObject; + var comboBox = (ComboBox) new ComboBoxTester("assessmentSectionComboBox", dialog).TheObject; + comboBox.SelectedItem = selectedAssessmentSection; + + var dataGridView = (DataGridView) new ControlTester("dataGridView", dialog).TheObject; + + DataGridViewRowCollection rows = dataGridView.Rows; + rows[selectedFailureMechanismOne].Cells[isSelectedIndex].Value = true; + rows[selectedFailureMechanismTwo].Cells[isSelectedIndex].Value = true; + + var button = new ButtonTester("importButton", formName); + button.Click(); + } + }; + + using (var dialogParent = new Form()) + using (var dialog = new AssessmentSectionMergeDataProviderDialog(dialogParent)) + { + // When + bool result = dialog.SelectData(new[] + { + new AssessmentSection(random.NextEnumValue()), + selectedAssessmentSection + }); + + // Then + Assert.IsTrue(result); + Assert.AreSame(selectedAssessmentSection, dialog.SelectedAssessmentSection); + + IEnumerable selectedFailureMechanisms = dialog.SelectedFailureMechanisms; + Assert.AreEqual(2, selectedFailureMechanisms.Count()); + CollectionAssert.AreEquivalent(new IFailureMechanism[] + { + selectedAssessmentSection.StabilityStoneCover, + selectedAssessmentSection.GrassCoverErosionOutwards + }, selectedFailureMechanisms); + } + } + + [Test] + public void GivenDialogWithAssessmentSection_WhenSelectingOtherAssessmentSection_ThenDataUpdated() + { + // Given + var random = new Random(21); + AssessmentSection[] assessmentSections = + { + TestDataGenerator.GetAssessmentSectionWithAllCalculationConfigurations(), + new AssessmentSection(random.NextEnumValue()) + }; + + DialogBoxHandler = (formName, wnd) => + { + using (new FormTester(formName)) {} + }; + + using (var dialogParent = new Form()) + using (var dialog = new AssessmentSectionMergeDataProviderDialog(dialogParent)) + { + dialog.SelectData(assessmentSections); + + var comboBox = (ComboBox) new ComboBoxTester("assessmentSectionComboBox", dialog).TheObject; + var dataGridView = (DataGridView) new ControlTester("dataGridView", dialog).TheObject; + + // Precondition + AssessmentSection defaultSelectedAssessmentSection = assessmentSections[0]; + Assert.AreSame(defaultSelectedAssessmentSection, comboBox.SelectedItem); + AssertFailureMechanismRows(defaultSelectedAssessmentSection, dataGridView.Rows); + + // When + AssessmentSection itemToBeSelected = assessmentSections[1]; + comboBox.SelectedItem = itemToBeSelected; + + // Then + AssertFailureMechanismRows(itemToBeSelected, dataGridView.Rows); + } + } + + private static void AssertFailureMechanismRows(AssessmentSection expectedAssessmentSection, DataGridViewRowCollection rows) + { + Assert.AreEqual(expectedAssessmentSection.GetFailureMechanisms().Count(), rows.Count); + AssertDataGridViewRow(expectedAssessmentSection.Piping, rows[0].Cells); + AssertDataGridViewRow(expectedAssessmentSection.GrassCoverErosionInwards, rows[1].Cells); + AssertDataGridViewRow(expectedAssessmentSection.MacroStabilityInwards, rows[2].Cells); + AssertDataGridViewRow(expectedAssessmentSection.MacroStabilityOutwards, rows[3].Cells); + AssertDataGridViewRow(expectedAssessmentSection.Microstability, rows[4].Cells); + AssertDataGridViewRow(expectedAssessmentSection.StabilityStoneCover, rows[5].Cells); + AssertDataGridViewRow(expectedAssessmentSection.WaveImpactAsphaltCover, rows[6].Cells); + AssertDataGridViewRow(expectedAssessmentSection.WaterPressureAsphaltCover, rows[7].Cells); + AssertDataGridViewRow(expectedAssessmentSection.GrassCoverErosionOutwards, rows[8].Cells); + AssertDataGridViewRow(expectedAssessmentSection.GrassCoverSlipOffOutwards, rows[9].Cells); + AssertDataGridViewRow(expectedAssessmentSection.GrassCoverSlipOffInwards, rows[10].Cells); + AssertDataGridViewRow(expectedAssessmentSection.HeightStructures, rows[11].Cells); + AssertDataGridViewRow(expectedAssessmentSection.ClosingStructures, rows[12].Cells); + AssertDataGridViewRow(expectedAssessmentSection.PipingStructure, rows[13].Cells); + AssertDataGridViewRow(expectedAssessmentSection.StabilityPointStructures, rows[14].Cells); + AssertDataGridViewRow(expectedAssessmentSection.StrengthStabilityLengthwiseConstruction, rows[15].Cells); + AssertDataGridViewRow(expectedAssessmentSection.DuneErosion, rows[16].Cells); + AssertDataGridViewRow(expectedAssessmentSection.TechnicalInnovation, rows[17].Cells); + } + + private static void AssertDataGridViewRow(IFailureMechanism expectedFailureMechanism, + DataGridViewCellCollection cells) + { + Assert.AreEqual(false, cells[isSelectedIndex].Value); + Assert.AreEqual(expectedFailureMechanism.Name, cells[failureMechanismNameIndex].Value); + Assert.AreEqual(expectedFailureMechanism.IsRelevant, cells[isRelevantIndex].Value); + Assert.AreEqual(expectedFailureMechanism.Sections.Any(), cells[hasSectionsIndex].Value); + Assert.AreEqual(expectedFailureMechanism.Calculations.Count(), cells[numberOfCalculationsIndex].Value); + } + + private static Icon BitmapToIcon(Bitmap icon) + { + return Icon.FromHandle(icon.GetHicon()); + } + } +} \ No newline at end of file Fisheye: Tag e1fa673058810802afec7e0c661f16a13bf0e1a3 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Merge/AssessmentSectionProviderDialogTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj =================================================================== diff -u -r2f76dec1e282b3a6a8dc4fb593643248d36aac28 -re1fa673058810802afec7e0c661f16a13bf0e1a3 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision 2f76dec1e282b3a6a8dc4fb593643248d36aac28) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision e1fa673058810802afec7e0c661f16a13bf0e1a3) @@ -33,7 +33,7 @@ - +