Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Merge/AssessmentSectionProviderDialog.Designer.cs =================================================================== diff -u -r5541793b120764195e9409183cc51b7e97cae079 -r283277d753eec15fec834e7e24a0bf83342a5c09 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Merge/AssessmentSectionProviderDialog.Designer.cs (.../AssessmentSectionProviderDialog.Designer.cs) (revision 5541793b120764195e9409183cc51b7e97cae079) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Merge/AssessmentSectionProviderDialog.Designer.cs (.../AssessmentSectionProviderDialog.Designer.cs) (revision 283277d753eec15fec834e7e24a0bf83342a5c09) @@ -1,4 +1,6 @@ -namespace Ringtoets.Integration.Forms.Merge +using System.Windows.Forms; + +namespace Ringtoets.Integration.Forms.Merge { partial class AssessmentSectionProviderDialog { @@ -28,12 +30,90 @@ /// private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); + 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 + // + this.tableLayoutPanel.ColumnCount = 1; + this.tableLayoutPanel.RowCount = 5; + this.tableLayoutPanel.Dock = DockStyle.Fill; + 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 + // + this.assessmentSectionSelectLabel.Text = "Selecteer traject:"; + this.assessmentSectionSelectLabel.Name = "assessmentSectionSelectLabel"; + // + // assessmentSectionComboBox + // + this.assessmentSectionComboBox.Name = "assessmentSectionComboBox"; + this.assessmentSectionComboBox.TabIndex = 0; + // + // dataGridViewControl + // + this.dataGridViewControl.MultiSelect = true; + this.dataGridViewControl.Name = "dataGridViewControl"; + // + // assessmentSectionSelectLabel + // + this.failureMechanismsSelectLabel.Text = "Selecteer toetssporen:"; + this.failureMechanismsSelectLabel.Name = "failureMechanismsSelectLabel"; + // + // flowLayoutPanelButtons + // + this.flowLayoutPanelButtons.Controls.Add(this.cancelButton); + this.flowLayoutPanelButtons.Controls.Add(this.importButton); + this.flowLayoutPanelButtons.Name = "flowLayoutPanelButtons"; + // + // cancelButton + // + this.cancelButton.Name = "cancelButton"; + this.cancelButton.Text = "Annuleren"; + this.cancelButton.UseVisualStyleBackColor = true; + // + // importButton + // + this.importButton.Name = "importButton"; + this.importButton.Text = "Importeren"; + this.importButton.UseVisualStyleBackColor = true; + // + // AssessmentSectionProviderDialog + // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "AssessmentSectionProviderDialog"; + this.Controls.Add(this.tableLayoutPanel); + this.Name = "AssessmentSectionProviderDialog"; + this.Text = "Selecteer trajectinformatie"; + this.tableLayoutPanel.ResumeLayout(false); + this.tableLayoutPanel.PerformLayout(); + this.flowLayoutPanelButtons.ResumeLayout(false); + this.flowLayoutPanelButtons.PerformLayout(); + this.ResumeLayout(false); } #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/AssessmentSectionProviderDialog.cs =================================================================== diff -u -r5541793b120764195e9409183cc51b7e97cae079 -r283277d753eec15fec834e7e24a0bf83342a5c09 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Merge/AssessmentSectionProviderDialog.cs (.../AssessmentSectionProviderDialog.cs) (revision 5541793b120764195e9409183cc51b7e97cae079) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Merge/AssessmentSectionProviderDialog.cs (.../AssessmentSectionProviderDialog.cs) (revision 283277d753eec15fec834e7e24a0bf83342a5c09) @@ -10,8 +10,7 @@ { public partial class AssessmentSectionProviderDialog : DialogBase, IMergeDataProvider { - public AssessmentSectionProviderDialog(IEnumerable assessmentSections, - IWin32Window dialogParent) + public AssessmentSectionProviderDialog(IWin32Window dialogParent, IEnumerable assessmentSections) : base(dialogParent, RingtoetsCommonFormsResources.SelectionDialogIcon, 500, 350) { if (assessmentSections == null) @@ -20,18 +19,29 @@ } InitializeComponent(); + InitializeDataGridView(); } - protected override Button GetCancelButton() - { - throw new NotImplementedException(); - } - public AssessmentSection SelectedAssessmentSection { get; } public IEnumerable SelectedFailureMechanisms { get; } + public bool SelectData(IEnumerable assessmentSections) { throw new NotImplementedException(); } + + 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); + } } } \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Merge/AssessmentSectionProviderDialog.resx =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Merge/AssessmentSectionProviderDialog.resx (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Merge/AssessmentSectionProviderDialog.resx (revision 283277d753eec15fec834e7e24a0bf83342a5c09) @@ -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/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj =================================================================== diff -u -r2f76dec1e282b3a6a8dc4fb593643248d36aac28 -r283277d753eec15fec834e7e24a0bf83342a5c09 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision 2f76dec1e282b3a6a8dc4fb593643248d36aac28) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision 283277d753eec15fec834e7e24a0bf83342a5c09) @@ -319,6 +319,9 @@ MergeDataProviderStub.cs + + AssessmentSectionProviderDialog.cs + PublicResXFileCodeGenerator Designer Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Merge/AssessmentSectionProviderDialogTest.cs =================================================================== diff -u -r5541793b120764195e9409183cc51b7e97cae079 -r283277d753eec15fec834e7e24a0bf83342a5c09 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Merge/AssessmentSectionProviderDialogTest.cs (.../AssessmentSectionProviderDialogTest.cs) (revision 5541793b120764195e9409183cc51b7e97cae079) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Merge/AssessmentSectionProviderDialogTest.cs (.../AssessmentSectionProviderDialogTest.cs) (revision 283277d753eec15fec834e7e24a0bf83342a5c09) @@ -3,8 +3,10 @@ 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.Forms.Properties; @@ -14,9 +16,27 @@ namespace Ringtoets.Integration.Forms.Test.Merge { [TestFixture] - public class AssessmentSectionProviderDialogTest + public class AssessmentSectionProviderDialogTest : 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 AssessmentSectionProviderDialog(null, Enumerable.Empty()); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("dialogParent", exception.ParamName); + } + + [Test] public void Constructor_AssessmentSectionsNull_ThrowsArgumentNullException() { // Setup @@ -25,7 +45,7 @@ mocks.ReplayAll(); // Call - TestDelegate call = () => new AssessmentSectionProviderDialog(null, dialogParent); + TestDelegate call = () => new AssessmentSectionProviderDialog(dialogParent, null); // Assert var exception = Assert.Throws(call); @@ -34,17 +54,6 @@ } [Test] - public void Constructor_DialogParentNull_ThrowsArgumentNullException() - { - // Call - TestDelegate call = () => new AssessmentSectionProviderDialog(Enumerable.Empty(), null); - - // Assert - var exception = Assert.Throws(call); - Assert.AreEqual("dialogParent", exception.ParamName); - } - - [Test] public void Constructor_ExpectedValues() { // Setup @@ -55,12 +64,14 @@ IEnumerable assessmentSections = Enumerable.Empty(); // Call - using (var dialog = new AssessmentSectionProviderDialog(assessmentSections, dialogParent)) + using (var dialog = new AssessmentSectionProviderDialog(dialogParent, assessmentSections)) { // 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(); @@ -70,6 +81,72 @@ mocks.VerifyAll(); } + [Test] + public void ShowDialog_Always_DefaultProperties() + { + // Setup + using (var dialogParent = new Form()) + using (var dialog = new AssessmentSectionProviderDialog(dialogParent, Enumerable.Empty())) + { + // Call + dialog.Show(); + + // Assert + 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); + + 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.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(500, dialog.MinimumSize.Width); + Assert.AreEqual(350, dialog.MinimumSize.Height); + } + } + private static Icon BitmapToIcon(Bitmap icon) { return Icon.FromHandle(icon.GetHicon());