Index: Core/Plugins/src/Core.Plugins.Map/Legend/MapLegendView.cs =================================================================== diff -u -rae5c573fb82f4b30350f63cb6f202ae99275f4ff -r6ab9f58d961acb9f1f80fab04e8759b9990262e0 --- Core/Plugins/src/Core.Plugins.Map/Legend/MapLegendView.cs (.../MapLegendView.cs) (revision ae5c573fb82f4b30350f63cb6f202ae99275f4ff) +++ Core/Plugins/src/Core.Plugins.Map/Legend/MapLegendView.cs (.../MapLegendView.cs) (revision 6ab9f58d961acb9f1f80fab04e8759b9990262e0) @@ -114,6 +114,9 @@ { Text = mapPointData => mapPointData.Name, Image = mapPointData => MapResources.PointsIcon, + ContextMenuStrip = (nodeData, parentData, treeView) => contextMenuBuilderProvider.Get(nodeData, treeView) + .AddPropertiesItem() + .Build(), CanDrag = (mapPointData, parentData) => true, CanCheck = mapPointData => true, IsChecked = mapPointData => mapPointData.IsVisible, @@ -124,6 +127,9 @@ { Text = mapLineData => mapLineData.Name, Image = mapLineData => MapResources.LineIcon, + ContextMenuStrip = (nodeData, parentData, treeView) => contextMenuBuilderProvider.Get(nodeData, treeView) + .AddPropertiesItem() + .Build(), CanDrag = (mapLineData, parentData) => true, CanCheck = mapLineData => true, IsChecked = mapLineData => mapLineData.IsVisible, @@ -134,6 +140,9 @@ { Text = mapPolygonData => mapPolygonData.Name, Image = mapPolygonData => MapResources.AreaIcon, + ContextMenuStrip = (nodeData, parentData, treeView) => contextMenuBuilderProvider.Get(nodeData, treeView) + .AddPropertiesItem() + .Build(), CanDrag = (mapPolygonData, parentData) => true, CanCheck = mapPolygonData => true, IsChecked = mapPolygonData => mapPolygonData.IsVisible, Index: Core/Plugins/test/Core.Plugins.Map.Test/Legend/MapLineDataTreeNodeInfoTest.cs =================================================================== diff -u -rae99d19be5c1bd59e6cc85669c96a3b9895e660d -r6ab9f58d961acb9f1f80fab04e8759b9990262e0 --- Core/Plugins/test/Core.Plugins.Map.Test/Legend/MapLineDataTreeNodeInfoTest.cs (.../MapLineDataTreeNodeInfoTest.cs) (revision ae99d19be5c1bd59e6cc85669c96a3b9895e660d) +++ Core/Plugins/test/Core.Plugins.Map.Test/Legend/MapLineDataTreeNodeInfoTest.cs (.../MapLineDataTreeNodeInfoTest.cs) (revision 6ab9f58d961acb9f1f80fab04e8759b9990262e0) @@ -38,15 +38,16 @@ [TestFixture] public class MapLineDataTreeNodeInfoTest { + private TreeNodeInfo info; private MockRepository mocks; private MapLegendView mapLegendView; - private TreeNodeInfo info; + private IContextMenuBuilderProvider contextMenuBuilderProvider; [SetUp] public void SetUp() { mocks = new MockRepository(); - var contextMenuBuilderProvider = mocks.StrictMock(); + contextMenuBuilderProvider = mocks.StrictMock(); var parentWindow = mocks.StrictMock(); mapLegendView = new MapLegendView(contextMenuBuilderProvider, parentWindow); @@ -74,7 +75,6 @@ // Assert Assert.AreEqual(typeof(MapLineData), info.TagType); Assert.IsNull(info.ForeColor); - Assert.IsNull(info.ContextMenuStrip); Assert.IsNull(info.EnsureVisibleOnCreate); Assert.IsNull(info.ChildNodeObjects); Assert.IsNull(info.CanRename); @@ -114,6 +114,25 @@ } [Test] + public void ContextMenuStrip_Always_CallsBuilder() + { + // Setup + var menuBuilderMock = mocks.StrictMock(); + menuBuilderMock.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.Build()).Return(null); + + contextMenuBuilderProvider.Expect(p => p.Get(null, null)).IgnoreArguments().Return(menuBuilderMock); + + mocks.ReplayAll(); + + // Call + info.ContextMenuStrip(null, null, null); + + // Assert + // Assert expectancies are called in TearDown() + } + + [Test] public void CanCheck_Always_ReturnsTrue() { // Setup Index: Core/Plugins/test/Core.Plugins.Map.Test/Legend/MapPointDataTreeNodeInfoTest.cs =================================================================== diff -u -r38ee40c1f98ff4b1921d4de64fd032c8fbcadf92 -r6ab9f58d961acb9f1f80fab04e8759b9990262e0 --- Core/Plugins/test/Core.Plugins.Map.Test/Legend/MapPointDataTreeNodeInfoTest.cs (.../MapPointDataTreeNodeInfoTest.cs) (revision 38ee40c1f98ff4b1921d4de64fd032c8fbcadf92) +++ Core/Plugins/test/Core.Plugins.Map.Test/Legend/MapPointDataTreeNodeInfoTest.cs (.../MapPointDataTreeNodeInfoTest.cs) (revision 6ab9f58d961acb9f1f80fab04e8759b9990262e0) @@ -38,15 +38,16 @@ [TestFixture] public class MapPointDataTreeNodeInfoTest { + private TreeNodeInfo info; private MockRepository mocks; private MapLegendView mapLegendView; - private TreeNodeInfo info; + private IContextMenuBuilderProvider contextMenuBuilderProvider; [SetUp] public void SetUp() { mocks = new MockRepository(); - var contextMenuBuilderProvider = mocks.StrictMock(); + contextMenuBuilderProvider = mocks.StrictMock(); var parentWindow = mocks.StrictMock(); mapLegendView = new MapLegendView(contextMenuBuilderProvider, parentWindow); @@ -74,7 +75,6 @@ // Assert Assert.AreEqual(typeof(MapPointData), info.TagType); Assert.IsNull(info.ForeColor); - Assert.IsNull(info.ContextMenuStrip); Assert.IsNull(info.EnsureVisibleOnCreate); Assert.IsNull(info.ChildNodeObjects); Assert.IsNull(info.CanRename); @@ -114,6 +114,25 @@ } [Test] + public void ContextMenuStrip_Always_CallsBuilder() + { + // Setup + var menuBuilderMock = mocks.StrictMock(); + menuBuilderMock.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.Build()).Return(null); + + contextMenuBuilderProvider.Expect(p => p.Get(null, null)).IgnoreArguments().Return(menuBuilderMock); + + mocks.ReplayAll(); + + // Call + info.ContextMenuStrip(null, null, null); + + // Assert + // Assert expectancies are called in TearDown() + } + + [Test] public void CanCheck_Always_ReturnsTrue() { // Setup Index: Core/Plugins/test/Core.Plugins.Map.Test/Legend/MapPolygonDataTreeNodeInfoTest.cs =================================================================== diff -u -r38ee40c1f98ff4b1921d4de64fd032c8fbcadf92 -r6ab9f58d961acb9f1f80fab04e8759b9990262e0 --- Core/Plugins/test/Core.Plugins.Map.Test/Legend/MapPolygonDataTreeNodeInfoTest.cs (.../MapPolygonDataTreeNodeInfoTest.cs) (revision 38ee40c1f98ff4b1921d4de64fd032c8fbcadf92) +++ Core/Plugins/test/Core.Plugins.Map.Test/Legend/MapPolygonDataTreeNodeInfoTest.cs (.../MapPolygonDataTreeNodeInfoTest.cs) (revision 6ab9f58d961acb9f1f80fab04e8759b9990262e0) @@ -38,25 +38,24 @@ [TestFixture] public class MapPolygonDataTreeNodeInfoTest { + private TreeNodeInfo info; private MockRepository mocks; private MapLegendView mapLegendView; - private TreeNodeInfo info; + private IContextMenuBuilderProvider contextMenuBuilderProvider; [SetUp] public void SetUp() { - var mockRepository = new MockRepository(); - var contextMenuBuilderProvider = mockRepository.StrictMock(); - var parentWindow = mockRepository.StrictMock(); + mocks = new MockRepository(); + contextMenuBuilderProvider = mocks.StrictMock(); + var parentWindow = mocks.StrictMock(); mapLegendView = new MapLegendView(contextMenuBuilderProvider, parentWindow); TreeViewControl treeViewControl = TypeUtils.GetField(mapLegendView, "treeViewControl"); Dictionary treeNodeInfoLookup = TypeUtils.GetField>(treeViewControl, "tagTypeTreeNodeInfoLookup"); info = treeNodeInfoLookup[typeof(MapPolygonData)]; - - mocks = mockRepository; } [TearDown] @@ -76,7 +75,6 @@ // Assert Assert.AreEqual(typeof(MapPolygonData), info.TagType); Assert.IsNull(info.ForeColor); - Assert.IsNull(info.ContextMenuStrip); Assert.IsNull(info.EnsureVisibleOnCreate); Assert.IsNull(info.ChildNodeObjects); Assert.IsNull(info.CanRename); @@ -116,6 +114,25 @@ } [Test] + public void ContextMenuStrip_Always_CallsBuilder() + { + // Setup + var menuBuilderMock = mocks.StrictMock(); + menuBuilderMock.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.Build()).Return(null); + + contextMenuBuilderProvider.Expect(p => p.Get(null, null)).IgnoreArguments().Return(menuBuilderMock); + + mocks.ReplayAll(); + + // Call + info.ContextMenuStrip(null, null, null); + + // Assert + // Assert expectancies are called in TearDown() + } + + [Test] public void CanCheck_Always_ReturnsTrue() { // Setup