Index: Core/Common/test/Core.Common.Controls.Test/DataGrid/DataGridViewComboBoxItemWrapperTest.cs =================================================================== diff -u -r112a4274ab494057ed0a24f5f9c2e1ec3ce3cea8 -r9ae12afceb5ab8bf068abdcf70b0e516393e355e --- Core/Common/test/Core.Common.Controls.Test/DataGrid/DataGridViewComboBoxItemWrapperTest.cs (.../DataGridViewComboBoxItemWrapperTest.cs) (revision 112a4274ab494057ed0a24f5f9c2e1ec3ce3cea8) +++ Core/Common/test/Core.Common.Controls.Test/DataGrid/DataGridViewComboBoxItemWrapperTest.cs (.../DataGridViewComboBoxItemWrapperTest.cs) (revision 9ae12afceb5ab8bf068abdcf70b0e516393e355e) @@ -16,7 +16,6 @@ var dataGridViewComboBoxItemWrapper = new DataGridViewComboBoxItemWrapper(testClass); // Assert - Assert.AreEqual("Test class", dataGridViewComboBoxItemWrapper.ToString()); Assert.AreEqual("Test class", dataGridViewComboBoxItemWrapper.DisplayName); Assert.AreEqual(testClass, dataGridViewComboBoxItemWrapper.WrappedObject); Assert.AreEqual(dataGridViewComboBoxItemWrapper, dataGridViewComboBoxItemWrapper.This); @@ -25,20 +24,39 @@ [Test] public void Constructor_WithWrappedObjectNull_ExpectedValues() { - // Setup - var testClass = new TestClass(); - // Call var dataGridViewComboBoxItemWrapper = new DataGridViewComboBoxItemWrapper(null); // Assert - Assert.AreEqual(Properties.Resources.DataGridViewComboBoxItemWrapper_DisplayName_None, dataGridViewComboBoxItemWrapper.ToString()); Assert.AreEqual(Properties.Resources.DataGridViewComboBoxItemWrapper_DisplayName_None, dataGridViewComboBoxItemWrapper.DisplayName); Assert.IsNull(dataGridViewComboBoxItemWrapper.WrappedObject); Assert.AreEqual(dataGridViewComboBoxItemWrapper, dataGridViewComboBoxItemWrapper.This); } [Test] + public void ToString_WithWrappedObject_ReturnsDisplayName() + { + // Setup + var testClass = new TestClass(); + + // Call + var dataGridViewComboBoxItemWrapper = new DataGridViewComboBoxItemWrapper(testClass); + + // Assert + Assert.AreEqual(dataGridViewComboBoxItemWrapper.DisplayName, dataGridViewComboBoxItemWrapper.ToString()); + } + + [Test] + public void ToString_WithWrappedObjectNull_ReturnsDisplayName() + { + // Call + var dataGridViewComboBoxItemWrapper = new DataGridViewComboBoxItemWrapper(null); + + // Assert + Assert.AreEqual(dataGridViewComboBoxItemWrapper.DisplayName, dataGridViewComboBoxItemWrapper.ToString()); + } + + [Test] public void Equals_EqualsWithItself_ReturnTrue() { // Setup Index: Core/Common/test/Core.Common.Utils.Test/IO/EmbeddedResourceFileWriterTest.cs =================================================================== diff -u -rf9f9c0b7a1648fa87a6b423140e09d29c4b26a9d -r9ae12afceb5ab8bf068abdcf70b0e516393e355e --- Core/Common/test/Core.Common.Utils.Test/IO/EmbeddedResourceFileWriterTest.cs (.../EmbeddedResourceFileWriterTest.cs) (revision f9f9c0b7a1648fa87a6b423140e09d29c4b26a9d) +++ Core/Common/test/Core.Common.Utils.Test/IO/EmbeddedResourceFileWriterTest.cs (.../EmbeddedResourceFileWriterTest.cs) (revision 9ae12afceb5ab8bf068abdcf70b0e516393e355e) @@ -37,6 +37,12 @@ // Assert Assert.AreEqual(!removeFilesOnDispose, File.Exists(Path.Combine(targetFolderPath, "EmbeddedResource1.txt"))); Assert.AreEqual(!removeFilesOnDispose, File.Exists(Path.Combine(targetFolderPath, "EmbeddedResource2.txt"))); + + // Cleanup + if (!removeFilesOnDispose) + { + Directory.Delete(targetFolderPath, true); + } } [TestCase(true)] Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingCalculationsView.cs =================================================================== diff -u -rb7c59ffa650714887cb57f30453ad06ff30d4779 -r9ae12afceb5ab8bf068abdcf70b0e516393e355e --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingCalculationsView.cs (.../PipingCalculationsView.cs) (revision b7c59ffa650714887cb57f30453ad06ff30d4779) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingCalculationsView.cs (.../PipingCalculationsView.cs) (revision 9ae12afceb5ab8bf068abdcf70b0e516393e355e) @@ -163,7 +163,7 @@ private void InitializeDataGridView() { dataGridView.CurrentCellDirtyStateChanged += DataGridViewCurrentCellDirtyStateChanged; - dataGridView.RowEnter += DataGridViewRowEnter; + dataGridView.CellClick += DataGridViewOnCellClick; var nameColumn = new DataGridViewTextBoxColumn { @@ -598,20 +598,20 @@ } } - private void DataGridViewRowEnter(object sender, DataGridViewCellEventArgs e) + private void DataGridViewOnCellClick(object sender, DataGridViewCellEventArgs e) { if (updatingDataSource) { return; } - UpdateApplicationSelection((PipingCalculationRow) dataGridView.Rows[e.RowIndex].DataBoundItem); + UpdateApplicationSelection(); } private void ListBoxOnSelectedValueChanged(object sender, EventArgs e) { UpdateDataGridViewDataSource(); - UpdateApplicationSelection(dataGridView.CurrentRow != null ? (PipingCalculationRow) dataGridView.CurrentRow.DataBoundItem : null); + UpdateApplicationSelection(); } private void OnGenerateScenariosButtonClick(object sender, EventArgs e) @@ -630,13 +630,17 @@ pipingCalculationGroup.NotifyObservers(); } - private void UpdateApplicationSelection(PipingCalculationRow pipingCalculationRow) + private void UpdateApplicationSelection() { if (ApplicationSelection == null) { return; } + var pipingCalculationRow = dataGridView.CurrentRow != null + ? (PipingCalculationRow) dataGridView.CurrentRow.DataBoundItem + : null; + PipingInputContext selection = null; if (pipingCalculationRow != null) { @@ -646,7 +650,12 @@ pipingFailureMechanism.StochasticSoilModels, assessmentSection); } - ApplicationSelection.Selection = selection; + + if ((ApplicationSelection.Selection == null && selection != null) + || (ApplicationSelection.Selection != null && !ApplicationSelection.Selection.Equals(selection))) + { + ApplicationSelection.Selection = selection; + } } # endregion Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationsViewTest.cs =================================================================== diff -u -r5782c43794d78fe92cd8864cd8f8b0b53957ec06 -r9ae12afceb5ab8bf068abdcf70b0e516393e355e --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationsViewTest.cs (.../PipingCalculationsViewTest.cs) (revision 5782c43794d78fe92cd8864cd8f8b0b53957ec06) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationsViewTest.cs (.../PipingCalculationsViewTest.cs) (revision 9ae12afceb5ab8bf068abdcf70b0e516393e355e) @@ -309,7 +309,7 @@ } [Test] - public void PipingCalculationsView_EnteringRow_ApplicationSelectionCorrectlySynced() + public void PipingCalculationsView_SelectingCell_ApplicationSelectionCorrectlySynced() { // Setup var pipingCalculationsView = ShowFullyConfiguredPipingCalculationsView(); @@ -323,7 +323,7 @@ // Call dataGridView.CurrentCell = dataGridView.Rows[1].Cells[0]; - dataGridView.BeginEdit(true); + EventHelper.RaiseEvent(dataGridView, "CellClick", new DataGridViewCellEventArgs(1, 0)); // Assert var pipingInputContext = pipingCalculationsView.ApplicationSelection.Selection as PipingInputContext;