Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs =================================================================== diff -u -r53bfde12ab449eba06567e6ff64627faec1d8026 -rfb3cd6ea3148ac270b92a764bf7a0965785ddb1c --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 53bfde12ab449eba06567e6ff64627faec1d8026) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision fb3cd6ea3148ac270b92a764bf7a0965785ddb1c) @@ -712,7 +712,8 @@ yield return new TreeNodeInfo { Text = context => RingtoetsFormsResources.DesignWaterLevelLocationsContext_DisplayName, - Image = context => RingtoetsCommonFormsResources.GeneralFolderIcon + Image = context => RingtoetsCommonFormsResources.GeneralFolderIcon, + ChildNodeObjects = DesignWaterLevelLocationsGroupContextChildNodeObjects }; yield return new TreeNodeInfo @@ -725,7 +726,8 @@ yield return new TreeNodeInfo { Text = context => RingtoetsFormsResources.WaveHeightLocationsContext_DisplayName, - Image = context => RingtoetsCommonFormsResources.GeneralFolderIcon + Image = context => RingtoetsCommonFormsResources.GeneralFolderIcon, + ChildNodeObjects = WaveHeightLocationsGroupContextChildNodeObjects }; yield return new TreeNodeInfo @@ -1866,6 +1868,28 @@ log.Info(RingtoetsFormsResources.Calculations_Cleared); } + private static object[] DesignWaterLevelLocationsGroupContextChildNodeObjects(DesignWaterLevelLocationsGroupContext context) + { + return new object[] + { + new DesignWaterLevelLocationsContext(context.WrappedData, context.AssessmentSection, hbl => hbl.DesignWaterLevelCalculation1), + new DesignWaterLevelLocationsContext(context.WrappedData, context.AssessmentSection, hbl => hbl.DesignWaterLevelCalculation2), + new DesignWaterLevelLocationsContext(context.WrappedData, context.AssessmentSection, hbl => hbl.DesignWaterLevelCalculation3), + new DesignWaterLevelLocationsContext(context.WrappedData, context.AssessmentSection, hbl => hbl.DesignWaterLevelCalculation4) + }; + } + + private static object[] WaveHeightLocationsGroupContextChildNodeObjects(WaveHeightLocationsGroupContext context) + { + return new object[] + { + new WaveHeightLocationsContext(context.WrappedData, context.AssessmentSection, hbl => hbl.WaveHeightCalculation1), + new WaveHeightLocationsContext(context.WrappedData, context.AssessmentSection, hbl => hbl.WaveHeightCalculation2), + new WaveHeightLocationsContext(context.WrappedData, context.AssessmentSection, hbl => hbl.WaveHeightCalculation3), + new WaveHeightLocationsContext(context.WrappedData, context.AssessmentSection, hbl => hbl.WaveHeightCalculation4) + }; + } + #endregion #endregion Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/DesignWaterLevelLocationsGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -r53bfde12ab449eba06567e6ff64627faec1d8026 -rfb3cd6ea3148ac270b92a764bf7a0965785ddb1c --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/DesignWaterLevelLocationsGroupContextTreeNodeInfoTest.cs (.../DesignWaterLevelLocationsGroupContextTreeNodeInfoTest.cs) (revision 53bfde12ab449eba06567e6ff64627faec1d8026) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/DesignWaterLevelLocationsGroupContextTreeNodeInfoTest.cs (.../DesignWaterLevelLocationsGroupContextTreeNodeInfoTest.cs) (revision fb3cd6ea3148ac270b92a764bf7a0965785ddb1c) @@ -21,10 +21,15 @@ using System.Drawing; using System.Linq; +using Core.Common.Base; using Core.Common.Controls.TreeView; using Core.Common.TestUtil; using NUnit.Extensions.Forms; using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Hydraulics; +using Ringtoets.Common.Data.TestUtil; using Ringtoets.Integration.Forms.PresentationObjects; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; @@ -48,7 +53,7 @@ Assert.IsNull(info.ContextMenuStrip); Assert.IsNull(info.EnsureVisibleOnCreate); Assert.IsNull(info.ExpandOnCreate); - Assert.IsNull(info.ChildNodeObjects); + Assert.IsNotNull(info.ChildNodeObjects); Assert.IsNull(info.CanRename); Assert.IsNull(info.OnNodeRenamed); Assert.IsNull(info.CanRemove); @@ -95,6 +100,43 @@ } } + [Test] + public void ChildNodeObjects_Always_ReturnsChildrenOfData() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.StrictMock(); + mocks.ReplayAll(); + + var locations = new ObservableList(); + var locationsGroupContext = new DesignWaterLevelLocationsGroupContext(locations, assessmentSection); + + using (var plugin = new RingtoetsPlugin()) + { + TreeNodeInfo info = GetInfo(plugin); + + // Call + object[] childNodeObjects = info.ChildNodeObjects(locationsGroupContext); + + // Assert + Assert.AreEqual(4, childNodeObjects.Length); + + DesignWaterLevelLocationsContext[] locationsContexts = childNodeObjects.OfType().ToArray(); + Assert.AreEqual(4, locationsContexts.Length); + + Assert.IsTrue(locationsContexts.All(c => ReferenceEquals(locations, c.WrappedData))); + Assert.IsTrue(locationsContexts.All(c => ReferenceEquals(assessmentSection, c.AssessmentSection))); + + var testLocation = new TestHydraulicBoundaryLocation(); + Assert.AreSame(testLocation.DesignWaterLevelCalculation1, locationsContexts[0].GetCalculationFunc(testLocation)); + Assert.AreSame(testLocation.DesignWaterLevelCalculation2, locationsContexts[1].GetCalculationFunc(testLocation)); + Assert.AreSame(testLocation.DesignWaterLevelCalculation3, locationsContexts[2].GetCalculationFunc(testLocation)); + Assert.AreSame(testLocation.DesignWaterLevelCalculation4, locationsContexts[3].GetCalculationFunc(testLocation)); + } + + mocks.VerifyAll(); + } + private static TreeNodeInfo GetInfo(RingtoetsPlugin plugin) { return plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(DesignWaterLevelLocationsGroupContext)); Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/WaveHeightLocationsGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -r44d4c114a254db9859fbf71812e599c468dcbe77 -rfb3cd6ea3148ac270b92a764bf7a0965785ddb1c --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/WaveHeightLocationsGroupContextTreeNodeInfoTest.cs (.../WaveHeightLocationsGroupContextTreeNodeInfoTest.cs) (revision 44d4c114a254db9859fbf71812e599c468dcbe77) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/WaveHeightLocationsGroupContextTreeNodeInfoTest.cs (.../WaveHeightLocationsGroupContextTreeNodeInfoTest.cs) (revision fb3cd6ea3148ac270b92a764bf7a0965785ddb1c) @@ -21,10 +21,15 @@ using System.Drawing; using System.Linq; +using Core.Common.Base; using Core.Common.Controls.TreeView; using Core.Common.TestUtil; using NUnit.Extensions.Forms; using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Hydraulics; +using Ringtoets.Common.Data.TestUtil; using Ringtoets.Integration.Forms.PresentationObjects; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; @@ -48,7 +53,7 @@ Assert.IsNull(info.ContextMenuStrip); Assert.IsNull(info.EnsureVisibleOnCreate); Assert.IsNull(info.ExpandOnCreate); - Assert.IsNull(info.ChildNodeObjects); + Assert.IsNotNull(info.ChildNodeObjects); Assert.IsNull(info.CanRename); Assert.IsNull(info.OnNodeRenamed); Assert.IsNull(info.CanRemove); @@ -96,6 +101,43 @@ } } + [Test] + public void ChildNodeObjects_Always_ReturnsChildrenOfData() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.StrictMock(); + mocks.ReplayAll(); + + var locations = new ObservableList(); + var locationsGroupContext = new WaveHeightLocationsGroupContext(locations, assessmentSection); + + using (var plugin = new RingtoetsPlugin()) + { + TreeNodeInfo info = GetInfo(plugin); + + // Call + object[] childNodeObjects = info.ChildNodeObjects(locationsGroupContext); + + // Assert + Assert.AreEqual(4, childNodeObjects.Length); + + WaveHeightLocationsContext[] locationsContexts = childNodeObjects.OfType().ToArray(); + Assert.AreEqual(4, locationsContexts.Length); + + Assert.IsTrue(locationsContexts.All(c => ReferenceEquals(locations, c.WrappedData))); + Assert.IsTrue(locationsContexts.All(c => ReferenceEquals(assessmentSection, c.AssessmentSection))); + + var testLocation = new TestHydraulicBoundaryLocation(); + Assert.AreSame(testLocation.WaveHeightCalculation1, locationsContexts[0].GetCalculationFunc(testLocation)); + Assert.AreSame(testLocation.WaveHeightCalculation2, locationsContexts[1].GetCalculationFunc(testLocation)); + Assert.AreSame(testLocation.WaveHeightCalculation3, locationsContexts[2].GetCalculationFunc(testLocation)); + Assert.AreSame(testLocation.WaveHeightCalculation4, locationsContexts[3].GetCalculationFunc(testLocation)); + } + + mocks.VerifyAll(); + } + private static TreeNodeInfo GetInfo(RingtoetsPlugin plugin) { return plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(WaveHeightLocationsGroupContext));