Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/GrassCoverErosionInwardsDikeProfileSelectionDialogTest.cs =================================================================== diff -u -rce871f8d394d4539208c9ef68372dd9d64ae1941 -r6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/GrassCoverErosionInwardsDikeProfileSelectionDialogTest.cs (.../GrassCoverErosionInwardsDikeProfileSelectionDialogTest.cs) (revision ce871f8d394d4539208c9ef68372dd9d64ae1941) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/GrassCoverErosionInwardsDikeProfileSelectionDialogTest.cs (.../GrassCoverErosionInwardsDikeProfileSelectionDialogTest.cs) (revision 6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a) @@ -47,32 +47,41 @@ [Test] public void Constructor_WithoutDikeProfiles_ThrowsArgumentNullException() { - // Call - TestDelegate test = () => new GrassCoverErosionInwardsDikeProfileSelectionDialog(new Form(), null); + // Setup + using (var viewParent = new Form()) + { + // Call + TestDelegate test = () => new GrassCoverErosionInwardsDikeProfileSelectionDialog(viewParent, null); - // Assert - var parameter = Assert.Throws(test).ParamName; - Assert.AreEqual("dikeProfiles", parameter); + // Assert + var parameter = Assert.Throws(test).ParamName; + Assert.AreEqual("dikeProfiles", parameter); + } } [Test] public void Constructor_WithParentAndDikeProfiles_DefaultProperties() { - // Call - using (var dialog = new GrassCoverErosionInwardsDikeProfileSelectionDialog(new Form(), Enumerable.Empty())) + // Setup + using (var viewParent = new Form()) { - // Assert - Assert.IsEmpty(dialog.SelectedDikeProfiles); - Assert.IsInstanceOf(new ControlTester("GrassCoverErosionInwardsDikeProfileSelectionView", dialog).TheObject); - Assert.AreEqual("Selecteer dijkprofielen", dialog.Text); + // Call + using (var dialog = new GrassCoverErosionInwardsDikeProfileSelectionDialog(viewParent, Enumerable.Empty())) + { + // Assert + Assert.IsEmpty(dialog.SelectedDikeProfiles); + Assert.IsInstanceOf(new ControlTester("GrassCoverErosionInwardsDikeProfileSelectionView", dialog).TheObject); + Assert.AreEqual("Selecteer dijkprofielen", dialog.Text); + } } } [Test] public void OnLoad_Always_SetMinimumSize() { // Setup - using (var dialog = new GrassCoverErosionInwardsDikeProfileSelectionDialog(new Form(), Enumerable.Empty())) + using (var viewParent = new Form()) + using (var dialog = new GrassCoverErosionInwardsDikeProfileSelectionDialog(viewParent, Enumerable.Empty())) { // Call dialog.Show(); @@ -93,17 +102,20 @@ CreateDikeProfile() }; - var dialog = new GrassCoverErosionInwardsDikeProfileSelectionDialog(new Form(), dikeProfiles); - var selectionView = (DataGridView) new ControlTester("DikeProfileDataGrid", dialog).TheObject; + using (var viewParent = new Form()) + using (var dialog = new GrassCoverErosionInwardsDikeProfileSelectionDialog(viewParent, dikeProfiles)) + { + var selectionView = (DataGridView) new ControlTester("DikeProfileDataGrid", dialog).TheObject; - dialog.Show(); - selectionView.Rows[0].Cells[0].Value = true; + dialog.Show(); + selectionView.Rows[0].Cells[0].Value = true; - // When - dialog.Close(); + // When + dialog.Close(); - // Then - Assert.IsEmpty(dialog.SelectedDikeProfiles); + // Then + Assert.IsEmpty(dialog.SelectedDikeProfiles); + } } [Test] @@ -117,18 +129,21 @@ CreateDikeProfile() }; - var dialog = new GrassCoverErosionInwardsDikeProfileSelectionDialog(new Form(), dikeProfiles); - var selectionView = (DataGridView) new ControlTester("DikeProfileDataGrid", dialog).TheObject; + using (var viewParent = new Form()) + using (var dialog = new GrassCoverErosionInwardsDikeProfileSelectionDialog(viewParent, dikeProfiles)) + { + var selectionView = (DataGridView) new ControlTester("DikeProfileDataGrid", dialog).TheObject; - dialog.Show(); - selectionView.Rows[0].Cells[0].Value = true; + dialog.Show(); + selectionView.Rows[0].Cells[0].Value = true; - // When - var cancelButton = new ButtonTester("CustomCancelButton", dialog); - cancelButton.Click(); + // When + var cancelButton = new ButtonTester("CustomCancelButton", dialog); + cancelButton.Click(); - // Then - Assert.IsEmpty(dialog.SelectedDikeProfiles); + // Then + Assert.IsEmpty(dialog.SelectedDikeProfiles); + } } [Test] @@ -142,22 +157,25 @@ CreateDikeProfile() }; - var dialog = new GrassCoverErosionInwardsDikeProfileSelectionDialog(new Form(), dikeProfiles); - var selectionView = (DataGridView) new ControlTester("DikeProfileDataGrid", dialog).TheObject; + using (var viewParent = new Form()) + using (var dialog = new GrassCoverErosionInwardsDikeProfileSelectionDialog(viewParent, dikeProfiles)) + { + var selectionView = (DataGridView) new ControlTester("DikeProfileDataGrid", dialog).TheObject; - dialog.Show(); - selectionView.Rows[0].Cells[0].Value = true; + dialog.Show(); + selectionView.Rows[0].Cells[0].Value = true; - // When - var okButton = new ButtonTester("OkButton", dialog); - okButton.Click(); + // When + var okButton = new ButtonTester("OkButton", dialog); + okButton.Click(); - // Then - var result = dialog.SelectedDikeProfiles; - CollectionAssert.AreEqual(new[] - { - selectedDikeProfile - }, result); + // Then + var result = dialog.SelectedDikeProfiles; + CollectionAssert.AreEqual(new[] + { + selectedDikeProfile + }, result); + } } private DikeProfile CreateDikeProfile()