Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs =================================================================== diff -u -r7b5dd1eb32582acc70e3c6395c767eb51a2c93e3 -r41864fb27f6bb9d542e5775f998f6802c4b42247 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs (.../HeightStructuresPlugin.cs) (revision 7b5dd1eb32582acc70e3c6395c767eb51a2c93e3) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs (.../HeightStructuresPlugin.cs) (revision 41864fb27f6bb9d542e5775f998f6802c4b42247) @@ -176,7 +176,7 @@ }; yield return new ViewInfo< - FailureMechanismSectionResultContext, + ProbabilityFailureMechanismSectionResultContext, IEnumerable, HeightStructuresFailureMechanismResultView> { @@ -244,7 +244,7 @@ .Build() }; - yield return new TreeNodeInfo> + yield return new TreeNodeInfo> { Text = context => RingtoetsCommonFormsResources.FailureMechanism_AssessmentResult_DisplayName, Image = context => RingtoetsCommonFormsResources.FailureMechanismSectionResultIcon, @@ -382,7 +382,7 @@ { new CategoryTreeFolder(RingtoetsCommonFormsResources.FailureMechanism_Inputs_DisplayName, GetInputs(wrappedData, context.Parent), TreeFolderCategory.Input), new HeightStructuresCalculationGroupContext(wrappedData.CalculationsGroup, null, wrappedData, context.Parent), - new CategoryTreeFolder(RingtoetsCommonFormsResources.FailureMechanism_Outputs_DisplayName, GetOutputs(wrappedData), TreeFolderCategory.Output) + new CategoryTreeFolder(RingtoetsCommonFormsResources.FailureMechanism_Outputs_DisplayName, GetOutputs(wrappedData, context.Parent), TreeFolderCategory.Output) }; } @@ -397,13 +397,13 @@ }; } - private static IEnumerable GetOutputs(HeightStructuresFailureMechanism failureMechanism) + private static IEnumerable GetOutputs(HeightStructuresFailureMechanism failureMechanism, IAssessmentSection assessmentSection) { return new object[] { new HeightStructuresScenariosContext(failureMechanism.CalculationsGroup, failureMechanism), - new FailureMechanismSectionResultContext( - failureMechanism.SectionResults, failureMechanism), + new ProbabilityFailureMechanismSectionResultContext( + failureMechanism.SectionResults, failureMechanism, assessmentSection), failureMechanism.OutputComments }; } Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/HeightStructuresPluginTest.cs =================================================================== diff -u -r7b5dd1eb32582acc70e3c6395c767eb51a2c93e3 -r41864fb27f6bb9d542e5775f998f6802c4b42247 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/HeightStructuresPluginTest.cs (.../HeightStructuresPluginTest.cs) (revision 7b5dd1eb32582acc70e3c6395c767eb51a2c93e3) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/HeightStructuresPluginTest.cs (.../HeightStructuresPluginTest.cs) (revision 41864fb27f6bb9d542e5775f998f6802c4b42247) @@ -106,7 +106,7 @@ Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(HeightStructuresContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(HeightStructure))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(HeightStructuresScenariosContext))); - Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismSectionResultContext))); + Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(ProbabilityFailureMechanismSectionResultContext))); } } @@ -129,7 +129,7 @@ PluginTestHelper.AssertViewInfoDefined( viewInfos, - typeof(FailureMechanismSectionResultContext), + typeof(ProbabilityFailureMechanismSectionResultContext), typeof(IEnumerable), typeof(HeightStructuresFailureMechanismResultView)); Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/Ringtoets.HeightStructures.Plugin.Test.csproj =================================================================== diff -u -r7b5dd1eb32582acc70e3c6395c767eb51a2c93e3 -r41864fb27f6bb9d542e5775f998f6802c4b42247 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/Ringtoets.HeightStructures.Plugin.Test.csproj (.../Ringtoets.HeightStructures.Plugin.Test.csproj) (revision 7b5dd1eb32582acc70e3c6395c767eb51a2c93e3) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/Ringtoets.HeightStructures.Plugin.Test.csproj (.../Ringtoets.HeightStructures.Plugin.Test.csproj) (revision 41864fb27f6bb9d542e5775f998f6802c4b42247) @@ -34,7 +34,7 @@ - + Fisheye: Tag 41864fb27f6bb9d542e5775f998f6802c4b42247 refers to a dead (removed) revision in file `Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/TreeNodeInfos/FailureMechanismResultContextTreeNodeInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/TreeNodeInfos/HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -r6e4bf216d76f52ad3159a6cf1ab3ea38c2f17f28 -r41864fb27f6bb9d542e5775f998f6802c4b42247 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/TreeNodeInfos/HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs (.../HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs) (revision 6e4bf216d76f52ad3159a6cf1ab3ea38c2f17f28) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/TreeNodeInfos/HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs (.../HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs) (revision 41864fb27f6bb9d542e5775f998f6802c4b42247) @@ -161,9 +161,10 @@ Assert.AreSame(failureMechanism, scenariosContext.ParentFailureMechanism); Assert.AreSame(failureMechanism.CalculationsGroup, scenariosContext.WrappedData); - var failureMechanismResultsContext = (FailureMechanismSectionResultContext) outputsFolder.Contents.ElementAt(1); + var failureMechanismResultsContext = (ProbabilityFailureMechanismSectionResultContext) outputsFolder.Contents.ElementAt(1); Assert.AreSame(failureMechanism, failureMechanismResultsContext.FailureMechanism); Assert.AreSame(failureMechanism.SectionResults, failureMechanismResultsContext.WrappedData); + Assert.AreSame(assessmentSection, failureMechanismResultsContext.AssessmentSection); var outputComment = (Comment) outputsFolder.Contents.ElementAt(2); Assert.AreSame(failureMechanism.OutputComments, outputComment); Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/TreeNodeInfos/ProbabilityFailureMechanismResultContextTreeNodeInfoTest.cs =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/TreeNodeInfos/ProbabilityFailureMechanismResultContextTreeNodeInfoTest.cs (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/TreeNodeInfos/ProbabilityFailureMechanismResultContextTreeNodeInfoTest.cs (revision 41864fb27f6bb9d542e5775f998f6802c4b42247) @@ -0,0 +1,144 @@ +// Copyright (C) Stichting Deltares 2017. 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.Drawing; +using System.Linq; +using Core.Common.Controls.TreeView; +using Core.Common.Gui; +using Core.Common.Gui.ContextMenu; +using Core.Common.TestUtil; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Forms.PresentationObjects; +using Ringtoets.HeightStructures.Data; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.HeightStructures.Plugin.Test.TreeNodeInfos +{ + [TestFixture] + public class ProbabilityFailureMechanismResultContextTreeNodeInfoTest + { + private MockRepository mocks; + private HeightStructuresPlugin plugin; + private TreeNodeInfo info; + + [SetUp] + public void SetUp() + { + mocks = new MockRepository(); + plugin = new HeightStructuresPlugin(); + info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(ProbabilityFailureMechanismSectionResultContext)); + } + + [TearDown] + public void TearDown() + { + plugin.Dispose(); + mocks.VerifyAll(); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Setup + mocks.ReplayAll(); + + // Assert + Assert.IsNotNull(info.Text); + Assert.IsNull(info.ForeColor); + Assert.IsNotNull(info.Image); + Assert.IsNotNull(info.ContextMenuStrip); + Assert.IsNull(info.EnsureVisibleOnCreate); + Assert.IsNull(info.ExpandOnCreate); + Assert.IsNull(info.ChildNodeObjects); + Assert.IsNull(info.CanRename); + Assert.IsNull(info.OnNodeRenamed); + Assert.IsNull(info.CanRemove); + Assert.IsNull(info.OnNodeRemoved); + Assert.IsNull(info.CanCheck); + Assert.IsNull(info.IsChecked); + Assert.IsNull(info.OnNodeChecked); + Assert.IsNull(info.CanDrag); + Assert.IsNull(info.CanDrop); + Assert.IsNull(info.CanInsert); + Assert.IsNull(info.OnDrop); + } + + [Test] + public void Text_Always_ReturnsFailureMechanismSectionResultDisplayName() + { + // Setup + mocks.ReplayAll(); + + // Call + string text = info.Text(null); + + // Assert + Assert.AreEqual(RingtoetsCommonFormsResources.FailureMechanism_AssessmentResult_DisplayName, text); + } + + [Test] + public void Image_Always_ReturnsFailureMechanismSectionResultIcon() + { + // Setup + mocks.ReplayAll(); + + // Call + Image image = info.Image(null); + + // Assert + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.FailureMechanismSectionResultIcon, image); + } + + [Test] + public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods() + { + // Setup + var assessmentSection = mocks.Stub(); + var menuBuilder = mocks.StrictMock(); + using (mocks.Ordered()) + { + menuBuilder.Expect(mb => mb.AddOpenItem()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.Build()).Return(null); + } + + var failureMechanism = new HeightStructuresFailureMechanism(); + var context = new ProbabilityFailureMechanismSectionResultContext( + Enumerable.Empty(), failureMechanism, assessmentSection); + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocks.Stub(); + gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(menuBuilder); + + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + info.ContextMenuStrip(context, null, treeViewControl); + } + // Assert + // Assert expectancies are called in TearDown() + } + } +} \ No newline at end of file Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/ViewInfos/HeightStructuresFailureMechanismResultViewInfoTest.cs =================================================================== diff -u -rf4049b9b0967513aeadfddb1fe58efa3b3aa1677 -r41864fb27f6bb9d542e5775f998f6802c4b42247 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/ViewInfos/HeightStructuresFailureMechanismResultViewInfoTest.cs (.../HeightStructuresFailureMechanismResultViewInfoTest.cs) (revision f4049b9b0967513aeadfddb1fe58efa3b3aa1677) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/ViewInfos/HeightStructuresFailureMechanismResultViewInfoTest.cs (.../HeightStructuresFailureMechanismResultViewInfoTest.cs) (revision 41864fb27f6bb9d542e5775f998f6802c4b42247) @@ -60,7 +60,7 @@ public void Initialized_Always_ExpectedPropertiesSet() { // Assert - Assert.AreEqual(typeof(FailureMechanismSectionResultContext), info.DataType); + Assert.AreEqual(typeof(ProbabilityFailureMechanismSectionResultContext), info.DataType); Assert.AreEqual(typeof(IEnumerable), info.ViewDataType); } @@ -78,19 +78,25 @@ public void GetViewData_Always_ReturnsSectionResults() { // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + var sectionResults = new[] { new HeightStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()) }; - var context = new FailureMechanismSectionResultContext(sectionResults, - new HeightStructuresFailureMechanism()); + var context = new ProbabilityFailureMechanismSectionResultContext(sectionResults, + new HeightStructuresFailureMechanism(), + assessmentSection); // Call object viewData = info.GetViewData(context); // Assert Assert.AreSame(sectionResults, viewData); + mocks.VerifyAll(); } [Test] @@ -273,13 +279,16 @@ { // Setup var failureMechanism = new HeightStructuresFailureMechanism(); - var context = new FailureMechanismSectionResultContext(failureMechanism.SectionResults, failureMechanism); var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); var view = mocks.StrictMock(); view.Expect(v => v.FailureMechanism = failureMechanism); mocks.ReplayAll(); + var context = new ProbabilityFailureMechanismSectionResultContext( + failureMechanism.SectionResults, failureMechanism, assessmentSection); + // Call info.AfterCreate(view, context);