Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/HydraulicBoundaryDatabaseContextTreeNodeInfoTest.cs =================================================================== diff -u -rc13161f3509cbbea4cc80a7774ee1d03530ac045 -ra1a8a692616323e706458111e9dc881f60ee5daa --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/HydraulicBoundaryDatabaseContextTreeNodeInfoTest.cs (.../HydraulicBoundaryDatabaseContextTreeNodeInfoTest.cs) (revision c13161f3509cbbea4cc80a7774ee1d03530ac045) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/HydraulicBoundaryDatabaseContextTreeNodeInfoTest.cs (.../HydraulicBoundaryDatabaseContextTreeNodeInfoTest.cs) (revision a1a8a692616323e706458111e9dc881f60ee5daa) @@ -276,28 +276,15 @@ public void GivenNoDatabaseLinked_WhenOpeningValidFileFromContextMenu_ThenDatabaseLinkedObserversNotifiedAndLogMessagesAdded() { // Given - var hydraulicBoundaryDatabaseObserver = mocks.StrictMock(); - hydraulicBoundaryDatabaseObserver.Expect(o => o.UpdateObserver()); - - var hydraulicBoundaryLocationsObserver = mocks.StrictMock(); - hydraulicBoundaryLocationsObserver.Expect(o => o.UpdateObserver()); - - var grassCoverErosionOutwardsLocationsObserver = mocks.StrictMock(); - grassCoverErosionOutwardsLocationsObserver.Expect(o => o.UpdateObserver()); - string testFile = Path.Combine(testDataPath, "HRD dutch coast south.sqlite"); var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + + AttachObservers(assessmentSection, true); + var hydraulicBoundaryDatabaseContext = new HydraulicBoundaryDatabaseContext(assessmentSection.HydraulicBoundaryDatabase, assessmentSection); - ObservableList hydraulicBoundaryLocations = assessmentSection.HydraulicBoundaryDatabase.Locations; - GrassCoverErosionOutwardsFailureMechanism grassCoverErosionOutwardsFailureMechanism = assessmentSection.GrassCoverErosionOutwards; - - assessmentSection.HydraulicBoundaryDatabase.Attach(hydraulicBoundaryDatabaseObserver); - hydraulicBoundaryLocations.Attach(hydraulicBoundaryLocationsObserver); - grassCoverErosionOutwardsFailureMechanism.HydraulicBoundaryLocations.Attach(grassCoverErosionOutwardsLocationsObserver); - using (var treeViewControl = new TreeViewControl()) using (var plugin = new RingtoetsPlugin()) { @@ -340,6 +327,9 @@ Assert.AreEqual(testFile, assessmentSection.HydraulicBoundaryDatabase.FilePath); Assert.AreEqual("Dutch coast South19-11-2015 12:0013", assessmentSection.HydraulicBoundaryDatabase.Version); + ObservableList hydraulicBoundaryLocations = assessmentSection.HydraulicBoundaryDatabase.Locations; + GrassCoverErosionOutwardsFailureMechanism grassCoverErosionOutwardsFailureMechanism = assessmentSection.GrassCoverErosionOutwards; + CollectionAssert.IsNotEmpty(hydraulicBoundaryLocations); CollectionAssert.AreEqual(hydraulicBoundaryLocations, assessmentSection.WaterLevelCalculationsForFactorizedSignalingNorm.Select(hblc => hblc.HydraulicBoundaryLocation)); CollectionAssert.AreEqual(hydraulicBoundaryLocations, assessmentSection.WaterLevelCalculationsForSignalingNorm.Select(hblc => hblc.HydraulicBoundaryLocation)); @@ -367,20 +357,15 @@ public void GivenNoDatabaseLinked_WhenOpeningInvalidFileFromContextMenu_ThenNoDatabaseLinkedNoObserversNotifiedAndLogMessagesAdded() { // Given - var hydraulicBoundaryDatabaseObserver = mocks.StrictMock(); - var hydraulicBoundaryLocationsObserver = mocks.StrictMock(); - var grassCoverErosionOutwardsLocationsObserver = mocks.StrictMock(); - string testFile = Path.Combine(testDataPath, "empty.sqlite"); var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + + AttachObservers(assessmentSection); + var hydraulicBoundaryDatabaseContext = new HydraulicBoundaryDatabaseContext(assessmentSection.HydraulicBoundaryDatabase, assessmentSection); - assessmentSection.HydraulicBoundaryDatabase.Attach(hydraulicBoundaryDatabaseObserver); - assessmentSection.HydraulicBoundaryDatabase.Locations.Attach(hydraulicBoundaryLocationsObserver); - assessmentSection.GrassCoverErosionOutwards.HydraulicBoundaryLocations.Attach(grassCoverErosionOutwardsLocationsObserver); - using (var treeViewControl = new TreeViewControl()) using (var plugin = new RingtoetsPlugin()) { @@ -423,20 +408,15 @@ public void GivenNoDatabaseLinked_WhenOpeningValidFileWithoutHLCDFromContextMenu_ThenNoDatabaseLinkedNoObserversNotifiedAndLogMessagesAdded() { // Given - var hydraulicBoundaryDatabaseObserver = mocks.StrictMock(); - var hydraulicBoundaryLocationsObserver = mocks.StrictMock(); - var grassCoverErosionOutwardsLocationsObserver = mocks.StrictMock(); - string testFile = Path.Combine(testDataPathNoHlcd, "HRD dutch coast south.sqlite"); var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + + AttachObservers(assessmentSection); + var hydraulicBoundaryDatabaseContext = new HydraulicBoundaryDatabaseContext(assessmentSection.HydraulicBoundaryDatabase, assessmentSection); - assessmentSection.HydraulicBoundaryDatabase.Attach(hydraulicBoundaryDatabaseObserver); - assessmentSection.HydraulicBoundaryDatabase.Locations.Attach(hydraulicBoundaryLocationsObserver); - assessmentSection.GrassCoverErosionOutwards.HydraulicBoundaryLocations.Attach(grassCoverErosionOutwardsLocationsObserver); - using (var treeViewControl = new TreeViewControl()) using (var plugin = new RingtoetsPlugin()) { @@ -480,29 +460,24 @@ public void GivenDatabaseLinked_WhenOpeningSameFileFromContextMenu_ThenCalculationsWillNotBeClearedAndNoObserversNotified() { // Given - var hydraulicBoundaryDatabaseObserver = mocks.StrictMock(); - var hydraulicBoundaryLocationsObserver = mocks.StrictMock(); - var grassCoverErosionOutwardsLocationsObserver = mocks.StrictMock(); - string validFilePath = Path.Combine(testDataPath, "HRD dutch coast south.sqlite"); var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + using (var importer = new HydraulicBoundaryDatabaseImporter()) { importer.Import(assessmentSection, validFilePath); } + AttachObservers(assessmentSection); + ObservableList hydraulicBoundaryLocations = assessmentSection.HydraulicBoundaryDatabase.Locations; GrassCoverErosionOutwardsFailureMechanism grassCoverErosionOutwardsFailureMechanism = assessmentSection.GrassCoverErosionOutwards; assessmentSection.SetHydraulicBoundaryLocationCalculations(hydraulicBoundaryLocations); grassCoverErosionOutwardsFailureMechanism.SetHydraulicBoundaryLocationCalculations(hydraulicBoundaryLocations); grassCoverErosionOutwardsFailureMechanism.SetGrassCoverErosionOutwardsHydraulicBoundaryLocations(assessmentSection.HydraulicBoundaryDatabase.Locations); - assessmentSection.HydraulicBoundaryDatabase.Attach(hydraulicBoundaryDatabaseObserver); - hydraulicBoundaryLocations.Attach(hydraulicBoundaryLocationsObserver); - grassCoverErosionOutwardsFailureMechanism.HydraulicBoundaryLocations.Attach(grassCoverErosionOutwardsLocationsObserver); - PipingOutput pipingOutput = PipingOutputTestFactory.Create(); var pipingCalculation = new PipingCalculation(new GeneralPipingInput()) { @@ -603,6 +578,75 @@ mocks = new MockRepository(); } + private void AttachObservers(AssessmentSection assessmentSection, bool expectUpdateObserver = false) + { + var hydraulicBoundaryDatabaseObserver = mocks.StrictMock(); + var hydraulicBoundaryLocationsObserver = mocks.StrictMock(); + + var waterLevelCalculationsForFactorizedSignalingNormObserver = mocks.StrictMock(); + var waterLevelCalculationsForSignalingNormObserver = mocks.StrictMock(); + var waterLevelCalculationsForLowerLimitNormObserver = mocks.StrictMock(); + var waterLevelCalculationsForFactorizedLowerLimitNormObserver = mocks.StrictMock(); + var waveHeightCalculationsForFactorizedSignalingNormObserver = mocks.StrictMock(); + var waveHeightCalculationsForSignalingNormObserver = mocks.StrictMock(); + var waveHeightCalculationsForLowerLimitNormObserver = mocks.StrictMock(); + var waveHeightCalculationsForFactorizedLowerLimitNormObserver = mocks.StrictMock(); + + var grassCoverErosionOutwardsLocationsObserver = mocks.StrictMock(); + + var waterLevelCalculationsForMechanismSpecificFactorizedSignalingNormObserver = mocks.StrictMock(); + var waterLevelCalculationsForMechanismSpecificSignalingNormObserver = mocks.StrictMock(); + var waterLevelCalculationsForMechanismSpecificLowerLimitNormObserver = mocks.StrictMock(); + var waveHeightCalculationsForMechanismSpecificFactorizedSignalingNormObserver = mocks.StrictMock(); + var waveHeightCalculationsForMechanismSpecificSignalingNormObserver = mocks.StrictMock(); + var waveHeightCalculationsForMechanismSpecificLowerLimitNormObserver = mocks.StrictMock(); + + assessmentSection.HydraulicBoundaryDatabase.Attach(hydraulicBoundaryDatabaseObserver); + assessmentSection.HydraulicBoundaryDatabase.Locations.Attach(hydraulicBoundaryLocationsObserver); + + assessmentSection.WaterLevelCalculationsForFactorizedSignalingNorm.Attach(waterLevelCalculationsForFactorizedSignalingNormObserver); + assessmentSection.WaterLevelCalculationsForSignalingNorm.Attach(waterLevelCalculationsForSignalingNormObserver); + assessmentSection.WaterLevelCalculationsForLowerLimitNorm.Attach(waterLevelCalculationsForLowerLimitNormObserver); + assessmentSection.WaterLevelCalculationsForFactorizedLowerLimitNorm.Attach(waterLevelCalculationsForFactorizedLowerLimitNormObserver); + assessmentSection.WaveHeightCalculationsForFactorizedSignalingNorm.Attach(waveHeightCalculationsForFactorizedSignalingNormObserver); + assessmentSection.WaveHeightCalculationsForSignalingNorm.Attach(waveHeightCalculationsForSignalingNormObserver); + assessmentSection.WaveHeightCalculationsForLowerLimitNorm.Attach(waveHeightCalculationsForLowerLimitNormObserver); + assessmentSection.WaveHeightCalculationsForFactorizedLowerLimitNorm.Attach(waveHeightCalculationsForFactorizedLowerLimitNormObserver); + + assessmentSection.GrassCoverErosionOutwards.HydraulicBoundaryLocations.Attach(grassCoverErosionOutwardsLocationsObserver); + + assessmentSection.GrassCoverErosionOutwards.WaterLevelCalculationsForMechanismSpecificFactorizedSignalingNorm.Attach(waterLevelCalculationsForMechanismSpecificFactorizedSignalingNormObserver); + assessmentSection.GrassCoverErosionOutwards.WaterLevelCalculationsForMechanismSpecificSignalingNorm.Attach(waterLevelCalculationsForMechanismSpecificSignalingNormObserver); + assessmentSection.GrassCoverErosionOutwards.WaterLevelCalculationsForMechanismSpecificLowerLimitNorm.Attach(waterLevelCalculationsForMechanismSpecificLowerLimitNormObserver); + assessmentSection.GrassCoverErosionOutwards.WaveHeightCalculationsForMechanismSpecificFactorizedSignalingNorm.Attach(waveHeightCalculationsForMechanismSpecificFactorizedSignalingNormObserver); + assessmentSection.GrassCoverErosionOutwards.WaveHeightCalculationsForMechanismSpecificSignalingNorm.Attach(waveHeightCalculationsForMechanismSpecificSignalingNormObserver); + assessmentSection.GrassCoverErosionOutwards.WaveHeightCalculationsForMechanismSpecificLowerLimitNorm.Attach(waveHeightCalculationsForMechanismSpecificLowerLimitNormObserver); + + if (expectUpdateObserver) + { + hydraulicBoundaryDatabaseObserver.Expect(o => o.UpdateObserver()); + hydraulicBoundaryLocationsObserver.Expect(o => o.UpdateObserver()); + + waterLevelCalculationsForFactorizedSignalingNormObserver.Expect(o => o.UpdateObserver()); + waterLevelCalculationsForSignalingNormObserver.Expect(o => o.UpdateObserver()); + waterLevelCalculationsForLowerLimitNormObserver.Expect(o => o.UpdateObserver()); + waterLevelCalculationsForFactorizedLowerLimitNormObserver.Expect(o => o.UpdateObserver()); + waveHeightCalculationsForFactorizedSignalingNormObserver.Expect(o => o.UpdateObserver()); + waveHeightCalculationsForSignalingNormObserver.Expect(o => o.UpdateObserver()); + waveHeightCalculationsForLowerLimitNormObserver.Expect(o => o.UpdateObserver()); + waveHeightCalculationsForFactorizedLowerLimitNormObserver.Expect(o => o.UpdateObserver()); + + grassCoverErosionOutwardsLocationsObserver.Expect(o => o.UpdateObserver()); + + waterLevelCalculationsForMechanismSpecificFactorizedSignalingNormObserver.Expect(o => o.UpdateObserver()); + waterLevelCalculationsForMechanismSpecificSignalingNormObserver.Expect(o => o.UpdateObserver()); + waterLevelCalculationsForMechanismSpecificLowerLimitNormObserver.Expect(o => o.UpdateObserver()); + waveHeightCalculationsForMechanismSpecificFactorizedSignalingNormObserver.Expect(o => o.UpdateObserver()); + waveHeightCalculationsForMechanismSpecificSignalingNormObserver.Expect(o => o.UpdateObserver()); + waveHeightCalculationsForMechanismSpecificLowerLimitNormObserver.Expect(o => o.UpdateObserver()); + } + } + private static TreeNodeInfo GetInfo(RingtoetsPlugin plugin) { return plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(HydraulicBoundaryDatabaseContext));