Index: Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs =================================================================== diff -u -rfddd65d624333457956862dd117f69d54aff1171 -r5299261dce08137976c5f234f1261d4c0683e6e9 --- Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision fddd65d624333457956862dd117f69d54aff1171) +++ Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision 5299261dce08137976c5f234f1261d4c0683e6e9) @@ -91,7 +91,10 @@ CreateInstance = context => new WaveHeightCalculationsProperties(context.WrappedData) }; - yield return new PropertyInfo(); + yield return new PropertyInfo + { + CreateInstance = context => new GrassCoverErosionOutwardsWaveConditionsOutputProperties(context.WrappedData, context.Input) + }; yield return new PropertyInfo { @@ -296,10 +299,10 @@ .Build() }; - yield return new TreeNodeInfo + yield return new TreeNodeInfo { - Text = emptyOutput => RiskeerCommonFormsResources.CalculationOutput_DisplayName, - Image = emptyOutput => RiskeerCommonFormsResources.GeneralOutputIcon, + Text = context => RiskeerCommonFormsResources.CalculationOutput_DisplayName, + Image = context => RiskeerCommonFormsResources.GeneralOutputIcon, ContextMenuStrip = (nodeData, parentData, treeViewControl) => Gui.Get(nodeData, treeViewControl) .AddPropertiesItem() .Build() @@ -905,7 +908,7 @@ if (calculation.HasOutput) { - childNodes.Add(calculation.Output); + childNodes.Add(new GrassCoverErosionOutwardsWaveConditionsOutputContext(calculation.Output, calculation.InputParameters)); } else { Index: Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/GrassCoverErosionOutwardsPluginTest.cs =================================================================== diff -u -r86594ccd7329d320872573a1d066fe18959d3cea -r5299261dce08137976c5f234f1261d4c0683e6e9 --- Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/GrassCoverErosionOutwardsPluginTest.cs (.../GrassCoverErosionOutwardsPluginTest.cs) (revision 86594ccd7329d320872573a1d066fe18959d3cea) +++ Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/GrassCoverErosionOutwardsPluginTest.cs (.../GrassCoverErosionOutwardsPluginTest.cs) (revision 5299261dce08137976c5f234f1261d4c0683e6e9) @@ -116,7 +116,7 @@ Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(GrassCoverErosionOutwardsWaveConditionsCalculationContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(EmptyGrassCoverErosionOutwardsOutput))); - Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(GrassCoverErosionOutwardsWaveConditionsOutput))); + Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(GrassCoverErosionOutwardsWaveConditionsOutputContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(GrassCoverErosionOutwardsDesignWaterLevelCalculationsGroupContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(GrassCoverErosionOutwardsWaveHeightCalculationsGroupContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(GrassCoverErosionOutwardsWaveConditionsInputContext))); @@ -152,7 +152,7 @@ PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, - typeof(GrassCoverErosionOutwardsWaveConditionsOutput), + typeof(GrassCoverErosionOutwardsWaveConditionsOutputContext), typeof(GrassCoverErosionOutwardsWaveConditionsOutputProperties)); PluginTestHelper.AssertPropertyInfoDefined( Index: Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/PropertyInfos/GrassCoverErosionOutwardsWaveConditionsOutputContextPropertyInfoTest.cs =================================================================== diff -u --- Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/PropertyInfos/GrassCoverErosionOutwardsWaveConditionsOutputContextPropertyInfoTest.cs (revision 0) +++ Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/PropertyInfos/GrassCoverErosionOutwardsWaveConditionsOutputContextPropertyInfoTest.cs (revision 5299261dce08137976c5f234f1261d4c0683e6e9) @@ -0,0 +1,76 @@ +// Copyright (C) Stichting Deltares 2019. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer 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.Linq; +using Core.Common.Gui.Plugin; +using Core.Common.Gui.PropertyBag; +using NUnit.Framework; +using Riskeer.GrassCoverErosionOutwards.Data; +using Riskeer.GrassCoverErosionOutwards.Data.TestUtil; +using Riskeer.GrassCoverErosionOutwards.Forms.PresentationObjects; +using Riskeer.GrassCoverErosionOutwards.Forms.PropertyClasses; + +namespace Riskeer.GrassCoverErosionOutwards.Plugin.Test.PropertyInfos +{ + [TestFixture] + public class GrassCoverErosionOutwardsWaveConditionsOutputContextPropertyInfoTest + { + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Setup + using (var plugin = new GrassCoverErosionOutwardsPlugin()) + { + // Call + PropertyInfo info = GetInfo(plugin); + + // Assert + Assert.AreEqual(typeof(GrassCoverErosionOutwardsWaveConditionsOutputContext), info.DataType); + Assert.AreEqual(typeof(GrassCoverErosionOutwardsWaveConditionsOutputProperties), info.PropertyObjectType); + } + } + + [Test] + public void CreateInstance_WithContext_SetsOutputAsData() + { + // Setup + GrassCoverErosionOutwardsWaveConditionsOutput output = GrassCoverErosionOutwardsWaveConditionsOutputTestFactory.Create(); + var context = new GrassCoverErosionOutwardsWaveConditionsOutputContext(output, new GrassCoverErosionOutwardsWaveConditionsInput()); + + using (var plugin = new GrassCoverErosionOutwardsPlugin()) + { + PropertyInfo info = GetInfo(plugin); + + // Call + IObjectProperties objectProperties = info.CreateInstance(context); + + // Assert + Assert.IsInstanceOf(objectProperties); + Assert.AreSame(output, objectProperties.Data); + } + } + + private static PropertyInfo GetInfo(GrassCoverErosionOutwardsPlugin plugin) + { + return plugin.GetPropertyInfos().First(pi => pi.DataType == typeof(GrassCoverErosionOutwardsWaveConditionsOutputContext)); + } + } +} \ No newline at end of file Index: Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/Riskeer.GrassCoverErosionOutwards.Plugin.Test.csproj =================================================================== diff -u -r9bba38e3ebe3fe261e7c97c338b016681e07c140 -r5299261dce08137976c5f234f1261d4c0683e6e9 --- Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/Riskeer.GrassCoverErosionOutwards.Plugin.Test.csproj (.../Riskeer.GrassCoverErosionOutwards.Plugin.Test.csproj) (revision 9bba38e3ebe3fe261e7c97c338b016681e07c140) +++ Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/Riskeer.GrassCoverErosionOutwards.Plugin.Test.csproj (.../Riskeer.GrassCoverErosionOutwards.Plugin.Test.csproj) (revision 5299261dce08137976c5f234f1261d4c0683e6e9) @@ -41,14 +41,15 @@ + - + Index: Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveConditionsCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -r877f0d6830122b89d78bc3e27aa3c61736617276 -r5299261dce08137976c5f234f1261d4c0683e6e9 --- Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveConditionsCalculationContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsWaveConditionsCalculationContextTreeNodeInfoTest.cs) (revision 877f0d6830122b89d78bc3e27aa3c61736617276) +++ Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveConditionsCalculationContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsWaveConditionsCalculationContextTreeNodeInfoTest.cs) (revision 5299261dce08137976c5f234f1261d4c0683e6e9) @@ -422,8 +422,9 @@ location }, inputContext.HydraulicBoundaryLocations); - var output = (GrassCoverErosionOutwardsWaveConditionsOutput) children[2]; - Assert.AreSame(calculation.Output, output); + var outputContext = (GrassCoverErosionOutwardsWaveConditionsOutputContext) children[2]; + Assert.AreSame(calculation.Output, outputContext.WrappedData); + Assert.AreSame(calculation.InputParameters, outputContext.Input); } [Test] Index: Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveConditionsOutputContextTreeNodeInfoTest.cs =================================================================== diff -u --- Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveConditionsOutputContextTreeNodeInfoTest.cs (revision 0) +++ Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveConditionsOutputContextTreeNodeInfoTest.cs (revision 5299261dce08137976c5f234f1261d4c0683e6e9) @@ -0,0 +1,142 @@ +// Copyright (C) Stichting Deltares 2019. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer 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 Riskeer.GrassCoverErosionOutwards.Data; +using Riskeer.GrassCoverErosionOutwards.Data.TestUtil; +using Riskeer.GrassCoverErosionOutwards.Forms.PresentationObjects; +using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; + +namespace Riskeer.GrassCoverErosionOutwards.Plugin.Test.TreeNodeInfos +{ + [TestFixture] + public class GrassCoverErosionOutwardsWaveConditionsOutputContextTreeNodeInfoTest + { + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Setup + using (var plugin = new GrassCoverErosionOutwardsPlugin()) + { + 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.CheckedState); + 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_ReturnName() + { + // Setup + using (var plugin = new GrassCoverErosionOutwardsPlugin()) + { + TreeNodeInfo info = GetInfo(plugin); + + // Call + string nodeText = info.Text(null); + + // Assert + Assert.AreEqual("Resultaat", nodeText); + } + } + + [Test] + public void Image_Always_ReturnOutputIcon() + { + // Setup + using (var plugin = new GrassCoverErosionOutwardsPlugin()) + { + TreeNodeInfo info = GetInfo(plugin); + + // Call + Image icon = info.Image(null); + + // Assert + TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.GeneralOutputIcon, icon); + } + } + + [Test] + public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods() + { + // Setup + var mocks = new MockRepository(); + using (var treeViewControl = new TreeViewControl()) + { + GrassCoverErosionOutwardsWaveConditionsOutput output = GrassCoverErosionOutwardsWaveConditionsOutputTestFactory.Create(); + var context = new GrassCoverErosionOutwardsWaveConditionsOutputContext(output, new GrassCoverErosionOutwardsWaveConditionsInput()); + + var menuBuilder = mocks.StrictMock(); + using (mocks.Ordered()) + { + menuBuilder.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.Build()).Return(null); + } + + var gui = mocks.Stub(); + gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(menuBuilder); + mocks.ReplayAll(); + + using (var plugin = new GrassCoverErosionOutwardsPlugin()) + { + TreeNodeInfo info = GetInfo(plugin); + plugin.Gui = gui; + + // Call + info.ContextMenuStrip(context, null, treeViewControl); + } + } + + // Assert + mocks.VerifyAll(); + } + + private TreeNodeInfo GetInfo(GrassCoverErosionOutwardsPlugin plugin) + { + return plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(GrassCoverErosionOutwardsWaveConditionsOutputContext)); + } + } +} \ No newline at end of file Fisheye: Tag 5299261dce08137976c5f234f1261d4c0683e6e9 refers to a dead (removed) revision in file `Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveConditionsOutputTreeNodeInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff?