Index: Core/Common/test/Core.Common.Integration.Test/Riskeer/Application.Riskeer/GuiCoreIntegrationTest.cs
===================================================================
diff -u
--- Core/Common/test/Core.Common.Integration.Test/Riskeer/Application.Riskeer/GuiCoreIntegrationTest.cs (revision 0)
+++ Core/Common/test/Core.Common.Integration.Test/Riskeer/Application.Riskeer/GuiCoreIntegrationTest.cs (revision 7c4b4bf21c06e22e8909c5664c3962bba60a4ef5)
@@ -0,0 +1,126 @@
+// Copyright (C) Stichting Deltares 2018. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets 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.Threading;
+using System.Windows.Controls;
+using System.Windows.Threading;
+using Core.Common.Base.Data;
+using Core.Common.Base.Storage;
+using Core.Common.Gui;
+using Core.Common.Gui.Forms.MainWindow;
+using Core.Common.Gui.Settings;
+using Core.Common.TestUtil;
+using Core.Plugins.ProjectExplorer;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Riskeer.Integration.Plugin;
+
+namespace Core.Common.Integration.Test.Ringtoets.Application.Ringtoets
+{
+ [TestFixture]
+ public class GuiCoreIntegrationTest
+ {
+ [SetUp]
+ public void SetUp()
+ {
+ LogHelper.ResetLogging();
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ Dispatcher.CurrentDispatcher.InvokeShutdown();
+ }
+
+ [Test]
+ [Apartment(ApartmentState.STA)]
+ public void Run_GuiWithRingtoetsPlugin_DoesNotCrash()
+ {
+ 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()))
+ {
+ gui.Plugins.Add(new RingtoetsPlugin());
+ gui.Run();
+ }
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ [Apartment(ApartmentState.STA)]
+ public void Run_StartWithCommonPlugins_RunsFasterThanThreshold()
+ {
+ TestHelper.AssertIsFasterThan(7500, StartWithCommonPlugins);
+ }
+
+ [Test]
+ [Apartment(ApartmentState.STA)]
+ public void FormActionIsRunForMainWindow()
+ {
+ //testing testhelper + visible changed event of mainwindow.
+ //could be tested separately but the combination is vital to many tests. That's why this test is here.
+ 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()))
+ {
+ gui.Run();
+ var callCount = 0;
+ WpfTestHelper.ShowModal((Control) gui.MainWindow, () => callCount++);
+ Assert.AreEqual(1, callCount);
+ }
+
+ mocks.VerifyAll();
+ }
+
+ private static void StartWithCommonPlugins()
+ {
+ 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()))
+ {
+ gui.Plugins.Add(new RingtoetsPlugin());
+ gui.Plugins.Add(new ProjectExplorerPlugin());
+
+ gui.Run();
+
+ WpfTestHelper.ShowModal((Control) gui.MainWindow);
+ }
+
+ mocks.VerifyAll();
+ }
+ }
+}
\ No newline at end of file