Index: Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/ImportInfos/ForeshoreProfilesContextImportInfoTest.cs =================================================================== diff -u -r79ff4139050f2d5eb2ce2bea4f998a0d4aaa2114 -r0eab9d948d5bd86b8e844769ed0861db9909958a --- Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/ImportInfos/ForeshoreProfilesContextImportInfoTest.cs (.../ForeshoreProfilesContextImportInfoTest.cs) (revision 79ff4139050f2d5eb2ce2bea4f998a0d4aaa2114) +++ Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/ImportInfos/ForeshoreProfilesContextImportInfoTest.cs (.../ForeshoreProfilesContextImportInfoTest.cs) (revision 0eab9d948d5bd86b8e844769ed0861db9909958a) @@ -39,6 +39,7 @@ using Riskeer.Common.Forms.PresentationObjects; using Riskeer.Common.IO.FileImporters; using Riskeer.Integration.Plugin.Properties; +using Riskeer.Integration.TestUtil; namespace Riskeer.Integration.Plugin.Test.ImportInfos { @@ -201,10 +202,8 @@ var assessmentSection = mocks.Stub(); var mainWindow = mocks.Stub(); - var gui = mocks.Stub(); + IGui gui = StubFactory.CreateGuiStub(mocks); gui.Stub(g => g.MainWindow).Return(mainWindow); - gui.Stub(g => g.ProjectOpened += null).IgnoreArguments(); - gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments(); var calculationWithoutOutput = mocks.Stub(); calculationWithoutOutput.Stub(calc => calc.HasOutput).Return(false); @@ -246,10 +245,8 @@ var assessmentSection = mocks.Stub(); var mainWindow = mocks.Stub(); - var gui = mocks.Stub(); + IGui gui = StubFactory.CreateGuiStub(mocks); gui.Stub(g => g.MainWindow).Return(mainWindow); - gui.Stub(g => g.ProjectOpened += null).IgnoreArguments(); - gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments(); var calculationWithoutOutput = mocks.Stub(); calculationWithoutOutput.Stub(calc => calc.HasOutput).Return(true); Index: Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/ImportInfos/HydraulicBoundaryDatabaseContextImportInfoTest.cs =================================================================== diff -u -r79ff4139050f2d5eb2ce2bea4f998a0d4aaa2114 -r0eab9d948d5bd86b8e844769ed0861db9909958a --- Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/ImportInfos/HydraulicBoundaryDatabaseContextImportInfoTest.cs (.../HydraulicBoundaryDatabaseContextImportInfoTest.cs) (revision 79ff4139050f2d5eb2ce2bea4f998a0d4aaa2114) +++ Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/ImportInfos/HydraulicBoundaryDatabaseContextImportInfoTest.cs (.../HydraulicBoundaryDatabaseContextImportInfoTest.cs) (revision 0eab9d948d5bd86b8e844769ed0861db9909958a) @@ -34,6 +34,7 @@ using Riskeer.Integration.Data; using Riskeer.Integration.Forms.PresentationObjects; using Riskeer.Integration.IO.Importers; +using Riskeer.Integration.TestUtil; using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; namespace Riskeer.Integration.Plugin.Test.ImportInfos @@ -49,10 +50,8 @@ public void SetUp() { mocks = new MockRepository(); - var gui = mocks.Stub(); + IGui gui = StubFactory.CreateGuiStub(mocks); gui.Stub(g => g.ViewCommands).Return(mocks.Stub()); - gui.Stub(g => g.ProjectOpened += null).IgnoreArguments(); - gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments(); mocks.ReplayAll(); plugin = new RiskeerPlugin Index: Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/ImportInfos/ReferenceLineContextImportInfoTest.cs =================================================================== diff -u -rb36b927ea533f0dc445e9f762b407702d499ea29 -r0eab9d948d5bd86b8e844769ed0861db9909958a --- Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/ImportInfos/ReferenceLineContextImportInfoTest.cs (.../ReferenceLineContextImportInfoTest.cs) (revision b36b927ea533f0dc445e9f762b407702d499ea29) +++ Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/ImportInfos/ReferenceLineContextImportInfoTest.cs (.../ReferenceLineContextImportInfoTest.cs) (revision 0eab9d948d5bd86b8e844769ed0861db9909958a) @@ -32,6 +32,7 @@ using Riskeer.Common.Data.AssessmentSection; using Riskeer.Common.Forms.PresentationObjects; using Riskeer.Common.IO.ReferenceLines; +using Riskeer.Integration.TestUtil; using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; namespace Riskeer.Integration.Plugin.Test.ImportInfos @@ -47,10 +48,8 @@ public void SetUp() { mocks = new MockRepository(); - var gui = mocks.Stub(); + IGui gui = StubFactory.CreateGuiStub(mocks); gui.Stub(g => g.ViewCommands).Return(mocks.Stub()); - gui.Stub(g => g.ProjectOpened += null).IgnoreArguments(); - gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments(); mocks.ReplayAll(); plugin = new RiskeerPlugin Index: Riskeer/Integration/test/Riskeer.Integration.TestUtil/Riskeer.Integration.TestUtil.csproj =================================================================== diff -u -r48244f68eee25ef1d91701d82e4c4867f0252ffc -r0eab9d948d5bd86b8e844769ed0861db9909958a --- Riskeer/Integration/test/Riskeer.Integration.TestUtil/Riskeer.Integration.TestUtil.csproj (.../Riskeer.Integration.TestUtil.csproj) (revision 48244f68eee25ef1d91701d82e4c4867f0252ffc) +++ Riskeer/Integration/test/Riskeer.Integration.TestUtil/Riskeer.Integration.TestUtil.csproj (.../Riskeer.Integration.TestUtil.csproj) (revision 0eab9d948d5bd86b8e844769ed0861db9909958a) @@ -25,37 +25,37 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: Riskeer/Integration/test/Riskeer.Integration.TestUtil/StubFactory.cs =================================================================== diff -u --- Riskeer/Integration/test/Riskeer.Integration.TestUtil/StubFactory.cs (revision 0) +++ Riskeer/Integration/test/Riskeer.Integration.TestUtil/StubFactory.cs (revision 0eab9d948d5bd86b8e844769ed0861db9909958a) @@ -0,0 +1,49 @@ +// 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 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 General Public License for more details. +// +// You should have received a copy of the GNU 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 Core.Gui; +using Core.Gui.Forms.ViewHost; +using Rhino.Mocks; + +namespace Riskeer.Integration.TestUtil +{ + /// + /// Factory for creating stubs. + /// + public static class StubFactory + { + /// + /// Creates a basic stub of . + /// + /// The repository to use for creating the stub. + /// The created stub. + public static IGui CreateGuiStub(MockRepository mockRepository) + { + var gui = mockRepository.Stub(); + + gui.Stub(g => g.ProjectOpened += null).IgnoreArguments(); + gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments(); + gui.Stub(g => g.ViewHost).Return(mockRepository.Stub()); + + return gui; + } + } +} \ No newline at end of file