Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -r2a5b882dc9e52231eea22d40d686b075aa72a1aa -r16aaa945951f39aae43afb02993721a4a4a2b671 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs) (revision 2a5b882dc9e52231eea22d40d686b075aa72a1aa) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs) (revision 16aaa945951f39aae43afb02993721a4a4a2b671) @@ -236,7 +236,7 @@ // Setup var group = new CalculationGroup(); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); - var assessmentSection = mocks.Stub(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(mocks); var groupContext = new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(group, null, failureMechanism, @@ -288,7 +288,7 @@ // Setup var group = new CalculationGroup(); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); - var assessmentSection = mocks.Stub(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(mocks); var groupContext = new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(group, null, failureMechanism, @@ -353,7 +353,7 @@ var group = new CalculationGroup(); var parentGroup = new CalculationGroup(); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); - var assessmentSection = mocks.Stub(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(mocks); var groupContext = new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(group, parentGroup, failureMechanism, @@ -410,7 +410,7 @@ var group = new CalculationGroup(); var parentGroup = new CalculationGroup(); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); - var assessmentSection = mocks.Stub(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(mocks); var groupContext = new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(group, parentGroup, failureMechanism, @@ -474,7 +474,7 @@ public void ContextMenuStrip_WithoutParentNodeWithoutHydraulicLocationsDefaultBehavior_ReturnContextMenuWithoutRenameRemove() { // Setup - var assessmentSection = mocks.Stub(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(mocks); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); @@ -571,13 +571,13 @@ { // Setup var assessmentSection = mocks.Stub(); - assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(new HydraulicBoundaryDatabase { Locations = { new TestHydraulicBoundaryLocation() } - }; + }); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); @@ -674,7 +674,7 @@ var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); - var assessmentSection = mocks.Stub(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(mocks); var nodeData = new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(group, failureMechanism.WaveConditionsCalculationGroup, failureMechanism, @@ -705,7 +705,7 @@ } [Test] - public void ContextMenuStrip_NoHydraulicBoundaryDatabase_CalculateAllAndValidateAllDisabled() + public void ContextMenuStrip_HydraulicBoundaryDatabaseNotLinked_CalculateAllAndValidateAllDisabled() { // Setup using (var treeViewControl = new TreeViewControl()) @@ -719,7 +719,7 @@ }; failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); - var assessmentSection = mocks.Stub(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(mocks); var nodeData = new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(group, failureMechanism.WaveConditionsCalculationGroup, failureMechanism, @@ -750,7 +750,7 @@ } [Test] - public void ContextMenuStrip_HydraulicBoundaryDatabaseNotValid_CalculateAllAndValidateAllDisabled() + public void ContextMenuStrip_HydraulicBoundaryDatabaseLinkedToInvalidFile_CalculateAllAndValidateAllDisabled() { // Setup using (var treeViewControl = new TreeViewControl()) @@ -764,11 +764,8 @@ }; failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); - var assessmentSection = mocks.Stub(); - assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase - { - FilePath = "" - }; + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(null, mocks, "invalidFilePath"); + var nodeData = new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(group, failureMechanism.WaveConditionsCalculationGroup, failureMechanism, @@ -792,7 +789,7 @@ ToolStripItem calculateItem = contextMenu.Items[contextMenuCalculateAllIndexNestedGroup]; Assert.IsFalse(validateItem.Enabled); Assert.IsFalse(calculateItem.Enabled); - const string message = "Herstellen van de verbinding met de hydraulische randvoorwaardendatabase is mislukt. Fout bij het lezen van bestand '': bestandspad mag niet leeg of ongedefinieerd zijn."; + const string message = "Herstellen van de verbinding met de hydraulische randvoorwaardendatabase is mislukt. Fout bij het lezen van bestand 'invalidFilePath': het bestand bestaat niet."; Assert.AreEqual(message, calculateItem.ToolTipText); Assert.AreEqual(message, validateItem.ToolTipText); } @@ -818,10 +815,11 @@ failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); var assessmentSection = mocks.Stub(); - assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(new HydraulicBoundaryDatabase { FilePath = validHydroDatabasePath - }; + }); + var nodeData = new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(group, failureMechanism.WaveConditionsCalculationGroup, failureMechanism, @@ -873,10 +871,11 @@ failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); var assessmentSection = mocks.Stub(); - assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(new HydraulicBoundaryDatabase { FilePath = validHydroDatabasePath - }; + }); + var nodeData = new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(group, failureMechanism.WaveConditionsCalculationGroup, failureMechanism, @@ -917,7 +916,7 @@ Name = "A", InputParameters = { - HydraulicBoundaryLocation = TestHydraulicBoundaryLocation.CreateDesignWaterLevelCalculated(12), + HydraulicBoundaryLocation = CreateHydraulicBoundaryLocationWithNormativeOutput(), LowerBoundaryRevetment = (RoundedDouble) 1.0, UpperBoundaryRevetment = (RoundedDouble) 10.0, StepSize = WaveConditionsInputStepSize.One, @@ -931,7 +930,7 @@ Name = "B", InputParameters = { - HydraulicBoundaryLocation = TestHydraulicBoundaryLocation.CreateDesignWaterLevelCalculated(12), + HydraulicBoundaryLocation = CreateHydraulicBoundaryLocationWithNormativeOutput(), LowerBoundaryRevetment = (RoundedDouble) 1.0, UpperBoundaryRevetment = (RoundedDouble) 10.0, StepSize = WaveConditionsInputStepSize.One, @@ -1001,7 +1000,7 @@ Name = "A", InputParameters = { - HydraulicBoundaryLocation = TestHydraulicBoundaryLocation.CreateDesignWaterLevelCalculated(12), + HydraulicBoundaryLocation = CreateHydraulicBoundaryLocationWithNormativeOutput(), LowerBoundaryRevetment = (RoundedDouble) 1.0, UpperBoundaryRevetment = (RoundedDouble) 10.0, StepSize = WaveConditionsInputStepSize.One, @@ -1068,7 +1067,7 @@ Name = "A", InputParameters = { - HydraulicBoundaryLocation = TestHydraulicBoundaryLocation.CreateDesignWaterLevelCalculated(12), + HydraulicBoundaryLocation = CreateHydraulicBoundaryLocationWithNormativeOutput(), LowerBoundaryRevetment = (RoundedDouble) 1.0, UpperBoundaryRevetment = (RoundedDouble) 10.0, StepSize = WaveConditionsInputStepSize.One, @@ -1087,16 +1086,12 @@ }; failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); - IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStubWithoutBoundaryDatabase( - failureMechanism, mocks); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub( + failureMechanism, mocks, Path.Combine(hrdPath, "HRD ijsselmeer.sqlite")); - assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase - { - FilePath = Path.Combine(hrdPath, "HRD ijsselmeer.sqlite"), - CanUsePreprocessor = true, - UsePreprocessor = false, - PreprocessorDirectory = "InvalidPreprocessorDirectory" - }; + assessmentSection.HydraulicBoundaryDatabase.CanUsePreprocessor = true; + assessmentSection.HydraulicBoundaryDatabase.UsePreprocessor = false; + assessmentSection.HydraulicBoundaryDatabase.PreprocessorDirectory = "InvalidPreprocessorDirectory"; var nodeData = new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(group, failureMechanism.WaveConditionsCalculationGroup, @@ -1143,7 +1138,7 @@ Name = "A", InputParameters = { - HydraulicBoundaryLocation = TestHydraulicBoundaryLocation.CreateDesignWaterLevelCalculated(12), + HydraulicBoundaryLocation = CreateHydraulicBoundaryLocationWithNormativeOutput(), LowerBoundaryRevetment = (RoundedDouble) 1.0, UpperBoundaryRevetment = (RoundedDouble) 10.0, StepSize = WaveConditionsInputStepSize.One, @@ -1162,16 +1157,12 @@ }; failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); - IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStubWithoutBoundaryDatabase( - failureMechanism, mocks); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub( + failureMechanism, mocks, Path.Combine(hrdPath, "HRD ijsselmeer.sqlite")); - assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase - { - FilePath = Path.Combine(hrdPath, "HRD ijsselmeer.sqlite"), - CanUsePreprocessor = true, - UsePreprocessor = true, - PreprocessorDirectory = TestHelper.GetScratchPadPath() - }; + assessmentSection.HydraulicBoundaryDatabase.CanUsePreprocessor = true; + assessmentSection.HydraulicBoundaryDatabase.UsePreprocessor = true; + assessmentSection.HydraulicBoundaryDatabase.PreprocessorDirectory = TestHelper.GetScratchPadPath(); var nodeData = new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(group, failureMechanism.WaveConditionsCalculationGroup, @@ -1218,7 +1209,7 @@ Name = "A", InputParameters = { - HydraulicBoundaryLocation = TestHydraulicBoundaryLocation.CreateDesignWaterLevelCalculated(12), + HydraulicBoundaryLocation = CreateHydraulicBoundaryLocationWithNormativeOutput(), LowerBoundaryRevetment = (RoundedDouble) 1.0, UpperBoundaryRevetment = (RoundedDouble) 10.0, StepSize = WaveConditionsInputStepSize.One, @@ -1237,16 +1228,12 @@ }; failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); - IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStubWithoutBoundaryDatabase( - failureMechanism, mocks); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub( + failureMechanism, mocks, Path.Combine(hrdPath, "HRD ijsselmeer.sqlite")); - assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase - { - FilePath = Path.Combine(hrdPath, "HRD ijsselmeer.sqlite"), - CanUsePreprocessor = true, - UsePreprocessor = true, - PreprocessorDirectory = "InvalidPreprocessorDirectory" - }; + assessmentSection.HydraulicBoundaryDatabase.CanUsePreprocessor = true; + assessmentSection.HydraulicBoundaryDatabase.UsePreprocessor = true; + assessmentSection.HydraulicBoundaryDatabase.PreprocessorDirectory = "InvalidPreprocessorDirectory"; var nodeData = new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(group, failureMechanism.WaveConditionsCalculationGroup, @@ -1555,7 +1542,7 @@ // Setup using (var treeViewControl = new TreeViewControl()) { - var assessmentSection = mocks.Stub(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(mocks); var group = new CalculationGroup(); @@ -1610,7 +1597,7 @@ public void ContextMenuStrip_WithForeshoreProfileAndChanges_ContextMenuItemUpdateAllForeshoreProfilesEnabled() { // Setup - var assessmentSection = mocks.Stub(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(mocks); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); var calculation = new GrassCoverErosionOutwardsWaveConditionsCalculation { @@ -1660,7 +1647,7 @@ var calculationInputObserver = mocks.StrictMock(); calculationInputObserver.Expect(o => o.UpdateObserver()); - var assessmentSection = mocks.Stub(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(mocks); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); var calculation = new GrassCoverErosionOutwardsWaveConditionsCalculation @@ -1709,7 +1696,7 @@ { // Given var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); - var assessmentSection = mocks.Stub(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(mocks); var context = new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, null, @@ -1760,7 +1747,7 @@ var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); failureMechanism.WaveConditionsCalculationGroup.Attach(observer); - var assessmentSection = mocks.Stub(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(mocks); var context = new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, null, @@ -1863,15 +1850,16 @@ hydraulicBoundaryLocation2 } }; + var assessmentSection = mocks.Stub(); - assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(new HydraulicBoundaryDatabase { Locations = { hydraulicBoundaryLocation1, hydraulicBoundaryLocation2 } - }; + }); var observer = mocks.StrictMock(); observer.Expect(o => o.UpdateObserver()); @@ -1939,16 +1927,17 @@ hydraulicBoundaryLocation2 } }; + var assessmentSection = mocks.Stub(); - assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(new HydraulicBoundaryDatabase { Locations = { new TestHydraulicBoundaryLocation(), hydraulicBoundaryLocation1, hydraulicBoundaryLocation2 } - }; + }); var nodeData = new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(group, null, @@ -1987,13 +1976,24 @@ } } + private static TestHydraulicBoundaryLocation CreateHydraulicBoundaryLocationWithNormativeOutput() + { + return new TestHydraulicBoundaryLocation + { + DesignWaterLevelCalculation3 = + { + Output = new TestHydraulicBoundaryLocationOutput(12) + } + }; + } + private static GrassCoverErosionOutwardsWaveConditionsCalculation GetValidCalculation() { return new GrassCoverErosionOutwardsWaveConditionsCalculation { InputParameters = { - HydraulicBoundaryLocation = TestHydraulicBoundaryLocation.CreateDesignWaterLevelCalculated(9.3), + HydraulicBoundaryLocation = CreateHydraulicBoundaryLocationWithNormativeOutput(), ForeshoreProfile = new TestForeshoreProfile(true), UseForeshore = true, UseBreakWater = true,