Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -r41fac7fff0a505c08945108d795dcb877f10b816 -rea99af5c043eadf5c2ba83b82a847ae009181191 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismContextTreeNodeInfoTest.cs (.../FailureMechanismContextTreeNodeInfoTest.cs) (revision 41fac7fff0a505c08945108d795dcb877f10b816) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismContextTreeNodeInfoTest.cs (.../FailureMechanismContextTreeNodeInfoTest.cs) (revision ea99af5c043eadf5c2ba83b82a847ae009181191) @@ -19,7 +19,6 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. -using System; using System.Collections.Generic; using System.Drawing; using System.Linq; @@ -35,8 +34,8 @@ using Rhino.Mocks; using Ringtoets.Common.Data; using Ringtoets.Common.Data.AssessmentSection; -using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Integration.Forms.PresentationObjects; using Ringtoets.Integration.Plugin; @@ -148,20 +147,16 @@ { // Setup var assessmentSection = mocks.Stub(); - mocks.ReplayAll(); using (var plugin = new RingtoetsGuiPlugin()) { var info = GetInfo(plugin); var failureMechanism = new TestFailureMechanism("test", "C"); - failureMechanism.AddSection(new FailureMechanismSection("A", new[] - { - new Point2D(1, 2), - new Point2D(5, 6) - })); - var failureMechanismContext = new CustomFailureMechanismContext(failureMechanism, assessmentSection); + var failureMechanismContext = mocks.Stub>(failureMechanism, assessmentSection); + mocks.ReplayAll(); + // Call object[] children = info.ChildNodeObjects(failureMechanismContext).ToArray(); @@ -183,15 +178,67 @@ var outputFolder = (CategoryTreeFolder) children[1]; Assert.AreEqual("Uitvoer", outputFolder.Name); Assert.AreEqual(TreeFolderCategory.Output, outputFolder.Category); + } + mocks.VerifyAll(); + } + [Test] + public void ChildNodeObjects_FailureMechanismIsRelevantWithCustomSectinoResults_OutputNodeAdded() + { + + // Setup + var assessmentSection = mocks.Stub(); + + using (var plugin = new RingtoetsGuiPlugin()) + { + var info = GetInfo(plugin); + + var failureMechanism = mocks.StrictMultiMock>(typeof(IFailureMechanism)); + failureMechanism.Expect(fm => ((IFailureMechanism) fm).IsRelevant).Return(true); + failureMechanism.Expect(fm => fm.SectionResults).Return(new List()).Repeat.Any(); + var failureMechanismContext = mocks.Stub>(failureMechanism, assessmentSection); + + mocks.ReplayAll(); + + // Call + object[] children = info.ChildNodeObjects(failureMechanismContext).ToArray(); + var outputFolder = (CategoryTreeFolder)children[1]; + var failureMechanismResultsContext = (FailureMechanismSectionResultContext) outputFolder.Contents[0]; Assert.AreSame(failureMechanism, failureMechanismResultsContext.FailureMechanism); Assert.AreSame(failureMechanism.SectionResults, failureMechanismResultsContext.SectionResults); } - mocks.VerifyAll(); } [Test] + public void ChildNodeObjects_FailureMechanismIsRelevantWithSimpleSectinoResults_OutputNodeAdded() + { + + // Setup + var assessmentSection = mocks.Stub(); + + using (var plugin = new RingtoetsGuiPlugin()) + { + var info = GetInfo(plugin); + + var failureMechanism = mocks.StrictMultiMock>(typeof(IFailureMechanism)); + failureMechanism.Expect(fm => ((IFailureMechanism)fm).IsRelevant).Return(true); + failureMechanism.Expect(fm => fm.SectionResults).Return(new List()).Repeat.Any(); + var failureMechanismContext = mocks.Stub>(failureMechanism, assessmentSection); + + mocks.ReplayAll(); + + // Call + object[] children = info.ChildNodeObjects(failureMechanismContext).ToArray(); + var outputFolder = (CategoryTreeFolder)children[1]; + + var failureMechanismResultsContext = (FailureMechanismSectionResultContext) outputFolder.Contents[0]; + Assert.AreSame(failureMechanism, failureMechanismResultsContext.FailureMechanism); + Assert.AreSame(failureMechanism.SectionResults, failureMechanismResultsContext.SectionResults); + } + } + + [Test] public void ChildNodeObjects_FailureMechanismIsNotRelevant_ReturnOnlyFailureMechanismComments() { // Setup @@ -445,25 +492,6 @@ { return guiPlugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(FailureMechanismContext)); } - - public class TestFailureMechanism : FailureMechanismBase, IHasSectionResults - { - public TestFailureMechanism(string name, string code) - : base(name, code) - { - SectionResults = new List(); - } - - public IEnumerable SectionResults { get; private set; } - - public override IEnumerable Calculations - { - get - { - throw new NotImplementedException(); - } - } - } } } \ No newline at end of file