Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/FailureMechanismSectionResultContext.cs
===================================================================
diff -u
--- Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/FailureMechanismSectionResultContext.cs (revision 0)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/FailureMechanismSectionResultContext.cs (revision 2c58a8ed345659c071f1531edb80bf6fc9e4f913)
@@ -0,0 +1,63 @@
+// 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.
+
+using System;
+using System.Collections.Generic;
+using Ringtoets.Common.Data;
+
+namespace Ringtoets.Common.Forms.PresentationObjects
+{
+ public class FailureMechanismSectionResultContext
+ {
+ private readonly IEnumerable sectionResults;
+ private readonly IFailureMechanism failureMechanism;
+
+ public FailureMechanismSectionResultContext(IEnumerable sectionResults, IFailureMechanism failureMechanism)
+ {
+ if (sectionResults == null)
+ {
+ throw new ArgumentNullException("sectionResults");
+ }
+ if (failureMechanism == null)
+ {
+ throw new ArgumentNullException("failureMechanism");
+ }
+ this.sectionResults = sectionResults;
+ this.failureMechanism = failureMechanism;
+ }
+
+ public IEnumerable SectionResults
+ {
+ get
+ {
+ return sectionResults;
+ }
+ }
+
+ public IFailureMechanism FailureMechanism
+ {
+ get
+ {
+ return failureMechanism;
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj
===================================================================
diff -u -r6f069737c5a49402fc344e4f7e350c6d869b69f2 -r2c58a8ed345659c071f1531edb80bf6fc9e4f913
--- Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision 6f069737c5a49402fc344e4f7e350c6d869b69f2)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision 2c58a8ed345659c071f1531edb80bf6fc9e4f913)
@@ -47,6 +47,7 @@
Code
+
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/FailureMechanismResultView.cs
===================================================================
diff -u -r6f069737c5a49402fc344e4f7e350c6d869b69f2 -r2c58a8ed345659c071f1531edb80bf6fc9e4f913
--- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/FailureMechanismResultView.cs (.../FailureMechanismResultView.cs) (revision 6f069737c5a49402fc344e4f7e350c6d869b69f2)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/FailureMechanismResultView.cs (.../FailureMechanismResultView.cs) (revision 2c58a8ed345659c071f1531edb80bf6fc9e4f913)
@@ -62,6 +62,8 @@
}
}
+ public IFailureMechanism FailureMechanism { get; set; }
+
private void InitializeDataGridView()
{
var sectionName = new DataGridViewTextBoxColumn
Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs
===================================================================
diff -u -r6f069737c5a49402fc344e4f7e350c6d869b69f2 -r2c58a8ed345659c071f1531edb80bf6fc9e4f913
--- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs (.../RingtoetsGuiPlugin.cs) (revision 6f069737c5a49402fc344e4f7e350c6d869b69f2)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs (.../RingtoetsGuiPlugin.cs) (revision 2c58a8ed345659c071f1531edb80bf6fc9e4f913)
@@ -108,11 +108,13 @@
Image = RingtoetsFormsResources.Map
};
- yield return new ViewInfo, FailureMechanismResultView>
+ yield return new ViewInfo, FailureMechanismResultView>
{
GetViewName = (v, o) => RingtoetsCommonDataResources.FailureMechanism_AssessmentResult_DisplayName,
Image = RingtoetsCommonFormsResources.GenericInputOutputIcon,
- CloseForData = CloseFailureMechanismResultViewForData
+ CloseForData = CloseFailureMechanismResultViewForData,
+ GetViewData = context => context.SectionResults,
+ AfterCreate = (view, context) => view.FailureMechanism = context.FailureMechanism
};
}
@@ -216,7 +218,7 @@
ContextMenuStrip = HydraulicBoundaryDatabaseContextMenuStrip
};
- yield return new TreeNodeInfo>
+ yield return new TreeNodeInfo
{
Text = context => RingtoetsCommonDataResources.FailureMechanism_AssessmentResult_DisplayName,
Image = context => RingtoetsCommonFormsResources.GenericInputOutputIcon,
@@ -353,7 +355,7 @@
{
return new ArrayList
{
- nodeData.SectionResults
+ new FailureMechanismSectionResultContext(nodeData.SectionResults, nodeData)
};
}
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismPlaceholderTreeNodeInfoTest.cs
===================================================================
diff -u -r6f069737c5a49402fc344e4f7e350c6d869b69f2 -r2c58a8ed345659c071f1531edb80bf6fc9e4f913
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismPlaceholderTreeNodeInfoTest.cs (.../FailureMechanismPlaceholderTreeNodeInfoTest.cs) (revision 6f069737c5a49402fc344e4f7e350c6d869b69f2)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismPlaceholderTreeNodeInfoTest.cs (.../FailureMechanismPlaceholderTreeNodeInfoTest.cs) (revision 2c58a8ed345659c071f1531edb80bf6fc9e4f913)
@@ -132,7 +132,10 @@
var outputFolder = (CategoryTreeFolder)children[1];
Assert.AreEqual("Uitvoer", outputFolder.Name);
Assert.AreEqual(TreeFolderCategory.Output, outputFolder.Category);
- Assert.AreEqual(new[]{failureMechanism.SectionResults}, outputFolder.Contents);
+
+ var failureMechanismResultsContext = (FailureMechanismSectionResultContext)outputFolder.Contents[0];
+ Assert.AreSame(failureMechanism, failureMechanismResultsContext.FailureMechanism);
+ Assert.AreSame(failureMechanism.SectionResults, failureMechanismResultsContext.SectionResults);
mocks.VerifyAll();
}
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismSectionResultTreeNodeInfoTest.cs
===================================================================
diff -u -r6f069737c5a49402fc344e4f7e350c6d869b69f2 -r2c58a8ed345659c071f1531edb80bf6fc9e4f913
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismSectionResultTreeNodeInfoTest.cs (.../FailureMechanismSectionResultTreeNodeInfoTest.cs) (revision 6f069737c5a49402fc344e4f7e350c6d869b69f2)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismSectionResultTreeNodeInfoTest.cs (.../FailureMechanismSectionResultTreeNodeInfoTest.cs) (revision 2c58a8ed345659c071f1531edb80bf6fc9e4f913)
@@ -28,6 +28,7 @@
using NUnit.Framework;
using Rhino.Mocks;
using Ringtoets.Common.Data;
+using Ringtoets.Common.Forms.PresentationObjects;
using Ringtoets.Integration.Plugin;
using Ringtoets.Piping.Data;
using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
@@ -46,14 +47,14 @@
{
mocks = new MockRepository();
plugin = new RingtoetsGuiPlugin();
- info = Enumerable.First(plugin.GetTreeNodeInfos(), tni => tni.TagType == typeof(IEnumerable));
+ info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(FailureMechanismSectionResultContext));
}
[Test]
public void Initialized_Always_ExpectedPropertiesSet()
{
// Assert
- Assert.AreEqual(typeof(IEnumerable), info.TagType);
+ Assert.AreEqual(typeof(FailureMechanismSectionResultContext), info.TagType);
Assert.IsNull(info.ForeColor);
Assert.IsNull(info.EnsureVisibleOnCreate);
Assert.IsNull(info.CanRename);
@@ -76,9 +77,10 @@
mocks.ReplayAll();
var mechanism = new PipingFailureMechanism();
+ var context = new FailureMechanismSectionResultContext(mechanism.SectionResults, mechanism);
// Call
- var text = info.Text(mechanism.SectionResults);
+ var text = info.Text(context);
// Assert
Assert.AreEqual("Oordeel", text);
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsGuiPluginTest.cs
===================================================================
diff -u -r6f069737c5a49402fc344e4f7e350c6d869b69f2 -r2c58a8ed345659c071f1531edb80bf6fc9e4f913
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsGuiPluginTest.cs (.../RingtoetsGuiPluginTest.cs) (revision 6f069737c5a49402fc344e4f7e350c6d869b69f2)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsGuiPluginTest.cs (.../RingtoetsGuiPluginTest.cs) (revision 2c58a8ed345659c071f1531edb80bf6fc9e4f913)
@@ -84,7 +84,8 @@
Assert.AreEqual(typeof(AssessmentSectionView), mapViewInfo.ViewType);
TestHelper.AssertImagesAreEqual(RingtoetsFormsResources.Map, mapViewInfo.Image);
- var resultViewInfo = viewInfos.Single(vi => vi.DataType == typeof(IEnumerable));
+ var resultViewInfo = viewInfos.Single(vi => vi.DataType == typeof(FailureMechanismSectionResultContext));
+ Assert.AreEqual(typeof(IEnumerable), resultViewInfo.ViewDataType);
Assert.AreEqual(typeof(FailureMechanismResultView), resultViewInfo.ViewType);
TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GenericInputOutputIcon, resultViewInfo.Image);
}
@@ -121,7 +122,7 @@
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismSectionsContext)));
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismContribution)));
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(HydraulicBoundaryDatabaseContext)));
- Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(IEnumerable)));
+ Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismSectionResultContext)));
}
mocks.VerifyAll();
}
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/FailureMechanismResultViewInfoTest.cs
===================================================================
diff -u -r6f069737c5a49402fc344e4f7e350c6d869b69f2 -r2c58a8ed345659c071f1531edb80bf6fc9e4f913
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/FailureMechanismResultViewInfoTest.cs (.../FailureMechanismResultViewInfoTest.cs) (revision 6f069737c5a49402fc344e4f7e350c6d869b69f2)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/FailureMechanismResultViewInfoTest.cs (.../FailureMechanismResultViewInfoTest.cs) (revision 2c58a8ed345659c071f1531edb80bf6fc9e4f913)
@@ -26,6 +26,7 @@
using NUnit.Framework;
using Rhino.Mocks;
using Ringtoets.Common.Data;
+using Ringtoets.Common.Forms.PresentationObjects;
using Ringtoets.Common.Forms.Views;
using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
@@ -56,18 +57,20 @@
public void Initialized_Always_ExpectedPropertiesSet()
{
// Assert
- Assert.AreEqual(typeof(IEnumerable), info.DataType);
+ Assert.AreEqual(typeof(FailureMechanismSectionResultContext), info.DataType);
+ Assert.AreEqual(typeof(IEnumerable), info.ViewDataType);
}
[Test]
public void GetViewData_Always_ReturnsWrappedFailureMechanismResult()
{
// Setup
var failureMechanism = new SimpleFailureMechanism();
+ var context = new FailureMechanismSectionResultContext(failureMechanism.SectionResults, failureMechanism);
mocks.ReplayAll();
// Call
- var viewData = info.GetViewData(failureMechanism.SectionResults);
+ var viewData = info.GetViewData(context);
// Assert
Assert.AreSame(failureMechanism.SectionResults, viewData);
Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs
===================================================================
diff -u -r6f069737c5a49402fc344e4f7e350c6d869b69f2 -r2c58a8ed345659c071f1531edb80bf6fc9e4f913
--- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs (.../PipingGuiPlugin.cs) (revision 6f069737c5a49402fc344e4f7e350c6d869b69f2)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs (.../PipingGuiPlugin.cs) (revision 2c58a8ed345659c071f1531edb80bf6fc9e4f913)
@@ -32,7 +32,6 @@
using Ringtoets.Common.Data;
using Ringtoets.Common.Forms.Helpers;
using Ringtoets.Common.Forms.PresentationObjects;
-using Ringtoets.Common.Forms.Views;
using Ringtoets.Piping.Data;
using Ringtoets.Piping.Forms;
using Ringtoets.Piping.Forms.PresentationObjects;
@@ -443,7 +442,7 @@
{
return new ArrayList
{
- failureMechanism.SectionResults
+ new FailureMechanismSectionResultContext(failureMechanism.SectionResults, failureMechanism)
};
}
Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingFailureMechanismTreeNodeInfoTest.cs
===================================================================
diff -u -r756f077b356b86d6524dac7234ed6003b51a6d68 -r2c58a8ed345659c071f1531edb80bf6fc9e4f913
--- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingFailureMechanismTreeNodeInfoTest.cs (.../PipingFailureMechanismTreeNodeInfoTest.cs) (revision 756f077b356b86d6524dac7234ed6003b51a6d68)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingFailureMechanismTreeNodeInfoTest.cs (.../PipingFailureMechanismTreeNodeInfoTest.cs) (revision 2c58a8ed345659c071f1531edb80bf6fc9e4f913)
@@ -162,10 +162,10 @@
var outputsFolder = (CategoryTreeFolder) children[2];
Assert.AreEqual("Uitvoer", outputsFolder.Name);
Assert.AreEqual(TreeFolderCategory.Output, outputsFolder.Category);
- CollectionAssert.AreEqual(new object[]
- {
- pipingFailureMechanism.SectionResults
- }, outputsFolder.Contents);
+
+ var failureMechanismResultsContext = (FailureMechanismSectionResultContext)outputsFolder.Contents[0];
+ Assert.AreSame(pipingFailureMechanism, failureMechanismResultsContext.FailureMechanism);
+ Assert.AreSame(pipingFailureMechanism.SectionResults, failureMechanismResultsContext.SectionResults);
mocks.VerifyAll();
}