Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -rae04c23f970bb96e54adbfb8c2fe1aaf95d13326 -r3a89e41054c6cfe6babdc150e8282cbe4a6dc672 --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs (.../StabilityStoneCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs) (revision ae04c23f970bb96e54adbfb8c2fe1aaf95d13326) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs (.../StabilityStoneCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs) (revision 3a89e41054c6cfe6babdc150e8282cbe4a6dc672) @@ -643,8 +643,21 @@ var calculation = new StabilityStoneCoverWaveConditionsCalculation { - Name = "A" + Name = "A", + InputParameters = + { + HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "", 1, 1) + { + DesignWaterLevel = (RoundedDouble) 12.0 + }, + LowerBoundaryRevetment = (RoundedDouble) 1.0, + UpperBoundaryRevetment = (RoundedDouble) 10.0, + StepSize = WaveConditionsInputStepSize.One, + LowerBoundaryWaterLevels = (RoundedDouble) 1.0, + UpperBoundaryWaterLevels = (RoundedDouble) 10.0 + } }; + var context = new StabilityStoneCoverWaveConditionsCalculationContext(calculation, failureMechanism, assessmentSection); @@ -695,6 +708,83 @@ } [Test] + public void GivenInValidCalculation_WhenValidating_ThenCalculationFailsValidation() + { + // Given + string validHydroDatabasePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.HydraRing.IO, + 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 + { + FilePath = validHydroDatabasePath + }; + assessmentSection.Stub(a => a.Id).Return("someId"); + assessmentSection.Stub(a => a.FailureMechanismContribution).Return( + new FailureMechanismContribution(Enumerable.Empty(), 100, 20)); + + 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)) + { + // Precondition + TestHelper.AssertContextMenuStripContainsItem(contextMenu, + validateMenuItemIndex, + "&Valideren", + "Valideer de invoer voor deze berekening.", + RingtoetsCommonFormsResources.ValidateIcon); + + // When + ToolStripItem validateMenuItem = contextMenu.Items[validateMenuItemIndex]; + Action call = () => validateMenuItem.PerformClick(); + + // Then + TestHelper.AssertLogMessages(call, logMessages => + { + var messages = logMessages.ToArray(); + Assert.AreEqual(3, messages.Length); + StringAssert.StartsWith("Validatie van 'A' gestart om: ", messages[0]); + StringAssert.StartsWith("Validatie mislukt: Er is geen hydraulische randvoorwaardenlocatie geselecteerd.", messages[1]); + StringAssert.StartsWith("Validatie van 'A' beƫindigd om: ", messages[2]); + }); + } + } + } + + [Test] public void GivenAnyCalculation_ThenCalculateItemEnabled() { // Given @@ -1003,13 +1093,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; }