Index: Ringtoets/Common/src/Ringtoets.Common.Data/AssessmentSection/IAssessmentSection.cs =================================================================== diff -u -r5ef5e3e186036b4985798236624d86b2801b87d3 -rfa424689d48793c024e73bfcee1c202559eea3e0 --- Ringtoets/Common/src/Ringtoets.Common.Data/AssessmentSection/IAssessmentSection.cs (.../IAssessmentSection.cs) (revision 5ef5e3e186036b4985798236624d86b2801b87d3) +++ Ringtoets/Common/src/Ringtoets.Common.Data/AssessmentSection/IAssessmentSection.cs (.../IAssessmentSection.cs) (revision fa424689d48793c024e73bfcee1c202559eea3e0) @@ -31,7 +31,7 @@ /// /// Base implementation of assessment sections. /// - public interface IAssessmentSection : IComment, IObservable, IStorable + public interface IAssessmentSection : ICommentable, IObservable, IStorable { /// /// Gets or sets the name of the assessment section. Index: Ringtoets/Common/src/Ringtoets.Common.Data/FailureMechanism/ICalculationItem.cs =================================================================== diff -u -r638c0c354f63b4c8be69feb448712b004d8bb933 -rfa424689d48793c024e73bfcee1c202559eea3e0 --- Ringtoets/Common/src/Ringtoets.Common.Data/FailureMechanism/ICalculationItem.cs (.../ICalculationItem.cs) (revision 638c0c354f63b4c8be69feb448712b004d8bb933) +++ Ringtoets/Common/src/Ringtoets.Common.Data/FailureMechanism/ICalculationItem.cs (.../ICalculationItem.cs) (revision fa424689d48793c024e73bfcee1c202559eea3e0) @@ -27,7 +27,7 @@ /// /// A calculation related object. /// - public interface ICalculationItem : IComment, IObservable + public interface ICalculationItem : ICommentable, IObservable { /// /// Clears the calculated output. Index: Ringtoets/Common/src/Ringtoets.Common.Data/FailureMechanism/IFailureMechanism.cs =================================================================== diff -u -r638c0c354f63b4c8be69feb448712b004d8bb933 -rfa424689d48793c024e73bfcee1c202559eea3e0 --- Ringtoets/Common/src/Ringtoets.Common.Data/FailureMechanism/IFailureMechanism.cs (.../IFailureMechanism.cs) (revision 638c0c354f63b4c8be69feb448712b004d8bb933) +++ Ringtoets/Common/src/Ringtoets.Common.Data/FailureMechanism/IFailureMechanism.cs (.../IFailureMechanism.cs) (revision fa424689d48793c024e73bfcee1c202559eea3e0) @@ -29,7 +29,7 @@ /// /// Defines a failure mechanism. /// - public interface IFailureMechanism : IComment, IStorable, IObservable + public interface IFailureMechanism : ICommentable, IStorable, IObservable { /// /// Gets the amount of contribution as a percentage (0-100) for the Fisheye: Tag fa424689d48793c024e73bfcee1c202559eea3e0 refers to a dead (removed) revision in file `Ringtoets/Common/src/Ringtoets.Common.Data/IComment.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Common/src/Ringtoets.Common.Data/ICommentable.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.Data/ICommentable.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.Data/ICommentable.cs (revision fa424689d48793c024e73bfcee1c202559eea3e0) @@ -0,0 +1,34 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +namespace Ringtoets.Common.Data +{ + /// + /// Interface for a object for which people can leave comments about. + /// + public interface ICommentable + { + /// + /// Gets or sets the comments associated with the data object. + /// + string Comments { get; set; } + } +} \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj =================================================================== diff -u -rc4d2af65ad23757fb3bd11f93458839bc1787ded -rfa424689d48793c024e73bfcee1c202559eea3e0 --- Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj (.../Ringtoets.Common.Data.csproj) (revision c4d2af65ad23757fb3bd11f93458839bc1787ded) +++ Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj (.../Ringtoets.Common.Data.csproj) (revision fa424689d48793c024e73bfcee1c202559eea3e0) @@ -45,7 +45,7 @@ - + True Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/CommentContext.cs =================================================================== diff -u -r1e6d07e8cbd1c29a16b5addddb7205e717543729 -rfa424689d48793c024e73bfcee1c202559eea3e0 --- Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/CommentContext.cs (.../CommentContext.cs) (revision 1e6d07e8cbd1c29a16b5addddb7205e717543729) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/CommentContext.cs (.../CommentContext.cs) (revision fa424689d48793c024e73bfcee1c202559eea3e0) @@ -21,43 +21,31 @@ using System; using Ringtoets.Common.Data; -using Ringtoets.Common.Data.AssessmentSection; namespace Ringtoets.Common.Forms.PresentationObjects { /// /// This class is a presentation object for the comment of . /// - public class CommentContext where T : IComment + public class CommentContext where T : ICommentable { /// /// Creates a new instance of . /// /// The container to wrap. - /// The assessment section the belongs to. /// Thrown when is null. - public CommentContext(T commentContainer, IAssessmentSection assessmentSection) + public CommentContext(T commentContainer) { if (commentContainer == null) { throw new ArgumentNullException("commentContainer"); } - if (assessmentSection == null) - { - throw new ArgumentNullException("assessmentSection"); - } CommentContainer = commentContainer; - AssessmentSection = assessmentSection; } /// /// Gets the wrapped comment container. /// public T CommentContainer { get; private set; } - - /// - /// Gets the assessment section which the belongs to. - /// - public IAssessmentSection AssessmentSection { get; private set; } } } Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/CommentView.cs =================================================================== diff -u -r091761507d94a388b18fefebd38a5d106b9b89c4 -rfa424689d48793c024e73bfcee1c202559eea3e0 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/CommentView.cs (.../CommentView.cs) (revision 091761507d94a388b18fefebd38a5d106b9b89c4) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/CommentView.cs (.../CommentView.cs) (revision fa424689d48793c024e73bfcee1c202559eea3e0) @@ -23,7 +23,6 @@ using System.Windows.Forms; using Core.Common.Controls.Views; using Ringtoets.Common.Data; -using Ringtoets.Common.Data.AssessmentSection; namespace Ringtoets.Common.Forms.Views { @@ -32,7 +31,7 @@ /// public partial class CommentView : UserControl, IView { - private IComment data; + private ICommentable data; /// /// Creates a new instance of . @@ -44,11 +43,6 @@ InitializeRichTextEditor(); } - /// - /// Gets and sets the assessment section the belongs to. - /// - public IAssessmentSection AssessmentSection { get; set; } - public object Data { get @@ -57,7 +51,7 @@ } set { - data = value as IComment; + data = value as ICommentable; if (data != null) { Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/Contribution/OtherFailureMechanismTest.cs =================================================================== diff -u -rc4d2af65ad23757fb3bd11f93458839bc1787ded -rfa424689d48793c024e73bfcee1c202559eea3e0 --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/Contribution/OtherFailureMechanismTest.cs (.../OtherFailureMechanismTest.cs) (revision c4d2af65ad23757fb3bd11f93458839bc1787ded) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/Contribution/OtherFailureMechanismTest.cs (.../OtherFailureMechanismTest.cs) (revision fa424689d48793c024e73bfcee1c202559eea3e0) @@ -1,6 +1,7 @@ using NUnit.Framework; using Ringtoets.Common.Data.Contribution; +using Ringtoets.Common.Data.FailureMechanism; namespace Ringtoets.Common.Data.Test.Contribution { @@ -15,6 +16,8 @@ // Assert Assert.AreEqual("Overig", result.Name); + Assert.IsInstanceOf(result); + CollectionAssert.IsEmpty(result.CalculationItems); } } } \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/FailureMechanism/FailureMechanismBaseTest.cs =================================================================== diff -u -rd320e912103d060e7a359846539a67dc54c616a4 -rfa424689d48793c024e73bfcee1c202559eea3e0 --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/FailureMechanism/FailureMechanismBaseTest.cs (.../FailureMechanismBaseTest.cs) (revision d320e912103d060e7a359846539a67dc54c616a4) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/FailureMechanism/FailureMechanismBaseTest.cs (.../FailureMechanismBaseTest.cs) (revision fa424689d48793c024e73bfcee1c202559eea3e0) @@ -25,7 +25,7 @@ // Assert Assert.IsInstanceOf(failureMechanism); Assert.IsInstanceOf(failureMechanism); - Assert.IsInstanceOf(failureMechanism); + Assert.IsInstanceOf(failureMechanism); Assert.AreEqual(0, failureMechanism.Contribution); Assert.AreEqual(name, failureMechanism.Name); Assert.AreEqual(0, failureMechanism.StorageId); Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/CommentContextTest.cs =================================================================== diff -u -r1e6d07e8cbd1c29a16b5addddb7205e717543729 -rfa424689d48793c024e73bfcee1c202559eea3e0 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/CommentContextTest.cs (.../CommentContextTest.cs) (revision 1e6d07e8cbd1c29a16b5addddb7205e717543729) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/CommentContextTest.cs (.../CommentContextTest.cs) (revision fa424689d48793c024e73bfcee1c202559eea3e0) @@ -2,7 +2,6 @@ using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Common.Data; -using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Forms.PresentationObjects; namespace Ringtoets.Common.Forms.Test.PresentationObjects @@ -15,49 +14,27 @@ { // Setup var mocks = new MockRepository(); - var commentMock = mocks.StrictMock(); - var assessmentSectionMock = mocks.StrictMock(); - + var commentMock = mocks.StrictMock(); mocks.ReplayAll(); // Call - var context = new CommentContext(commentMock, assessmentSectionMock); + var context = new CommentContext(commentMock); // Assert Assert.AreSame(commentMock, context.CommentContainer); - Assert.AreSame(assessmentSectionMock, context.AssessmentSection); + + mocks.VerifyAll(); } [Test] public void Constructor_CommentContainerNull_ThrowsArgumentNullException() { - // Setup - var mocks = new MockRepository(); - var assessmentSectionMock = mocks.StrictMock(); - - mocks.ReplayAll(); // Call - TestDelegate call = () => new CommentContext(null, assessmentSectionMock); + TestDelegate call = () => new CommentContext(null); // Assert var exception = Assert.Throws(call); Assert.AreEqual("commentContainer", exception.ParamName); } - - [Test] - public void Constructor_AssessmentSectionNull_ThrowsArgumentNullException() - { - // Setup - var mocks = new MockRepository(); - var commentMock = mocks.StrictMock(); - - mocks.ReplayAll(); - // Call - TestDelegate call = () => new CommentContext(commentMock, null); - - // Assert - var exception = Assert.Throws(call); - Assert.AreEqual("assessmentSection", exception.ParamName); - } } } \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/CommentViewTest.cs =================================================================== diff -u -r091761507d94a388b18fefebd38a5d106b9b89c4 -rfa424689d48793c024e73bfcee1c202559eea3e0 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/CommentViewTest.cs (.../CommentViewTest.cs) (revision 091761507d94a388b18fefebd38a5d106b9b89c4) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/CommentViewTest.cs (.../CommentViewTest.cs) (revision fa424689d48793c024e73bfcee1c202559eea3e0) @@ -55,7 +55,7 @@ // Setup var mocks = new MockRepository(); var view = new CommentView(); - var data = mocks.Stub(); + var data = mocks.Stub(); mocks.ReplayAll(); @@ -86,7 +86,7 @@ // Setup var mocks = new MockRepository(); var view = new CommentView(); - var data = mocks.Stub(); + var data = mocks.Stub(); var expectedText = ""; var validRtfString = GetValidRtfString(expectedText); data.Comments = validRtfString; @@ -118,7 +118,7 @@ var richTextBoxControl = (RichTextBoxControl)new ControlTester("richTextBoxControl").TheObject; var mocks = new MockRepository(); - var data = mocks.Stub(); + var data = mocks.Stub(); mocks.ReplayAll(); view.Data = data; Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs =================================================================== diff -u -r091761507d94a388b18fefebd38a5d106b9b89c4 -rfa424689d48793c024e73bfcee1c202559eea3e0 --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs (.../RingtoetsGuiPlugin.cs) (revision 091761507d94a388b18fefebd38a5d106b9b89c4) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs (.../RingtoetsGuiPlugin.cs) (revision fa424689d48793c024e73bfcee1c202559eea3e0) @@ -164,13 +164,12 @@ AfterCreate = (view, context) => view.FailureMechanism = context.FailureMechanism }; - yield return new ViewInfo, IComment, CommentView> + yield return new ViewInfo, ICommentable, CommentView> { GetViewName = (v, o) => Resources.Comment_DisplayName, GetViewData = context => context.CommentContainer, Image = RingtoetsCommonFormsResources.EditDocumentIcon, - CloseForData = CloseCommentViewForData, - AfterCreate = (view, context) => view.AssessmentSection = context.AssessmentSection + CloseForData = CloseCommentViewForData }; } @@ -283,7 +282,7 @@ .Build() }; - yield return new TreeNodeInfo> + yield return new TreeNodeInfo> { Text = comment => Resources.Comment_DisplayName, Image = context => RingtoetsCommonFormsResources.EditDocumentIcon, @@ -315,19 +314,54 @@ #region Comment ViewInfo - private static bool CloseCommentViewForData(CommentView view, object o) + private static bool CloseCommentViewForData(CommentView commentView, object o) { var calculationContext = o as PipingCalculationContext; + if (calculationContext != null) + { + return calculationContext.WrappedData == commentView.Data; + } - if (calculationContext != null && calculationContext.WrappedData == view.Data) + var calculationGroupContext = o as PipingCalculationGroupContext; + if (calculationGroupContext != null) { - return true; + return GetCommentableElements(calculationGroupContext) + .Any(commentableElement => ReferenceEquals(commentView.Data, commentableElement)); } var assessmentSection = o as IAssessmentSection; - return assessmentSection != null && assessmentSection == view.AssessmentSection; + if (assessmentSection != null) + { + return GetCommentableElements(assessmentSection) + .Any(commentableElement => ReferenceEquals(commentView.Data, commentableElement)); + } + + return false; } + private static IEnumerable GetCommentableElements(PipingCalculationGroupContext calculationGroupContext) + { + return calculationGroupContext.WrappedData.GetPipingCalculations(); + } + + private static IEnumerable GetCommentableElements(IAssessmentSection assessmentSection) + { + yield return assessmentSection; + foreach (var commentable in assessmentSection.GetFailureMechanisms().SelectMany(GetCommentableElements)) + { + yield return commentable; + } + } + + private static IEnumerable GetCommentableElements(IFailureMechanism failureMechanism) + { + yield return failureMechanism; + foreach (ICalculationItem commentableCalculation in failureMechanism.CalculationItems) + { + yield return commentableCalculation; + } + } + #endregion #region FailureMechanismSectionsContext @@ -350,7 +384,7 @@ new ReferenceLineContext(nodeData), new FailureMechanismContributionContext(nodeData.FailureMechanismContribution, nodeData), new HydraulicBoundaryDatabaseContext(nodeData), - new CommentContext(nodeData, nodeData) + new CommentContext(nodeData) }; var failureMechanismContexts = WrapFailureMechanismsInContexts(nodeData); @@ -436,7 +470,7 @@ new FailureMechanismSectionsContext(nodeData, assessmentSection), nodeData.Locations, nodeData.BoundaryConditions, - new CommentContext(nodeData, assessmentSection) + new CommentContext(nodeData) }; } Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/AssessmentSectionTest.cs =================================================================== diff -u -rd320e912103d060e7a359846539a67dc54c616a4 -rfa424689d48793c024e73bfcee1c202559eea3e0 --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/AssessmentSectionTest.cs (.../AssessmentSectionTest.cs) (revision d320e912103d060e7a359846539a67dc54c616a4) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/AssessmentSectionTest.cs (.../AssessmentSectionTest.cs) (revision fa424689d48793c024e73bfcee1c202559eea3e0) @@ -51,7 +51,7 @@ // Assert Assert.IsInstanceOf(section); Assert.IsInstanceOf(section); - Assert.IsInstanceOf(section); + Assert.IsInstanceOf(section); Assert.AreEqual("Traject", section.Name); Assert.IsNull(section.Comments); Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/AssessmentSectionTreeNodeInfoTest.cs =================================================================== diff -u -rc4d2af65ad23757fb3bd11f93458839bc1787ded -rfa424689d48793c024e73bfcee1c202559eea3e0 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/AssessmentSectionTreeNodeInfoTest.cs (.../AssessmentSectionTreeNodeInfoTest.cs) (revision c4d2af65ad23757fb3bd11f93458839bc1787ded) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/AssessmentSectionTreeNodeInfoTest.cs (.../AssessmentSectionTreeNodeInfoTest.cs) (revision fa424689d48793c024e73bfcee1c202559eea3e0) @@ -177,7 +177,7 @@ Assert.AreSame(assessmentSection.HydraulicBoundaryDatabase, context.Parent.HydraulicBoundaryDatabase); Assert.AreSame(assessmentSection, context.Parent); - var commentContext = (CommentContext)objects[3]; + var commentContext = (CommentContext)objects[3]; Assert.AreSame(assessmentSection, commentContext.CommentContainer); var pipingFailureMechanismContext = (PipingFailureMechanismContext) objects[4]; Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/CommentContextTreeNodeInfoTest.cs =================================================================== diff -u -r091761507d94a388b18fefebd38a5d106b9b89c4 -rfa424689d48793c024e73bfcee1c202559eea3e0 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/CommentContextTreeNodeInfoTest.cs (.../CommentContextTreeNodeInfoTest.cs) (revision 091761507d94a388b18fefebd38a5d106b9b89c4) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/CommentContextTreeNodeInfoTest.cs (.../CommentContextTreeNodeInfoTest.cs) (revision fa424689d48793c024e73bfcee1c202559eea3e0) @@ -27,7 +27,6 @@ using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Common.Data; -using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Integration.Plugin; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; @@ -54,7 +53,7 @@ var info = GetInfo(plugin); // Assert - Assert.AreEqual(typeof(CommentContext), info.TagType); + Assert.AreEqual(typeof(CommentContext), info.TagType); Assert.IsNull(info.EnsureVisibleOnCreate); Assert.IsNull(info.ChildNodeObjects); Assert.IsNull(info.CanRename); @@ -76,16 +75,14 @@ public void Text_Always_ReturnsName() { // Setup - var commentMock = mocks.StrictMock(); - var assessmentSectionMock = mocks.StrictMock(); - + var commentMock = mocks.StrictMock(); mocks.ReplayAll(); using (var plugin = new RingtoetsGuiPlugin()) { var info = GetInfo(plugin); - var context = new CommentContext(commentMock, assessmentSectionMock); + var context = new CommentContext(commentMock); // Call var text = info.Text(context); @@ -101,14 +98,13 @@ public void Image_Always_ReturnsSetImage() { // Setup - var commentMock = mocks.StrictMock(); - var assessmentSectionMock = mocks.StrictMock(); + var commentMock = mocks.StrictMock(); mocks.ReplayAll(); using (var plugin = new RingtoetsGuiPlugin()) { var info = GetInfo(plugin); - var context = new CommentContext(commentMock, assessmentSectionMock); + var context = new CommentContext(commentMock); // Call var image = info.Image(context); @@ -152,7 +148,7 @@ private TreeNodeInfo GetInfo(Core.Common.Gui.Plugin.GuiPlugin gui) { - return gui.GetTreeNodeInfos().First(tni => tni.TagType == typeof(CommentContext)); + return gui.GetTreeNodeInfos().First(tni => tni.TagType == typeof(CommentContext)); } } } Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismPlaceholderTreeNodeInfoTest.cs =================================================================== diff -u -rc4d2af65ad23757fb3bd11f93458839bc1787ded -rfa424689d48793c024e73bfcee1c202559eea3e0 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismPlaceholderTreeNodeInfoTest.cs (.../FailureMechanismPlaceholderTreeNodeInfoTest.cs) (revision c4d2af65ad23757fb3bd11f93458839bc1787ded) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismPlaceholderTreeNodeInfoTest.cs (.../FailureMechanismPlaceholderTreeNodeInfoTest.cs) (revision fa424689d48793c024e73bfcee1c202559eea3e0) @@ -150,7 +150,7 @@ Assert.AreSame(failureMechanism.Locations, inputFolder.Contents[1]); Assert.AreSame(failureMechanism.BoundaryConditions, inputFolder.Contents[2]); - var commentContext = (CommentContext) inputFolder.Contents[3]; + var commentContext = (CommentContext) inputFolder.Contents[3]; Assert.IsNotNull(commentContext); Assert.AreSame(failureMechanism, commentContext.CommentContainer); @@ -227,8 +227,16 @@ // Call var menu = info.ContextMenuStrip(null, null, treeViewControlMock); - TestHelper.AssertContextMenuStripContainsItem(menu, 0, RingtoetsCommonFormsResources.Calculate_all, RingtoetsCommonFormsResources.Calculate_all_ToolTip, RingtoetsCommonFormsResources.CalculateAllIcon, false); - TestHelper.AssertContextMenuStripContainsItem(menu, 1, RingtoetsCommonFormsResources.Clear_all_output, RingtoetsCommonFormsResources.Clear_all_output_ToolTip, RingtoetsCommonFormsResources.ClearIcon, false); + TestHelper.AssertContextMenuStripContainsItem(menu, 0, + RingtoetsCommonFormsResources.Calculate_all, + RingtoetsCommonFormsResources.Calculate_all_ToolTip, + RingtoetsCommonFormsResources.CalculateAllIcon, + false); + TestHelper.AssertContextMenuStripContainsItem(menu, 1, + RingtoetsCommonFormsResources.Clear_all_output, + RingtoetsCommonFormsResources.Clear_all_output_ToolTip, + RingtoetsCommonFormsResources.ClearIcon, + false); } // Assert Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsGuiPluginTest.cs =================================================================== diff -u -r52bb7ac3ae5191063f4b26ea26cb4b2ce5f486ed -rfa424689d48793c024e73bfcee1c202559eea3e0 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsGuiPluginTest.cs (.../RingtoetsGuiPluginTest.cs) (revision 52bb7ac3ae5191063f4b26ea26cb4b2ce5f486ed) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsGuiPluginTest.cs (.../RingtoetsGuiPluginTest.cs) (revision fa424689d48793c024e73bfcee1c202559eea3e0) @@ -201,7 +201,7 @@ Assert.AreEqual(typeof(FailureMechanismResultView), resultViewInfo.ViewType); TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GenericInputOutputIcon, resultViewInfo.Image); - var commentView = viewInfos.Single(vi => vi.DataType == typeof(CommentContext)); + var commentView = viewInfos.Single(vi => vi.DataType == typeof(CommentContext)); Assert.AreEqual(typeof(CommentView), commentView.ViewType); TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GenericInputOutputIcon, commentView.Image); } @@ -239,7 +239,7 @@ Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismContributionContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(HydraulicBoundaryDatabaseContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismSectionResultContext))); - Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(CommentContext))); + Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(CommentContext))); } mocks.VerifyAll(); } Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/CommentViewInfoTest.cs =================================================================== diff -u -r091761507d94a388b18fefebd38a5d106b9b89c4 -rfa424689d48793c024e73bfcee1c202559eea3e0 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/CommentViewInfoTest.cs (.../CommentViewInfoTest.cs) (revision 091761507d94a388b18fefebd38a5d106b9b89c4) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/CommentViewInfoTest.cs (.../CommentViewInfoTest.cs) (revision fa424689d48793c024e73bfcee1c202559eea3e0) @@ -5,6 +5,7 @@ using Rhino.Mocks; using Ringtoets.Common.Data; using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.Forms.Views; using Ringtoets.Piping.Data; @@ -39,14 +40,14 @@ public void Initialized_Always_ExpectedPropertiesSet() { // Assert - Assert.AreEqual(typeof(CommentContext), info.DataType); + Assert.AreEqual(typeof(CommentContext), info.DataType); } [Test] public void GetViewName_Always_ReturnsViewName() { // Setup - var commentMock = mocks.StrictMock(); + var commentMock = mocks.StrictMock(); var viewMock = mocks.StrictMock(); mocks.ReplayAll(); @@ -62,9 +63,8 @@ public void GetViewData_Always_ReturnsIComment() { // Setup - var commentMock = mocks.StrictMock(); - var assessmentSectionMock = mocks.StrictMock(); - var contextMock = mocks.StrictMock>(commentMock, assessmentSectionMock); + var commentMock = mocks.StrictMock(); + var contextMock = mocks.StrictMock>(commentMock); mocks.ReplayAll(); // Call @@ -91,7 +91,7 @@ var dataType = info.DataType; // Assert - Assert.AreEqual(typeof(CommentContext), dataType); + Assert.AreEqual(typeof(CommentContext), dataType); } [Test] @@ -101,7 +101,7 @@ var viewDataType = info.ViewDataType; // Assert - Assert.AreEqual(typeof(IComment), viewDataType); + Assert.AreEqual(typeof(ICommentable), viewDataType); } [Test] @@ -115,93 +115,339 @@ } [Test] - public void CloseForData_ViewCorrespondingToRemovedAssessmentSection_ReturnsTrue() + public void CloseForData_ObjectIsNotObjectOfInterest_ReturnFalse() { // Setup - var commentMock = mocks.Stub(); - var assessmentSectionMock = mocks.Stub(); - var viewMock = mocks.StrictMock(); + var commentableMock = mocks.Stub(); + mocks.ReplayAll(); - viewMock.Expect(vm => vm.Data).Return(commentMock); - viewMock.Expect(vm => vm.AssessmentSection).Return(assessmentSectionMock); + using (var view = new CommentView + { + Data = commentableMock + }) + { + // Call + var closeForData = info.CloseForData(view, new object()); + // Assert + Assert.IsFalse(closeForData); + } + mocks.VerifyAll(); + } + + [Test] + public void CloseForData_ViewDataIsDeletedAssessmentSection_ReturnTrue() + { + // Setup + var assessmentSection = mocks.Stub(); + assessmentSection.Stub(s => s.GetFailureMechanisms()).Return(Enumerable.Empty()); mocks.ReplayAll(); - // Call - var closeForData = info.CloseForData(viewMock, assessmentSectionMock); + using (var view = new CommentView + { + Data = assessmentSection + }) + { + // Call + var closeForData = info.CloseForData(view, assessmentSection); - // Assert - Assert.IsTrue(closeForData); + // Assert + Assert.IsTrue(closeForData); + } + mocks.VerifyAll(); } [Test] - public void CloseForData_ViewNotCorrespondingToRemovedAssessmentSection_ReturnsFalse() + public void CloseForData_ViewDataIsOtherInstanceThenDeletedAssessmentSection_ReturnFalse() { // Setup - var commentMock = mocks.Stub(); - var assessmentSectionMock = mocks.StrictMock(); - var assessmentSectionMock2 = mocks.StrictMock(); - var viewMock = mocks.StrictMock(); + var deletedAssessmentSection = mocks.Stub(); + deletedAssessmentSection.Stub(s => s.GetFailureMechanisms()).Return(Enumerable.Empty()); - viewMock.Expect(vm => vm.Data).Return(commentMock); - viewMock.Expect(vm => vm.AssessmentSection).Return(assessmentSectionMock2); + var viewDataAssessmentSection = mocks.Stub(); + viewDataAssessmentSection.Stub(s => s.GetFailureMechanisms()).Return(Enumerable.Empty()); + mocks.ReplayAll(); + using (var view = new CommentView + { + Data = viewDataAssessmentSection + }) + { + // Call + var closeForData = info.CloseForData(view, deletedAssessmentSection); + + // Assert + Assert.IsFalse(closeForData); + } + mocks.VerifyAll(); + } + + [Test] + public void CloseForData_ViewDataIsFailureMechanismOfDeletedAssessmentSection_ReturnTrue() + { + // Setup + var failureMechanism = mocks.Stub(); + failureMechanism.Stub(fm => fm.CalculationItems).Return(Enumerable.Empty()); + + var assessmentSection = mocks.Stub(); + assessmentSection.Stub(s => s.GetFailureMechanisms()).Return(new[] + { + failureMechanism + }); mocks.ReplayAll(); - // Call - var closeForData = info.CloseForData(viewMock, assessmentSectionMock); + using (var view = new CommentView + { + Data = failureMechanism + }) + { + // Call + var closeForData = info.CloseForData(view, assessmentSection); - // Assert - Assert.IsFalse(closeForData); + // Assert + Assert.IsTrue(closeForData); + } + mocks.VerifyAll(); } [Test] - public void CloseForData_ViewCorrespondingToRemovedCalculationItem_ReturnsTrue() + public void CloseForData_ViewDataIsFailureMechanismButNotOfDeletedAssessmentSection_ReturnFalse() { // Setup - var calculation = new PipingCalculation(new GeneralPipingInput(), new SemiProbabilisticPipingInput()); + var viewDataFailureMechanism = mocks.Stub(); + viewDataFailureMechanism.Stub(fm => fm.CalculationItems).Return(Enumerable.Empty()); - var pipingFailureMechanismMock = mocks.StrictMock(); - var assessmentSectionMock = mocks.StrictMock(); + var deletedFailureMechanism = mocks.Stub(); + deletedFailureMechanism.Stub(fm => fm.CalculationItems).Return(Enumerable.Empty()); - var calculationContextMock = mocks.StrictMock(calculation, Enumerable.Empty(), Enumerable.Empty(), pipingFailureMechanismMock, assessmentSectionMock); - var viewMock = mocks.StrictMock(); + var deletedAssessmentSection = mocks.Stub(); + deletedAssessmentSection.Stub(s => s.GetFailureMechanisms()).Return(new[] + { + deletedFailureMechanism + }); + mocks.ReplayAll(); - viewMock.Expect(vm => vm.Data).Return(calculationContextMock.WrappedData); + using (var view = new CommentView + { + Data = viewDataFailureMechanism + }) + { + // Call + var closeForData = info.CloseForData(view, deletedAssessmentSection); + // Assert + Assert.IsFalse(closeForData); + } + mocks.VerifyAll(); + } + + [Test] + public void CloseForData_ViewDataIsCalculationOfDeletedAssessmentSection_ReturnTrue() + { + // Setup + var calculation = mocks.Stub(); + + var failureMechanism = mocks.Stub(); + failureMechanism.Stub(fm => fm.CalculationItems).Return(new[] + { + calculation + }); + + var assessmentSection = mocks.Stub(); + assessmentSection.Stub(s => s.GetFailureMechanisms()).Return(new[] + { + failureMechanism + }); mocks.ReplayAll(); - // Call - var closeForData = info.CloseForData(viewMock, calculationContextMock); + using (var view = new CommentView + { + Data = calculation + }) + { + // Call + var closeForData = info.CloseForData(view, assessmentSection); - // Assert - Assert.IsTrue(closeForData); + // Assert + Assert.IsTrue(closeForData); + + mocks.VerifyAll(); + } } [Test] + public void CloseForData_ViewDataIsCalculationButNotOfDeletedAssessmentSection_ReturnFalse() + { + // Setup + var viewDataCalculation = mocks.Stub(); + + var deletedCalculation = mocks.Stub(); + + var deletedfailureMechanism = mocks.Stub(); + deletedfailureMechanism.Stub(fm => fm.CalculationItems).Return(new[] + { + deletedCalculation + }); + + var deletedAssessmentSection = mocks.Stub(); + deletedAssessmentSection.Stub(s => s.GetFailureMechanisms()).Return(new[] + { + deletedfailureMechanism + }); + mocks.ReplayAll(); + + using (var view = new CommentView + { + Data = viewDataCalculation + }) + { + // Call + var closeForData = info.CloseForData(view, deletedAssessmentSection); + + // Assert + Assert.IsFalse(closeForData); + + mocks.VerifyAll(); + } + } + + [Test] + public void CloseForData_ViewCorrespondingToRemovedCalculationItem_ReturnsTrue() + { + // Setup + var assessmentSectionMock = mocks.StrictMock(); + mocks.ReplayAll(); + + var viewDataCalculation = new PipingCalculation(new GeneralPipingInput(), new SemiProbabilisticPipingInput()); + var failureMechanism = new PipingFailureMechanism(); + + var deletedCalculationContext = new PipingCalculationContext(viewDataCalculation, + Enumerable.Empty(), + Enumerable.Empty(), + failureMechanism, + assessmentSectionMock); + + using (var view = new CommentView + { + Data = viewDataCalculation + }) + { + // Call + var closeForData = info.CloseForData(view, deletedCalculationContext); + + // Assert + Assert.IsTrue(closeForData); + } + + mocks.VerifyAll(); + } + + [Test] public void CloseForData_ViewNotCorrespondingToRemovedCalculationItem_ReturnsFalse() { // Setup + var assessmentSectionMock = mocks.StrictMock(); + mocks.ReplayAll(); + var calculation = new PipingCalculation(new GeneralPipingInput(), new SemiProbabilisticPipingInput()); - var calculation2 = new PipingCalculation(new GeneralPipingInput(), new SemiProbabilisticPipingInput()); + var viewDataCalculation = new PipingCalculation(new GeneralPipingInput(), new SemiProbabilisticPipingInput()); - var pipingFailureMechanismMock = mocks.StrictMock(); + var failureMechanism = new PipingFailureMechanism(); + + var deletedCalculationContext = new PipingCalculationContext(calculation, + Enumerable.Empty(), + Enumerable.Empty(), + failureMechanism, + assessmentSectionMock); + + using (var view = new CommentView + { + Data = viewDataCalculation + }) + { + // Call + var closeForData = info.CloseForData(view, deletedCalculationContext); + + // Assert + Assert.IsFalse(closeForData); + } + mocks.VerifyAll(); + } + + [Test] + public void CloseForData_ViewDataIsCalculationOfRemovedCalculationGroup_ReturnsTrue() + { + // Setup var assessmentSectionMock = mocks.StrictMock(); + mocks.ReplayAll(); - var calculationContextMock = mocks.StrictMock(calculation, Enumerable.Empty(), Enumerable.Empty(), pipingFailureMechanismMock, assessmentSectionMock); - var calculationContextMock2 = mocks.StrictMock(calculation2, Enumerable.Empty(), Enumerable.Empty(), pipingFailureMechanismMock, assessmentSectionMock); - var viewMock = mocks.StrictMock(); + var failureMechanism = new PipingFailureMechanism(); + var viewDataCalculation = new PipingCalculation(new GeneralPipingInput(), new SemiProbabilisticPipingInput()); + var deletedGroup = new PipingCalculationGroup + { + Children = + { + viewDataCalculation + } + }; + var deletedGroupContext = new PipingCalculationGroupContext(deletedGroup, + Enumerable.Empty(), + Enumerable.Empty(), + failureMechanism, + assessmentSectionMock); - viewMock.Expect(vm => vm.Data).Return(calculationContextMock2.WrappedData); - viewMock.Expect(vm => vm.AssessmentSection).Return(assessmentSectionMock); + using (var view = new CommentView + { + Data = viewDataCalculation + }) + { + // Call + var closeForData = info.CloseForData(view, deletedGroupContext); + // Assert + Assert.IsTrue(closeForData); + + mocks.VerifyAll(); + } + } + + [Test] + public void CloseForData_ViewDataIsCalculationButNotOfRemovedCalculationGroup_ReturnsFalse() + { + // Setup + var assessmentSectionMock = mocks.StrictMock(); mocks.ReplayAll(); - // Call - var closeForData = info.CloseForData(viewMock, calculationContextMock); + var failureMechanism = new PipingFailureMechanism(); + var viewDataCalculation = new PipingCalculation(new GeneralPipingInput(), new SemiProbabilisticPipingInput()); - // Assert - Assert.IsFalse(closeForData); + var deletedCalculation = new PipingCalculation(new GeneralPipingInput(), new SemiProbabilisticPipingInput()); + var deletedGroup = new PipingCalculationGroup + { + Children = + { + deletedCalculation + } + }; + var deletedGroupContext = new PipingCalculationGroupContext(deletedGroup, + Enumerable.Empty(), + Enumerable.Empty(), + failureMechanism, + assessmentSectionMock); + + using (var view = new CommentView + { + Data = viewDataCalculation + }) + { + // Call + var closeForData = info.CloseForData(view, deletedGroupContext); + + // Assert + Assert.IsFalse(closeForData); + + mocks.VerifyAll(); + } } } } \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs =================================================================== diff -u -r1e6d07e8cbd1c29a16b5addddb7205e717543729 -rfa424689d48793c024e73bfcee1c202559eea3e0 --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs (.../PipingGuiPlugin.cs) (revision 1e6d07e8cbd1c29a16b5addddb7205e717543729) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs (.../PipingGuiPlugin.cs) (revision fa424689d48793c024e73bfcee1c202559eea3e0) @@ -437,7 +437,7 @@ new FailureMechanismSectionsContext(failureMechanism, assessmentSection), new RingtoetsPipingSurfaceLinesContext(failureMechanism, assessmentSection), new StochasticSoilModelContext(failureMechanism, assessmentSection), - new CommentContext(failureMechanism, assessmentSection) + new CommentContext(failureMechanism) }; } @@ -498,7 +498,7 @@ { var childNodes = new List { - new CommentContext(pipingCalculationContext.WrappedData, pipingCalculationContext.AssessmentSection), + new CommentContext(pipingCalculationContext.WrappedData), new PipingInputContext(pipingCalculationContext.WrappedData.InputParameters, pipingCalculationContext.AvailablePipingSurfaceLines, pipingCalculationContext.AvailableStochasticSoilModels, Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingCalculationTest.cs =================================================================== diff -u -rd320e912103d060e7a359846539a67dc54c616a4 -rfa424689d48793c024e73bfcee1c202559eea3e0 --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingCalculationTest.cs (.../PipingCalculationTest.cs) (revision d320e912103d060e7a359846539a67dc54c616a4) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingCalculationTest.cs (.../PipingCalculationTest.cs) (revision fa424689d48793c024e73bfcee1c202559eea3e0) @@ -32,7 +32,7 @@ // Assert Assert.IsInstanceOf(calculation); - Assert.IsInstanceOf(calculation); + Assert.IsInstanceOf(calculation); Assert.AreEqual("Nieuwe berekening", calculation.Name); Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -rc4d2af65ad23757fb3bd11f93458839bc1787ded -rfa424689d48793c024e73bfcee1c202559eea3e0 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationContextTreeNodeInfoTest.cs (.../PipingCalculationContextTreeNodeInfoTest.cs) (revision c4d2af65ad23757fb3bd11f93458839bc1787ded) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationContextTreeNodeInfoTest.cs (.../PipingCalculationContextTreeNodeInfoTest.cs) (revision fa424689d48793c024e73bfcee1c202559eea3e0) @@ -163,9 +163,9 @@ // Assert Assert.AreEqual(4, children.Length); - var commentContext = children[0] as CommentContext; + var commentContext = children[0] as CommentContext; Assert.IsNotNull(commentContext); - Assert.AreSame(pipingCalculationContext.WrappedData.Comments, commentContext.CommentContainer.Comments); + Assert.AreSame(pipingCalculationContext.WrappedData, commentContext.CommentContainer); var pipingInputContext = (PipingInputContext) children[1]; Assert.AreSame(pipingCalculationContext.WrappedData.InputParameters, pipingInputContext.WrappedData); @@ -197,9 +197,9 @@ // Assert Assert.AreEqual(4, children.Length); - var commentContext = children[0] as CommentContext; + var commentContext = children[0] as CommentContext; Assert.IsNotNull(commentContext); - Assert.AreSame(pipingCalculationContext.WrappedData.Comments, commentContext.CommentContainer.Comments); + Assert.AreSame(pipingCalculationContext.WrappedData, commentContext.CommentContainer); var pipingInputContext = (PipingInputContext) children[1]; Assert.AreSame(pipingCalculationContext.WrappedData.InputParameters, pipingInputContext.WrappedData); Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingFailureMechanismTreeNodeInfoTest.cs =================================================================== diff -u -rc4d2af65ad23757fb3bd11f93458839bc1787ded -rfa424689d48793c024e73bfcee1c202559eea3e0 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingFailureMechanismTreeNodeInfoTest.cs (.../PipingFailureMechanismTreeNodeInfoTest.cs) (revision c4d2af65ad23757fb3bd11f93458839bc1787ded) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingFailureMechanismTreeNodeInfoTest.cs (.../PipingFailureMechanismTreeNodeInfoTest.cs) (revision fa424689d48793c024e73bfcee1c202559eea3e0) @@ -155,7 +155,7 @@ Assert.AreSame(pipingFailureMechanism, stochasticSoilModelContext.FailureMechanism); Assert.AreSame(assessmentSection, stochasticSoilModelContext.AssessmentSection); - var commentContext = (CommentContext) inputsFolder.Contents[3]; + var commentContext = (CommentContext) inputsFolder.Contents[3]; Assert.AreSame(pipingFailureMechanism, commentContext.CommentContainer); var calculationsFolder = (PipingCalculationGroupContext) children[1];