Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs =================================================================== diff -u -r6d48b5cce955b3dfa27776f475d919f05e40bfc5 -r91ff3f5d204bd88b21e62d553cfd867f1843859e --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 6d48b5cce955b3dfa27776f475d919f05e40bfc5) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 91ff3f5d204bd88b21e62d553cfd867f1843859e) @@ -542,9 +542,9 @@ { Text = context => RingtoetsCommonDataResources.ReferenceLine_DisplayName, Image = context => RingtoetsCommonFormsResources.ReferenceLineIcon, - ForeColor = context => context.WrappedData.ReferenceLine == null ? - Color.FromKnownColor(KnownColor.GrayText) : - Color.FromKnownColor(KnownColor.ControlText), + ForeColor = context => context.WrappedData.ReferenceLine == null + ? Color.FromKnownColor(KnownColor.GrayText) + : Color.FromKnownColor(KnownColor.ControlText), ContextMenuStrip = (nodeData, parentData, treeViewControl) => Gui.Get(nodeData, treeViewControl) .AddImportItem() @@ -562,9 +562,9 @@ { Text = context => RingtoetsCommonFormsResources.FailureMechanism_Sections_DisplayName, Image = context => RingtoetsCommonFormsResources.SectionsIcon, - ForeColor = context => context.WrappedData.Sections.Any() ? - Color.FromKnownColor(KnownColor.ControlText) : - Color.FromKnownColor(KnownColor.GrayText), + ForeColor = context => context.WrappedData.Sections.Any() + ? Color.FromKnownColor(KnownColor.ControlText) + : Color.FromKnownColor(KnownColor.GrayText), ContextMenuStrip = FailureMechanismSectionsContextMenuStrip }; @@ -591,9 +591,9 @@ { Text = hydraulicBoundaryDatabase => RingtoetsFormsResources.HydraulicBoundaryDatabase_DisplayName, Image = hydraulicBoundaryDatabase => RingtoetsCommonFormsResources.GenericInputOutputIcon, - ForeColor = context => context.WrappedData.HydraulicBoundaryDatabase == null ? - Color.FromKnownColor(KnownColor.GrayText) : - Color.FromKnownColor(KnownColor.ControlText), + ForeColor = context => context.WrappedData.HydraulicBoundaryDatabase == null + ? Color.FromKnownColor(KnownColor.GrayText) + : Color.FromKnownColor(KnownColor.ControlText), ChildNodeObjects = HydraulicBoundaryDatabaseChildNodeObjects, ContextMenuStrip = HydraulicBoundaryDatabaseContextMenuStrip }; @@ -616,17 +616,15 @@ { Text = context => RingtoetsCommonFormsResources.ForeshoreProfiles_DisplayName, Image = context => RingtoetsCommonFormsResources.GeneralFolderIcon, - ForeColor = context => context.WrappedData.Any() ? - Color.FromKnownColor(KnownColor.ControlText) : - Color.FromKnownColor(KnownColor.GrayText), + ForeColor = context => context.WrappedData.Any() + ? Color.FromKnownColor(KnownColor.ControlText) + : Color.FromKnownColor(KnownColor.GrayText), ChildNodeObjects = context => context.WrappedData .Cast() .ToArray(), ContextMenuStrip = (nodeData, parentData, treeViewControl) => Gui.Get(nodeData, treeViewControl) .AddImportItem() .AddSeparator() - .AddDeleteChildrenItem() - .AddSeparator() .AddCollapseAllItem() .AddExpandAllItem() .AddSeparator() @@ -648,12 +646,8 @@ Text = foreshoreProfile => foreshoreProfile.Name, Image = context => RingtoetsIntegrationPluginResources.Foreshore, ContextMenuStrip = (nodeData, parentData, treeViewControl) => Gui.Get(nodeData, treeViewControl) - .AddDeleteItem() - .AddSeparator() .AddPropertiesItem() - .Build(), - CanRemove = CanRemoveForeshoreProfile, - OnNodeRemoved = OnForeshoreProfileRemoved + .Build() }; yield return RingtoetsTreeNodeInfoFactory.CreateEmptyProbabilityAssessmentOutputTreeNodeInfo( @@ -1063,7 +1057,7 @@ if (failureMechanism != null) { - calculations = (IEnumerable)failureMechanism.Calculations; + calculations = (IEnumerable) failureMechanism.Calculations; } return calculations; @@ -1164,83 +1158,6 @@ #endregion - #region ForeshoreProfile TreeNodeInfo - - private static bool CanRemoveForeshoreProfile(ForeshoreProfile nodeData, object parentNodeData) - { - var parentContext = (ForeshoreProfilesContext) parentNodeData; - IFailureMechanism failureMechanism = parentContext.ParentFailureMechanism; - return failureMechanism is StabilityStoneCoverFailureMechanism || - failureMechanism is WaveImpactAsphaltCoverFailureMechanism || - failureMechanism is GrassCoverErosionOutwardsFailureMechanism || - failureMechanism is HeightStructuresFailureMechanism || - failureMechanism is ClosingStructuresFailureMechanism || - failureMechanism is StabilityPointStructuresFailureMechanism; - } - - private static void OnForeshoreProfileRemoved(ForeshoreProfile nodeData, object parentNodeData) - { - var parentContext = (ForeshoreProfilesContext) parentNodeData; - IFailureMechanism failureMechanism = parentContext.ParentFailureMechanism; - - var stabilityStoneCoverFailureMechanism = failureMechanism as StabilityStoneCoverFailureMechanism; - if (stabilityStoneCoverFailureMechanism != null) - { - IEnumerable affectedObservables = RingtoetsDataSynchronizationService.RemoveForeshoreProfile(stabilityStoneCoverFailureMechanism, nodeData); - foreach (IObservable affectedObservable in affectedObservables) - { - affectedObservable.NotifyObservers(); - } - } - var waveImpactAsphaltCoverFailureMechanism = failureMechanism as WaveImpactAsphaltCoverFailureMechanism; - if (waveImpactAsphaltCoverFailureMechanism != null) - { - IEnumerable affectedObservables = RingtoetsDataSynchronizationService.RemoveForeshoreProfile(waveImpactAsphaltCoverFailureMechanism, nodeData); - foreach (IObservable affectedObservable in affectedObservables) - { - affectedObservable.NotifyObservers(); - } - } - var grassCoverErosionOutwardsFailureMechanism = failureMechanism as GrassCoverErosionOutwardsFailureMechanism; - if (grassCoverErosionOutwardsFailureMechanism != null) - { - IEnumerable affectedObservables = RingtoetsDataSynchronizationService.RemoveForeshoreProfile(grassCoverErosionOutwardsFailureMechanism, nodeData); - foreach (IObservable affectedObservable in affectedObservables) - { - affectedObservable.NotifyObservers(); - } - } - var heightStructuresFailureMechanism = failureMechanism as HeightStructuresFailureMechanism; - if (heightStructuresFailureMechanism != null) - { - IEnumerable affectedObservables = RingtoetsDataSynchronizationService.RemoveForeshoreProfile(heightStructuresFailureMechanism, nodeData); - foreach (IObservable affectedObservable in affectedObservables) - { - affectedObservable.NotifyObservers(); - } - } - var closingStructuresFailureMechanism = failureMechanism as ClosingStructuresFailureMechanism; - if (closingStructuresFailureMechanism != null) - { - IEnumerable affectedObservables = RingtoetsDataSynchronizationService.RemoveForeshoreProfile(closingStructuresFailureMechanism, nodeData); - foreach (IObservable affectedObservable in affectedObservables) - { - affectedObservable.NotifyObservers(); - } - } - var stabilityPointStructuresFailureMechanism = failureMechanism as StabilityPointStructuresFailureMechanism; - if (stabilityPointStructuresFailureMechanism != null) - { - IEnumerable affectedObservables = RingtoetsDataSynchronizationService.RemoveForeshoreProfile(stabilityPointStructuresFailureMechanism, nodeData); - foreach (IObservable affectedObservable in affectedObservables) - { - affectedObservable.NotifyObservers(); - } - } - } - - #endregion - #region AssessmentSection TreeNodeInfo private static object[] AssessmentSectionChildNodeObjects(AssessmentSection nodeData) Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/ForeshoreProfileTreeNodeInfoTest.cs =================================================================== diff -u -r7179946a6b62ebb33a90167c52af7c32f1100d73 -r91ff3f5d204bd88b21e62d553cfd867f1843859e --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/ForeshoreProfileTreeNodeInfoTest.cs (.../ForeshoreProfileTreeNodeInfoTest.cs) (revision 7179946a6b62ebb33a90167c52af7c32f1100d73) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/ForeshoreProfileTreeNodeInfoTest.cs (.../ForeshoreProfileTreeNodeInfoTest.cs) (revision 91ff3f5d204bd88b21e62d553cfd867f1843859e) @@ -77,8 +77,8 @@ Assert.IsNull(info.ChildNodeObjects); Assert.IsNull(info.CanRename); Assert.IsNull(info.OnNodeRenamed); - Assert.IsNotNull(info.CanRemove); - Assert.IsNotNull(info.OnNodeRemoved); + Assert.IsNull(info.CanRemove); + Assert.IsNull(info.OnNodeRemoved); Assert.IsNull(info.CanCheck); Assert.IsNull(info.IsChecked); Assert.IsNull(info.OnNodeChecked); @@ -111,647 +111,8 @@ // Assert TestHelper.AssertImagesAreEqual(Resources.Foreshore, image); } - + [Test] - public void CanRemove_ParentFailureMechanismIsStabilityStoneCover_ReturnTrue() - { - // Setup - var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); - mocks.ReplayAll(); - - var failureMechanism = new StabilityStoneCoverFailureMechanism(); - - var parentData = new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, failureMechanism, assessmentSection); - - // Call - bool canRemove = info.CanRemove(null, parentData); - - // Assert - Assert.IsTrue(canRemove); - mocks.VerifyAll(); - } - - [Test] - public void CanRemove_ParentFailureMechanismIsWaveImpactAsphaltCover_ReturnTrue() - { - // Setup - var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); - mocks.ReplayAll(); - - var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); - - var parentData = new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, failureMechanism, assessmentSection); - - // Call - bool canRemove = info.CanRemove(null, parentData); - - // Assert - Assert.IsTrue(canRemove); - mocks.VerifyAll(); - } - - [Test] - public void CanRemove_ParentFailureMechanismIsGrassCoverErosionOutwards_ReturnTrue() - { - // Setup - var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); - mocks.ReplayAll(); - - var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); - - var parentData = new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, failureMechanism, assessmentSection); - - // Call - bool canRemove = info.CanRemove(null, parentData); - - // Assert - Assert.IsTrue(canRemove); - mocks.VerifyAll(); - } - - [Test] - public void CanRemove_ParentFailureMechanismIsHeightStructures_ReturnTrue() - { - // Setup - var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); - mocks.ReplayAll(); - - var failureMechanism = new HeightStructuresFailureMechanism(); - - var parentData = new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, failureMechanism, assessmentSection); - - // Call - bool canRemove = info.CanRemove(null, parentData); - - // Assert - Assert.IsTrue(canRemove); - mocks.VerifyAll(); - } - - [Test] - public void CanRemove_ParentFailureMechanismIsClosingStructures_ReturnTrue() - { - // Setup - var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); - mocks.ReplayAll(); - - var failureMechanism = new ClosingStructuresFailureMechanism(); - - var parentData = new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, failureMechanism, assessmentSection); - - // Call - bool canRemove = info.CanRemove(null, parentData); - - // Assert - Assert.IsTrue(canRemove); - mocks.VerifyAll(); - } - - [Test] - public void CanRemove_ParentFailureMechanismIsStabilityPointStructures_ReturnTrue() - { - // Setup - var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); - mocks.ReplayAll(); - - var failureMechanism = new StabilityPointStructuresFailureMechanism(); - - var parentData = new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, failureMechanism, assessmentSection); - - // Call - bool canRemove = info.CanRemove(null, parentData); - - // Assert - Assert.IsTrue(canRemove); - mocks.VerifyAll(); - } - - [Test] - public void CanRemove_UnsupportedFailureMechanism_ReturnFalse() - { - // Setup - var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); - var failureMechanism = mocks.Stub(); - mocks.ReplayAll(); - - var foreshoreProfiles = new ForeshoreProfileCollection(); - - var parentData = new ForeshoreProfilesContext(foreshoreProfiles, failureMechanism, assessmentSection); - - // Call - bool canRemove = info.CanRemove(null, parentData); - - // Assert - Assert.IsFalse(canRemove); - mocks.VerifyAll(); - } - - [Test] - public void OnNodeRemoved_ForeshoreProfileOfStabilityStoneCoverWaveConditionsCalculation_ForeshoreProfileRemovedFromFailureMechanismAndCalculationForeshoreProfileCleared() - { - // Setup - var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); - var observer = mocks.Stub(); - observer.Expect(o => o.UpdateObserver()); - var calculation1Observer = mocks.StrictMock(); - calculation1Observer.Expect(o => o.UpdateObserver()); - var calculation2Observer = mocks.StrictMock(); - calculation2Observer.Expect(o => o.UpdateObserver()); - var calculation3Observer = mocks.StrictMock(); - calculation3Observer.Expect(o => o.UpdateObserver()).Repeat.Never(); - mocks.ReplayAll(); - - ForeshoreProfile nodeData = new TestForeshoreProfile("A", "ID A"); - ForeshoreProfile otherProfile = new TestForeshoreProfile("B", "ID B"); - - var calculation1 = new StabilityStoneCoverWaveConditionsCalculation - { - InputParameters = - { - ForeshoreProfile = nodeData - } - }; - calculation1.InputParameters.Attach(calculation1Observer); - var calculation2 = new StabilityStoneCoverWaveConditionsCalculation - { - InputParameters = - { - ForeshoreProfile = nodeData - } - }; - calculation2.InputParameters.Attach(calculation2Observer); - var calculation3 = new StabilityStoneCoverWaveConditionsCalculation - { - InputParameters = - { - ForeshoreProfile = otherProfile - } - }; - calculation3.InputParameters.Attach(calculation3Observer); - - var failureMechanism = new StabilityStoneCoverFailureMechanism - { - WaveConditionsCalculationGroup = - { - Children = - { - calculation1, - new CalculationGroup("A", true) - { - Children = - { - calculation2 - } - }, - calculation3 - } - } - }; - failureMechanism.ForeshoreProfiles.AddRange(new[] - { - nodeData, - otherProfile - }, "path"); - failureMechanism.ForeshoreProfiles.Attach(observer); - - var parentData = new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, failureMechanism, assessmentSection); - - // Call - info.OnNodeRemoved(nodeData, parentData); - - // Assert - CollectionAssert.DoesNotContain(failureMechanism.ForeshoreProfiles, nodeData); - - Assert.IsNull(calculation1.InputParameters.ForeshoreProfile); - Assert.IsNull(calculation2.InputParameters.ForeshoreProfile); - Assert.AreSame(otherProfile, calculation3.InputParameters.ForeshoreProfile); - mocks.VerifyAll(); - } - - [Test] - public void OnNodeRemoved_ForeshoreProfileOfWaveImpactAsphaltCoverWaveConditionsCalculation_ForeshoreProfileRemovedFromFailureMechanismAndCalculationForeshoreProfileCleared() - { - // Setup - var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); - var observer = mocks.Stub(); - observer.Expect(o => o.UpdateObserver()); - var calculation1Observer = mocks.StrictMock(); - calculation1Observer.Expect(o => o.UpdateObserver()); - var calculation2Observer = mocks.StrictMock(); - calculation2Observer.Expect(o => o.UpdateObserver()); - var calculation3Observer = mocks.StrictMock(); - calculation3Observer.Expect(o => o.UpdateObserver()).Repeat.Never(); - mocks.ReplayAll(); - - ForeshoreProfile nodeData = new TestForeshoreProfile("A", "ID A"); - ForeshoreProfile otherProfile = new TestForeshoreProfile("B", "ID B"); - - var calculation1 = new WaveImpactAsphaltCoverWaveConditionsCalculation - { - InputParameters = - { - ForeshoreProfile = nodeData - } - }; - calculation1.InputParameters.Attach(calculation1Observer); - var calculation2 = new WaveImpactAsphaltCoverWaveConditionsCalculation - { - InputParameters = - { - ForeshoreProfile = nodeData - } - }; - calculation2.InputParameters.Attach(calculation2Observer); - var calculation3 = new WaveImpactAsphaltCoverWaveConditionsCalculation - { - InputParameters = - { - ForeshoreProfile = otherProfile - } - }; - calculation3.InputParameters.Attach(calculation3Observer); - - var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism - { - WaveConditionsCalculationGroup = - { - Children = - { - calculation1, - new CalculationGroup("A", true) - { - Children = - { - calculation2 - } - }, - calculation3 - } - } - }; - failureMechanism.ForeshoreProfiles.AddRange(new[] - { - nodeData, - otherProfile - }, "path"); - failureMechanism.ForeshoreProfiles.Attach(observer); - - var parentData = new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, failureMechanism, assessmentSection); - - // Call - info.OnNodeRemoved(nodeData, parentData); - - // Assert - CollectionAssert.DoesNotContain(failureMechanism.ForeshoreProfiles, nodeData); - - Assert.IsNull(calculation1.InputParameters.ForeshoreProfile); - Assert.IsNull(calculation2.InputParameters.ForeshoreProfile); - Assert.AreSame(otherProfile, calculation3.InputParameters.ForeshoreProfile); - mocks.VerifyAll(); - } - - [Test] - public void OnNodeRemoved_ForeshoreProfileOfGrassCoverErosionOutwardsWaveConditionsCalculation_ForeshoreProfileRemovedFromFailureMechanismAndCalculationForeshoreProfileCleared() - { - // Setup - var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); - var observer = mocks.Stub(); - observer.Expect(o => o.UpdateObserver()); - var calculation1Observer = mocks.StrictMock(); - calculation1Observer.Expect(o => o.UpdateObserver()); - var calculation2Observer = mocks.StrictMock(); - calculation2Observer.Expect(o => o.UpdateObserver()); - var calculation3Observer = mocks.StrictMock(); - calculation3Observer.Expect(o => o.UpdateObserver()).Repeat.Never(); - mocks.ReplayAll(); - - ForeshoreProfile nodeData = new TestForeshoreProfile("A", "ID A"); - ForeshoreProfile otherProfile = new TestForeshoreProfile("B", "ID B"); - - var calculation1 = new GrassCoverErosionOutwardsWaveConditionsCalculation - { - InputParameters = - { - ForeshoreProfile = nodeData - } - }; - calculation1.InputParameters.Attach(calculation1Observer); - var calculation2 = new GrassCoverErosionOutwardsWaveConditionsCalculation - { - InputParameters = - { - ForeshoreProfile = nodeData - } - }; - calculation2.InputParameters.Attach(calculation2Observer); - var calculation3 = new GrassCoverErosionOutwardsWaveConditionsCalculation - { - InputParameters = - { - ForeshoreProfile = otherProfile - } - }; - calculation3.InputParameters.Attach(calculation3Observer); - - var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism - { - WaveConditionsCalculationGroup = - { - Children = - { - calculation1, - new CalculationGroup("A", true) - { - Children = - { - calculation2 - } - }, - calculation3 - } - } - }; - failureMechanism.ForeshoreProfiles.AddRange(new[] - { - nodeData, - otherProfile - }, "path"); - failureMechanism.ForeshoreProfiles.Attach(observer); - - var parentData = new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, failureMechanism, assessmentSection); - - // Call - info.OnNodeRemoved(nodeData, parentData); - - // Assert - CollectionAssert.DoesNotContain(failureMechanism.ForeshoreProfiles, nodeData); - - Assert.IsNull(calculation1.InputParameters.ForeshoreProfile); - Assert.IsNull(calculation2.InputParameters.ForeshoreProfile); - Assert.AreSame(otherProfile, calculation3.InputParameters.ForeshoreProfile); - mocks.VerifyAll(); - } - - [Test] - public void OnNodeRemoved_ForeshoreProfileOfHeightStructuresWaveConditionsCalculation_ForeshoreProfileRemovedFromFailureMechanismAndCalculationForeshoreProfileCleared() - { - // Setup - var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); - var observer = mocks.Stub(); - observer.Expect(o => o.UpdateObserver()); - var calculation1Observer = mocks.StrictMock(); - calculation1Observer.Expect(o => o.UpdateObserver()); - var calculation2Observer = mocks.StrictMock(); - calculation2Observer.Expect(o => o.UpdateObserver()); - var calculation3Observer = mocks.StrictMock(); - calculation3Observer.Expect(o => o.UpdateObserver()).Repeat.Never(); - mocks.ReplayAll(); - - ForeshoreProfile nodeData = new TestForeshoreProfile("A", "ID A"); - ForeshoreProfile otherProfile = new TestForeshoreProfile("B", "ID B"); - - var calculation1 = new StructuresCalculation - { - InputParameters = - { - ForeshoreProfile = nodeData - } - }; - calculation1.InputParameters.Attach(calculation1Observer); - var calculation2 = new StructuresCalculation - { - InputParameters = - { - ForeshoreProfile = nodeData - } - }; - calculation2.InputParameters.Attach(calculation2Observer); - var calculation3 = new StructuresCalculation - { - InputParameters = - { - ForeshoreProfile = otherProfile - } - }; - calculation3.InputParameters.Attach(calculation3Observer); - - var failureMechanism = new HeightStructuresFailureMechanism - { - CalculationsGroup = - { - Children = - { - calculation1, - new CalculationGroup("A", true) - { - Children = - { - calculation2 - } - }, - calculation3 - } - } - }; - failureMechanism.ForeshoreProfiles.AddRange(new[] - { - nodeData, - otherProfile - }, "path"); - failureMechanism.ForeshoreProfiles.Attach(observer); - - var parentData = new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, failureMechanism, assessmentSection); - - // Call - info.OnNodeRemoved(nodeData, parentData); - - // Assert - CollectionAssert.DoesNotContain(failureMechanism.ForeshoreProfiles, nodeData); - - Assert.IsNull(calculation1.InputParameters.ForeshoreProfile); - Assert.IsNull(calculation2.InputParameters.ForeshoreProfile); - Assert.AreSame(otherProfile, calculation3.InputParameters.ForeshoreProfile); - mocks.VerifyAll(); - } - - [Test] - public void OnNodeRemoved_ForeshoreProfileOfClosingStructuresWaveConditionsCalculation_ForeshoreProfileRemovedFromFailureMechanismAndCalculationForeshoreProfileCleared() - { - // Setup - var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); - var observer = mocks.Stub(); - observer.Expect(o => o.UpdateObserver()); - var calculation1Observer = mocks.StrictMock(); - calculation1Observer.Expect(o => o.UpdateObserver()); - var calculation2Observer = mocks.StrictMock(); - calculation2Observer.Expect(o => o.UpdateObserver()); - var calculation3Observer = mocks.StrictMock(); - calculation3Observer.Expect(o => o.UpdateObserver()).Repeat.Never(); - mocks.ReplayAll(); - - ForeshoreProfile nodeData = new TestForeshoreProfile("A", "ID A"); - ForeshoreProfile otherProfile = new TestForeshoreProfile("B", "ID B"); - - var calculation1 = new StructuresCalculation - { - InputParameters = - { - ForeshoreProfile = nodeData - } - }; - calculation1.InputParameters.Attach(calculation1Observer); - var calculation2 = new StructuresCalculation - { - InputParameters = - { - ForeshoreProfile = nodeData - } - }; - calculation2.InputParameters.Attach(calculation2Observer); - var calculation3 = new StructuresCalculation - { - InputParameters = - { - ForeshoreProfile = otherProfile - } - }; - calculation3.InputParameters.Attach(calculation3Observer); - - var failureMechanism = new ClosingStructuresFailureMechanism - { - CalculationsGroup = - { - Children = - { - calculation1, - new CalculationGroup("A", true) - { - Children = - { - calculation2 - } - }, - calculation3 - } - } - }; - failureMechanism.ForeshoreProfiles.AddRange(new[] - { - nodeData, - otherProfile - }, "path"); - failureMechanism.ForeshoreProfiles.Attach(observer); - - var parentData = new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, failureMechanism, assessmentSection); - - // Call - info.OnNodeRemoved(nodeData, parentData); - - // Assert - CollectionAssert.DoesNotContain(failureMechanism.ForeshoreProfiles, nodeData); - - Assert.IsNull(calculation1.InputParameters.ForeshoreProfile); - Assert.IsNull(calculation2.InputParameters.ForeshoreProfile); - Assert.AreSame(otherProfile, calculation3.InputParameters.ForeshoreProfile); - mocks.VerifyAll(); - } - - [Test] - public void OnNodeRemoved_ForeshoreProfileOfStabilityPointStructuresWaveConditionsCalculation_ForeshoreProfileRemovedFromFailureMechanismAndCalculationForeshoreProfileCleared() - { - // Setup - var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); - var observer = mocks.Stub(); - observer.Expect(o => o.UpdateObserver()); - var calculation1Observer = mocks.StrictMock(); - calculation1Observer.Expect(o => o.UpdateObserver()); - var calculation2Observer = mocks.StrictMock(); - calculation2Observer.Expect(o => o.UpdateObserver()); - var calculation3Observer = mocks.StrictMock(); - calculation3Observer.Expect(o => o.UpdateObserver()).Repeat.Never(); - mocks.ReplayAll(); - - ForeshoreProfile nodeData = new TestForeshoreProfile("A", "ID A"); - ForeshoreProfile otherProfile = new TestForeshoreProfile("B", "ID B"); - - var calculation1 = new StructuresCalculation - { - InputParameters = - { - ForeshoreProfile = nodeData - } - }; - calculation1.InputParameters.Attach(calculation1Observer); - var calculation2 = new StructuresCalculation - { - InputParameters = - { - ForeshoreProfile = nodeData - } - }; - calculation2.InputParameters.Attach(calculation2Observer); - var calculation3 = new StructuresCalculation - { - InputParameters = - { - ForeshoreProfile = otherProfile - } - }; - calculation3.InputParameters.Attach(calculation3Observer); - - var failureMechanism = new StabilityPointStructuresFailureMechanism - { - CalculationsGroup = - { - Children = - { - calculation1, - new CalculationGroup("A", true) - { - Children = - { - calculation2 - } - }, - calculation3 - } - } - }; - failureMechanism.ForeshoreProfiles.AddRange(new[] - { - nodeData, - otherProfile - }, "path"); - failureMechanism.ForeshoreProfiles.Attach(observer); - - var parentData = new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, failureMechanism, assessmentSection); - - // Call - info.OnNodeRemoved(nodeData, parentData); - - // Assert - CollectionAssert.DoesNotContain(failureMechanism.ForeshoreProfiles, nodeData); - - Assert.IsNull(calculation1.InputParameters.ForeshoreProfile); - Assert.IsNull(calculation2.InputParameters.ForeshoreProfile); - Assert.AreSame(otherProfile, calculation3.InputParameters.ForeshoreProfile); - mocks.VerifyAll(); - } - - [Test] public void ContextMenuStrip_Always_CallsBuilder() { // Setup @@ -760,8 +121,6 @@ var menuBuilderMock = mocks.StrictMock(); using (mocks.Ordered()) { - menuBuilderMock.Expect(mb => mb.AddDeleteItem()).Return(menuBuilderMock); - menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.Build()).Return(null); } Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/ForeshoreProfilesContextTreeNodeInfoTest.cs =================================================================== diff -u -r57aa4b3ba3e2171b2f6c9a86719a26557dba29e6 -r91ff3f5d204bd88b21e62d553cfd867f1843859e --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/ForeshoreProfilesContextTreeNodeInfoTest.cs (.../ForeshoreProfilesContextTreeNodeInfoTest.cs) (revision 57aa4b3ba3e2171b2f6c9a86719a26557dba29e6) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/ForeshoreProfilesContextTreeNodeInfoTest.cs (.../ForeshoreProfilesContextTreeNodeInfoTest.cs) (revision 91ff3f5d204bd88b21e62d553cfd867f1843859e) @@ -199,8 +199,6 @@ { contextMenuBuilder.Expect(b => b.AddImportItem()).Return(contextMenuBuilder); contextMenuBuilder.Expect(b => b.AddSeparator()).Return(contextMenuBuilder); - contextMenuBuilder.Expect(b => b.AddDeleteChildrenItem()).Return(contextMenuBuilder); - contextMenuBuilder.Expect(b => b.AddSeparator()).Return(contextMenuBuilder); contextMenuBuilder.Expect(b => b.AddCollapseAllItem()).Return(contextMenuBuilder); contextMenuBuilder.Expect(b => b.AddExpandAllItem()).Return(contextMenuBuilder); contextMenuBuilder.Expect(b => b.AddSeparator()).Return(contextMenuBuilder);