Index: Core/Gui/test/Core.Gui.Test/Forms/ViewHost/AvalonDockViewHostTest.cs =================================================================== diff -u -rfe1f6b0769b2da567cc99579eb93205ddd8d0571 -r9d314bdfad94ff3fa9695732f06e4b541facb2a7 --- Core/Gui/test/Core.Gui.Test/Forms/ViewHost/AvalonDockViewHostTest.cs (.../AvalonDockViewHostTest.cs) (revision fe1f6b0769b2da567cc99579eb93205ddd8d0571) +++ Core/Gui/test/Core.Gui.Test/Forms/ViewHost/AvalonDockViewHostTest.cs (.../AvalonDockViewHostTest.cs) (revision 9d314bdfad94ff3fa9695732f06e4b541facb2a7) @@ -31,6 +31,7 @@ using Core.Common.TestUtil; using Core.Common.Util.Reflection; using Core.Gui.Forms.ViewHost; +using Core.Gui.TestUtil; using NUnit.Framework; using Rhino.Mocks; using Xceed.Wpf.AvalonDock.Layout; @@ -184,7 +185,7 @@ avalonDockViewHost.AddDocumentView(testView, title); // Assert - Assert.IsTrue(IsTitleSet(avalonDockViewHost, testView, title)); + Assert.IsTrue(AvalonDockViewHostTestHelper.IsTitleSet(avalonDockViewHost, testView, title)); } } @@ -480,13 +481,13 @@ avalonDockViewHost.AddDocumentView(testView, string.Empty); // Precondition - Assert.IsFalse(IsTitleSet(avalonDockViewHost, testView, titleToSet)); + Assert.IsFalse(AvalonDockViewHostTestHelper.IsTitleSet(avalonDockViewHost, testView, titleToSet)); // Call avalonDockViewHost.SetTitle(testView, titleToSet); // Assert - Assert.IsTrue(IsTitleSet(avalonDockViewHost, testView, titleToSet)); + Assert.IsTrue(AvalonDockViewHostTestHelper.IsTitleSet(avalonDockViewHost, testView, titleToSet)); } } @@ -599,7 +600,7 @@ avalonDockViewHost.AddToolView(testView, ToolViewLocation.Left, title, string.Empty); // Assert - Assert.IsTrue(IsTitleSet(avalonDockViewHost, testView, title)); + Assert.IsTrue(AvalonDockViewHostTestHelper.IsTitleSet(avalonDockViewHost, testView, title)); } } @@ -858,13 +859,13 @@ avalonDockViewHost.AddToolView(testView, ToolViewLocation.Left, string.Empty, string.Empty); // Precondition - Assert.IsFalse(IsTitleSet(avalonDockViewHost, testView, titleToSet)); + Assert.IsFalse(AvalonDockViewHostTestHelper.IsTitleSet(avalonDockViewHost, testView, titleToSet)); // Call avalonDockViewHost.SetTitle(testView, titleToSet); // Assert - Assert.IsTrue(IsTitleSet(avalonDockViewHost, testView, titleToSet)); + Assert.IsTrue(AvalonDockViewHostTestHelper.IsTitleSet(avalonDockViewHost, testView, titleToSet)); } } @@ -953,15 +954,6 @@ .First(lc => ((WindowsFormsHost) lc.Content).Child == view).IconSource != null; } - private static bool IsTitleSet(AvalonDockViewHost avalonDockViewHost, IView view, string title) - { - return avalonDockViewHost.DockingManager - .Layout - .Descendents() - .OfType() - .First(lc => ((WindowsFormsHost) lc.Content).Child == view).Title == title; - } - private static void SetActiveView(AvalonDockViewHost avalonDockViewHost, IView view) { avalonDockViewHost.DockingManager.Layout.Descendents() Index: Core/Gui/test/Core.Gui.TestUtil/AvalonDockViewHostTestHelper.cs =================================================================== diff -u --- Core/Gui/test/Core.Gui.TestUtil/AvalonDockViewHostTestHelper.cs (revision 0) +++ Core/Gui/test/Core.Gui.TestUtil/AvalonDockViewHostTestHelper.cs (revision 9d314bdfad94ff3fa9695732f06e4b541facb2a7) @@ -0,0 +1,51 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.Linq; +using System.Windows.Forms.Integration; +using Core.Common.Controls.Views; +using Core.Gui.Forms.ViewHost; +using Xceed.Wpf.AvalonDock.Layout; + +namespace Core.Gui.TestUtil +{ + /// + /// Contains routines for testing classes which are related to . + /// + public static class AvalonDockViewHostTestHelper + { + /// + /// Returns whether is set for . + /// + /// The view host that owns the view. + /// The view to check the title for. + /// The title to check for. + /// Whether is set for . + public static bool IsTitleSet(AvalonDockViewHost avalonDockViewHost, IView view, string title) + { + return avalonDockViewHost.DockingManager + .Layout + .Descendents() + .OfType() + .First(lc => ((WindowsFormsHost) lc.Content).Child == view).Title == title; + } + } +} \ No newline at end of file Index: Core/Gui/test/Core.Gui.TestUtil/Core.Gui.TestUtil.csproj =================================================================== diff -u -r3cc7b5657809a8caee7ca5224d0657c7625dc7f3 -r9d314bdfad94ff3fa9695732f06e4b541facb2a7 --- Core/Gui/test/Core.Gui.TestUtil/Core.Gui.TestUtil.csproj (.../Core.Gui.TestUtil.csproj) (revision 3cc7b5657809a8caee7ca5224d0657c7625dc7f3) +++ Core/Gui/test/Core.Gui.TestUtil/Core.Gui.TestUtil.csproj (.../Core.Gui.TestUtil.csproj) (revision 9d314bdfad94ff3fa9695732f06e4b541facb2a7) @@ -4,6 +4,8 @@ + + @@ -19,6 +21,9 @@ + + 2.0.2000 + 3.8.1 Index: Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/RiskeerPluginTest.cs =================================================================== diff -u -r619c8da05c7b74130ee6a652dfec3918d91b44f9 -r9d314bdfad94ff3fa9695732f06e4b541facb2a7 --- Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/RiskeerPluginTest.cs (.../RiskeerPluginTest.cs) (revision 619c8da05c7b74130ee6a652dfec3918d91b44f9) +++ Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/RiskeerPluginTest.cs (.../RiskeerPluginTest.cs) (revision 9d314bdfad94ff3fa9695732f06e4b541facb2a7) @@ -28,9 +28,11 @@ using Core.Common.Base; using Core.Common.Base.Storage; using Core.Common.Controls.TreeView; +using Core.Common.Controls.Views; using Core.Common.TestUtil; using Core.Gui; using Core.Gui.Forms.Main; +using Core.Gui.Forms.ViewHost; using Core.Gui.Plugin; using Core.Gui.Settings; using Core.Gui.TestUtil; @@ -358,7 +360,7 @@ propertyInfos, typeof(AssemblyResultCategoriesContext), typeof(AssemblyResultCategoriesProperties)); - + PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, typeof(StructuresOutputContext), @@ -760,6 +762,112 @@ } } + [Test] + [Apartment(ApartmentState.STA)] + public void GivenPluginWithGuiSetAndOpenedDesignWaterLevelCalculationsView_WhenChangingCorrespondingUserSpecifiedTargetProbabilityAndObserversNotified_ThenViewTitleUpdated() + { + // Given + var mocks = new MockRepository(); + var projectStore = mocks.Stub(); + var projectMigrator = mocks.Stub(); + mocks.ReplayAll(); + + using (var gui = new GuiCore(new MainWindow(), projectStore, projectMigrator, new RiskeerProjectFactory(() => null), new GuiCoreSettings())) + { + SetPlugins(gui); + gui.Run(); + + var calculationsForTargetProbability = new HydraulicBoundaryLocationCalculationsForTargetProbability(); + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) + { + WaterLevelCalculationsForUserDefinedTargetProbabilities = + { + calculationsForTargetProbability + } + }; + + var project = new RiskeerProject + { + AssessmentSections = + { + assessmentSection + } + }; + + gui.SetProject(project, null); + + gui.DocumentViewController.CloseAllViews(); + gui.DocumentViewController.OpenViewForData(new WaterLevelCalculationsForUserDefinedTargetProbabilityContext( + calculationsForTargetProbability, assessmentSection)); + + IView view = gui.ViewHost.DocumentViews.First(); + + // Precondition + Assert.IsInstanceOf(view); + Assert.IsTrue(AvalonDockViewHostTestHelper.IsTitleSet((AvalonDockViewHost) gui.ViewHost, view, "Waterstanden bij doelkans - 1/10")); + + // When + calculationsForTargetProbability.TargetProbability = 0.01; + calculationsForTargetProbability.NotifyObservers(); + + // Then + Assert.IsTrue(AvalonDockViewHostTestHelper.IsTitleSet((AvalonDockViewHost) gui.ViewHost, view, "Waterstanden bij doelkans - 1/100")); + } + } + + [Test] + [Apartment(ApartmentState.STA)] + public void GivenPluginWithGuiSetAndOpenedWaveHeightCalculationsView_WhenChangingCorrespondingUserSpecifiedTargetProbabilityAndObserversNotified_ThenViewTitleUpdated() + { + // Given + var mocks = new MockRepository(); + var projectStore = mocks.Stub(); + var projectMigrator = mocks.Stub(); + mocks.ReplayAll(); + + using (var gui = new GuiCore(new MainWindow(), projectStore, projectMigrator, new RiskeerProjectFactory(() => null), new GuiCoreSettings())) + { + SetPlugins(gui); + gui.Run(); + + var calculationsForTargetProbability = new HydraulicBoundaryLocationCalculationsForTargetProbability(); + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) + { + WaveHeightCalculationsForUserDefinedTargetProbabilities = + { + calculationsForTargetProbability + } + }; + + var project = new RiskeerProject + { + AssessmentSections = + { + assessmentSection + } + }; + + gui.SetProject(project, null); + + gui.DocumentViewController.CloseAllViews(); + gui.DocumentViewController.OpenViewForData(new WaveHeightCalculationsForUserDefinedTargetProbabilityContext( + calculationsForTargetProbability, assessmentSection)); + + IView view = gui.ViewHost.DocumentViews.First(); + + // Precondition + Assert.IsInstanceOf(view); + Assert.IsTrue(AvalonDockViewHostTestHelper.IsTitleSet((AvalonDockViewHost) gui.ViewHost, view, "Golfhoogten bij doelkans - 1/10")); + + // When + calculationsForTargetProbability.TargetProbability = 0.01; + calculationsForTargetProbability.NotifyObservers(); + + // Then + Assert.IsTrue(AvalonDockViewHostTestHelper.IsTitleSet((AvalonDockViewHost) gui.ViewHost, view, "Golfhoogten bij doelkans - 1/100")); + } + } + private static void SetPlugins(IPluginsHost gui) { gui.Plugins.AddRange(new PluginBase[]