Index: Riskeer/Common/test/Riskeer.Common.Forms.Test/Views/CalculationsViewTest.cs =================================================================== diff -u -rc622215237d325733df3e3b8d2ced554c615118c -r349e355fa968efd993e4d3d2fd642ffa96c8efa0 --- Riskeer/Common/test/Riskeer.Common.Forms.Test/Views/CalculationsViewTest.cs (.../CalculationsViewTest.cs) (revision c622215237d325733df3e3b8d2ced554c615118c) +++ Riskeer/Common/test/Riskeer.Common.Forms.Test/Views/CalculationsViewTest.cs (.../CalculationsViewTest.cs) (revision 349e355fa968efd993e4d3d2fd642ffa96c8efa0) @@ -208,6 +208,8 @@ public bool GenerateButtonClicked { get; private set; } + public int HydraulicBoundaryLocationChangedCounter { get; private set; } + protected override object CreateSelectedItemFromCurrentRow(TestCalculationRow currentRow) { return currentRow; @@ -241,6 +243,25 @@ { GenerateButtonClicked = true; } + + protected override void SubscribeToCalculationRow(TestCalculationRow calculationRow) + { + base.SubscribeToCalculationRow(calculationRow); + + calculationRow.HydraulicBoundaryLocationChanged += OnHydraulicBoundaryLocationChanged; + } + + protected override void UnsubscribeFromCalculationRow(TestCalculationRow calculationRow) + { + base.UnsubscribeFromCalculationRow(calculationRow); + + calculationRow.HydraulicBoundaryLocationChanged -= OnHydraulicBoundaryLocationChanged; + } + + private void OnHydraulicBoundaryLocationChanged(object sender, EventArgs e) + { + HydraulicBoundaryLocationChangedCounter++; + } } #region Initialization @@ -570,6 +591,30 @@ mocks.VerifyAll(); } + [Test] + [Apartment(ApartmentState.STA)] + public void CalculationsView_ChangingCellValueWhereSubscribed_CellValueEdited() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + TestCalculationsView calculationsView = ShowFullyConfiguredCalculationsView(assessmentSection); + + var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + + // Call + DataGridViewCell dataGridViewCell = dataGridView.Rows[0].Cells[selectableHydraulicBoundaryLocationsColumnIndex]; + dataGridView.CurrentCell = dataGridViewCell; + dataGridViewCell.Value = dataGridView.Rows[1].Cells[selectableHydraulicBoundaryLocationsColumnIndex].Value; + + // Assert + Assert.AreEqual(1, calculationsView.HydraulicBoundaryLocationChangedCounter); + WindowsFormsTestHelper.CloseAll(); + mocks.VerifyAll(); + } + #endregion #region Observers Index: Riskeer/Common/test/Riskeer.Common.Forms.TestUtil/TestCalculationRow.cs =================================================================== diff -u -rc622215237d325733df3e3b8d2ced554c615118c -r349e355fa968efd993e4d3d2fd642ffa96c8efa0 --- Riskeer/Common/test/Riskeer.Common.Forms.TestUtil/TestCalculationRow.cs (.../TestCalculationRow.cs) (revision c622215237d325733df3e3b8d2ced554c615118c) +++ Riskeer/Common/test/Riskeer.Common.Forms.TestUtil/TestCalculationRow.cs (.../TestCalculationRow.cs) (revision 349e355fa968efd993e4d3d2fd642ffa96c8efa0) @@ -33,6 +33,8 @@ /// public class TestCalculationRow : CalculationRow { + public event EventHandler HydraulicBoundaryLocationChanged; + /// /// Creates a new instance of . /// @@ -50,7 +52,12 @@ protected override HydraulicBoundaryLocation HydraulicBoundaryLocation { get => Calculation.InputParameters.HydraulicBoundaryLocation; - set => Calculation.InputParameters.HydraulicBoundaryLocation = value; + set + { + Calculation.InputParameters.HydraulicBoundaryLocation = value; + + HydraulicBoundaryLocationChanged?.Invoke(this, new EventArgs()); + } } } } \ No newline at end of file