Index: Riskeer/ClosingStructures/src/Riskeer.ClosingStructures.Forms/Views/ClosingStructuresCalculationRow.cs =================================================================== diff -u -r657f95dc50d360c668d21e1a25ae88a6b05a05b8 -rbe9cffbc5ed8f0a3787298d5693574e49bf94981 --- Riskeer/ClosingStructures/src/Riskeer.ClosingStructures.Forms/Views/ClosingStructuresCalculationRow.cs (.../ClosingStructuresCalculationRow.cs) (revision 657f95dc50d360c668d21e1a25ae88a6b05a05b8) +++ Riskeer/ClosingStructures/src/Riskeer.ClosingStructures.Forms/Views/ClosingStructuresCalculationRow.cs (.../ClosingStructuresCalculationRow.cs) (revision be9cffbc5ed8f0a3787298d5693574e49bf94981) @@ -138,7 +138,11 @@ get => CalculationScenario.InputParameters.UseBreakWater; set { - PropertyChangeHelper.ChangePropertyAndNotify(() => CalculationScenario.InputParameters.UseBreakWater = value, propertyChangeHandler); + if (!CalculationScenario.InputParameters.UseBreakWater.Equals(value)) + { + PropertyChangeHelper.ChangePropertyAndNotify(() => CalculationScenario.InputParameters.UseBreakWater = value, propertyChangeHandler); + } + UpdateUseBreakWaterColumnStateDefinitions(); } } @@ -151,7 +155,10 @@ get => CalculationScenario.InputParameters.BreakWater.Type; set { - PropertyChangeHelper.ChangePropertyAndNotify(() => CalculationScenario.InputParameters.BreakWater.Type = value, propertyChangeHandler); + if (!CalculationScenario.InputParameters.BreakWater.Type.Equals(value)) + { + PropertyChangeHelper.ChangePropertyAndNotify(() => CalculationScenario.InputParameters.BreakWater.Type = value, propertyChangeHandler); + } } } @@ -193,7 +200,10 @@ get => CalculationScenario.InputParameters.InflowModelType; set { - PropertyChangeHelper.ChangePropertyAndNotify(() => CalculationScenario.InputParameters.InflowModelType = value, propertyChangeHandler); + if (!CalculationScenario.InputParameters.InflowModelType.Equals(value)) + { + PropertyChangeHelper.ChangePropertyAndNotify(() => CalculationScenario.InputParameters.InflowModelType = value, propertyChangeHandler); + } } } Index: Riskeer/ClosingStructures/src/Riskeer.ClosingStructures.Forms/Views/ClosingStructuresCalculationsView.cs =================================================================== diff -u -r664975c4924bc7713f0b12795358a326e2d8638a -rbe9cffbc5ed8f0a3787298d5693574e49bf94981 --- Riskeer/ClosingStructures/src/Riskeer.ClosingStructures.Forms/Views/ClosingStructuresCalculationsView.cs (.../ClosingStructuresCalculationsView.cs) (revision 664975c4924bc7713f0b12795358a326e2d8638a) +++ Riskeer/ClosingStructures/src/Riskeer.ClosingStructures.Forms/Views/ClosingStructuresCalculationsView.cs (.../ClosingStructuresCalculationsView.cs) (revision be9cffbc5ed8f0a3787298d5693574e49bf94981) @@ -175,12 +175,11 @@ dataGridViewControl.AddCheckBoxColumn(nameof(ClosingStructuresCalculationRow.UseForeShoreGeometry), RiskeerCommonFormsResources.Use_ForeShore_DisplayName); - dataGridViewControl.AddComboBoxColumn>( - nameof(ClosingStructuresCalculationRow.InflowModelType), - RiskeerCommonFormsResources.Structure_InflowModelType_DisplayName, - null, - nameof(DataGridViewComboBoxItemWrapper.This), - nameof(DataGridViewComboBoxItemWrapper.DisplayName)); + dataGridViewControl.AddComboBoxColumn(nameof(ClosingStructuresCalculationRow.InflowModelType), + RiskeerCommonFormsResources.Structure_InflowModelType_DisplayName, + GetInflowModelTypes(), + nameof(EnumDisplayWrapper.Value), + nameof(EnumDisplayWrapper.DisplayName)); dataGridViewControl.AddTextBoxColumn( nameof(ClosingStructuresCalculationRow.MeanInsideWaterLevel), @@ -432,6 +431,14 @@ .ToArray(); } + private static IEnumerable> GetInflowModelTypes() + { + return Enum.GetValues(typeof(ClosingStructureInflowModelType)) + .OfType() + .Select(imt => new EnumDisplayWrapper(imt)) + .ToArray(); + } + private IEnumerable GetSelectableHydraulicBoundaryLocationsFromFailureMechanism() { List hydraulicBoundaryLocations = assessmentSection.HydraulicBoundaryDatabase.Locations; @@ -458,22 +465,22 @@ using (var dialog = new StructureSelectionDialog(Parent, failureMechanism.ClosingStructures)) { dialog.ShowDialog(); - //GenerateCalculations(calculationGroup, dialog.SelectedItems); + GenerateCalculations(calculationGroup, dialog.SelectedItems.Cast()); } calculationGroup.NotifyObservers(); } - private static void GenerateCalculations(CalculationGroup calculationGroup, IEnumerable foreshoreProfiles) + private static void GenerateCalculations(CalculationGroup calculationGroup, IEnumerable structures) { - foreach (ForeshoreProfile profile in foreshoreProfiles) + foreach (ClosingStructure structure in structures) { var calculation = new StructuresCalculationScenario { - Name = NamingHelper.GetUniqueName(calculationGroup.Children, profile.Name, c => c.Name), + Name = NamingHelper.GetUniqueName(calculationGroup.Children, structure.Name, c => c.Name), InputParameters = { - ForeshoreProfile = profile + Structure = structure } }; calculationGroup.Children.Add(calculation); Index: Riskeer/ClosingStructures/test/Riskeer.ClosingStructures.Forms.Test/Views/ClosingStructuresCalculationsViewTest.cs =================================================================== diff -u -r664975c4924bc7713f0b12795358a326e2d8638a -rbe9cffbc5ed8f0a3787298d5693574e49bf94981 --- Riskeer/ClosingStructures/test/Riskeer.ClosingStructures.Forms.Test/Views/ClosingStructuresCalculationsViewTest.cs (.../ClosingStructuresCalculationsViewTest.cs) (revision 664975c4924bc7713f0b12795358a326e2d8638a) +++ Riskeer/ClosingStructures/test/Riskeer.ClosingStructures.Forms.Test/Views/ClosingStructuresCalculationsViewTest.cs (.../ClosingStructuresCalculationsViewTest.cs) (revision be9cffbc5ed8f0a3787298d5693574e49bf94981) @@ -157,7 +157,7 @@ AssertColumnMembers(dataGridView.Columns.OfType().ToArray()); - // AssertDataGridViewControlColumnHeaders(dataGridView); + //AssertDataGridViewControlColumnHeaders(dataGridView); mocks.VerifyAll(); } @@ -355,7 +355,7 @@ Assert.AreEqual("Havendam", cells[breakWaterTypeColumnIndex].FormattedValue); Assert.AreEqual(3.30.ToString("0.00", CultureInfo.CurrentCulture), cells[breakWaterHeightColumnIndex].FormattedValue); Assert.AreEqual(false, cells[useForeShoreGeometryColumnIndex].FormattedValue); - Assert.AreEqual("", cells[inflowModelTypeColumnIndex].FormattedValue); + Assert.AreEqual("Verdronken koker", cells[inflowModelTypeColumnIndex].FormattedValue); Assert.AreEqual(0.30.ToString("0.00", CultureInfo.CurrentCulture), cells[meanInsideWaterLevelColumnIndex].FormattedValue); Assert.AreEqual(0.01.ToString("0.00", CultureInfo.CurrentCulture), cells[criticalOvertoppingDischargeColumnIndex].FormattedValue); Assert.AreEqual(100.0.ToString("0.00", CultureInfo.CurrentCulture), cells[allowedLevelIncreaseStorageColumnIndex].FormattedValue); @@ -461,49 +461,47 @@ mocks.VerifyAll(); } - // [Test] - // [TestCase(1, breakWaterHeightColumnIndex)] - // [TestCase(1e-2, breakWaterHeightColumnIndex)] - // [TestCase(1e+6, breakWaterHeightColumnIndex)] - // [TestCase(14.3, breakWaterHeightColumnIndex)] - // [TestCase(1, meanInsideWaterLevelColumnIndex)] - // [TestCase(1e+6, meanInsideWaterLevelColumnIndex)] - // [TestCase(14.3, meanInsideWaterLevelColumnIndex)] - // [TestCase(1, criticalOvertoppingDischargeColumnIndex)] - // [TestCase(1e-6, criticalOvertoppingDischargeColumnIndex)] - // [TestCase(1e+6, criticalOvertoppingDischargeColumnIndex)] - // [TestCase(14.3, criticalOvertoppingDischargeColumnIndex)] - // [TestCase(1, allowedLevelIncreaseStorageColumnIndex)] - // [TestCase(1e-6, allowedLevelIncreaseStorageColumnIndex)] - // [TestCase(1e+6, allowedLevelIncreaseStorageColumnIndex)] - // [TestCase(14.3, allowedLevelIncreaseStorageColumnIndex)] - // public void FailureMechanismResultView_EditValueValid_DoNotShowErrorToolTipAndEditValue(double newValue, int cellIndex) - // { - // // Setup - // var mocks = new MockRepository(); - // var assessmentSection = mocks.Stub(); - // mocks.ReplayAll(); - // - // ConfigureHydraulicBoundaryDatabase(assessmentSection); - // ClosingStructuresFailureMechanism failureMechanism = ConfigureFailureMechanism(); - // CalculationGroup calculationGroup = ConfigureCalculationGroup(failureMechanism, assessmentSection); - // - // var newRoundedValue = (RoundedDouble) newValue; - // - // ShowCalculationsView(calculationGroup, failureMechanism, assessmentSection); - // - // mocks.ReplayAll(); - // - // var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; - // - // // Call - // dataGridView.Rows[0].Cells[cellIndex].Value = newRoundedValue; - // - // // Assert - // Assert.IsEmpty(dataGridView.Rows[0].ErrorText); - // - // mocks.VerifyAll(); - // } + [Test] + [TestCase(1, breakWaterHeightColumnIndex)] + [TestCase(1e-2, breakWaterHeightColumnIndex)] + [TestCase(1e+6, breakWaterHeightColumnIndex)] + [TestCase(14.3, breakWaterHeightColumnIndex)] + [TestCase(1, meanInsideWaterLevelColumnIndex)] + [TestCase(1e+6, meanInsideWaterLevelColumnIndex)] + [TestCase(14.3, meanInsideWaterLevelColumnIndex)] + [TestCase(1, criticalOvertoppingDischargeColumnIndex)] + [TestCase(1e+6, criticalOvertoppingDischargeColumnIndex)] + [TestCase(14.3, criticalOvertoppingDischargeColumnIndex)] + [TestCase(1, allowedLevelIncreaseStorageColumnIndex)] + [TestCase(1e+6, allowedLevelIncreaseStorageColumnIndex)] + [TestCase(14.3, allowedLevelIncreaseStorageColumnIndex)] + public void FailureMechanismResultView_EditValueValid_DoNotShowErrorToolTipAndEditValue(double newValue, int cellIndex) + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + ConfigureHydraulicBoundaryDatabase(assessmentSection); + ClosingStructuresFailureMechanism failureMechanism = ConfigureFailureMechanism(); + CalculationGroup calculationGroup = ConfigureCalculationGroup(failureMechanism, assessmentSection); + + var newRoundedValue = (RoundedDouble) newValue; + + ShowCalculationsView(calculationGroup, failureMechanism, assessmentSection); + + mocks.ReplayAll(); + + var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + + // Call + dataGridView.Rows[0].Cells[cellIndex].Value = newRoundedValue; + + // Assert + Assert.IsEmpty(dataGridView.Rows[0].ErrorText); + + mocks.VerifyAll(); + } [Test] public void CalculationsViewWithFailureMechanism_WhenSectionsAddedAndFailureMechanismNotified_ThenSectionsListBoxCorrectlyUpdated() Index: Riskeer/ClosingStructures/test/Riskeer.ClosingStructures.Plugin.Test/ClosingStructuresPluginTest.cs =================================================================== diff -u -r95ce9d6e938ed15b9e5d3cf9b1ae6e5183674a6d -rbe9cffbc5ed8f0a3787298d5693574e49bf94981 --- Riskeer/ClosingStructures/test/Riskeer.ClosingStructures.Plugin.Test/ClosingStructuresPluginTest.cs (.../ClosingStructuresPluginTest.cs) (revision 95ce9d6e938ed15b9e5d3cf9b1ae6e5183674a6d) +++ Riskeer/ClosingStructures/test/Riskeer.ClosingStructures.Plugin.Test/ClosingStructuresPluginTest.cs (.../ClosingStructuresPluginTest.cs) (revision be9cffbc5ed8f0a3787298d5693574e49bf94981) @@ -123,7 +123,7 @@ ViewInfo[] viewInfos = plugin.GetViewInfos().ToArray(); // Assert - Assert.AreEqual(3, viewInfos.Length); + Assert.AreEqual(4, viewInfos.Length); PluginTestHelper.AssertViewInfoDefined( viewInfos, @@ -141,6 +141,12 @@ typeof(ClosingStructuresScenariosContext), typeof(CalculationGroup), typeof(ClosingStructuresScenariosView)); + + PluginTestHelper.AssertViewInfoDefined( + viewInfos, + typeof(ClosingStructuresCalculationGroupContext), + typeof(CalculationGroup), + typeof(ClosingStructuresCalculationsView)); } }