Index: Core/Plugins/test/Core.Plugins.Map.Test/MapPluginTest.cs =================================================================== diff -u -r9675f3b443d0f1e5133c267494ea744f781b0c46 -rb2b948b3cfebe14dbd1f46ae3a690682f47721a9 --- Core/Plugins/test/Core.Plugins.Map.Test/MapPluginTest.cs (.../MapPluginTest.cs) (revision 9675f3b443d0f1e5133c267494ea744f781b0c46) +++ Core/Plugins/test/Core.Plugins.Map.Test/MapPluginTest.cs (.../MapPluginTest.cs) (revision b2b948b3cfebe14dbd1f46ae3a690682f47721a9) @@ -379,6 +379,54 @@ Dispatcher.CurrentDispatcher.InvokeShutdown(); } + [Test] + [Apartment(ApartmentState.STA)] + public void GivenConfiguredGui_WhenOtherMapViewRemoved_ThenComponentsNotUpdated() + { + // Given + var mocks = new MockRepository(); + var projectStore = mocks.Stub(); + var projectMigrator = mocks.Stub(); + var projectFactory = mocks.Stub(); + projectFactory.Stub(pf => pf.CreateNewProject()).Return(mocks.Stub()); + mocks.ReplayAll(); + + using (var gui = new GuiCore(new MainWindow(), projectStore, projectMigrator, projectFactory, new GuiCoreSettings())) + { + var plugin = new MapPlugin + { + Gui = gui + }; + + gui.Plugins.Add(plugin); + gui.Run(); + + var view1 = new TestMapView(); + var view2 = new TestMapView(); + IViewHost guiViewHost = gui.ViewHost; + MapLegendView mapLegendView = guiViewHost.ToolViews.OfType().First(); + var mapRibbon = (MapRibbon) plugin.RibbonCommandHandler; + + guiViewHost.AddDocumentView(view1); + guiViewHost.AddDocumentView(view2); + + // Precondition + Assert.AreSame(view2.Map, GetMapControl(mapLegendView)); + Assert.AreSame(view2.Map, GetMapControl(mapRibbon)); + + // When + guiViewHost.Remove(view1); + + // Then + Assert.AreSame(view2.Map, GetMapControl(mapLegendView)); + Assert.AreSame(view2.Map, GetMapControl(mapRibbon)); + + mocks.VerifyAll(); + } + + Dispatcher.CurrentDispatcher.InvokeShutdown(); + } + private static IMapControl GetMapControl(MapRibbon mapRibbon) { return TypeUtils.GetProperty(mapRibbon, "Map");