Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/AssemblyResultPerSectionContextTreeNodeInfoTest.cs =================================================================== diff -u -r9dbf7bccb39f8f0516c34a816cdec5ad669d440f -rbb353158cc56b9555c8441b7fe62009b88cde790 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/AssemblyResultPerSectionContextTreeNodeInfoTest.cs (.../AssemblyResultPerSectionContextTreeNodeInfoTest.cs) (revision 9dbf7bccb39f8f0516c34a816cdec5ad669d440f) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/AssemblyResultPerSectionContextTreeNodeInfoTest.cs (.../AssemblyResultPerSectionContextTreeNodeInfoTest.cs) (revision bb353158cc56b9555c8441b7fe62009b88cde790) @@ -19,11 +19,17 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; 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.Integration.Data; using Ringtoets.Integration.Forms.PresentationObjects; using Ringtoets.Integration.Plugin.Properties; @@ -44,7 +50,7 @@ Assert.IsNotNull(info.Text); Assert.IsNull(info.ForeColor); Assert.IsNotNull(info.Image); - Assert.IsNull(info.ContextMenuStrip); + Assert.IsNotNull(info.ContextMenuStrip); Assert.IsNull(info.EnsureVisibleOnCreate); Assert.IsNull(info.ExpandOnCreate); Assert.IsNull(info.ChildNodeObjects); @@ -94,6 +100,46 @@ } } + [Test] + public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods() + { + // Setup + var random = new Random(21); + var assessmentSection = new AssessmentSection(random.NextEnumValue()); + var context = new AssemblyResultPerSectionContext(assessmentSection); + + var mocks = new MockRepository(); + var menuBuilder = mocks.StrictMock(); + + using (mocks.Ordered()) + { + 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.ProjectOpened += null).IgnoreArguments(); + gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments(); + gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(menuBuilder); + mocks.ReplayAll(); + + using (var plugin = new RingtoetsPlugin()) + { + TreeNodeInfo info = GetInfo(plugin); + + plugin.Gui = gui; + + // Call + info.ContextMenuStrip(context, null, treeViewControl); + } + } + + // Assert + mocks.VerifyAll(); + } + private static TreeNodeInfo GetInfo(RingtoetsPlugin plugin) { return plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(AssemblyResultPerSectionContext));