Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/CommentContext.cs
===================================================================
diff -u -r5ef5e3e186036b4985798236624d86b2801b87d3 -r1e6d07e8cbd1c29a16b5addddb7205e717543729
--- Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/CommentContext.cs (.../CommentContext.cs) (revision 5ef5e3e186036b4985798236624d86b2801b87d3)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/CommentContext.cs (.../CommentContext.cs) (revision 1e6d07e8cbd1c29a16b5addddb7205e717543729)
@@ -21,6 +21,7 @@
using System;
using Ringtoets.Common.Data;
+using Ringtoets.Common.Data.AssessmentSection;
namespace Ringtoets.Common.Forms.PresentationObjects
{
@@ -33,19 +34,30 @@
/// Creates a new instance of .
///
/// The container to wrap.
+ /// The assessment section the belongs to.
/// Thrown when is null.
- public CommentContext(T commentContainer)
+ public CommentContext(T commentContainer, IAssessmentSection assessmentSection)
{
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 -r638c0c354f63b4c8be69feb448712b004d8bb933 -r1e6d07e8cbd1c29a16b5addddb7205e717543729
--- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/CommentView.cs (.../CommentView.cs) (revision 638c0c354f63b4c8be69feb448712b004d8bb933)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/CommentView.cs (.../CommentView.cs) (revision 1e6d07e8cbd1c29a16b5addddb7205e717543729)
@@ -24,6 +24,7 @@
using Core.Common.Controls.TextEditor;
using Core.Common.Controls.Views;
using Ringtoets.Common.Data;
+using Ringtoets.Common.Data.AssessmentSection;
namespace Ringtoets.Common.Forms.Views
{
@@ -45,6 +46,11 @@
InitializeRichTextEditor();
}
+ ///
+ /// Gets and sets the assessment section the belongs to.
+ ///
+ public IAssessmentSection AssessmentSection { get; set; }
+
public object Data
{
get
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/CommentContextTest.cs
===================================================================
diff -u -r5ef5e3e186036b4985798236624d86b2801b87d3 -r1e6d07e8cbd1c29a16b5addddb7205e717543729
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/CommentContextTest.cs (.../CommentContextTest.cs) (revision 5ef5e3e186036b4985798236624d86b2801b87d3)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/CommentContextTest.cs (.../CommentContextTest.cs) (revision 1e6d07e8cbd1c29a16b5addddb7205e717543729)
@@ -1,6 +1,7 @@
using System;
using NUnit.Framework;
using Rhino.Mocks;
+using Ringtoets.Common.Data;
using Ringtoets.Common.Data.AssessmentSection;
using Ringtoets.Common.Forms.PresentationObjects;
@@ -14,26 +15,49 @@
{
// Setup
var mocks = new MockRepository();
+ var commentMock = mocks.StrictMock();
var assessmentSectionMock = mocks.StrictMock();
mocks.ReplayAll();
// Call
- var context = new CommentContext(assessmentSectionMock);
+ var context = new CommentContext(commentMock, assessmentSectionMock);
// Assert
- Assert.AreSame(assessmentSectionMock, context.CommentContainer);
+ Assert.AreSame(commentMock, context.CommentContainer);
+ Assert.AreSame(assessmentSectionMock, context.AssessmentSection);
}
[Test]
- public void Constructor_AssessmentSectionNull_ThrowsArgumentNullException()
+ public void Constructor_CommentContainerNull_ThrowsArgumentNullException()
{
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSectionMock = mocks.StrictMock();
+
+ mocks.ReplayAll();
// Call
- TestDelegate call = () => new CommentContext(null);
+ TestDelegate call = () => new CommentContext(null, assessmentSectionMock);
// 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/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs
===================================================================
diff -u -rc4d2af65ad23757fb3bd11f93458839bc1787ded -r1e6d07e8cbd1c29a16b5addddb7205e717543729
--- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs (.../RingtoetsGuiPlugin.cs) (revision c4d2af65ad23757fb3bd11f93458839bc1787ded)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs (.../RingtoetsGuiPlugin.cs) (revision 1e6d07e8cbd1c29a16b5addddb7205e717543729)
@@ -166,7 +166,8 @@
GetViewName = (v, o) => RingtoetsCommonDataResources.AssessmentSectionComment_DisplayName,
GetViewData = context => context.CommentContainer,
Image = RingtoetsCommonFormsResources.GenericInputOutputIcon,
- CloseForData = CloseCommentViewForData
+ CloseForData = CloseCommentViewForData,
+ AfterCreate = (view, context) => view.AssessmentSection = context.AssessmentSection
};
}
@@ -314,8 +315,8 @@
private static bool CloseCommentViewForData(CommentView view, object o)
{
- var comment = o as IComment;
- return comment != null && comment == view.Data;
+ var assessmentSection = o as IAssessmentSection;
+ return assessmentSection != null && assessmentSection == view.AssessmentSection;
}
#endregion
@@ -340,7 +341,7 @@
new ReferenceLineContext(nodeData),
new FailureMechanismContributionContext(nodeData.FailureMechanismContribution, nodeData),
new HydraulicBoundaryDatabaseContext(nodeData),
- new CommentContext(nodeData)
+ new CommentContext(nodeData, nodeData)
};
var failureMechanismContexts = WrapFailureMechanismsInContexts(nodeData);
@@ -426,7 +427,7 @@
new FailureMechanismSectionsContext(nodeData, assessmentSection),
nodeData.Locations,
nodeData.BoundaryConditions,
- new CommentContext(nodeData)
+ new CommentContext(nodeData, assessmentSection)
};
}
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/CommentContextTreeNodeInfoTest.cs
===================================================================
diff -u -r638c0c354f63b4c8be69feb448712b004d8bb933 -r1e6d07e8cbd1c29a16b5addddb7205e717543729
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/CommentContextTreeNodeInfoTest.cs (.../CommentContextTreeNodeInfoTest.cs) (revision 638c0c354f63b4c8be69feb448712b004d8bb933)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/CommentContextTreeNodeInfoTest.cs (.../CommentContextTreeNodeInfoTest.cs) (revision 1e6d07e8cbd1c29a16b5addddb7205e717543729)
@@ -76,6 +76,7 @@
public void Text_Always_ReturnsName()
{
// Setup
+ var commentMock = mocks.StrictMock();
var assessmentSectionMock = mocks.StrictMock();
mocks.ReplayAll();
@@ -84,7 +85,7 @@
{
var info = GetInfo(plugin);
- var context = new CommentContext(assessmentSectionMock);
+ var context = new CommentContext(commentMock, assessmentSectionMock);
// Call
var text = info.Text(context);
@@ -100,13 +101,14 @@
public void Image_Always_ReturnsSetImage()
{
// Setup
+ var commentMock = mocks.StrictMock();
var assessmentSectionMock = mocks.StrictMock();
mocks.ReplayAll();
using (var plugin = new RingtoetsGuiPlugin())
{
var info = GetInfo(plugin);
- var context = new CommentContext(assessmentSectionMock);
+ var context = new CommentContext(commentMock, assessmentSectionMock);
// Call
var image = info.Image(context);
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/CommentViewInfoTest.cs
===================================================================
diff -u -r638c0c354f63b4c8be69feb448712b004d8bb933 -r1e6d07e8cbd1c29a16b5addddb7205e717543729
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/CommentViewInfoTest.cs (.../CommentViewInfoTest.cs) (revision 638c0c354f63b4c8be69feb448712b004d8bb933)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/CommentViewInfoTest.cs (.../CommentViewInfoTest.cs) (revision 1e6d07e8cbd1c29a16b5addddb7205e717543729)
@@ -43,19 +43,35 @@
public void GetViewName_Always_ReturnsViewName()
{
// Setup
- var assessmentSectionMock = mocks.StrictMock();
+ var commentMock = mocks.StrictMock();
var viewMock = mocks.StrictMock();
mocks.ReplayAll();
// Call
- var viewName = info.GetViewName(viewMock, assessmentSectionMock);
+ var viewName = info.GetViewName(viewMock, commentMock);
// Assert
Assert.AreEqual("Opmerkingen", viewName);
}
[Test]
+ public void GetViewData_Always_ReturnsIComment()
+ {
+ // Setup
+ var commentMock = mocks.StrictMock();
+ var assessmentSectionMock = mocks.StrictMock();
+ var contextMock = mocks.StrictMock>(commentMock, assessmentSectionMock);
+ mocks.ReplayAll();
+
+ // Call
+ var viewData = info.GetViewData(contextMock);
+
+ // Assert
+ Assert.AreSame(commentMock, viewData);
+ }
+
+ [Test]
public void ViewType_Always_ReturnsViewType()
{
// Call
@@ -100,9 +116,11 @@
{
// Setup
var viewMock = mocks.StrictMock();
+ var commentMock = mocks.Stub();
var assessmentSectionMock = mocks.Stub();
- viewMock.Expect(vm => vm.Data).Return(assessmentSectionMock);
+ viewMock.Expect(vm => vm.Data).Return(commentMock);
+ viewMock.Expect(vm => vm.AssessmentSection).Return(assessmentSectionMock);
mocks.ReplayAll();
@@ -118,10 +136,12 @@
{
// Setup
var viewMock = mocks.StrictMock();
+ var commentMock = mocks.Stub();
var assessmentSectionMock = mocks.StrictMock();
var assessmentSectionMock2 = mocks.StrictMock();
- viewMock.Expect(vm => vm.Data).Return(assessmentSectionMock2);
+ viewMock.Expect(vm => vm.Data).Return(commentMock);
+ viewMock.Expect(vm => vm.AssessmentSection).Return(assessmentSectionMock2);
mocks.ReplayAll();
Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs
===================================================================
diff -u -rc4d2af65ad23757fb3bd11f93458839bc1787ded -r1e6d07e8cbd1c29a16b5addddb7205e717543729
--- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs (.../PipingGuiPlugin.cs) (revision c4d2af65ad23757fb3bd11f93458839bc1787ded)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs (.../PipingGuiPlugin.cs) (revision 1e6d07e8cbd1c29a16b5addddb7205e717543729)
@@ -437,7 +437,7 @@
new FailureMechanismSectionsContext(failureMechanism, assessmentSection),
new RingtoetsPipingSurfaceLinesContext(failureMechanism, assessmentSection),
new StochasticSoilModelContext(failureMechanism, assessmentSection),
- new CommentContext(failureMechanism)
+ new CommentContext(failureMechanism, assessmentSection)
};
}
@@ -498,7 +498,7 @@
{
var childNodes = new List