Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs =================================================================== diff -u -rd3f74e71ab47dc8afda0c64ca923f2f889f4154b -r7a165d807e1cce8ca51f7707ce6addb0951aa8b4 --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs (.../ClosingStructuresPlugin.cs) (revision d3f74e71ab47dc8afda0c64ca923f2f889f4154b) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs (.../ClosingStructuresPlugin.cs) (revision 7a165d807e1cce8ca51f7707ce6addb0951aa8b4) @@ -312,7 +312,7 @@ { return new object[] { - new CommentContext(closingStructuresFailureMechanismContext.WrappedData) + new CommentContext(closingStructuresFailureMechanismContext.WrappedData.NotRelevantComments) }; } @@ -323,7 +323,7 @@ new FailureMechanismSectionsContext(failureMechanism, assessmentSection), new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, failureMechanism, assessmentSection), new ClosingStructuresContext(failureMechanism.ClosingStructures, failureMechanism, assessmentSection), - new CommentContext(failureMechanism) + new CommentContext(failureMechanism.InputComments) }; } @@ -332,7 +332,9 @@ return new ArrayList { new ClosingStructuresScenariosContext(failureMechanism.CalculationsGroup, failureMechanism), - new FailureMechanismSectionResultContext(failureMechanism.SectionResults, failureMechanism) + new FailureMechanismSectionResultContext( + failureMechanism.SectionResults, failureMechanism), + new CommentContext(failureMechanism.OutputComments) }; } @@ -364,11 +366,15 @@ Gui.ViewCommands.RemoveAllViewsForItem(failureMechanismContext); } - private ContextMenuStrip FailureMechanismDisabledContextMenuStrip(ClosingStructuresFailureMechanismContext closingStructuresFailureMechanismContext, object parentData, TreeViewControl treeViewControl) + private ContextMenuStrip FailureMechanismDisabledContextMenuStrip(ClosingStructuresFailureMechanismContext closingStructuresFailureMechanismContext, + object parentData, + TreeViewControl treeViewControl) { - var builder = new RingtoetsContextMenuBuilder(Gui.Get(closingStructuresFailureMechanismContext, treeViewControl)); + var builder = new RingtoetsContextMenuBuilder(Gui.Get(closingStructuresFailureMechanismContext, + treeViewControl)); - return builder.AddToggleRelevancyOfFailureMechanismItem(closingStructuresFailureMechanismContext, null) + return builder.AddToggleRelevancyOfFailureMechanismItem(closingStructuresFailureMechanismContext, + RemoveAllViewsForItem) .AddSeparator() .AddExpandAllItem() .AddCollapseAllItem() Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructureFailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -rbc9af05d3eb0d40e5620b96f537ed92f3ae52e94 -r7a165d807e1cce8ca51f7707ce6addb0951aa8b4 --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructureFailureMechanismContextTreeNodeInfoTest.cs (.../ClosingStructureFailureMechanismContextTreeNodeInfoTest.cs) (revision bc9af05d3eb0d40e5620b96f537ed92f3ae52e94) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructureFailureMechanismContextTreeNodeInfoTest.cs (.../ClosingStructureFailureMechanismContextTreeNodeInfoTest.cs) (revision 7a165d807e1cce8ca51f7707ce6addb0951aa8b4) @@ -146,8 +146,8 @@ Assert.AreSame(failureMechanism, closingStructuresContext.FailureMechanism); Assert.AreSame(assessmentSectionMock, closingStructuresContext.AssessmentSection); - var commentContext = (CommentContext) inputsFolder.Contents[3]; - Assert.AreSame(failureMechanism, commentContext.WrappedData); + var inputCommentContext = (CommentContext) inputsFolder.Contents[3]; + Assert.AreSame(failureMechanism.InputComments, inputCommentContext.WrappedData); var calculationsFolder = (ClosingStructuresCalculationGroupContext) children[1]; Assert.AreEqual("Berekeningen", calculationsFolder.WrappedData.Name); @@ -157,19 +157,22 @@ var outputsFolder = (CategoryTreeFolder) children[2]; Assert.AreEqual("Oordeel", outputsFolder.Name); Assert.AreEqual(TreeFolderCategory.Output, outputsFolder.Category); - Assert.AreEqual(2, outputsFolder.Contents.Count); + Assert.AreEqual(3, outputsFolder.Contents.Count); var scenariosContext = (ClosingStructuresScenariosContext) outputsFolder.Contents[0]; Assert.AreSame(failureMechanism.CalculationsGroup, scenariosContext.WrappedData); Assert.AreSame(failureMechanism, scenariosContext.ParentFailureMechanism); var failureMechanismResultsContext = (FailureMechanismSectionResultContext) outputsFolder.Contents[1]; Assert.AreSame(failureMechanism, failureMechanismResultsContext.FailureMechanism); Assert.AreSame(failureMechanism.SectionResults, failureMechanismResultsContext.WrappedData); + + var outputCommentContext = (CommentContext) outputsFolder.Contents[2]; + Assert.AreSame(failureMechanism.OutputComments, outputCommentContext.WrappedData); } [Test] - public void ChildNodeObjects_FailureMechanismIsNotRelevant_ReturnOnlyFailureMechanismComments() + public void ChildNodeObjects_FailureMechanismIsNotRelevant_ReturnOnlyFailureMechanismNotRelevantComments() { // Setup var assessmentSectionMock = mocksRepository.Stub(); @@ -187,7 +190,7 @@ // Assert Assert.AreEqual(1, children.Length); var commentContext = (CommentContext) children[0]; - Assert.AreSame(failureMechanism, commentContext.WrappedData); + Assert.AreSame(failureMechanism.NotRelevantComments, commentContext.WrappedData); } [Test] @@ -354,8 +357,8 @@ { // Setup var failureMechanism = new ClosingStructuresFailureMechanism(); - var assessmentSectionMock = mocksRepository.Stub(); - var failureMechanismContext = new ClosingStructuresFailureMechanismContext(failureMechanism, assessmentSectionMock); + var assessmentSectionStub = mocksRepository.Stub(); + var failureMechanismContext = new ClosingStructuresFailureMechanismContext(failureMechanism, assessmentSectionStub); var viewCommandsMock = mocksRepository.StrictMock(); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var guiMock = mocksRepository.StrictMock(); @@ -382,18 +385,22 @@ } [Test] - public void ContextMenuStrip_FailureMechanismIsNotRelevantAndClickOnIsRelevantItem_MakeFailureMechanismRelevant() + public void ContextMenuStrip_FailureMechanismIsNotRelevantAndClickOnIsRelevantItem_OnChangeActionRemovesAllViewsForItem() { // Setup var failureMechanism = new ClosingStructuresFailureMechanism { IsRelevant = false }; - var assessmentSectionMock = mocksRepository.Stub(); - var failureMechanismContext = new ClosingStructuresFailureMechanismContext(failureMechanism, assessmentSectionMock); + var assessmentSectionStub = mocksRepository.Stub(); + var failureMechanismContext = new ClosingStructuresFailureMechanismContext(failureMechanism, assessmentSectionStub); + var viewCommandsMock = mocksRepository.StrictMock(); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var guiMock = mocksRepository.StrictMock(); + viewCommandsMock.Expect(vs => vs.RemoveAllViewsForItem(failureMechanismContext)); + guiMock.Stub(g => g.ViewCommands).Return(viewCommandsMock); + using (var treeViewControl = new TreeViewControl()) { guiMock.Expect(g => g.Get(failureMechanismContext, treeViewControl)).Return(menuBuilder); Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -r306b732e03a09bf7dcd66e37dc1db8fa281b1480 -r7a165d807e1cce8ca51f7707ce6addb0951aa8b4 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismContextTreeNodeInfoTest.cs (.../FailureMechanismContextTreeNodeInfoTest.cs) (revision 306b732e03a09bf7dcd66e37dc1db8fa281b1480) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismContextTreeNodeInfoTest.cs (.../FailureMechanismContextTreeNodeInfoTest.cs) (revision 7a165d807e1cce8ca51f7707ce6addb0951aa8b4) @@ -233,7 +233,7 @@ } [Test] - public void ChildNodeObjects_FailureMechanismIsNotRelevant_ReturnOnlyFailureMechanismComments() + public void ChildNodeObjects_FailureMechanismIsNotRelevant_ReturnOnlyFailureMechanismNotRelevantComments() { // Setup var assessmentSection = mocks.Stub();