Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveConditionsCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -rd689ea05c1014eb4d51b927e11eb6c48255f0a47 -r0f6049b15bcadf8de3a59c74e829f27bb725c013 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveConditionsCalculationContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsWaveConditionsCalculationContextTreeNodeInfoTest.cs) (revision d689ea05c1014eb4d51b927e11eb6c48255f0a47) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveConditionsCalculationContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsWaveConditionsCalculationContextTreeNodeInfoTest.cs) (revision 0f6049b15bcadf8de3a59c74e829f27bb725c013) @@ -182,8 +182,8 @@ var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); var context = new GrassCoverErosionOutwardsWaveConditionsCalculationContext(calculation, - failureMechanism, - assessmentSection); + failureMechanism, + assessmentSection); const string name = "the new name!"; // Call @@ -207,12 +207,12 @@ var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); failureMechanism.WaveConditionsCalculationGroup.Children.Add(calculation); var context = new GrassCoverErosionOutwardsWaveConditionsCalculationContext(calculation, - failureMechanism, - assessmentSection); + failureMechanism, + assessmentSection); var parentContext = new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, - failureMechanism, - assessmentSection); + failureMechanism, + assessmentSection); // Call bool canRemoveCalculation = info.CanRemove(context, parentContext); @@ -234,12 +234,12 @@ }; var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); var context = new GrassCoverErosionOutwardsWaveConditionsCalculationContext(calculation, - failureMechanism, - assessmentSection); + failureMechanism, + assessmentSection); var parentContext = new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, - failureMechanism, - assessmentSection); + failureMechanism, + assessmentSection); // Call bool canRemoveCalculation = info.CanRemove(context, parentContext); @@ -265,12 +265,12 @@ failureMechanism.WaveConditionsCalculationGroup.Children.Add(calculation); failureMechanism.WaveConditionsCalculationGroup.Attach(observer); var context = new GrassCoverErosionOutwardsWaveConditionsCalculationContext(calculation, - failureMechanism, - assessmentSection); + failureMechanism, + assessmentSection); var parentContext = new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, - failureMechanism, - assessmentSection); + failureMechanism, + assessmentSection); // Call info.OnNodeRemoved(context, parentContext); @@ -301,8 +301,8 @@ var calculation = new GrassCoverErosionOutwardsWaveConditionsCalculation(); var context = new GrassCoverErosionOutwardsWaveConditionsCalculationContext(calculation, - failureMechanism, - assessmentSection); + failureMechanism, + assessmentSection); var menuBuilderMock = mocks.StrictMock(); menuBuilderMock.Expect(mb => mb.AddExportItem()).Return(menuBuilderMock); @@ -341,20 +341,15 @@ { // Given var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("A", new[] - { - new Point2D(0, 0), - new Point2D(1, 1) - })); var assessmentSection = mocks.Stub(); var calculation = new GrassCoverErosionOutwardsWaveConditionsCalculation { Name = "A" }; var context = new GrassCoverErosionOutwardsWaveConditionsCalculationContext(calculation, - failureMechanism, - assessmentSection); + failureMechanism, + assessmentSection); using (var treeViewControl = new TreeViewControl()) { @@ -394,11 +389,6 @@ { // Given var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("A", new[] - { - new Point2D(0, 0), - new Point2D(1, 1) - })); var assessmentSection = mocks.Stub(); assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); @@ -407,8 +397,8 @@ Name = "A" }; var context = new GrassCoverErosionOutwardsWaveConditionsCalculationContext(calculation, - failureMechanism, - assessmentSection); + failureMechanism, + assessmentSection); using (var treeViewControl = new TreeViewControl()) { @@ -451,11 +441,6 @@ Path.Combine("HydraulicBoundaryLocationReader", "complete.sqlite")); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("A", new[] - { - new Point2D(0, 0), - new Point2D(1, 1) - })); var assessmentSection = mocks.Stub(); assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase { @@ -467,8 +452,8 @@ Name = "A" }; var context = new GrassCoverErosionOutwardsWaveConditionsCalculationContext(calculation, - failureMechanism, - assessmentSection); + failureMechanism, + assessmentSection); using (var treeViewControl = new TreeViewControl()) { @@ -510,11 +495,6 @@ Path.Combine("HydraulicBoundaryLocationReader", "complete.sqlite")); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("A", new[] - { - new Point2D(0, 0), - new Point2D(1, 1) - })); var assessmentSection = mocks.Stub(); assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase { @@ -531,19 +511,19 @@ { HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "", 1, 1) { - DesignWaterLevel = (RoundedDouble)12.0 + DesignWaterLevel = (RoundedDouble) 12.0 }, - LowerBoundaryRevetment = (RoundedDouble)1.0, - UpperBoundaryRevetment = (RoundedDouble)10.0, + LowerBoundaryRevetment = (RoundedDouble) 1.0, + UpperBoundaryRevetment = (RoundedDouble) 10.0, StepSize = WaveConditionsInputStepSize.One, - LowerBoundaryWaterLevels = (RoundedDouble)1.0, - UpperBoundaryWaterLevels = (RoundedDouble)10.0 + LowerBoundaryWaterLevels = (RoundedDouble) 1.0, + UpperBoundaryWaterLevels = (RoundedDouble) 10.0 } }; var context = new GrassCoverErosionOutwardsWaveConditionsCalculationContext(calculation, - failureMechanism, - assessmentSection); + failureMechanism, + assessmentSection); using (var treeViewControl = new TreeViewControl()) { @@ -598,11 +578,6 @@ Path.Combine("HydraulicBoundaryLocationReader", "complete.sqlite")); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("A", new[] - { - new Point2D(0, 0), - new Point2D(1, 1) - })); var assessmentSection = mocks.Stub(); assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase { @@ -618,8 +593,8 @@ }; var context = new GrassCoverErosionOutwardsWaveConditionsCalculationContext(calculation, - failureMechanism, - assessmentSection); + failureMechanism, + assessmentSection); using (var treeViewControl = new TreeViewControl()) { @@ -679,8 +654,8 @@ Name = "A" }; var context = new GrassCoverErosionOutwardsWaveConditionsCalculationContext(calculation, - failureMechanism, - assessmentSection); + failureMechanism, + assessmentSection); using (var treeViewControl = new TreeViewControl()) { @@ -720,11 +695,6 @@ { // Given var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("A", new[] - { - new Point2D(0, 0), - new Point2D(1, 1) - })); var assessmentSection = mocks.Stub(); assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); @@ -733,8 +703,8 @@ Name = "A" }; var context = new GrassCoverErosionOutwardsWaveConditionsCalculationContext(calculation, - failureMechanism, - assessmentSection); + failureMechanism, + assessmentSection); using (var treeViewControl = new TreeViewControl()) { @@ -777,11 +747,6 @@ Path.Combine("HydraulicBoundaryLocationReader", "complete.sqlite")); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("A", new[] - { - new Point2D(0, 0), - new Point2D(1, 1) - })); var assessmentSection = mocks.Stub(); assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase { @@ -793,8 +758,8 @@ Name = "A" }; var context = new GrassCoverErosionOutwardsWaveConditionsCalculationContext(calculation, - failureMechanism, - assessmentSection); + failureMechanism, + assessmentSection); using (var treeViewControl = new TreeViewControl()) { @@ -836,11 +801,6 @@ Path.Combine("HydraulicBoundaryLocationReader", "complete.sqlite")); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("A", new[] - { - new Point2D(0, 0), - new Point2D(1, 1) - })); var assessmentSection = mocks.Stub(); assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase { @@ -853,8 +813,8 @@ var calculation = GetValidCalculation(); calculation.Name = "A"; var context = new GrassCoverErosionOutwardsWaveConditionsCalculationContext(calculation, - failureMechanism, - assessmentSection); + failureMechanism, + assessmentSection); DialogBoxHandler = (name, wnd) => { @@ -927,8 +887,8 @@ Output = null }; var context = new GrassCoverErosionOutwardsWaveConditionsCalculationContext(calculation, - failureMechanism, - assessmentSection); + failureMechanism, + assessmentSection); using (var treeViewControl = new TreeViewControl()) { @@ -976,8 +936,8 @@ Output = new GrassCoverErosionOutwardsWaveConditionsOutput(Enumerable.Empty()) }; var context = new GrassCoverErosionOutwardsWaveConditionsCalculationContext(calculation, - failureMechanism, - assessmentSection); + failureMechanism, + assessmentSection); using (var treeViewControl = new TreeViewControl()) { @@ -1028,8 +988,8 @@ }; calculation.Attach(observer); var context = new GrassCoverErosionOutwardsWaveConditionsCalculationContext(calculation, - failureMechanism, - assessmentSection); + failureMechanism, + assessmentSection); using (var treeViewControl = new TreeViewControl()) { @@ -1088,13 +1048,13 @@ UseForeshore = true, UseBreakWater = true, StepSize = WaveConditionsInputStepSize.Half, - LowerBoundaryRevetment = (RoundedDouble)4, - UpperBoundaryRevetment = (RoundedDouble)10, - UpperBoundaryWaterLevels = (RoundedDouble)8, - LowerBoundaryWaterLevels = (RoundedDouble)7.1 + LowerBoundaryRevetment = (RoundedDouble) 4, + UpperBoundaryRevetment = (RoundedDouble) 10, + UpperBoundaryWaterLevels = (RoundedDouble) 8, + LowerBoundaryWaterLevels = (RoundedDouble) 7.1 } }; - calculation.InputParameters.HydraulicBoundaryLocation.DesignWaterLevel = (RoundedDouble)9.3; + calculation.InputParameters.HydraulicBoundaryLocation.DesignWaterLevel = (RoundedDouble) 9.3; return calculation; } Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -r4e529d43a3c3f0e4e809a33b6c4e1f3af1029431 -r0f6049b15bcadf8de3a59c74e829f27bb725c013 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs) (revision 4e529d43a3c3f0e4e809a33b6c4e1f3af1029431) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs) (revision 0f6049b15bcadf8de3a59c74e829f27bb725c013) @@ -561,10 +561,6 @@ using (var treeViewControl = new TreeViewControl()) { var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("", new[] - { - new Point2D(0, 0) - })); var group = new CalculationGroup(); group.Children.Add(new GrassCoverErosionOutwardsWaveConditionsCalculation()); failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); @@ -606,10 +602,6 @@ using (var treeViewControl = new TreeViewControl()) { var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("", new[] - { - new Point2D(0, 0) - })); var group = new CalculationGroup(); group.Children.Add(new GrassCoverErosionOutwardsWaveConditionsCalculation()); failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); @@ -683,10 +675,6 @@ group.Children.Add(calculation); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("", new[] - { - new Point2D(0, 0) - })); failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); var nodeData = new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(group, failureMechanism, @@ -754,10 +742,6 @@ group.Children.Add(calculationB); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("", new[] - { - new Point2D(0, 0) - })); failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); var nodeData = new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(group, failureMechanism, @@ -826,10 +810,6 @@ var group = new CalculationGroup(); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("", new[] - { - new Point2D(0, 0) - })); failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); var nodeData = new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(group, failureMechanism, @@ -887,10 +867,6 @@ group.Children.Add(calculationB); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("", new[] - { - new Point2D(0, 0) - })); failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); var nodeData = new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(group, failureMechanism, @@ -962,10 +938,6 @@ calculationB.Attach(observerB); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("", new[] - { - new Point2D(0, 0) - })); failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); var nodeData = new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(group, failureMechanism, Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Plugin/StabilityStoneCoverPlugin.cs =================================================================== diff -u -rd689ea05c1014eb4d51b927e11eb6c48255f0a47 -r0f6049b15bcadf8de3a59c74e829f27bb725c013 --- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Plugin/StabilityStoneCoverPlugin.cs (.../StabilityStoneCoverPlugin.cs) (revision d689ea05c1014eb4d51b927e11eb6c48255f0a47) +++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Plugin/StabilityStoneCoverPlugin.cs (.../StabilityStoneCoverPlugin.cs) (revision 0f6049b15bcadf8de3a59c74e829f27bb725c013) @@ -349,11 +349,6 @@ private string ValidateAllDataAvailableAndGetErrorMessage(IAssessmentSection assessmentSection, StabilityStoneCoverFailureMechanism failureMechanism) { - if (!failureMechanism.Sections.Any()) - { - return RingtoetsCommonFormsResources.Plugin_AllDataAvailable_No_failure_mechanism_sections_imported; - } - if (assessmentSection.HydraulicBoundaryDatabase == null) { return RingtoetsCommonFormsResources.Plugin_AllDataAvailable_No_hydraulic_boundary_database_imported; @@ -506,7 +501,7 @@ }, c.AssessmentSection.HydraulicBoundaryDatabase), ValidateAllDataAvailableAndGetErrorMessageForCalculation) - .AddPerformCalculationItem(calculation, nodeData, PerformCalculation) + .AddPerformCalculationItem(calculation, nodeData, PerformCalculation, ValidateAllDataAvailableAndGetErrorMessageForCalculation) .AddClearCalculationOutputItem(calculation) .AddSeparator() .AddRenameItem() Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -rd689ea05c1014eb4d51b927e11eb6c48255f0a47 -r0f6049b15bcadf8de3a59c74e829f27bb725c013 --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs (.../StabilityStoneCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs) (revision d689ea05c1014eb4d51b927e11eb6c48255f0a47) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs (.../StabilityStoneCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs) (revision 0f6049b15bcadf8de3a59c74e829f27bb725c013) @@ -446,7 +446,7 @@ TestHelper.AssertContextMenuStripContainsItem(contextMenu, validateMenuItemIndex, "&Valideren", - "Er is geen vakindeling geïmporteerd.", + "Er is geen hydraulische randvoorwaardendatabase geïmporteerd.", RingtoetsCommonFormsResources.ValidateIcon, false); } @@ -458,11 +458,6 @@ { // Given var failureMechanism = new StabilityStoneCoverFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("A", new[] - { - new Point2D(0, 0), - new Point2D(1, 1) - })); var assessmentSection = mocks.Stub(); var calculation = new StabilityStoneCoverWaveConditionsCalculation @@ -511,11 +506,6 @@ { // Given var failureMechanism = new StabilityStoneCoverFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("A", new[] - { - new Point2D(0, 0), - new Point2D(1, 1) - })); var assessmentSection = mocks.Stub(); assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); @@ -568,11 +558,6 @@ Path.Combine("HydraulicBoundaryLocationReader", "complete.sqlite")); var failureMechanism = new StabilityStoneCoverFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("A", new[] - { - new Point2D(0, 0), - new Point2D(1, 1) - })); var assessmentSection = mocks.Stub(); assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase { @@ -627,11 +612,6 @@ Path.Combine("HydraulicBoundaryLocationReader", "complete.sqlite")); var failureMechanism = new StabilityStoneCoverFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("A", new[] - { - new Point2D(0, 0), - new Point2D(1, 1) - })); var assessmentSection = mocks.Stub(); assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase { @@ -715,11 +695,6 @@ Path.Combine("HydraulicBoundaryLocationReader", "complete.sqlite")); var failureMechanism = new StabilityStoneCoverFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("A", new[] - { - new Point2D(0, 0), - new Point2D(1, 1) - })); var assessmentSection = mocks.Stub(); assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase { @@ -785,7 +760,7 @@ } [Test] - public void GivenAnyCalculation_ThenCalculateItemEnabled() + public void GivenAssessmentSectionWithoutHydroDatabase_ThenCalculationItemDisabled() { // Given var failureMechanism = new StabilityStoneCoverFailureMechanism(); @@ -825,6 +800,110 @@ TestHelper.AssertContextMenuStripContainsItem(contextMenu, calculateMenuItemIndex, "Be&rekenen", + "Er is geen hydraulische randvoorwaardendatabase geïmporteerd.", + RingtoetsCommonFormsResources.CalculateIcon, + false); + } + } + } + + [Test] + public void GivenAssessmentSectionWithoutValidPathForCalculation_ThenCalculationItemDisabled() + { + // Given + var failureMechanism = new StabilityStoneCoverFailureMechanism(); + var assessmentSection = mocks.Stub(); + assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); + + var calculation = new StabilityStoneCoverWaveConditionsCalculation + { + Name = "A" + }; + var context = new StabilityStoneCoverWaveConditionsCalculationContext(calculation, + failureMechanism, + assessmentSection); + + using (var treeViewControl = new TreeViewControl()) + { + var appFeatureCommandHandler = mocks.Stub(); + var importHandler = mocks.Stub(); + var exportHandler = mocks.Stub(); + var viewCommands = mocks.Stub(); + var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, + importHandler, + exportHandler, + viewCommands, + context, + treeViewControl); + + var gui = mocks.Stub(); + gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilderMock); + + mocks.ReplayAll(); + + plugin.Gui = gui; + + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl)) + { + // Then + TestHelper.AssertContextMenuStripContainsItem(contextMenu, + calculateMenuItemIndex, + "Be&rekenen", + "Herstellen van de verbinding met de hydraulische randvoorwaardendatabase is mislukt. Fout bij het lezen van bestand '': Bestandspad mag niet leeg of ongedefinieerd zijn.", + RingtoetsCommonFormsResources.CalculateIcon, + false); + } + } + } + + [Test] + public void GivenAssessmentSectionWithValidPathForCalculation_ThenCalculationItemEnabled() + { + // Given + string validHydroDatabasePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.HydraRing.IO, + Path.Combine("HydraulicBoundaryLocationReader", "complete.sqlite")); + + var failureMechanism = new StabilityStoneCoverFailureMechanism(); + var assessmentSection = mocks.Stub(); + assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = validHydroDatabasePath + }; + + var calculation = new StabilityStoneCoverWaveConditionsCalculation + { + Name = "A" + }; + var context = new StabilityStoneCoverWaveConditionsCalculationContext(calculation, + failureMechanism, + assessmentSection); + + using (var treeViewControl = new TreeViewControl()) + { + var appFeatureCommandHandler = mocks.Stub(); + var importHandler = mocks.Stub(); + var exportHandler = mocks.Stub(); + var viewCommands = mocks.Stub(); + var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, + importHandler, + exportHandler, + viewCommands, + context, + treeViewControl); + + var gui = mocks.Stub(); + gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilderMock); + + mocks.ReplayAll(); + + plugin.Gui = gui; + + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl)) + { + // Then + TestHelper.AssertContextMenuStripContainsItem(contextMenu, + calculateMenuItemIndex, + "Be&rekenen", "Voer deze berekening uit.", RingtoetsCommonFormsResources.CalculateIcon); } @@ -839,11 +918,6 @@ Path.Combine("HydraulicBoundaryLocationReader", "complete.sqlite")); var failureMechanism = new StabilityStoneCoverFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("A", new[] - { - new Point2D(0, 0), - new Point2D(1, 1) - })); var assessmentSection = mocks.Stub(); assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase { Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -rd41c64af372c44d81c66ed5bf25a9469816f3f48 -r0f6049b15bcadf8de3a59c74e829f27bb725c013 --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs (.../StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs) (revision d41c64af372c44d81c66ed5bf25a9469816f3f48) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs (.../StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs) (revision 0f6049b15bcadf8de3a59c74e829f27bb725c013) @@ -567,57 +567,12 @@ } [Test] - public void ContextMenuStrip_FailureMechanismWithNoSections_ValidateAndCalculateAllDisabled() - { - // Setup - using (var treeViewControl = new TreeViewControl()) - { - var failureMechanism = new StabilityStoneCoverFailureMechanism(); - var group = new CalculationGroup(); - group.Children.Add(new StabilityStoneCoverWaveConditionsCalculation()); - failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); - var assessmentSection = mocks.Stub(); - var nodeData = new StabilityStoneCoverWaveConditionsCalculationGroupContext(group, - failureMechanism, - assessmentSection); - var parentNodeData = new StabilityStoneCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, - failureMechanism, - assessmentSection); - - var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); - - var gui = mocks.Stub(); - gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); - - mocks.ReplayAll(); - - plugin.Gui = gui; - - // Call - using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) - { - // Assert - ToolStripItem validateItem = contextMenu.Items[contextMenuValidateAllIndexNestedGroupNoCalculations]; - ToolStripItem calculateItem = contextMenu.Items[contextMenuCalculateAllIndexNestedGroupNoCalculations]; - Assert.IsFalse(validateItem.Enabled); - Assert.IsFalse(calculateItem.Enabled); - Assert.AreEqual(RingtoetsCommonFormsResources.Plugin_AllDataAvailable_No_failure_mechanism_sections_imported, calculateItem.ToolTipText); - Assert.AreEqual(RingtoetsCommonFormsResources.Plugin_AllDataAvailable_No_failure_mechanism_sections_imported, validateItem.ToolTipText); - } - } - } - - [Test] public void ContextMenuStrip_AssessmentSectionWithoutHydraulicBoundaryDatabase_ValidateAndCalculateAllDisabled() { // Setup using (var treeViewControl = new TreeViewControl()) { var failureMechanism = new StabilityStoneCoverFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("", new[] - { - new Point2D(0, 0) - })); var group = new CalculationGroup(); group.Children.Add(new StabilityStoneCoverWaveConditionsCalculation()); failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); @@ -659,10 +614,6 @@ using (var treeViewControl = new TreeViewControl()) { var failureMechanism = new StabilityStoneCoverFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("", new[] - { - new Point2D(0, 0) - })); var group = new CalculationGroup(); group.Children.Add(new StabilityStoneCoverWaveConditionsCalculation()); failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); @@ -754,10 +705,6 @@ group.Children.Add(calculationB); var failureMechanism = new StabilityStoneCoverFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("", new[] - { - new Point2D(0, 0) - })); failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); var nodeData = new StabilityStoneCoverWaveConditionsCalculationGroupContext(group, failureMechanism, @@ -825,10 +772,6 @@ group.Children.Add(calculationB); var failureMechanism = new StabilityStoneCoverFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("", new[] - { - new Point2D(0, 0) - })); failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); var nodeData = new StabilityStoneCoverWaveConditionsCalculationGroupContext(group, failureMechanism, @@ -897,10 +840,6 @@ var group = new CalculationGroup(); var failureMechanism = new StabilityStoneCoverFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("", new[] - { - new Point2D(0, 0) - })); failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); var nodeData = new StabilityStoneCoverWaveConditionsCalculationGroupContext(group, failureMechanism, @@ -958,10 +897,6 @@ group.Children.Add(calculationB); var failureMechanism = new StabilityStoneCoverFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("", new[] - { - new Point2D(0, 0) - })); failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); var nodeData = new StabilityStoneCoverWaveConditionsCalculationGroupContext(group, failureMechanism, @@ -1037,10 +972,7 @@ calculationB.Attach(observerB); var failureMechanism = new StabilityStoneCoverFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("", new[] - { - new Point2D(0, 0) - })); + failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); var nodeData = new StabilityStoneCoverWaveConditionsCalculationGroupContext(group, failureMechanism, Index: Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Plugin/WaveImpactAsphaltCoverPlugin.cs =================================================================== diff -u -rd689ea05c1014eb4d51b927e11eb6c48255f0a47 -r0f6049b15bcadf8de3a59c74e829f27bb725c013 --- Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Plugin/WaveImpactAsphaltCoverPlugin.cs (.../WaveImpactAsphaltCoverPlugin.cs) (revision d689ea05c1014eb4d51b927e11eb6c48255f0a47) +++ Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Plugin/WaveImpactAsphaltCoverPlugin.cs (.../WaveImpactAsphaltCoverPlugin.cs) (revision 0f6049b15bcadf8de3a59c74e829f27bb725c013) @@ -339,21 +339,16 @@ private string ValidateAllDataAvailableAndGetErrorMessageForCalculationGroup(WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext context) { - return ValidateAllDataAvailableAndGetErrorMessage(context.AssessmentSection, context.FailureMechanism); + return ValidateAllDataAvailableAndGetErrorMessage(context.AssessmentSection); } private string ValidateAllDataAvailableAndGetErrorMessageForCalculation(WaveImpactAsphaltCoverWaveConditionsCalculationContext context) { - return ValidateAllDataAvailableAndGetErrorMessage(context.AssessmentSection, context.FailureMechanism); + return ValidateAllDataAvailableAndGetErrorMessage(context.AssessmentSection); } - private string ValidateAllDataAvailableAndGetErrorMessage(IAssessmentSection assessmentSection, WaveImpactAsphaltCoverFailureMechanism failureMechanism) + private string ValidateAllDataAvailableAndGetErrorMessage(IAssessmentSection assessmentSection) { - if (!failureMechanism.Sections.Any()) - { - return RingtoetsCommonFormsResources.Plugin_AllDataAvailable_No_failure_mechanism_sections_imported; - } - if (assessmentSection.HydraulicBoundaryDatabase == null) { return RingtoetsCommonFormsResources.Plugin_AllDataAvailable_No_hydraulic_boundary_database_imported; @@ -365,7 +360,7 @@ return string.Format(RingtoetsCommonServiceResources.Hydraulic_boundary_database_connection_failed_0_, validationProblem); } - + return null; } @@ -506,7 +501,7 @@ }, c.AssessmentSection.HydraulicBoundaryDatabase), ValidateAllDataAvailableAndGetErrorMessageForCalculation) - .AddPerformCalculationItem(calculation, nodeData, PerformCalculation) + .AddPerformCalculationItem(calculation, nodeData, PerformCalculation, ValidateAllDataAvailableAndGetErrorMessageForCalculation) .AddClearCalculationOutputItem(calculation) .AddSeparator() .AddRenameItem() Index: Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -rd689ea05c1014eb4d51b927e11eb6c48255f0a47 -r0f6049b15bcadf8de3a59c74e829f27bb725c013 --- Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs (.../WaveImpactAsphaltCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs) (revision d689ea05c1014eb4d51b927e11eb6c48255f0a47) +++ Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs (.../WaveImpactAsphaltCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs) (revision 0f6049b15bcadf8de3a59c74e829f27bb725c013) @@ -401,54 +401,6 @@ } [Test] - public void GivenFailureMechanismWithoutSections_ThenValidationItemDisabled() - { - // Given - var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); - var assessmentSection = mocks.Stub(); - - var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation - { - Name = "A" - }; - var context = new WaveImpactAsphaltCoverWaveConditionsCalculationContext(calculation, - failureMechanism, - assessmentSection); - - using (var treeViewControl = new TreeViewControl()) - { - var appFeatureCommandHandler = mocks.Stub(); - var importHandler = mocks.Stub(); - var exportHandler = mocks.Stub(); - var viewCommands = mocks.Stub(); - var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, - importHandler, - exportHandler, - viewCommands, - context, - treeViewControl); - - var gui = mocks.Stub(); - gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilderMock); - - mocks.ReplayAll(); - - plugin.Gui = gui; - - using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl)) - { - // Then - TestHelper.AssertContextMenuStripContainsItem(contextMenu, - validateMenuItemIndex, - "&Valideren", - "Er is geen vakindeling geïmporteerd.", - RingtoetsCommonFormsResources.ValidateIcon, - false); - } - } - } - - [Test] public void GivenAssessmentSectionWithoutHydroDatabase_ThenValidationItemDisabled() { // Given @@ -778,7 +730,7 @@ } [Test] - public void GivenAnyCalculation_ThenCalculateItemEnabled() + public void GivenAssessmentSectionWithoutHydroDatabase_ThenCalculationItemDisabled() { // Given var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); @@ -789,8 +741,8 @@ Name = "A" }; var context = new WaveImpactAsphaltCoverWaveConditionsCalculationContext(calculation, - failureMechanism, - assessmentSection); + failureMechanism, + assessmentSection); using (var treeViewControl = new TreeViewControl()) { @@ -818,6 +770,110 @@ TestHelper.AssertContextMenuStripContainsItem(contextMenu, calculateMenuItemIndex, "Be&rekenen", + "Er is geen hydraulische randvoorwaardendatabase geïmporteerd.", + RingtoetsCommonFormsResources.CalculateIcon, + false); + } + } + } + + [Test] + public void GivenAssessmentSectionWithoutValidPathForCalculation_ThenCalculationItemDisabled() + { + // Given + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var assessmentSection = mocks.Stub(); + assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); + + var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation + { + Name = "A" + }; + var context = new WaveImpactAsphaltCoverWaveConditionsCalculationContext(calculation, + failureMechanism, + assessmentSection); + + using (var treeViewControl = new TreeViewControl()) + { + var appFeatureCommandHandler = mocks.Stub(); + var importHandler = mocks.Stub(); + var exportHandler = mocks.Stub(); + var viewCommands = mocks.Stub(); + var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, + importHandler, + exportHandler, + viewCommands, + context, + treeViewControl); + + var gui = mocks.Stub(); + gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilderMock); + + mocks.ReplayAll(); + + plugin.Gui = gui; + + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl)) + { + // Then + TestHelper.AssertContextMenuStripContainsItem(contextMenu, + calculateMenuItemIndex, + "Be&rekenen", + "Herstellen van de verbinding met de hydraulische randvoorwaardendatabase is mislukt. Fout bij het lezen van bestand '': Bestandspad mag niet leeg of ongedefinieerd zijn.", + RingtoetsCommonFormsResources.CalculateIcon, + false); + } + } + } + + [Test] + public void GivenAssessmentSectionWithValidPathForCalculation_ThenCalculationItemEnabled() + { + // Given + string validHydroDatabasePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.HydraRing.IO, + Path.Combine("HydraulicBoundaryLocationReader", "complete.sqlite")); + + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var assessmentSection = mocks.Stub(); + assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = validHydroDatabasePath + }; + + var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation + { + Name = "A" + }; + var context = new WaveImpactAsphaltCoverWaveConditionsCalculationContext(calculation, + failureMechanism, + assessmentSection); + + using (var treeViewControl = new TreeViewControl()) + { + var appFeatureCommandHandler = mocks.Stub(); + var importHandler = mocks.Stub(); + var exportHandler = mocks.Stub(); + var viewCommands = mocks.Stub(); + var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, + importHandler, + exportHandler, + viewCommands, + context, + treeViewControl); + + var gui = mocks.Stub(); + gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilderMock); + + mocks.ReplayAll(); + + plugin.Gui = gui; + + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl)) + { + // Then + TestHelper.AssertContextMenuStripContainsItem(contextMenu, + calculateMenuItemIndex, + "Be&rekenen", "Voer deze berekening uit.", RingtoetsCommonFormsResources.CalculateIcon); } Index: Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -r0d43b27e8aa5f3bfa5224448946e0332d047b1e3 -r0f6049b15bcadf8de3a59c74e829f27bb725c013 --- Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs (.../WaveImpactAsphaltCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs) (revision 0d43b27e8aa5f3bfa5224448946e0332d047b1e3) +++ Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs (.../WaveImpactAsphaltCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs) (revision 0f6049b15bcadf8de3a59c74e829f27bb725c013) @@ -567,57 +567,12 @@ } [Test] - public void ContextMenuStrip_FailureMechanismWithNoSections_ValidateAndCalculateAllDisabled() - { - // Setup - using (var treeViewControl = new TreeViewControl()) - { - var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); - var group = new CalculationGroup(); - group.Children.Add(new WaveImpactAsphaltCoverWaveConditionsCalculation()); - failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); - var assessmentSection = mocks.Stub(); - var nodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(group, - failureMechanism, - assessmentSection); - var parentNodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, - failureMechanism, - assessmentSection); - - var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); - - var gui = mocks.Stub(); - gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); - - mocks.ReplayAll(); - - plugin.Gui = gui; - - // Call - using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) - { - // Assert - ToolStripItem validateItem = contextMenu.Items[contextMenuValidateAllIndexNestedGroupNoCalculations]; - ToolStripItem calculateItem = contextMenu.Items[contextMenuCalculateAllIndexNestedGroupNoCalculations]; - Assert.IsFalse(validateItem.Enabled); - Assert.IsFalse(calculateItem.Enabled); - Assert.AreEqual("Er is geen vakindeling geïmporteerd.", calculateItem.ToolTipText); - Assert.AreEqual("Er is geen vakindeling geïmporteerd.", validateItem.ToolTipText); - } - } - } - - [Test] public void ContextMenuStrip_AssessmentSectionWithoutHydraulicBoundaryDatabase_ValidateAndCalculateAllDisabled() { // Setup using (var treeViewControl = new TreeViewControl()) { var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("", new[] - { - new Point2D(0, 0) - })); var group = new CalculationGroup(); group.Children.Add(new WaveImpactAsphaltCoverWaveConditionsCalculation()); failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); @@ -659,10 +614,6 @@ using (var treeViewControl = new TreeViewControl()) { var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("", new[] - { - new Point2D(0, 0) - })); var group = new CalculationGroup(); group.Children.Add(new WaveImpactAsphaltCoverWaveConditionsCalculation()); failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); @@ -754,10 +705,6 @@ group.Children.Add(calculationB); var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("", new[] - { - new Point2D(0, 0) - })); failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); var nodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(group, failureMechanism, @@ -960,10 +907,6 @@ group.Children.Add(calculationB); var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("", new[] - { - new Point2D(0, 0) - })); failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); var nodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(group, failureMechanism, @@ -1035,10 +978,6 @@ calculationB.Attach(observerB); var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("", new[] - { - new Point2D(0, 0) - })); failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); var nodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(group, failureMechanism,