Index: Core/Common/test/Core.Common.Controls.Test/DataGrid/DataGridViewControlTest.cs =================================================================== diff -u -r2d014f7589947c4c9e34140b42687e496ee04c5f -r373e1f071d233dc36d360e9904fa6718af742200 --- Core/Common/test/Core.Common.Controls.Test/DataGrid/DataGridViewControlTest.cs (.../DataGridViewControlTest.cs) (revision 2d014f7589947c4c9e34140b42687e496ee04c5f) +++ Core/Common/test/Core.Common.Controls.Test/DataGrid/DataGridViewControlTest.cs (.../DataGridViewControlTest.cs) (revision 373e1f071d233dc36d360e9904fa6718af742200) @@ -1252,11 +1252,8 @@ public void SetColumnVisibility_IsVisible_SetColumnToGivenVisibility(bool isVisible) { // Setup - using (var form = new Form()) using (var control = new DataGridViewControl()) { - form.Controls.Add(control); - control.AddTextBoxColumn("Test property", "Test header"); DataGridViewColumn dataGridViewColumn = control.GetColumnFromIndex(0); Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/IllustrationPoints/TestSubMechanismIllustrationPointTest.cs =================================================================== diff -u -r2d014f7589947c4c9e34140b42687e496ee04c5f -r373e1f071d233dc36d360e9904fa6718af742200 --- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/IllustrationPoints/TestSubMechanismIllustrationPointTest.cs (.../TestSubMechanismIllustrationPointTest.cs) (revision 2d014f7589947c4c9e34140b42687e496ee04c5f) +++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/IllustrationPoints/TestSubMechanismIllustrationPointTest.cs (.../TestSubMechanismIllustrationPointTest.cs) (revision 373e1f071d233dc36d360e9904fa6718af742200) @@ -44,7 +44,7 @@ } [Test] - public void ParameterdConstructor_ExpectedValues() + public void ParameteredConstructor_ExpectedValues() { // Setup const double beta = 1.23; Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/IllustrationPointsControlTest.cs =================================================================== diff -u -r2d014f7589947c4c9e34140b42687e496ee04c5f -r373e1f071d233dc36d360e9904fa6718af742200 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/IllustrationPointsControlTest.cs (.../IllustrationPointsControlTest.cs) (revision 2d014f7589947c4c9e34140b42687e496ee04c5f) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/IllustrationPointsControlTest.cs (.../IllustrationPointsControlTest.cs) (revision 373e1f071d233dc36d360e9904fa6718af742200) @@ -70,8 +70,8 @@ form.Controls.Add(control); form.Show(); - IllustrationPointsChartControl chartControl = ControlTestHelper.GetControls(form, "IllustrationPointsChartControl").First(); - IllustrationPointsTableControl tableControl = ControlTestHelper.GetControls(form, "IllustrationPointsTableControl").First(); + IllustrationPointsChartControl chartControl = ControlTestHelper.GetControls(form, "IllustrationPointsChartControl").Single(); + IllustrationPointsTableControl tableControl = ControlTestHelper.GetControls(form, "IllustrationPointsTableControl").Single(); var data = new TestGeneralResultSubMechanismIllustrationPoint(); @@ -100,7 +100,7 @@ var selectionChangedCount = 0; control.SelectionChanged += (sender, args) => selectionChangedCount++; - IllustrationPointsTableControl tableControl = ControlTestHelper.GetControls(form, "IllustrationPointsTableControl").First(); + IllustrationPointsTableControl tableControl = ControlTestHelper.GetControls(form, "IllustrationPointsTableControl").Single(); // When EventHelper.RaiseEvent(tableControl, "SelectionChanged"); @@ -130,7 +130,7 @@ new TestSubMechanismIllustrationPoint()) }); - IllustrationPointsTableControl tableControl = ControlTestHelper.GetControls(form, "IllustrationPointsTableControl").First(); + IllustrationPointsTableControl tableControl = ControlTestHelper.GetControls(form, "IllustrationPointsTableControl").Single(); DataGridViewControl dataGridView = ControlTestHelper.GetDataGridViewControl(form, "illustrationPointsDataGridViewControl"); DataGridViewRow selectedLocationRow = dataGridView.Rows[0]; selectedLocationRow.Cells[0].Value = true; Index: Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil.Test/ControlTestHelperTest.cs =================================================================== diff -u -r2d014f7589947c4c9e34140b42687e496ee04c5f -r373e1f071d233dc36d360e9904fa6718af742200 --- Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil.Test/ControlTestHelperTest.cs (.../ControlTestHelperTest.cs) (revision 2d014f7589947c4c9e34140b42687e496ee04c5f) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil.Test/ControlTestHelperTest.cs (.../ControlTestHelperTest.cs) (revision 373e1f071d233dc36d360e9904fa6718af742200) @@ -124,7 +124,7 @@ } [Test] - public void GetControl_NoControlsOnForm_ReturnEmptyList() + public void GetControls_NoControlsOnForm_ReturnEmptyList() { // Call IEnumerable controls = ControlTestHelper.GetControls(new Form(), "name"); @@ -134,7 +134,7 @@ } [Test] - public void GetControl_ControlsOnFormWithSameName_ReturnControls() + public void GetControls_ControlsOnFormWithSameName_ReturnControls() { // Setup const string controlName = "control"; @@ -164,7 +164,7 @@ } [Test] - public void GetControl_ControlOnForm_ReturnControl() + public void GetControls_ControlOnForm_ReturnControl() { // Setup using (var form = new Form()) @@ -190,5 +190,34 @@ }, controls); } } + + [Test] + public void GetControls_DifferentControlsWithSameName_ReturnUserControl() + { + // Setup + const string controlName = "control"; + using (var form = new Form()) + using (var userControl = new UserControl + { + Name = controlName + }) + using (var control = new Control + { + Name = controlName + }) + { + form.Controls.Add(userControl); + form.Controls.Add(control); + + // Call + IEnumerable controls = ControlTestHelper.GetControls(form, controlName); + + // Assert + CollectionAssert.AreEqual(new[] + { + userControl + }, controls); + } + } } } \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil/ControlTestHelper.cs =================================================================== diff -u -r2d014f7589947c4c9e34140b42687e496ee04c5f -r373e1f071d233dc36d360e9904fa6718af742200 --- Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil/ControlTestHelper.cs (.../ControlTestHelper.cs) (revision 2d014f7589947c4c9e34140b42687e496ee04c5f) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil/ControlTestHelper.cs (.../ControlTestHelper.cs) (revision 373e1f071d233dc36d360e9904fa6718af742200) @@ -38,7 +38,7 @@ /// The form to get the control from. /// The name of the control. /// The found control. - /// Thrown when is null or empty. + /// Thrown when is null or empty. public static DataGridViewControl GetDataGridViewControl(Form form, string controlName) { return GetControls(form, controlName).FirstOrDefault(); @@ -50,7 +50,7 @@ /// The control to get the nested control from. /// The name of the control. /// The found control. - /// Thrown when is null or empty. + /// Thrown when is null or empty. public static DataGridView GetDataGridView(Control control, string controlName) { return GetControls(control, controlName).FirstOrDefault(); @@ -62,10 +62,10 @@ /// The control to get the nested control from. /// The name of the controls. /// The found controls. - /// Thrown when is null or empty. + /// Thrown when is null or empty. public static IEnumerable GetControls(Control control, string controlName) where TView : Control { - return control.Controls.Find(controlName, true).Cast(); + return control.Controls.Find(controlName, true).OfType(); } } } \ No newline at end of file