Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs =================================================================== diff -u -r327fdd939671af52327e89c26a177fa666ba97a9 -r512b95219f63a898d244925c2d3f7cea33560f6d --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs (.../ClosingStructuresPlugin.cs) (revision 327fdd939671af52327e89c26a177fa666ba97a9) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs (.../ClosingStructuresPlugin.cs) (revision 512b95219f63a898d244925c2d3f7cea33560f6d) @@ -104,7 +104,7 @@ }; yield return new ViewInfo< - FailureMechanismSectionResultContext, + ProbabilityFailureMechanismSectionResultContext, IEnumerable, ClosingStructuresFailureMechanismResultView> { @@ -143,7 +143,7 @@ CalculationContextContextMenuStrip, CalculationContextOnNodeRemoved); - yield return new TreeNodeInfo> + yield return new TreeNodeInfo> { Text = context => RingtoetsCommonFormsResources.FailureMechanism_AssessmentResult_DisplayName, Image = context => RingtoetsCommonFormsResources.FailureMechanismSectionResultIcon, @@ -354,14 +354,14 @@ #region ClosingStructuresFailureMechanismContext TreeNodeInfo - private static object[] FailureMechanismEnabledChildNodeObjects(ClosingStructuresFailureMechanismContext closingStructuresFailureMechanismContext) + private static object[] FailureMechanismEnabledChildNodeObjects(ClosingStructuresFailureMechanismContext context) { - ClosingStructuresFailureMechanism wrappedData = closingStructuresFailureMechanismContext.WrappedData; + ClosingStructuresFailureMechanism wrappedData = context.WrappedData; return new object[] { - new CategoryTreeFolder(RingtoetsCommonFormsResources.FailureMechanism_Inputs_DisplayName, GetInputs(wrappedData, closingStructuresFailureMechanismContext.Parent), TreeFolderCategory.Input), - new ClosingStructuresCalculationGroupContext(wrappedData.CalculationsGroup, null, wrappedData, closingStructuresFailureMechanismContext.Parent), - new CategoryTreeFolder(RingtoetsCommonFormsResources.FailureMechanism_Outputs_DisplayName, GetOutputs(wrappedData), TreeFolderCategory.Output) + new CategoryTreeFolder(RingtoetsCommonFormsResources.FailureMechanism_Inputs_DisplayName, GetInputs(wrappedData, context.Parent), TreeFolderCategory.Input), + new ClosingStructuresCalculationGroupContext(wrappedData.CalculationsGroup, null, wrappedData, context.Parent), + new CategoryTreeFolder(RingtoetsCommonFormsResources.FailureMechanism_Outputs_DisplayName, GetOutputs(wrappedData, context.Parent), TreeFolderCategory.Output) }; } @@ -384,13 +384,13 @@ }; } - private static IEnumerable GetOutputs(ClosingStructuresFailureMechanism failureMechanism) + private static IEnumerable GetOutputs(ClosingStructuresFailureMechanism failureMechanism, IAssessmentSection assessmentSection) { return new object[] { new ClosingStructuresScenariosContext(failureMechanism.CalculationsGroup, failureMechanism), - new FailureMechanismSectionResultContext( - failureMechanism.SectionResults, failureMechanism), + new ProbabilityFailureMechanismSectionResultContext( + failureMechanism.SectionResults, failureMechanism, assessmentSection), failureMechanism.OutputComments }; } Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/ClosingStructuresPluginTest.cs =================================================================== diff -u -r327fdd939671af52327e89c26a177fa666ba97a9 -r512b95219f63a898d244925c2d3f7cea33560f6d --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/ClosingStructuresPluginTest.cs (.../ClosingStructuresPluginTest.cs) (revision 327fdd939671af52327e89c26a177fa666ba97a9) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/ClosingStructuresPluginTest.cs (.../ClosingStructuresPluginTest.cs) (revision 512b95219f63a898d244925c2d3f7cea33560f6d) @@ -100,7 +100,7 @@ // Assert Assert.AreEqual(8, treeNodeInfos.Length); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(ClosingStructuresFailureMechanismContext))); - Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismSectionResultContext))); + Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(ProbabilityFailureMechanismSectionResultContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(ClosingStructuresContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(ClosingStructure))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(ClosingStructuresCalculationGroupContext))); @@ -129,7 +129,7 @@ PluginTestHelper.AssertViewInfoDefined( viewInfos, - typeof(FailureMechanismSectionResultContext), + typeof(ProbabilityFailureMechanismSectionResultContext), typeof(IEnumerable), typeof(ClosingStructuresFailureMechanismResultView)); Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/Ringtoets.ClosingStructures.Plugin.Test.csproj =================================================================== diff -u -r327fdd939671af52327e89c26a177fa666ba97a9 -r512b95219f63a898d244925c2d3f7cea33560f6d --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/Ringtoets.ClosingStructures.Plugin.Test.csproj (.../Ringtoets.ClosingStructures.Plugin.Test.csproj) (revision 327fdd939671af52327e89c26a177fa666ba97a9) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/Ringtoets.ClosingStructures.Plugin.Test.csproj (.../Ringtoets.ClosingStructures.Plugin.Test.csproj) (revision 512b95219f63a898d244925c2d3f7cea33560f6d) @@ -41,7 +41,7 @@ - + Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/TreeNodeInfos/ClosingStructuresFailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -r6e4bf216d76f52ad3159a6cf1ab3ea38c2f17f28 -r512b95219f63a898d244925c2d3f7cea33560f6d --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/TreeNodeInfos/ClosingStructuresFailureMechanismContextTreeNodeInfoTest.cs (.../ClosingStructuresFailureMechanismContextTreeNodeInfoTest.cs) (revision 6e4bf216d76f52ad3159a6cf1ab3ea38c2f17f28) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/TreeNodeInfos/ClosingStructuresFailureMechanismContextTreeNodeInfoTest.cs (.../ClosingStructuresFailureMechanismContextTreeNodeInfoTest.cs) (revision 512b95219f63a898d244925c2d3f7cea33560f6d) @@ -160,9 +160,10 @@ Assert.AreSame(failureMechanism.CalculationsGroup, scenariosContext.WrappedData); Assert.AreSame(failureMechanism, scenariosContext.ParentFailureMechanism); - 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); Fisheye: Tag 512b95219f63a898d244925c2d3f7cea33560f6d refers to a dead (removed) revision in file `Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/TreeNodeInfos/ClosingStructuresFailureMechanismSectionResultContextTreeNodeInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/TreeNodeInfos/ProbabilityFailureMechanismSectionResultContextTreeNodeInfoTest.cs =================================================================== diff -u --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/TreeNodeInfos/ProbabilityFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision 0) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/TreeNodeInfos/ProbabilityFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision 512b95219f63a898d244925c2d3f7cea33560f6d) @@ -0,0 +1,156 @@ +// 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.ClosingStructures.Data; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Forms.PresentationObjects; +using Ringtoets.Common.Forms.Properties; + +namespace Ringtoets.ClosingStructures.Plugin.Test.TreeNodeInfos +{ + [TestFixture] + public class ProbabilityFailureMechanismSectionResultContextTreeNodeInfoTest + { + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Setup + using (var plugin = new ClosingStructuresPlugin()) + { + TreeNodeInfo info = GetInfo(plugin); + + // 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_ReturnsName() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + using (var plugin = new ClosingStructuresPlugin()) + { + TreeNodeInfo info = GetInfo(plugin); + + var mechanism = new ClosingStructuresFailureMechanism(); + var context = new ProbabilityFailureMechanismSectionResultContext(mechanism.SectionResults, mechanism, + assessmentSection); + + // Call + string text = info.Text(context); + + // Assert + Assert.AreEqual("Resultaat", text); + } + + mocks.VerifyAll(); + } + + [Test] + public void Image_Always_ReturnsGenericInputOutputIcon() + { + // Setup + using (var plugin = new ClosingStructuresPlugin()) + { + TreeNodeInfo info = GetInfo(plugin); + + // Call + Image image = info.Image(null); + + // Assert + TestHelper.AssertImagesAreEqual(Resources.FailureMechanismSectionResultIcon, image); + } + } + + [Test] + public void ContextMenuStrip_Always_CallsBuilder() + { + // Setup + var mockRepository = new MockRepository(); + var assessmentSection = mockRepository.Stub(); + var menuBuilder = mockRepository.StrictMock(); + menuBuilder.Expect(mb => mb.AddOpenItem()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.Build()).Return(null); + + using (var treeViewControl = new TreeViewControl()) + { + var failureMechanism = new ClosingStructuresFailureMechanism(); + var sectionResult = new ClosingStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + var sectionResultContext = new ProbabilityFailureMechanismSectionResultContext(new[] + { + sectionResult + }, failureMechanism, assessmentSection); + + var gui = mockRepository.Stub(); + gui.Stub(g => g.Get(sectionResultContext, treeViewControl)).Return(menuBuilder); + mockRepository.ReplayAll(); + + using (var plugin = new ClosingStructuresPlugin()) + { + TreeNodeInfo info = GetInfo(plugin); + + plugin.Gui = gui; + + // Call + info.ContextMenuStrip(sectionResultContext, null, treeViewControl); + } + } + + // Assert + mockRepository.VerifyAll(); + } + + private static TreeNodeInfo GetInfo(ClosingStructuresPlugin plugin) + { + return plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(ProbabilityFailureMechanismSectionResultContext)); + } + } +} \ No newline at end of file Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/ViewInfos/ClosingStructuresFailureMechanismResultViewInfoTest.cs =================================================================== diff -u -r3178e116f5e59e03078d465efeb303c5e232c7bf -r512b95219f63a898d244925c2d3f7cea33560f6d --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/ViewInfos/ClosingStructuresFailureMechanismResultViewInfoTest.cs (.../ClosingStructuresFailureMechanismResultViewInfoTest.cs) (revision 3178e116f5e59e03078d465efeb303c5e232c7bf) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/ViewInfos/ClosingStructuresFailureMechanismResultViewInfoTest.cs (.../ClosingStructuresFailureMechanismResultViewInfoTest.cs) (revision 512b95219f63a898d244925c2d3f7cea33560f6d) @@ -31,8 +31,8 @@ using Ringtoets.ClosingStructures.Forms.PresentationObjects; using Ringtoets.ClosingStructures.Forms.Views; 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 RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; @@ -43,47 +43,58 @@ { private MockRepository mocks; private ViewInfo info; + private ClosingStructuresPlugin plugin; [SetUp] public void SetUp() { mocks = new MockRepository(); - using (var plugin = new ClosingStructuresPlugin()) - { - info = plugin.GetViewInfos().First(tni => tni.ViewType == typeof(ClosingStructuresFailureMechanismResultView)); - } + plugin = new ClosingStructuresPlugin(); + info = plugin.GetViewInfos().First(tni => tni.ViewType == typeof(ClosingStructuresFailureMechanismResultView)); } + [TearDown] + public void TearDown() + { + plugin.Dispose(); + } + [Test] public void Initialized_Always_ExpectedPropertiesSet() { // Assert - Assert.AreEqual(typeof(FailureMechanismSectionResultContext), info.DataType); + Assert.AreEqual(typeof(ProbabilityFailureMechanismSectionResultContext), info.DataType); Assert.AreEqual(typeof(IEnumerable), info.ViewDataType); } [Test] public void GetViewData_Always_ReturnsWrappedFailureMechanismResult() { // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + var failureMechanism = new ClosingStructuresFailureMechanism(); - var context = new FailureMechanismSectionResultContext(failureMechanism.SectionResults, failureMechanism); + var context = new ProbabilityFailureMechanismSectionResultContext(failureMechanism.SectionResults, failureMechanism, + assessmentSection); // Call object viewData = info.GetViewData(context); // Assert Assert.AreSame(failureMechanism.SectionResults, viewData); + mocks.VerifyAll(); } [Test] public void GetViewName_Always_ReturnsViewName() { // Setup - var failureMechanism = new ClosingStructuresFailureMechanism(); var view = mocks.StrictMock(); mocks.ReplayAll(); + var failureMechanism = new ClosingStructuresFailureMechanism(); + // Call string viewName = info.GetViewName(view, failureMechanism.SectionResults); @@ -93,36 +104,6 @@ } [Test] - public void ViewType_Always_ReturnsViewType() - { - // Call - Type viewType = info.ViewType; - - // Assert - Assert.AreEqual(typeof(ClosingStructuresFailureMechanismResultView), viewType); - } - - [Test] - public void DataType_Always_ReturnsDataType() - { - // Call - Type dataType = info.DataType; - - // Assert - Assert.AreEqual(typeof(FailureMechanismSectionResultContext), dataType); - } - - [Test] - public void ViewDataType_Always_ReturnsViewDataType() - { - // Call - Type viewDataType = info.ViewDataType; - - // Assert - Assert.AreEqual(typeof(IEnumerable), viewDataType); - } - - [Test] public void Image_Always_ReturnsFailureMechanismSectionResultIcon() { // Call @@ -264,6 +245,7 @@ // Assert Assert.IsTrue(closeForData); } + mocks.VerifyAll(); } @@ -288,6 +270,7 @@ // Assert Assert.IsFalse(closeForData); } + mocks.VerifyAll(); } @@ -296,10 +279,14 @@ { // Setup var failureMechanism = new ClosingStructuresFailureMechanism(); + + var assessmentSection = mocks.Stub(); var view = mocks.StrictMock(); - var context = new FailureMechanismSectionResultContext(failureMechanism.SectionResults, failureMechanism); view.Expect(v => v.FailureMechanism = failureMechanism); mocks.ReplayAll(); + + var context = new ProbabilityFailureMechanismSectionResultContext(failureMechanism.SectionResults, failureMechanism, + assessmentSection); // Call info.AfterCreate(view, context);