Index: Core/Plugins/src/Core.Plugins.Map/Legend/MapLegendView.cs =================================================================== diff -u -r713bf4768e34bcd1ef9281cc5ec0d9b19321fff8 -r9d437f957dbdd5360f2f5e6ab4c80993a10b85c7 --- Core/Plugins/src/Core.Plugins.Map/Legend/MapLegendView.cs (.../MapLegendView.cs) (revision 713bf4768e34bcd1ef9281cc5ec0d9b19321fff8) +++ Core/Plugins/src/Core.Plugins.Map/Legend/MapLegendView.cs (.../MapLegendView.cs) (revision 9d437f957dbdd5360f2f5e6ab4c80993a10b85c7) @@ -104,11 +104,13 @@ { get { - return (MapData) treeViewControl.Data; + return (MapDataCollectionContext) treeViewControl.Data; } set { - treeViewControl.Data = (MapData) value; + treeViewControl.Data = value != null + ? new MapDataCollectionContext((MapDataCollection) value, null) + : null; } } @@ -245,7 +247,7 @@ { return MapResources.PointsIcon; } - + if (context.WrappedData is MapLineData) { return MapResources.LineIcon; @@ -341,7 +343,7 @@ private static bool MapDataCollectionCanDropAndInsert(object draggedData, object targetData) { - var draggedDataContext = (MapDataCollectionContext) draggedData; + var draggedDataContext = (MapDataContext) draggedData; var targetDataContext = targetData as MapDataContext; object targetDataObject = targetDataContext != null ? targetDataContext.ParentMapData : targetData; Index: Core/Plugins/test/Core.Plugins.Map.Test/Legend/MapLegendViewTest.cs =================================================================== diff -u -rd02ab460ba97ccc3213c3b365158bf9ce2bb1d57 -r9d437f957dbdd5360f2f5e6ab4c80993a10b85c7 --- Core/Plugins/test/Core.Plugins.Map.Test/Legend/MapLegendViewTest.cs (.../MapLegendViewTest.cs) (revision d02ab460ba97ccc3213c3b365158bf9ce2bb1d57) +++ Core/Plugins/test/Core.Plugins.Map.Test/Legend/MapLegendViewTest.cs (.../MapLegendViewTest.cs) (revision 9d437f957dbdd5360f2f5e6ab4c80993a10b85c7) @@ -29,6 +29,7 @@ using Core.Common.Util.Reflection; using Core.Components.Gis.Data; using Core.Components.Gis.Forms; +using Core.Components.Gis.TestUtil; using Core.Plugins.Map.Legend; using Core.Plugins.Map.PresentationObjects; using Core.Plugins.Map.Properties; @@ -99,8 +100,10 @@ view.Data = mapData; // Assert - Assert.AreSame(mapData, view.Data); - Assert.IsInstanceOf(view.Data); + Assert.IsInstanceOf(view.Data); + var viewData = (MapDataCollectionContext) view.Data; + Assert.AreSame(mapData, viewData.WrappedData); + Assert.IsNull(viewData.ParentMapData); } } @@ -134,7 +137,7 @@ [Test] [Apartment(ApartmentState.STA)] - public void MapControl_MapControlHasMapWithData_DataReturnsMapDataOfMap() + public void MapControl_MapControlHasMapWithData_DataReturnsWrappedMapDataOfMap() { // Setup var mapData = new MapDataCollection("A"); @@ -153,7 +156,7 @@ view.MapControl = mapControl; // Assert - Assert.AreSame(mapData, view.Data); + Assert.AreSame(mapData, ((MapDataCollectionContext) view.Data).WrappedData); } mockRepository.VerifyAll(); @@ -178,42 +181,12 @@ [Test] [Apartment(ApartmentState.STA)] - public void Selection_NestedNodeData_ReturnsWrappedObjectData() + public void Selection_Always_ReturnsWrappedObjectData() { // Setup var mapData = new MapLineData("line data"); var mapDataCollection = new MapDataCollection("collection"); - mapDataCollection.Add(mapData); - using (var view = new MapLegendView(contextMenuBuilderProvider) - { - Data = mapDataCollection - }) - { - var context = new TestMapDataContext(mapData); - - var treeViewControl = TypeUtils.GetField(view, "treeViewControl"); - WindowsFormsTestHelper.Show(treeViewControl); - treeViewControl.TrySelectNodeForData(context); - - // Call - object selection = view.Selection; - - // Assert - Assert.AreSame(mapData, selection); - } - - WindowsFormsTestHelper.CloseAll(); - } - - [Test] - [Apartment(ApartmentState.STA)] - public void Selection_RootNodeData_ReturnsObjectData() - { - // Setup - var mapData = new MapLineData("line data"); - var mapDataCollection = new MapDataCollection("collection"); - mapDataCollection.Add(mapData); using (var view = new MapLegendView(contextMenuBuilderProvider) @@ -223,7 +196,7 @@ { var treeViewControl = TypeUtils.GetField(view, "treeViewControl"); WindowsFormsTestHelper.Show(treeViewControl); - treeViewControl.TrySelectNodeForData(mapDataCollection); + treeViewControl.TrySelectNodeForData(view.Data); // Call object selection = view.Selection; @@ -240,7 +213,7 @@ public void GivenMapLegendView_WhenSelectedNodeChanged_SelectionChangedFired() { // Given - var mapData = new MapLineData("line data"); + var mapData = new TestFeatureBasedMapData(); var mapDataCollection = new MapDataCollection("collection"); mapDataCollection.Add(mapData); @@ -256,7 +229,7 @@ view.SelectionChanged += (sender, args) => selectionChangedCount++; // When - var context = new TestMapDataContext(mapData); + var context = new FeatureBasedMapDataContext(mapData, mapDataCollection); treeViewControl.TrySelectNodeForData(context); // Then @@ -288,13 +261,5 @@ WindowsFormsTestHelper.CloseAll(); } - - private class TestMapDataContext : MapDataContext - { - public TestMapDataContext(MapData wrappedData) - : base(wrappedData) {} - - public override MapDataCollection ParentMapData { get; } - } } } \ No newline at end of file