Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/StabilityPointStructuresPlugin.cs =================================================================== diff -u -r1d60e53e7598655a856373fcddb0aa674dc084bd -rfb1234bf64085a67f7b277ca86d39f80e15ff644 --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/StabilityPointStructuresPlugin.cs (.../StabilityPointStructuresPlugin.cs) (revision 1d60e53e7598655a856373fcddb0aa674dc084bd) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/StabilityPointStructuresPlugin.cs (.../StabilityPointStructuresPlugin.cs) (revision fb1234bf64085a67f7b277ca86d39f80e15ff644) @@ -102,7 +102,7 @@ }; yield return new ViewInfo< - FailureMechanismSectionResultContext, + ProbabilityFailureMechanismSectionResultContext, IEnumerable, StabilityPointStructuresFailureMechanismResultView> { @@ -131,7 +131,7 @@ FailureMechanismEnabledContextMenuStrip, FailureMechanismDisabledContextMenuStrip); - yield return new TreeNodeInfo> + yield return new TreeNodeInfo> { Text = context => RingtoetsCommonFormsResources.FailureMechanism_AssessmentResult_DisplayName, Image = context => RingtoetsCommonFormsResources.FailureMechanismSectionResultIcon, @@ -366,20 +366,20 @@ #region StabilityPointStructuresFailureMechanismContext TreeNodeInfo - private static object[] FailureMechanismEnabledChildNodeObjects(StabilityPointStructuresFailureMechanismContext stabilityPointStructuresFailureMechanismContext) + private static object[] FailureMechanismEnabledChildNodeObjects(StabilityPointStructuresFailureMechanismContext context) { - StabilityPointStructuresFailureMechanism wrappedData = stabilityPointStructuresFailureMechanismContext.WrappedData; + StabilityPointStructuresFailureMechanism wrappedData = context.WrappedData; return new object[] { new CategoryTreeFolder(RingtoetsCommonFormsResources.FailureMechanism_Inputs_DisplayName, - GetInputs(wrappedData, stabilityPointStructuresFailureMechanismContext.Parent), + GetInputs(wrappedData, context.Parent), TreeFolderCategory.Input), new StabilityPointStructuresCalculationGroupContext(wrappedData.CalculationsGroup, null, wrappedData, - stabilityPointStructuresFailureMechanismContext.Parent), + context.Parent), new CategoryTreeFolder(RingtoetsCommonFormsResources.FailureMechanism_Outputs_DisplayName, - GetOutputs(wrappedData), + GetOutputs(wrappedData, context.Parent), TreeFolderCategory.Output) }; } @@ -404,13 +404,14 @@ }; } - private static IEnumerable GetOutputs(StabilityPointStructuresFailureMechanism failureMechanism) + private static IEnumerable GetOutputs(StabilityPointStructuresFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) { return new object[] { new StabilityPointStructuresScenariosContext(failureMechanism.CalculationsGroup, failureMechanism), - new FailureMechanismSectionResultContext( - failureMechanism.SectionResults, failureMechanism), + new ProbabilityFailureMechanismSectionResultContext( + failureMechanism.SectionResults, failureMechanism, assessmentSection), failureMechanism.OutputComments }; } Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/Ringtoets.StabilityPointStructures.Plugin.Test.csproj =================================================================== diff -u -r1d60e53e7598655a856373fcddb0aa674dc084bd -rfb1234bf64085a67f7b277ca86d39f80e15ff644 --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/Ringtoets.StabilityPointStructures.Plugin.Test.csproj (.../Ringtoets.StabilityPointStructures.Plugin.Test.csproj) (revision 1d60e53e7598655a856373fcddb0aa674dc084bd) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/Ringtoets.StabilityPointStructures.Plugin.Test.csproj (.../Ringtoets.StabilityPointStructures.Plugin.Test.csproj) (revision fb1234bf64085a67f7b277ca86d39f80e15ff644) @@ -41,7 +41,7 @@ - + Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/StabilityPointStructuresPluginTest.cs =================================================================== diff -u -r1d60e53e7598655a856373fcddb0aa674dc084bd -rfb1234bf64085a67f7b277ca86d39f80e15ff644 --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/StabilityPointStructuresPluginTest.cs (.../StabilityPointStructuresPluginTest.cs) (revision 1d60e53e7598655a856373fcddb0aa674dc084bd) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/StabilityPointStructuresPluginTest.cs (.../StabilityPointStructuresPluginTest.cs) (revision fb1234bf64085a67f7b277ca86d39f80e15ff644) @@ -100,7 +100,7 @@ // Assert Assert.AreEqual(8, treeNodeInfos.Length); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(StabilityPointStructuresFailureMechanismContext))); - 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(StabilityPointStructuresContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(StabilityPointStructure))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(StabilityPointStructuresScenariosContext))); @@ -129,7 +129,7 @@ PluginTestHelper.AssertViewInfoDefined( viewInfos, - typeof(FailureMechanismSectionResultContext), + typeof(ProbabilityFailureMechanismSectionResultContext), typeof(IEnumerable), typeof(StabilityPointStructuresFailureMechanismResultView)); Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/TreeNodeInfos/ProbabilityFailureMechanismSectionResultContextTreeNodeInfoTest.cs =================================================================== diff -u --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/TreeNodeInfos/ProbabilityFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision 0) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/TreeNodeInfos/ProbabilityFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision fb1234bf64085a67f7b277ca86d39f80e15ff644) @@ -0,0 +1,143 @@ +// 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.Common.Forms.Properties; +using Ringtoets.StabilityPointStructures.Data; + +namespace Ringtoets.StabilityPointStructures.Plugin.Test.TreeNodeInfos +{ + [TestFixture] + public class ProbabilityFailureMechanismSectionResultContextTreeNodeInfoTest + { + private MockRepository mocks; + private StabilityPointStructuresPlugin plugin; + private TreeNodeInfo info; + + [SetUp] + public void SetUp() + { + mocks = new MockRepository(); + plugin = new StabilityPointStructuresPlugin(); + 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_ReturnsName() + { + // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var mechanism = new StabilityPointStructuresFailureMechanism(); + var context = new ProbabilityFailureMechanismSectionResultContext( + mechanism.SectionResults, mechanism, assessmentSection); + + // Call + string text = info.Text(context); + + // Assert + Assert.AreEqual("Resultaat", text); + } + + [Test] + public void Image_Always_ReturnsFailureMechanismSectionResultIcon() + { + // Setup + mocks.ReplayAll(); + + // Call + Image image = info.Image(null); + + // Assert + TestHelper.AssertImagesAreEqual(Resources.FailureMechanismSectionResultIcon, image); + } + + [Test] + public void ContextMenuStrip_Always_CallsBuilder() + { + // Setup + var menuBuilder = mocks.StrictMock(); + menuBuilder.Expect(mb => mb.AddOpenItem()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.Build()).Return(null); + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocks.Stub(); + gui.Stub(g => g.Get(null, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.ProjectOpened += null).IgnoreArguments(); + gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments(); + + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + info.ContextMenuStrip(null, null, treeViewControl); + } + // Assert + // Assert expectancies are called in TearDown() + } + } +} \ No newline at end of file Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/TreeNodeInfos/StabilityPointStructuresFailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -r6e4bf216d76f52ad3159a6cf1ab3ea38c2f17f28 -rfb1234bf64085a67f7b277ca86d39f80e15ff644 --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/TreeNodeInfos/StabilityPointStructuresFailureMechanismContextTreeNodeInfoTest.cs (.../StabilityPointStructuresFailureMechanismContextTreeNodeInfoTest.cs) (revision 6e4bf216d76f52ad3159a6cf1ab3ea38c2f17f28) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/TreeNodeInfos/StabilityPointStructuresFailureMechanismContextTreeNodeInfoTest.cs (.../StabilityPointStructuresFailureMechanismContextTreeNodeInfoTest.cs) (revision fb1234bf64085a67f7b277ca86d39f80e15ff644) @@ -156,9 +156,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); Fisheye: Tag fb1234bf64085a67f7b277ca86d39f80e15ff644 refers to a dead (removed) revision in file `Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/TreeNodeInfos/StabilityPointStructuresFailureMechanismSectionResultContextTreeNodeInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/ViewInfos/StabilityPointStructuresResultViewInfoTest.cs =================================================================== diff -u -rff948d4633181ead2677ab35467a93b4118c6751 -rfb1234bf64085a67f7b277ca86d39f80e15ff644 --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/ViewInfos/StabilityPointStructuresResultViewInfoTest.cs (.../StabilityPointStructuresResultViewInfoTest.cs) (revision ff948d4633181ead2677ab35467a93b4118c6751) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/ViewInfos/StabilityPointStructuresResultViewInfoTest.cs (.../StabilityPointStructuresResultViewInfoTest.cs) (revision fb1234bf64085a67f7b277ca86d39f80e15ff644) @@ -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; @@ -28,8 +27,8 @@ using NUnit.Framework; using Rhino.Mocks; 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.StabilityPointStructures.Data; using Ringtoets.StabilityPointStructures.Forms.PresentationObjects; @@ -41,14 +40,12 @@ [TestFixture] public class StabilityPointStructuresResultViewInfoTest { - private MockRepository mocks; private StabilityPointStructuresPlugin plugin; private ViewInfo info; [SetUp] public void SetUp() { - mocks = new MockRepository(); plugin = new StabilityPointStructuresPlugin(); info = plugin.GetViewInfos().First(tni => tni.ViewType == typeof(StabilityPointStructuresFailureMechanismResultView)); } @@ -63,22 +60,28 @@ 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 mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + var failureMechanism = new StabilityPointStructuresFailureMechanism(); - 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] @@ -96,36 +99,6 @@ } [Test] - public void ViewType_Always_ReturnsViewType() - { - // Call - Type viewType = info.ViewType; - - // Assert - Assert.AreEqual(typeof(StabilityPointStructuresFailureMechanismResultView), 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_ReturnsGenericInputOutputIcon() { // Call @@ -139,6 +112,7 @@ public void CloseForData_AssessmentSectionRemovedWithoutFailureMechanism_ReturnsFalse() { // Setup + var mocks = new MockRepository(); var assessmentSection = mocks.Stub(); assessmentSection.Stub(asm => asm.GetFailureMechanisms()).Return(new IFailureMechanism[0]); mocks.ReplayAll(); @@ -154,22 +128,23 @@ // Assert Assert.IsFalse(closeForData); } + mocks.VerifyAll(); } [Test] public void CloseForData_ViewNotCorrespondingToRemovedAssessmentSection_ReturnsFalse() { // Setup - var assessmentSection = mocks.Stub(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); - var otherFailureMechanism = mocks.Stub("N", "C"); + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var otherFailureMechanism = mocks.Stub("N", "C"); assessmentSection.Stub(asm => asm.GetFailureMechanisms()).Return(new[] { otherFailureMechanism }); - mocks.ReplayAll(); using (var view = new StabilityPointStructuresFailureMechanismResultView()) @@ -182,22 +157,23 @@ // Assert Assert.IsFalse(closeForData); } + mocks.VerifyAll(); } [Test] public void CloseForData_ViewCorrespondingToRemovedAssessmentSection_ReturnsTrue() { // Setup - var assessmentSection = mocks.Stub(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); assessmentSection.Stub(asm => asm.GetFailureMechanisms()).Return(new IFailureMechanism[] { new TestFailureMechanism(), failureMechanism }); - mocks.ReplayAll(); using (var view = new StabilityPointStructuresFailureMechanismResultView()) @@ -210,6 +186,7 @@ // Assert Assert.IsTrue(closeForData); } + mocks.VerifyAll(); } @@ -251,6 +228,7 @@ public void CloseForData_ViewCorrespondingToRemovedFailureMechanismContext_ReturnsTrue() { // Setup + var mocks = new MockRepository(); var assessmentSection = mocks.Stub(); mocks.ReplayAll(); @@ -267,13 +245,15 @@ // Assert Assert.IsTrue(closeForData); } + mocks.VerifyAll(); } [Test] public void CloseForData_ViewNotCorrespondingToRemovedFailureMechanism_ReturnsFalse() { // Setup + var mocks = new MockRepository(); var assessmentSection = mocks.Stub(); mocks.ReplayAll(); @@ -291,6 +271,7 @@ // Assert Assert.IsFalse(closeForData); } + mocks.VerifyAll(); } @@ -299,31 +280,21 @@ { // Setup var failureMechanism = new StabilityPointStructuresFailureMechanism(); + + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); var view = mocks.StrictMock(); view.Expect(v => v.FailureMechanism = failureMechanism); - mocks.ReplayAll(); - var context = new FailureMechanismSectionResultContext(failureMechanism.SectionResults, failureMechanism); + var context = new ProbabilityFailureMechanismSectionResultContext( + failureMechanism.SectionResults, failureMechanism, assessmentSection); // Call info.AfterCreate(view, context); // Assert mocks.VerifyAll(); } - - private class TestFailureMechanism : FailureMechanismBase - { - public TestFailureMechanism() : base("Name", "FailureMechanismCode") {} - - public override IEnumerable Calculations - { - get - { - return null; - } - } - } } } \ No newline at end of file