Index: Riskeer/Integration/src/Riskeer.Integration.Plugin/Merge/AssessmentSectionMergeHandler.cs =================================================================== diff -u -r48244f68eee25ef1d91701d82e4c4867f0252ffc -r6bb3c5039c95b9056e5ec7c293a5b3f31eddf986 --- Riskeer/Integration/src/Riskeer.Integration.Plugin/Merge/AssessmentSectionMergeHandler.cs (.../AssessmentSectionMergeHandler.cs) (revision 48244f68eee25ef1d91701d82e4c4867f0252ffc) +++ Riskeer/Integration/src/Riskeer.Integration.Plugin/Merge/AssessmentSectionMergeHandler.cs (.../AssessmentSectionMergeHandler.cs) (revision 6bb3c5039c95b9056e5ec7c293a5b3f31eddf986) @@ -24,7 +24,6 @@ using System.Linq; using Core.Common.Base; using Core.Common.Util.Extensions; -using Core.Gui.Commands; using log4net; using Riskeer.ClosingStructures.Data; using Riskeer.Common.Data.AssessmentSection; @@ -54,25 +53,6 @@ { private static readonly ILog log = LogManager.GetLogger(typeof(AssessmentSectionMergeHandler)); - private readonly IViewCommands viewCommands; - - /// - /// Creates a new instance of . - /// - /// The view commands used to close views for the target - /// . - /// Thrown when - /// is null. - public AssessmentSectionMergeHandler(IViewCommands viewCommands) - { - if (viewCommands == null) - { - throw new ArgumentNullException(nameof(viewCommands)); - } - - this.viewCommands = viewCommands; - } - public void PerformMerge(AssessmentSection targetAssessmentSection, AssessmentSectionMergeData mergeData) { if (targetAssessmentSection == null) @@ -85,8 +65,6 @@ throw new ArgumentNullException(nameof(mergeData)); } - BeforeMerge(targetAssessmentSection, mergeData); - var changedObjects = new List { targetAssessmentSection @@ -98,36 +76,6 @@ AfterMerge(changedObjects); } - private void BeforeMerge(AssessmentSection assessmentSection, AssessmentSectionMergeData mergeData) - { - CloseViewsForFailureMechanism(mergeData.MergePiping, assessmentSection.Piping); - CloseViewsForFailureMechanism(mergeData.MergeGrassCoverErosionInwards, assessmentSection.GrassCoverErosionInwards); - CloseViewsForFailureMechanism(mergeData.MergeMacroStabilityInwards, assessmentSection.MacroStabilityInwards); - CloseViewsForFailureMechanism(mergeData.MergeMacroStabilityOutwards, assessmentSection.MacroStabilityOutwards); - CloseViewsForFailureMechanism(mergeData.MergeMicrostability, assessmentSection.Microstability); - CloseViewsForFailureMechanism(mergeData.MergeStabilityStoneCover, assessmentSection.StabilityStoneCover); - CloseViewsForFailureMechanism(mergeData.MergeWaveImpactAsphaltCover, assessmentSection.WaveImpactAsphaltCover); - CloseViewsForFailureMechanism(mergeData.MergeWaterPressureAsphaltCover, assessmentSection.WaterPressureAsphaltCover); - CloseViewsForFailureMechanism(mergeData.MergeGrassCoverErosionOutwards, assessmentSection.GrassCoverErosionOutwards); - CloseViewsForFailureMechanism(mergeData.MergeGrassCoverSlipOffOutwards, assessmentSection.GrassCoverSlipOffOutwards); - CloseViewsForFailureMechanism(mergeData.MergeGrassCoverSlipOffInwards, assessmentSection.GrassCoverSlipOffInwards); - CloseViewsForFailureMechanism(mergeData.MergeHeightStructures, assessmentSection.HeightStructures); - CloseViewsForFailureMechanism(mergeData.MergeClosingStructures, assessmentSection.ClosingStructures); - CloseViewsForFailureMechanism(mergeData.MergePipingStructure, assessmentSection.PipingStructure); - CloseViewsForFailureMechanism(mergeData.MergeStabilityPointStructures, assessmentSection.StabilityPointStructures); - CloseViewsForFailureMechanism(mergeData.MergeStrengthStabilityLengthwiseConstruction, assessmentSection.StrengthStabilityLengthwiseConstruction); - CloseViewsForFailureMechanism(mergeData.MergeDuneErosion, assessmentSection.DuneErosion); - CloseViewsForFailureMechanism(mergeData.MergeTechnicalInnovation, assessmentSection.TechnicalInnovation); - } - - private void CloseViewsForFailureMechanism(bool shouldClose, IFailureMechanism failureMechanism) - { - if (shouldClose) - { - viewCommands.RemoveAllViewsForItem(failureMechanism); - } - } - private static void AfterMerge(IEnumerable changedObjects) { changedObjects.ForEachElementDo(co => co.NotifyObservers()); Index: Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerPlugin.cs =================================================================== diff -u -r53c1ab15d75a6d5819a71fb345ccdf3dc56dafe5 -r6bb3c5039c95b9056e5ec7c293a5b3f31eddf986 --- Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerPlugin.cs (.../RiskeerPlugin.cs) (revision 53c1ab15d75a6d5819a71fb345ccdf3dc56dafe5) +++ Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerPlugin.cs (.../RiskeerPlugin.cs) (revision 6bb3c5039c95b9056e5ec7c293a5b3f31eddf986) @@ -1,4 +1,4 @@ -// Copyright (C) Stichting Deltares 2021. All rights reserved. +// Copyright (C) Stichting Deltares 2021. All rights reserved. // // This file is part of Riskeer. // @@ -148,7 +148,7 @@ new AssessmentSectionProvider(Gui.MainWindow, Gui.ProjectStore), new AssessmentSectionMergeComparer(), new AssessmentSectionMergeDataProviderDialog(Gui.MainWindow), - new AssessmentSectionMergeHandler(Gui.ViewCommands)); + new AssessmentSectionMergeHandler()); } public override IEnumerable GetStateInfos() Index: Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/Merge/AssessmentSectionMergeHandlerTest.cs =================================================================== diff -u -r48244f68eee25ef1d91701d82e4c4867f0252ffc -r6bb3c5039c95b9056e5ec7c293a5b3f31eddf986 --- Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/Merge/AssessmentSectionMergeHandlerTest.cs (.../AssessmentSectionMergeHandlerTest.cs) (revision 48244f68eee25ef1d91701d82e4c4867f0252ffc) +++ Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/Merge/AssessmentSectionMergeHandlerTest.cs (.../AssessmentSectionMergeHandlerTest.cs) (revision 6bb3c5039c95b9056e5ec7c293a5b3f31eddf986) @@ -25,7 +25,6 @@ using Core.Common.Base; using Core.Common.TestUtil; using Core.Common.Util.Extensions; -using Core.Gui.Commands; using NUnit.Framework; using Rhino.Mocks; using Riskeer.ClosingStructures.Data; @@ -53,62 +52,36 @@ public class AssessmentSectionMergeHandlerTest { [Test] - public void Constructor_ViewCommandsNull_ThrowsArgumentNullException() - { - // Call - void Call() => new AssessmentSectionMergeHandler(null); - - // Assert - var exception = Assert.Throws(Call); - Assert.AreEqual("viewCommands", exception.ParamName); - } - - [Test] public void Constructor_ExpectedValues() { - // Setup - var mocks = new MockRepository(); - var viewCommands = mocks.StrictMock(); - mocks.ReplayAll(); - // Call - var handler = new AssessmentSectionMergeHandler(viewCommands); + var handler = new AssessmentSectionMergeHandler(); // Assert Assert.IsInstanceOf(handler); - mocks.VerifyAll(); } [Test] public void PerformMerge_TargetAssessmentSectionNull_ThrowsArgumentNullException() { // Setup - var mocks = new MockRepository(); - var viewCommands = mocks.StrictMock(); - mocks.ReplayAll(); + var handler = new AssessmentSectionMergeHandler(); - var handler = new AssessmentSectionMergeHandler(viewCommands); - // Call void Call() => handler.PerformMerge(null, new AssessmentSectionMergeData(new AssessmentSection(AssessmentSectionComposition.Dike), new AssessmentSectionMergeData.ConstructionProperties())); // Assert var exception = Assert.Throws(Call); Assert.AreEqual("targetAssessmentSection", exception.ParamName); - mocks.VerifyAll(); } [Test] public void PerformMerge_MergeDataNull_ThrowsArgumentNullException() { // Setup - var mocks = new MockRepository(); - var viewCommands = mocks.StrictMock(); - mocks.ReplayAll(); + var handler = new AssessmentSectionMergeHandler(); - var handler = new AssessmentSectionMergeHandler(viewCommands); - // Call void Call() => handler.PerformMerge(new AssessmentSection(AssessmentSectionComposition.Dike), null); @@ -118,96 +91,10 @@ } [Test] - public void PerformMerge_WithAllFailureMechanismsToMerge_AllViewsForFailureMechanismsClosed() - { - // Setup - var targetAssessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - - var mocks = new MockRepository(); - var viewCommands = mocks.StrictMock(); - viewCommands.Expect(vc => vc.RemoveAllViewsForItem(targetAssessmentSection.Piping)); - viewCommands.Expect(vc => vc.RemoveAllViewsForItem(targetAssessmentSection.GrassCoverErosionInwards)); - viewCommands.Expect(vc => vc.RemoveAllViewsForItem(targetAssessmentSection.MacroStabilityInwards)); - viewCommands.Expect(vc => vc.RemoveAllViewsForItem(targetAssessmentSection.MacroStabilityOutwards)); - viewCommands.Expect(vc => vc.RemoveAllViewsForItem(targetAssessmentSection.Microstability)); - viewCommands.Expect(vc => vc.RemoveAllViewsForItem(targetAssessmentSection.StabilityStoneCover)); - viewCommands.Expect(vc => vc.RemoveAllViewsForItem(targetAssessmentSection.WaveImpactAsphaltCover)); - viewCommands.Expect(vc => vc.RemoveAllViewsForItem(targetAssessmentSection.WaterPressureAsphaltCover)); - viewCommands.Expect(vc => vc.RemoveAllViewsForItem(targetAssessmentSection.GrassCoverErosionOutwards)); - viewCommands.Expect(vc => vc.RemoveAllViewsForItem(targetAssessmentSection.GrassCoverSlipOffOutwards)); - viewCommands.Expect(vc => vc.RemoveAllViewsForItem(targetAssessmentSection.GrassCoverSlipOffInwards)); - viewCommands.Expect(vc => vc.RemoveAllViewsForItem(targetAssessmentSection.HeightStructures)); - viewCommands.Expect(vc => vc.RemoveAllViewsForItem(targetAssessmentSection.ClosingStructures)); - viewCommands.Expect(vc => vc.RemoveAllViewsForItem(targetAssessmentSection.PipingStructure)); - viewCommands.Expect(vc => vc.RemoveAllViewsForItem(targetAssessmentSection.StabilityPointStructures)); - viewCommands.Expect(vc => vc.RemoveAllViewsForItem(targetAssessmentSection.StrengthStabilityLengthwiseConstruction)); - viewCommands.Expect(vc => vc.RemoveAllViewsForItem(targetAssessmentSection.DuneErosion)); - viewCommands.Expect(vc => vc.RemoveAllViewsForItem(targetAssessmentSection.TechnicalInnovation)); - mocks.ReplayAll(); - - var handler = new AssessmentSectionMergeHandler(viewCommands); - - // Call - handler.PerformMerge(targetAssessmentSection, - new AssessmentSectionMergeData( - new AssessmentSection(AssessmentSectionComposition.Dike), - new AssessmentSectionMergeData.ConstructionProperties - { - MergePiping = true, - MergeGrassCoverErosionInwards = true, - MergeMacroStabilityInwards = true, - MergeMacroStabilityOutwards = true, - MergeMicrostability = true, - MergeStabilityStoneCover = true, - MergeWaveImpactAsphaltCover = true, - MergeWaterPressureAsphaltCover = true, - MergeGrassCoverErosionOutwards = true, - MergeGrassCoverSlipOffOutwards = true, - MergeGrassCoverSlipOffInwards = true, - MergeHeightStructures = true, - MergeClosingStructures = true, - MergePipingStructure = true, - MergeStabilityPointStructures = true, - MergeStrengthStabilityLengthwiseConstruction = true, - MergeDuneErosion = true, - MergeTechnicalInnovation = true - })); - - // Assert - mocks.VerifyAll(); - } - - [Test] - public void PerformMerge_WithNoFailureMechanismsToMerge_NoViewsClosed() - { - // Setup - var targetAssessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - - var mocks = new MockRepository(); - var viewCommands = mocks.StrictMock(); - mocks.ReplayAll(); - - var handler = new AssessmentSectionMergeHandler(viewCommands); - - // Call - handler.PerformMerge(targetAssessmentSection, - new AssessmentSectionMergeData( - new AssessmentSection(AssessmentSectionComposition.Dike), - new AssessmentSectionMergeData.ConstructionProperties())); - - // Assert - mocks.VerifyAll(); - } - - [Test] public void PerformMerge_WithAllFailureMechanismsToMerge_SetNewFailureMechanisms() { // Setup - var mocks = new MockRepository(); - var viewCommands = mocks.Stub(); - mocks.ReplayAll(); - - var handler = new AssessmentSectionMergeHandler(viewCommands); + var handler = new AssessmentSectionMergeHandler(); var targetAssessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); var sourceAssessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); @@ -261,11 +148,7 @@ public void PerformMerge_WithNoFailureMechanismsToMerge_FailureMechanismsSame() { // Setup - var mocks = new MockRepository(); - var viewCommands = mocks.Stub(); - mocks.ReplayAll(); - - var handler = new AssessmentSectionMergeHandler(viewCommands); + var handler = new AssessmentSectionMergeHandler(); var targetAssessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); var sourceAssessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); @@ -300,11 +183,7 @@ public void PerformMerge_WithAllFailureMechanismsToMerge_LogMessages() { // Setup - var mocks = new MockRepository(); - var viewCommands = mocks.Stub(); - mocks.ReplayAll(); - - var handler = new AssessmentSectionMergeHandler(viewCommands); + var handler = new AssessmentSectionMergeHandler(); var targetAssessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); var sourceAssessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); @@ -363,12 +242,8 @@ public void GivenFailureMechanismWithWithCalculations_WhenCalculationHasReferenceToHydraulicBoundaryLocation_ThenReferenceUpdated() { // Given - var mocks = new MockRepository(); - var viewCommands = mocks.Stub(); - mocks.ReplayAll(); + var handler = new AssessmentSectionMergeHandler(); - var handler = new AssessmentSectionMergeHandler(viewCommands); - var targetLocations = new[] { new HydraulicBoundaryLocation(1, "location 1", 1, 1), @@ -554,10 +429,6 @@ Func> getCalculationsFunc) { // Given - var mocks = new MockRepository(); - var viewCommands = mocks.Stub(); - mocks.ReplayAll(); - HydraulicBoundaryLocation[] locations = { new TestHydraulicBoundaryLocation(), @@ -573,7 +444,7 @@ SetOutput(targetCalculations); sourceCalculations.ForEachElementDo(c => c.InputParameters.ShouldIllustrationPointsBeCalculated = true); - var handler = new AssessmentSectionMergeHandler(viewCommands); + var handler = new AssessmentSectionMergeHandler(); // Precondition Assert.IsTrue(targetCalculations.All(c => c.HasOutput)); @@ -591,7 +462,6 @@ Assert.IsTrue(targetCalculations.All(c => c.HasOutput)); Assert.IsTrue(sourceCalculations.All(c => !c.HasOutput)); Assert.IsTrue(targetCalculations.All(c => !c.InputParameters.ShouldIllustrationPointsBeCalculated)); - mocks.VerifyAll(); } [Test] @@ -600,10 +470,6 @@ Func> getCalculationsFunc) { // Given - var mocks = new MockRepository(); - var viewCommands = mocks.Stub(); - mocks.ReplayAll(); - HydraulicBoundaryLocation[] locations = { new TestHydraulicBoundaryLocation(), @@ -620,7 +486,7 @@ SetOutput(sourceCalculations); sourceCalculations.ForEachElementDo(c => c.InputParameters.ShouldIllustrationPointsBeCalculated = true); - var handler = new AssessmentSectionMergeHandler(viewCommands); + var handler = new AssessmentSectionMergeHandler(); // Precondition Assert.IsTrue(targetCalculations.All(c => c.HasOutput)); @@ -641,7 +507,6 @@ Assert.IsTrue(targetCalculations.All(c => !c.Output.HasGeneralResult)); Assert.IsTrue(sourceCalculations.All(c => !c.Output.HasGeneralResult)); Assert.IsTrue(targetCalculations.All(c => !c.InputParameters.ShouldIllustrationPointsBeCalculated)); - mocks.VerifyAll(); } [Test] @@ -650,10 +515,6 @@ Func> getCalculationsFunc) { // Given - var mocks = new MockRepository(); - var viewCommands = mocks.Stub(); - mocks.ReplayAll(); - HydraulicBoundaryLocation[] locations = { new TestHydraulicBoundaryLocation(), @@ -669,7 +530,7 @@ SetOutput(sourceCalculations); sourceCalculations.ForEachElementDo(c => c.InputParameters.ShouldIllustrationPointsBeCalculated = true); - var handler = new AssessmentSectionMergeHandler(viewCommands); + var handler = new AssessmentSectionMergeHandler(); // Precondition Assert.IsTrue(targetCalculations.All(c => !c.HasOutput)); @@ -686,7 +547,6 @@ // Then Assert.IsTrue(targetCalculations.All(c => c.HasOutput)); Assert.IsTrue(targetCalculations.All(c => c.InputParameters.ShouldIllustrationPointsBeCalculated)); - mocks.VerifyAll(); } [Test] @@ -695,10 +555,6 @@ Func> getCalculationsFunc) { // Given - var mocks = new MockRepository(); - var viewCommands = mocks.Stub(); - mocks.ReplayAll(); - HydraulicBoundaryLocation[] locations = { new TestHydraulicBoundaryLocation(), @@ -714,7 +570,7 @@ SetOutput(targetCalculations, true); SetOutput(sourceCalculations); - var handler = new AssessmentSectionMergeHandler(viewCommands); + var handler = new AssessmentSectionMergeHandler(); // Precondition Assert.IsTrue(targetCalculations.All(c => c.HasOutput)); @@ -733,7 +589,6 @@ Assert.IsTrue(targetCalculations.All(c => c.Output.HasGeneralResult)); Assert.IsTrue(sourceCalculations.All(c => c.HasOutput)); Assert.IsTrue(sourceCalculations.All(c => !c.Output.HasGeneralResult)); - mocks.VerifyAll(); } [Test] @@ -742,10 +597,6 @@ Func> getCalculationsFunc) { // Given - var mocks = new MockRepository(); - var viewCommands = mocks.Stub(); - mocks.ReplayAll(); - HydraulicBoundaryLocation[] locations = { new TestHydraulicBoundaryLocation(), @@ -761,7 +612,7 @@ SetOutput(targetCalculations); SetOutput(sourceCalculations, true); - var handler = new AssessmentSectionMergeHandler(viewCommands); + var handler = new AssessmentSectionMergeHandler(); // Precondition Assert.IsTrue(targetCalculations.All(c => c.HasOutput)); @@ -778,7 +629,6 @@ // Then Assert.IsTrue(targetCalculations.All(c => c.HasOutput)); Assert.IsTrue(targetCalculations.All(c => c.Output.HasGeneralResult)); - mocks.VerifyAll(); } [Test] @@ -787,10 +637,6 @@ Func> getCalculationsFunc) { // Given - var mocks = new MockRepository(); - var viewCommands = mocks.Stub(); - mocks.ReplayAll(); - HydraulicBoundaryLocation[] locations = { new TestHydraulicBoundaryLocation(), @@ -807,7 +653,7 @@ SetOutput(sourceCalculations, true); sourceCalculations.ForEachElementDo(c => c.InputParameters.ShouldIllustrationPointsBeCalculated = true); - var handler = new AssessmentSectionMergeHandler(viewCommands); + var handler = new AssessmentSectionMergeHandler(); // Precondition Assert.IsTrue(targetCalculations.All(c => c.HasOutput)); @@ -828,7 +674,6 @@ Assert.IsTrue(targetCalculations.All(c => c.Output.HasGeneralResult)); Assert.IsTrue(sourceCalculations.All(c => c.Output.HasGeneralResult)); Assert.IsTrue(targetCalculations.All(c => !c.InputParameters.ShouldIllustrationPointsBeCalculated)); - mocks.VerifyAll(); } [Test] @@ -838,7 +683,6 @@ { // Setup var mocks = new MockRepository(); - var viewCommands = mocks.Stub(); var observer = mocks.StrictMock(); observer.Expect(o => o.UpdateObserver()).Repeat.Twice(); mocks.ReplayAll(); @@ -860,7 +704,7 @@ SetOutput(targetCalculations); SetOutput(sourceCalculations, true); - var handler = new AssessmentSectionMergeHandler(viewCommands); + var handler = new AssessmentSectionMergeHandler(); // Call void Call() => handler.PerformMerge(targetAssessmentSection, new AssessmentSectionMergeData( @@ -879,7 +723,6 @@ { // Setup var mocks = new MockRepository(); - var viewCommands = mocks.Stub(); var observer = mocks.StrictMock(); mocks.ReplayAll(); @@ -900,7 +743,7 @@ SetOutput(targetCalculations); SetOutput(sourceCalculations); - var handler = new AssessmentSectionMergeHandler(viewCommands); + var handler = new AssessmentSectionMergeHandler(); // Call void Call() => handler.PerformMerge(targetAssessmentSection, new AssessmentSectionMergeData(