Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Dialogs/AssessmentSectionProviderStub.Designer.cs =================================================================== diff -u -rd9d47cee30e2987819dfb5b8c0c935ee4a72e52a -r19363f8d54d6b2a71613fa87e3c1d3c86c9c0af2 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Dialogs/AssessmentSectionProviderStub.Designer.cs (.../AssessmentSectionProviderStub.Designer.cs) (revision d9d47cee30e2987819dfb5b8c0c935ee4a72e52a) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Dialogs/AssessmentSectionProviderStub.Designer.cs (.../AssessmentSectionProviderStub.Designer.cs) (revision 19363f8d54d6b2a71613fa87e3c1d3c86c9c0af2) @@ -81,6 +81,7 @@ // invalidProjectButton // this.invalidProjectButton.AutoSize = true; + this.invalidProjectButton.DialogResult = System.Windows.Forms.DialogResult.OK; this.invalidProjectButton.Location = new System.Drawing.Point(130, 3); this.invalidProjectButton.Name = "invalidProjectButton"; this.invalidProjectButton.Size = new System.Drawing.Size(135, 23); @@ -91,22 +92,26 @@ // noMatchButton // this.noMatchButton.AutoSize = true; + this.noMatchButton.DialogResult = System.Windows.Forms.DialogResult.OK; this.noMatchButton.Location = new System.Drawing.Point(3, 32); this.noMatchButton.Name = "noMatchButton"; this.noMatchButton.Size = new System.Drawing.Size(262, 23); this.noMatchButton.TabIndex = 2; this.noMatchButton.Text = "Selecteer project zonder overeenkomende trajecten"; this.noMatchButton.UseVisualStyleBackColor = true; + this.noMatchButton.Click += new System.EventHandler(this.noMatchButton_Click); // // matchButton // this.matchButton.AutoSize = true; + this.matchButton.DialogResult = System.Windows.Forms.DialogResult.OK; this.matchButton.Location = new System.Drawing.Point(3, 61); this.matchButton.Name = "matchButton"; this.matchButton.Size = new System.Drawing.Size(262, 23); this.matchButton.TabIndex = 3; this.matchButton.Text = "Selecteer project met overeenkomend traject"; this.matchButton.UseVisualStyleBackColor = true; + this.matchButton.Click += new System.EventHandler(this.matchButton_Click); // // AssessmentSectionProviderStub // @@ -119,6 +124,7 @@ this.flowLayoutPanel.ResumeLayout(false); this.flowLayoutPanel.PerformLayout(); this.ResumeLayout(false); + } #endregion Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Dialogs/AssessmentSectionProviderStub.cs =================================================================== diff -u -r3c4b3ed1591216f9b3b40534e35c6df156495514 -r19363f8d54d6b2a71613fa87e3c1d3c86c9c0af2 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Dialogs/AssessmentSectionProviderStub.cs (.../AssessmentSectionProviderStub.cs) (revision 3c4b3ed1591216f9b3b40534e35c6df156495514) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Dialogs/AssessmentSectionProviderStub.cs (.../AssessmentSectionProviderStub.cs) (revision 19363f8d54d6b2a71613fa87e3c1d3c86c9c0af2) @@ -21,8 +21,10 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Windows.Forms; using Core.Common.Controls.Dialogs; +using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Integration.Data; using Ringtoets.Integration.Service.Merge; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; @@ -34,6 +36,8 @@ /// public partial class AssessmentSectionProviderStub : DialogBase, IAssessmentSectionProvider { + private IEnumerable assessmentSectionsToReturn; + /// /// Creates a new instance of . /// @@ -47,17 +51,28 @@ public IEnumerable GetAssessmentSections(string filePath) { - if (ShowDialog() == DialogResult.Cancel) - { - return null; - } - - return new List(); + return ShowDialog() == DialogResult.OK + ? assessmentSectionsToReturn + : null; } protected override Button GetCancelButton() { return cancelButton; } + + private void noMatchButton_Click(object sender, EventArgs e) + { + assessmentSectionsToReturn = Enumerable.Empty(); + } + + private void matchButton_Click(object sender, EventArgs e) + { + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + assessmentSectionsToReturn = new[] + { + assessmentSection + }; + } } } \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Dialogs/AssessmentSectionProviderStubTest.cs =================================================================== diff -u -r3c4b3ed1591216f9b3b40534e35c6df156495514 -r19363f8d54d6b2a71613fa87e3c1d3c86c9c0af2 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Dialogs/AssessmentSectionProviderStubTest.cs (.../AssessmentSectionProviderStubTest.cs) (revision 3c4b3ed1591216f9b3b40534e35c6df156495514) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Dialogs/AssessmentSectionProviderStubTest.cs (.../AssessmentSectionProviderStubTest.cs) (revision 19363f8d54d6b2a71613fa87e3c1d3c86c9c0af2) @@ -20,6 +20,7 @@ // All rights reserved. using System.Collections.Generic; +using System.Linq; using System.Windows.Forms; using Core.Common.Controls.Dialogs; using NUnit.Extensions.Forms; @@ -56,11 +57,14 @@ public void GetAssessmentSections_Always_ShowsDialog() { // Setup + Button cancelButton = null; + DialogBoxHandler = (name, wnd) => { using (new FormTester(name)) { var button = new ButtonTester("cancelButton", name); + cancelButton = (Button) button.TheObject; button.Click(); } }; @@ -72,20 +76,20 @@ provider.GetAssessmentSections(null); // Assert - var invalidProjectButtonSelect = (Button)new ButtonTester("invalidProjectButton", provider).TheObject; + var invalidProjectButtonSelect = (Button) new ButtonTester("invalidProjectButton", provider).TheObject; Assert.AreEqual("Selecteer fout project", invalidProjectButtonSelect.Text); Assert.IsTrue(invalidProjectButtonSelect.Enabled); - var noMatchButtonSelect = (Button)new ButtonTester("noMatchButton", provider).TheObject; + var noMatchButtonSelect = (Button) new ButtonTester("noMatchButton", provider).TheObject; Assert.AreEqual("Selecteer project zonder overeenkomende trajecten", noMatchButtonSelect.Text); Assert.IsTrue(noMatchButtonSelect.Enabled); - var matchButtonSelect = (Button)new ButtonTester("matchButton", provider).TheObject; + var matchButtonSelect = (Button) new ButtonTester("matchButton", provider).TheObject; Assert.AreEqual("Selecteer project met overeenkomend traject", matchButtonSelect.Text); Assert.IsTrue(matchButtonSelect.Enabled); - var buttonCancel = (Button)new ButtonTester("cancelButton", provider).TheObject; - Assert.AreEqual("Annuleren", buttonCancel.Text); + Assert.AreEqual("Annuleren", cancelButton.Text); + Assert.AreEqual(cancelButton, provider.CancelButton); Assert.AreEqual(1, provider.MinimumSize.Width); Assert.AreEqual(1, provider.MinimumSize.Height); @@ -96,14 +100,11 @@ public void GivenDialog_WhenCancelPressed_ThenReturnNull() { // Setup - Button cancelButton = null; - DialogBoxHandler = (name, wnd) => { using (new FormTester(name)) { var button = new ButtonTester("cancelButton", name); - cancelButton = (Button) button.TheObject; button.Click(); } }; @@ -116,8 +117,79 @@ // Assert Assert.IsNull(assessmentSections); - Assert.AreEqual(provider.CancelButton, cancelButton); } } + + [Test] + public void GivenDialog_WhenInvalidProjectButtonPressed_ThenReturnNull() + { + // Setup + DialogBoxHandler = (name, wnd) => + { + using (new FormTester(name)) + { + var button = new ButtonTester("invalidProjectButton", name); + button.Click(); + } + }; + + using (var dialogParent = new Form()) + using (var provider = new AssessmentSectionProviderStub(dialogParent)) + { + // Call + IEnumerable assessmentSections = provider.GetAssessmentSections(null); + + // Assert + Assert.IsNull(assessmentSections); + } + } + + [Test] + public void GivenDialog_WhenNoMatchButtonPressed_ThenReturnEmptyCollection() + { + // Setup + DialogBoxHandler = (name, wnd) => + { + using (new FormTester(name)) + { + var button = new ButtonTester("noMatchButton", name); + button.Click(); + } + }; + + using (var dialogParent = new Form()) + using (var provider = new AssessmentSectionProviderStub(dialogParent)) + { + // Call + IEnumerable assessmentSections = provider.GetAssessmentSections(null); + + // Assert + CollectionAssert.IsEmpty(assessmentSections); + } + } + + [Test] + public void GivenDialog_WhenMatchButtonPressed_ThenReturnCollectionWithOneAssessmentSection() + { + // Setup + DialogBoxHandler = (name, wnd) => + { + using (new FormTester(name)) + { + var button = new ButtonTester("matchButton", name); + button.Click(); + } + }; + + using (var dialogParent = new Form()) + using (var provider = new AssessmentSectionProviderStub(dialogParent)) + { + // Call + IEnumerable assessmentSections = provider.GetAssessmentSections(null); + + // Assert + Assert.AreEqual(1, assessmentSections.Count()); + } + } } } \ No newline at end of file