Index: Application/Ringtoets/src/Application.Ringtoets/App.xaml.cs
===================================================================
diff -u -r8b9903ce9a5e5b860ee8ba6719737783be7a8cab -rce792554075b8bfb2723bbdab4b3bdcb6cc58d6f
--- Application/Ringtoets/src/Application.Ringtoets/App.xaml.cs (.../App.xaml.cs) (revision 8b9903ce9a5e5b860ee8ba6719737783be7a8cab)
+++ Application/Ringtoets/src/Application.Ringtoets/App.xaml.cs (.../App.xaml.cs) (revision ce792554075b8bfb2723bbdab4b3bdcb6cc58d6f)
@@ -33,7 +33,6 @@
using System.Windows.Controls.Primitives;
using System.Windows.Forms;
using Application.Ringtoets.Storage;
-using Core.Common.Base.Plugin;
using Core.Common.Controls.Dialogs;
using Core.Common.Gui;
using Core.Common.Gui.Appenders;
@@ -50,7 +49,6 @@
using Ringtoets.Integration.Plugin;
using Ringtoets.Piping.Plugin;
using MessageBox = System.Windows.MessageBox;
-
#if INCLUDE_DEMOPROJECT
using Demo.Ringtoets.GUIs;
@@ -138,12 +136,6 @@
Resources.Add(SystemParameters.MenuPopupAnimationKey, PopupAnimation.None);
- var applicationCore = new ApplicationCore();
-
- applicationCore.AddPlugin(new RingtoetsApplicationPlugin());
- applicationCore.AddPlugin(new PipingApplicationPlugin());
- applicationCore.AddPlugin(new GrassCoverErosionInwardsApplicationPlugin());
-
var settings = new GuiCoreSettings
{
StartPageUrl = "http://www.helpdeskwater.nl",
@@ -156,7 +148,7 @@
ManualFilePath = "Ringtoets_Manual.pdf"
};
var mainWindow = new MainWindow();
- gui = new GuiCore(mainWindow, new StorageSqLite(), applicationCore, settings)
+ gui = new GuiCore(mainWindow, new StorageSqLite(), settings)
{
Plugins =
{
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/StorageSqLiteIntegrationTest.cs
===================================================================
diff -u -r223b2a4edc4ac816051c7eeecb735c34a6246574 -rce792554075b8bfb2723bbdab4b3bdcb6cc58d6f
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/StorageSqLiteIntegrationTest.cs (.../StorageSqLiteIntegrationTest.cs) (revision 223b2a4edc4ac816051c7eeecb735c34a6246574)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/StorageSqLiteIntegrationTest.cs (.../StorageSqLiteIntegrationTest.cs) (revision ce792554075b8bfb2723bbdab4b3bdcb6cc58d6f)
@@ -28,7 +28,6 @@
using Core.Common.Base;
using Core.Common.Base.Data;
using Core.Common.Base.Geometry;
-using Core.Common.Base.Plugin;
using Core.Common.Gui;
using Core.Common.Gui.Forms.MainWindow;
using Core.Common.Gui.Settings;
@@ -145,7 +144,7 @@
// Precondition
SqLiteDatabaseHelper.CreateValidRingtoetsDatabase(tempRingtoetsFile, fullProject);
- using (var gui = new GuiCore(new MainWindow(), projectStore, new ApplicationCore(), new GuiCoreSettings()))
+ using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings()))
{
// Call
Action action = () => gui.Run(tempRingtoetsFile);
@@ -174,7 +173,7 @@
var testFile = "SomeFile";
var projectStore = new StorageSqLite();
- using (var gui = new GuiCore(new MainWindow(), projectStore, new ApplicationCore(), new GuiCoreSettings()))
+ using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings()))
{
// Call
Action action = () => gui.Run(testFile);
@@ -206,7 +205,7 @@
// Setup
var projectStore = new StorageSqLite();
- using (var gui = new GuiCore(new MainWindow(), projectStore, new ApplicationCore(), new GuiCoreSettings()))
+ using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings()))
{
// Call
Action action = () => gui.Run(testFile);
Index: Core/Common/src/Core.Common.Gui/GuiCore.cs
===================================================================
diff -u -r223b2a4edc4ac816051c7eeecb735c34a6246574 -rce792554075b8bfb2723bbdab4b3bdcb6cc58d6f
--- Core/Common/src/Core.Common.Gui/GuiCore.cs (.../GuiCore.cs) (revision 223b2a4edc4ac816051c7eeecb735c34a6246574)
+++ Core/Common/src/Core.Common.Gui/GuiCore.cs (.../GuiCore.cs) (revision ce792554075b8bfb2723bbdab4b3bdcb6cc58d6f)
@@ -30,7 +30,6 @@
using System.Reflection;
using System.Windows;
using Core.Common.Base.Data;
-using Core.Common.Base.Plugin;
using Core.Common.Base.Storage;
using Core.Common.Controls.TreeView;
using Core.Common.Gui.Commands;
@@ -74,12 +73,11 @@
///
/// The main window.
/// The project store.
- /// The application core.
/// The fixed settings.
/// When another
/// instance is running.
/// When any parameter is null.
- public GuiCore(IMainWindow mainWindow, IStoreProject projectStore, ApplicationCore applicationCore, GuiCoreSettings fixedSettings)
+ public GuiCore(IMainWindow mainWindow, IStoreProject projectStore, GuiCoreSettings fixedSettings)
{
// error detection code, make sure we use only a single instance of GuiCore at a time
if (isAlreadyRunningInstanceOfIGui)
@@ -96,17 +94,12 @@
{
throw new ArgumentNullException("projectStore");
}
- if (applicationCore == null)
- {
- throw new ArgumentNullException("applicationCore");
- }
if (fixedSettings == null)
{
throw new ArgumentNullException("fixedSettings");
}
MainWindow = mainWindow;
Storage = projectStore;
- ApplicationCore = applicationCore;
FixedSettings = fixedSettings;
isAlreadyRunningInstanceOfIGui = true;
@@ -129,8 +122,6 @@
ProjectOpened += ApplicationProjectOpened;
}
- public ApplicationCore ApplicationCore { get; private set; }
-
public IPropertyResolver PropertyResolver { get; private set; }
public IStoreProject Storage { get; private set; }
@@ -261,11 +252,6 @@
MessageWindowLogAppender.Instance.MessageWindow = null;
- if (ApplicationCore != null)
- {
- ApplicationCore.Dispose();
- }
-
RemoveLogging();
Plugins = null;
}
@@ -420,7 +406,7 @@
{
InitializeWindows();
- InitializeGuiPlugins();
+ InitializePlugins();
CopyDefaultViewsFromUserSettings();
@@ -535,7 +521,7 @@
mainWindow.ValidateItems();
}
- private void InitializeGuiPlugins()
+ private void InitializePlugins()
{
Plugins.ForEachElementDo(p => p.Gui = this);
Index: Core/Common/src/Core.Common.Gui/IGui.cs
===================================================================
diff -u -r223b2a4edc4ac816051c7eeecb735c34a6246574 -rce792554075b8bfb2723bbdab4b3bdcb6cc58d6f
--- Core/Common/src/Core.Common.Gui/IGui.cs (.../IGui.cs) (revision 223b2a4edc4ac816051c7eeecb735c34a6246574)
+++ Core/Common/src/Core.Common.Gui/IGui.cs (.../IGui.cs) (revision ce792554075b8bfb2723bbdab4b3bdcb6cc58d6f)
@@ -20,7 +20,6 @@
// All rights reserved.
using System;
-using Core.Common.Base.Plugin;
using Core.Common.Base.Storage;
using Core.Common.Gui.Commands;
using Core.Common.Gui.ContextMenu;
@@ -45,11 +44,6 @@
IPropertyResolver PropertyResolver { get; }
///
- /// Gets the of the .
- ///
- ApplicationCore ApplicationCore { get; }
-
- ///
/// Gets the current project storage.
///
IStoreProject Storage { get; }
Index: Core/Common/test/Core.Common.Gui.Test/GuiCoreTest.cs
===================================================================
diff -u -r223b2a4edc4ac816051c7eeecb735c34a6246574 -rce792554075b8bfb2723bbdab4b3bdcb6cc58d6f
--- Core/Common/test/Core.Common.Gui.Test/GuiCoreTest.cs (.../GuiCoreTest.cs) (revision 223b2a4edc4ac816051c7eeecb735c34a6246574)
+++ Core/Common/test/Core.Common.Gui.Test/GuiCoreTest.cs (.../GuiCoreTest.cs) (revision ce792554075b8bfb2723bbdab4b3bdcb6cc58d6f)
@@ -27,7 +27,6 @@
using System.Windows.Forms.VisualStyles;
using System.Windows.Threading;
using Core.Common.Base.Data;
-using Core.Common.Base.Plugin;
using Core.Common.Base.Storage;
using Core.Common.Controls.TreeView;
using Core.Common.Gui.Commands;
@@ -40,13 +39,10 @@
using Core.Common.Gui.Settings;
using Core.Common.Gui.Test.Forms.ViewHost;
using Core.Common.TestUtil;
-
using log4net;
using log4net.Appender;
using log4net.Repository.Hierarchy;
-
using NUnit.Framework;
-
using Rhino.Mocks;
namespace Core.Common.Gui.Test
@@ -83,54 +79,54 @@
var projectStore = mocks.Stub();
mocks.ReplayAll();
- var applicationCore = new ApplicationCore();
var guiCoreSettings = new GuiCoreSettings();
// Call
using (var mainWindow = new MainWindow())
- using (var gui = new GuiCore(mainWindow, projectStore, applicationCore, guiCoreSettings))
{
- // Assert
- Assert.AreSame(applicationCore, gui.ApplicationCore);
- Assert.AreEqual(null, gui.PropertyResolver);
- Assert.AreSame(projectStore, gui.Storage);
+ using (var gui = new GuiCore(mainWindow, projectStore, guiCoreSettings))
+ {
+ // Assert
+ Assert.AreEqual(null, gui.PropertyResolver);
+ Assert.AreSame(projectStore, gui.Storage);
- Assert.AreEqual(null, gui.ProjectFilePath);
- Assert.AreEqual(null, gui.Project);
+ Assert.AreEqual(null, gui.ProjectFilePath);
+ Assert.AreEqual(null, gui.Project);
- Assert.AreEqual(null, gui.Selection);
+ Assert.AreEqual(null, gui.Selection);
- Assert.IsInstanceOf(gui.ProjectCommands);
- Assert.IsInstanceOf(gui.StorageCommands);
- Assert.IsInstanceOf(gui.ViewCommands);
- Assert.AreEqual(null, gui.ApplicationCommands);
+ Assert.IsInstanceOf(gui.ProjectCommands);
+ Assert.IsInstanceOf(gui.StorageCommands);
+ Assert.IsInstanceOf(gui.ViewCommands);
+ Assert.AreEqual(null, gui.ApplicationCommands);
- Assert.AreEqual(null, gui.ViewHost);
- Assert.AreEqual(null, gui.DocumentViewController);
+ Assert.AreEqual(null, gui.ViewHost);
+ Assert.AreEqual(null, gui.DocumentViewController);
- AssertDefaultUserSettings(gui.UserSettings);
- Assert.AreSame(guiCoreSettings, gui.FixedSettings);
+ AssertDefaultUserSettings(gui.UserSettings);
+ Assert.AreSame(guiCoreSettings, gui.FixedSettings);
- CollectionAssert.IsEmpty(gui.Plugins);
+ CollectionAssert.IsEmpty(gui.Plugins);
- Assert.AreEqual(mainWindow, gui.MainWindow);
+ Assert.AreEqual(mainWindow, gui.MainWindow);
- Assert.AreSame(ViewPropertyEditor.ViewCommands, gui.ViewCommands);
+ Assert.AreSame(ViewPropertyEditor.ViewCommands, gui.ViewCommands);
- // Check for OS settings that allow visual styles to be rendered in the first place:
- if (VisualStyleInformation.IsSupportedByOS && VisualStyleInformation.IsEnabledByUser &&
- (Application.VisualStyleState == VisualStyleState.ClientAreaEnabled ||
- Application.VisualStyleState == VisualStyleState.ClientAndNonClientAreasEnabled))
- {
- Assert.IsTrue(Application.RenderWithVisualStyles,
- "OS configured to support visual styles, therefore GUI should enable this rendering style.");
+ // Check for OS settings that allow visual styles to be rendered in the first place:
+ if (VisualStyleInformation.IsSupportedByOS && VisualStyleInformation.IsEnabledByUser &&
+ (Application.VisualStyleState == VisualStyleState.ClientAreaEnabled ||
+ Application.VisualStyleState == VisualStyleState.ClientAndNonClientAreasEnabled))
+ {
+ Assert.IsTrue(Application.RenderWithVisualStyles,
+ "OS configured to support visual styles, therefore GUI should enable this rendering style.");
+ }
+ else
+ {
+ //
+ Assert.IsFalse(Application.RenderWithVisualStyles,
+ "OS not supporting visual styles, therefore application shouldn't be render with visual styles.");
+ }
}
- else
- {
- //
- Assert.IsFalse(Application.RenderWithVisualStyles,
- "OS not supporting visual styles, therefore application shouldn't be render with visual styles.");
- }
}
mocks.VerifyAll();
}
@@ -140,23 +136,21 @@
[TestCase(0)]
[TestCase(1)]
[TestCase(2)]
- [TestCase(3)]
- public void ParameteredConstructor_SomeArgumentIsNull_ThrowArgumentNullException(int nullArgumentIndex)
+ public void ParameteredConstructor_SomeArgumentIsNull_ThrowsArgumentNullException(int nullArgumentIndex)
{
// Setup
var mocks = new MockRepository();
IStoreProject projectStore = nullArgumentIndex == 1 ? null : mocks.Stub();
mocks.ReplayAll();
- ApplicationCore applicationCore = nullArgumentIndex == 2 ? null : new ApplicationCore();
- GuiCoreSettings guiCoreSettings = nullArgumentIndex == 3 ? null : new GuiCoreSettings();
+ GuiCoreSettings guiCoreSettings = nullArgumentIndex == 2 ? null : new GuiCoreSettings();
// Call
using (var mainWindow = new MainWindow())
-
+
{
// Call
- TestDelegate call = () => new GuiCore(nullArgumentIndex == 0 ? null : mainWindow, projectStore, applicationCore, guiCoreSettings);
+ TestDelegate call = () => new GuiCore(nullArgumentIndex == 0 ? null : mainWindow, projectStore, guiCoreSettings);
// Assert
TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "Value cannot be null.");
@@ -167,52 +161,33 @@
[Test]
[STAThread]
[ExpectedException(typeof(InvalidOperationException))]
- public void Constructor_ConstuctedAfterAnotherInstanceHasBeenCreated_ThrowInvalidOperationException()
+ public void Constructor_ConstuctedAfterAnotherInstanceHasBeenCreated_ThrowsInvalidOperationException()
{
// Setup
var mocks = new MockRepository();
var projectStore = mocks.Stub();
mocks.ReplayAll();
- var applicationCore = new ApplicationCore();
var guiCoreSettings = new GuiCoreSettings();
// Call
using (var mainWindow = new MainWindow())
- using (var gui = new GuiCore(mainWindow, projectStore, applicationCore, guiCoreSettings))
{
- // Call
- using (var gui2 = new GuiCore(mainWindow, projectStore, applicationCore, guiCoreSettings))
+ using (var gui = new GuiCore(mainWindow, projectStore, guiCoreSettings))
{
- // Assert
- Assert.Fail("Expected an InvalidOperationException to be thrown.");
+ // Call
+ using (var gui2 = new GuiCore(mainWindow, projectStore, guiCoreSettings))
+ {
+ // Assert
+ Assert.Fail("Expected an InvalidOperationException to be thrown.");
+ }
}
}
mocks.VerifyAll();
}
[Test]
[STAThread]
- public void Dispose_ApplicationCoreSet_DisposesOfApplicationCore()
- {
- // Setup
- var mocks = new MockRepository();
- var projectStore = mocks.Stub();
- var applicationCore = mocks.Stub();
- applicationCore.Expect(ac => ac.Dispose());
- mocks.ReplayAll();
-
- var gui = new GuiCore(new MainWindow(), projectStore, applicationCore, new GuiCoreSettings());
-
- // Call
- gui.Dispose();
-
- // Assert
- mocks.VerifyAll();
- }
-
- [Test]
- [STAThread]
public void Dispose_GuipluginsAdded_PluginsDisabledAndRemovedAndDisposed()
{
// Setup
@@ -223,7 +198,7 @@
guiPluginMock.Expect(p => p.Dispose());
mocks.ReplayAll();
- var gui = new GuiCore(new MainWindow(), projectStore, new ApplicationCore(), new GuiCoreSettings());
+ var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings());
gui.Plugins.Add(guiPluginMock);
// Call
@@ -246,7 +221,7 @@
guiPluginMock.Expect(p => p.Dispose());
mocks.ReplayAll();
- var gui = new GuiCore(new MainWindow(), projectStore, new ApplicationCore(), new GuiCoreSettings());
+ var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings());
gui.Plugins.Add(guiPluginMock);
// Call
@@ -267,7 +242,7 @@
var projectStore = mocks.Stub();
mocks.ReplayAll();
- var gui = new GuiCore(new MainWindow(), projectStore, new ApplicationCore(), new GuiCoreSettings())
+ var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings())
{
Selection = new object()
};
@@ -289,7 +264,7 @@
var projectStore = mocks.Stub();
mocks.ReplayAll();
- var gui = new GuiCore(new MainWindow(), projectStore, new ApplicationCore(), new GuiCoreSettings())
+ var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings())
{
Project = new Project()
};
@@ -313,7 +288,7 @@
using (var mainWindow = new MainWindow())
{
- var gui = new GuiCore(mainWindow, projectStore, new ApplicationCore(), new GuiCoreSettings());
+ var gui = new GuiCore(mainWindow, projectStore, new GuiCoreSettings());
// Call
gui.Dispose();
@@ -336,12 +311,12 @@
var messageWindowLogAppender = new MessageWindowLogAppender();
- var rootLogger = ((Hierarchy)LogManager.GetRepository()).Root;
+ var rootLogger = ((Hierarchy) LogManager.GetRepository()).Root;
rootLogger.AddAppender(messageWindowLogAppender);
try
{
- using (var gui = new GuiCore(new MainWindow(), projectStore, new ApplicationCore(), new GuiCoreSettings()))
+ using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings()))
{
gui.Run();
@@ -374,19 +349,21 @@
var projectStore = mocks.Stub();
mocks.ReplayAll();
- using(var toolView = new TestView())
- using (var gui = new GuiCore(new MainWindow(), projectStore, new ApplicationCore(), new GuiCoreSettings()))
+ using (var toolView = new TestView())
{
- gui.Run();
+ using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings()))
+ {
+ gui.Run();
- gui.ViewHost.AddToolView(toolView, ToolViewLocation.Left);
+ gui.ViewHost.AddToolView(toolView, ToolViewLocation.Left);
- // Call
- gui.Dispose();
+ // Call
+ gui.Dispose();
- // Assert
- Assert.IsEmpty(gui.ViewHost.ToolViews);
- Assert.IsTrue(toolView.IsDisposed);
+ // Assert
+ Assert.IsEmpty(gui.ViewHost.ToolViews);
+ Assert.IsTrue(toolView.IsDisposed);
+ }
}
mocks.VerifyAll();
}
@@ -401,19 +378,21 @@
mocks.ReplayAll();
using (var documentView = new TestView())
- using (var gui = new GuiCore(new MainWindow(), projectStore, new ApplicationCore(), new GuiCoreSettings()))
{
- gui.Run();
+ using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings()))
+ {
+ gui.Run();
- gui.ViewHost.AddDocumentView(documentView);
+ gui.ViewHost.AddDocumentView(documentView);
- // Call
- gui.Dispose();
+ // Call
+ gui.Dispose();
- // Assert
- Assert.IsEmpty(gui.ViewHost.DocumentViews);
- Assert.IsNull(gui.DocumentViewController);
- Assert.IsTrue(documentView.IsDisposed);
+ // Assert
+ Assert.IsEmpty(gui.ViewHost.DocumentViews);
+ Assert.IsNull(gui.DocumentViewController);
+ Assert.IsTrue(documentView.IsDisposed);
+ }
}
mocks.VerifyAll();
}
@@ -427,13 +406,13 @@
var projectStore = mocks.Stub();
mocks.ReplayAll();
- Logger rootLogger = ((Hierarchy)LogManager.GetRepository()).Root;
+ Logger rootLogger = ((Hierarchy) LogManager.GetRepository()).Root;
IAppender[] originalAppenders = rootLogger.Appenders.ToArray();
rootLogger.RemoveAllAppenders();
try
{
- using(var gui = new GuiCore(new MainWindow(), projectStore, new ApplicationCore(), new GuiCoreSettings()))
+ using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings()))
{
// Call
gui.Run();
@@ -470,15 +449,15 @@
var appender = new MessageWindowLogAppender();
- Logger rootLogger = ((Hierarchy)LogManager.GetRepository()).Root;
+ Logger rootLogger = ((Hierarchy) LogManager.GetRepository()).Root;
IAppender[] originalAppenders = rootLogger.Appenders.ToArray();
rootLogger.RemoveAllAppenders();
rootLogger.AddAppender(appender);
var rootloggerConfigured = rootLogger.Repository.Configured;
try
{
- using (var gui = new GuiCore(new MainWindow(), projectStore, new ApplicationCore(), new GuiCoreSettings()))
+ using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings()))
{
// Call
gui.Run();
@@ -524,27 +503,29 @@
};
using (var mainWindow = new MainWindow())
- using (var gui = new GuiCore(mainWindow, projectStore, new ApplicationCore(), fixedSettings))
{
- // Call
- Action call = () => gui.Run(testFile);
-
- // Assert
- var expectedMessages = new[]
+ using (var gui = new GuiCore(mainWindow, projectStore, fixedSettings))
{
- "Openen van bestaand Ringtoetsproject.",
- "Bestaand Ringtoetsproject succesvol geopend."
- };
- TestHelper.AssertLogMessagesAreGenerated(call, expectedMessages);
- Assert.AreEqual(testFile, gui.ProjectFilePath);
- Assert.AreSame(deserializedProject, gui.Project);
- Assert.AreEqual(fileName, gui.Project.Name,
- "Project name should be updated to the name of the file.");
+ // Call
+ Action call = () => gui.Run(testFile);
- Assert.AreSame(gui.Selection, gui.Project);
- var expectedTitle = string.Format("{0} - {1} {2}",
- fileName, fixedSettings.MainWindowTitle, SettingsHelper.ApplicationVersion);
- Assert.AreEqual(expectedTitle, mainWindow.Title);
+ // Assert
+ var expectedMessages = new[]
+ {
+ "Openen van bestaand Ringtoetsproject.",
+ "Bestaand Ringtoetsproject succesvol geopend."
+ };
+ TestHelper.AssertLogMessagesAreGenerated(call, expectedMessages);
+ Assert.AreEqual(testFile, gui.ProjectFilePath);
+ Assert.AreSame(deserializedProject, gui.Project);
+ Assert.AreEqual(fileName, gui.Project.Name,
+ "Project name should be updated to the name of the file.");
+
+ Assert.AreSame(gui.Selection, gui.Project);
+ var expectedTitle = string.Format("{0} - {1} {2}",
+ fileName, fixedSettings.MainWindowTitle, SettingsHelper.ApplicationVersion);
+ Assert.AreEqual(expectedTitle, mainWindow.Title);
+ }
}
mocks.VerifyAll();
}
@@ -570,32 +551,34 @@
};
using (var mainWindow = new MainWindow())
- using (var gui = new GuiCore(mainWindow, projectStore, new ApplicationCore(), fixedSettings))
{
- // Call
- Action call = () => gui.Run(testFile);
-
- // Assert
- var expectedMessages = new[]
+ using (var gui = new GuiCore(mainWindow, projectStore, fixedSettings))
{
- "Openen van bestaand Ringtoetsproject.",
- storageExceptionText,
- "Het is niet gelukt om het Ringtoetsproject te laden.",
- "Nieuw project aanmaken..."
- };
- TestHelper.AssertLogMessagesAreGenerated(call, expectedMessages);
+ // Call
+ Action call = () => gui.Run(testFile);
- Assert.IsNull(gui.ProjectFilePath);
- const string expectedProjectName = "Project";
- Assert.AreEqual(expectedProjectName, gui.Project.Name);
- Assert.AreEqual(string.Empty, gui.Project.Description);
- CollectionAssert.IsEmpty(gui.Project.Items);
- Assert.AreEqual(0, gui.Project.StorageId);
+ // Assert
+ var expectedMessages = new[]
+ {
+ "Openen van bestaand Ringtoetsproject.",
+ storageExceptionText,
+ "Het is niet gelukt om het Ringtoetsproject te laden.",
+ "Nieuw project aanmaken..."
+ };
+ TestHelper.AssertLogMessagesAreGenerated(call, expectedMessages);
- Assert.AreSame(gui.Selection, gui.Project);
- var expectedTitle = string.Format("{0} - {1} {2}",
- expectedProjectName, fixedSettings.MainWindowTitle, SettingsHelper.ApplicationVersion);
- Assert.AreEqual(expectedTitle, mainWindow.Title);
+ Assert.IsNull(gui.ProjectFilePath);
+ const string expectedProjectName = "Project";
+ Assert.AreEqual(expectedProjectName, gui.Project.Name);
+ Assert.AreEqual(string.Empty, gui.Project.Description);
+ CollectionAssert.IsEmpty(gui.Project.Items);
+ Assert.AreEqual(0, gui.Project.StorageId);
+
+ Assert.AreSame(gui.Selection, gui.Project);
+ var expectedTitle = string.Format("{0} - {1} {2}",
+ expectedProjectName, fixedSettings.MainWindowTitle, SettingsHelper.ApplicationVersion);
+ Assert.AreEqual(expectedTitle, mainWindow.Title);
+ }
}
mocks.VerifyAll();
}
@@ -617,33 +600,35 @@
MainWindowTitle = ""
};
- using(var mainWindow = new MainWindow())
- using (var gui = new GuiCore(mainWindow, projectStore, new ApplicationCore(), fixedSettings))
+ using (var mainWindow = new MainWindow())
{
- // Call
- Action call = () => gui.Run(path);
+ using (var gui = new GuiCore(mainWindow, projectStore, fixedSettings))
+ {
+ // Call
+ Action call = () => gui.Run(path);
- // Assert
- TestHelper.AssertLogMessageIsGenerated(call, "Nieuw project aanmaken...");
+ // Assert
+ TestHelper.AssertLogMessageIsGenerated(call, "Nieuw project aanmaken...");
- Assert.IsNull(gui.ProjectFilePath);
- const string expectedProjectName = "Project";
- Assert.AreEqual(expectedProjectName, gui.Project.Name);
- Assert.AreEqual(string.Empty, gui.Project.Description);
- CollectionAssert.IsEmpty(gui.Project.Items);
- Assert.AreEqual(0, gui.Project.StorageId);
+ Assert.IsNull(gui.ProjectFilePath);
+ const string expectedProjectName = "Project";
+ Assert.AreEqual(expectedProjectName, gui.Project.Name);
+ Assert.AreEqual(string.Empty, gui.Project.Description);
+ CollectionAssert.IsEmpty(gui.Project.Items);
+ Assert.AreEqual(0, gui.Project.StorageId);
- Assert.AreSame(gui.Selection, gui.Project);
- var expectedTitle = string.Format("{0} - {1} {2}",
- expectedProjectName, fixedSettings.MainWindowTitle, SettingsHelper.ApplicationVersion);
- Assert.AreEqual(expectedTitle, mainWindow.Title);
+ Assert.AreSame(gui.Selection, gui.Project);
+ var expectedTitle = string.Format("{0} - {1} {2}",
+ expectedProjectName, fixedSettings.MainWindowTitle, SettingsHelper.ApplicationVersion);
+ Assert.AreEqual(expectedTitle, mainWindow.Title);
+ }
}
mocks.VerifyAll();
}
[Test]
[STAThread]
- public void Run_WithGuiPlugins_SetGuiAndActivatePlugins()
+ public void Run_WithPlugins_SetGuiAndActivatePlugins()
{
var mocks = new MockRepository();
var projectStore = mocks.Stub();
@@ -656,7 +641,7 @@
mocks.ReplayAll();
// Setup
- using (var gui = new GuiCore(new MainWindow(), projectStore, new ApplicationCore(), new GuiCoreSettings()))
+ using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings()))
{
gui.Plugins.Add(guiPlugin);
@@ -671,7 +656,7 @@
[Test]
[STAThread]
- public void Run_WithGuiPluginThatThrowsExceptionWhenActivated_DeactivateAndDisposePlugin()
+ public void Run_WithPluginThatThrowsExceptionWhenActivated_DeactivateAndDisposePlugin()
{
var mocks = new MockRepository();
var projectStore = mocks.Stub();
@@ -684,7 +669,7 @@
mocks.ReplayAll();
// Setup
- using (var gui = new GuiCore(new MainWindow(), projectStore, new ApplicationCore(), new GuiCoreSettings()))
+ using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings()))
{
gui.Plugins.Add(guiPlugin);
@@ -697,7 +682,7 @@
[Test]
[STAThread]
- public void Run_WithGuiPluginThatThrowsExceptionWhenActivatedAndDeactivated_LogErrorForDeactivatingThenDispose()
+ public void Run_WithPluginThatThrowsExceptionWhenActivatedAndDeactivated_LogErrorForDeactivatingThenDispose()
{
var mocks = new MockRepository();
var projectStore = mocks.Stub();
@@ -710,7 +695,7 @@
mocks.ReplayAll();
// Setup
- using (var gui = new GuiCore(new MainWindow(), projectStore, new ApplicationCore(), new GuiCoreSettings()))
+ using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings()))
{
gui.Plugins.Add(guiPlugin);
@@ -733,7 +718,7 @@
var projectStore = mocks.Stub();
mocks.ReplayAll();
- using (var gui = new GuiCore(new MainWindow(), projectStore, new ApplicationCore(), new GuiCoreSettings()))
+ using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings()))
{
// Call
gui.Run();
@@ -761,7 +746,7 @@
var projectStore = mocks.Stub();
mocks.ReplayAll();
- using (var gui = new GuiCore(new MainWindow(), projectStore, new ApplicationCore(), new GuiCoreSettings()))
+ using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings()))
{
var rootData = new object();
@@ -800,7 +785,7 @@
plugin2.Stub(p => p.Deactivate());
mocks.ReplayAll();
- using (var gui = new GuiCore(new MainWindow(), projectStore, new ApplicationCore(), new GuiCoreSettings()))
+ using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings()))
{
gui.Plugins.Add(plugin1);
gui.Plugins.Add(plugin2);
@@ -831,7 +816,8 @@
var plugin1 = mocks.StrictMock();
plugin1.Expect(p => p.GetChildDataWithViewDefinitions(rootData)).Return(new[]
{
- rootData, rootChild
+ rootData,
+ rootChild
});
plugin1.Expect(p => p.GetChildDataWithViewDefinitions(rootChild)).Return(new[]
{
@@ -842,7 +828,8 @@
var plugin2 = mocks.StrictMock();
plugin2.Expect(p => p.GetChildDataWithViewDefinitions(rootData)).Return(new[]
{
- rootChild, rootData
+ rootChild,
+ rootData
});
plugin2.Expect(p => p.GetChildDataWithViewDefinitions(rootChild)).Return(new[]
{
@@ -852,7 +839,7 @@
plugin2.Stub(p => p.Deactivate());
mocks.ReplayAll();
- using (var gui = new GuiCore(new MainWindow(), projectStore, new ApplicationCore(), new GuiCoreSettings()))
+ using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings()))
{
gui.Plugins.Add(plugin1);
gui.Plugins.Add(plugin2);
@@ -863,7 +850,8 @@
// Assert
var expectedDataDefinitions = new[]
{
- rootData, rootChild
+ rootData,
+ rootChild
};
CollectionAssert.AreEquivalent(expectedDataDefinitions, dataInstancesWithViewDefinitions);
}
@@ -879,7 +867,7 @@
var projectStore = mocks.Stub();
mocks.ReplayAll();
- using (var gui = new GuiCore(new MainWindow(), projectStore, new ApplicationCore(), new GuiCoreSettings()))
+ using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings()))
{
// Call
var result = gui.GetTreeNodeInfos();
@@ -927,7 +915,7 @@
pluginC.Stub(p => p.Deactivate());
mocks.ReplayAll();
- using (var gui = new GuiCore(new MainWindow(), projectStore, new ApplicationCore(), new GuiCoreSettings()))
+ using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings()))
{
gui.Plugins.Add(pluginA);
gui.Plugins.Add(pluginB);
@@ -946,23 +934,24 @@
[Test]
[STAThread]
- public void Get_GuiHasntRunYet_ThrowInvalidOperationException()
+ public void Get_GuiHasNotRunYet_ThrowsInvalidOperationException()
{
// Setup
var mocks = new MockRepository();
var projectStore = mocks.Stub();
mocks.ReplayAll();
using (var treeView = new TreeViewControl())
- using (var gui = new GuiCore(new MainWindow(), projectStore, new ApplicationCore(), new GuiCoreSettings()))
{
- // Call
- TestDelegate call = () => gui.Get(new object(), treeView);
+ using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings()))
+ {
+ // Call
+ TestDelegate call = () => gui.Get(new object(), treeView);
- // Assert
- var message = Assert.Throws(call).Message;
- Assert.AreEqual("Call IGui.Run in order to initialize dependencies before getting the ContextMenuBuilder.", message);
-
+ // Assert
+ var message = Assert.Throws(call).Message;
+ Assert.AreEqual("Call IGui.Run in order to initialize dependencies before getting the ContextMenuBuilder.", message);
+ }
}
mocks.VerifyAll();
}
@@ -977,25 +966,27 @@
mocks.ReplayAll();
using (var treeView = new TreeViewControl())
- using (var gui = new GuiCore(new MainWindow(), projectStore, new ApplicationCore(), new GuiCoreSettings()))
{
- gui.Run();
+ using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings()))
+ {
+ gui.Run();
- // Call
- IContextMenuBuilder builder = gui.Get(new object(), treeView);
+ // Call
+ IContextMenuBuilder builder = gui.Get(new object(), treeView);
- // Assert
- ContextMenuStrip contextMenu = builder.AddRenameItem()
- .AddCollapseAllItem()
- .AddDeleteItem()
- .AddExpandAllItem()
- .AddImportItem()
- .AddExportItem()
- .AddOpenItem()
- .AddSeparator()
- .AddPropertiesItem()
- .Build();
- Assert.AreEqual(9, contextMenu.Items.Count);
+ // Assert
+ ContextMenuStrip contextMenu = builder.AddRenameItem()
+ .AddCollapseAllItem()
+ .AddDeleteItem()
+ .AddExpandAllItem()
+ .AddImportItem()
+ .AddExportItem()
+ .AddOpenItem()
+ .AddSeparator()
+ .AddPropertiesItem()
+ .Build();
+ Assert.AreEqual(9, contextMenu.Items.Count);
+ }
}
mocks.VerifyAll();
}
@@ -1009,7 +1000,7 @@
var storeProject = mocks.Stub();
mocks.ReplayAll();
- using (var gui = new GuiCore(new MainWindow(), storeProject, new ApplicationCore(), new GuiCoreSettings()))
+ using (var gui = new GuiCore(new MainWindow(), storeProject, new GuiCoreSettings()))
{
var oldProject = new Project("A");
var newProject = new Project("B");
@@ -1053,19 +1044,19 @@
Assert.AreEqual(7, settings.Properties.Count);
// Note: Cannot assert particular values, as they can be changed by user.
- var mruList = (StringCollection)settings["mruList"];
+ var mruList = (StringCollection) settings["mruList"];
Assert.IsNotNull(mruList);
- var defaultViewDataTypes = (StringCollection)settings["defaultViewDataTypes"];
+ var defaultViewDataTypes = (StringCollection) settings["defaultViewDataTypes"];
Assert.IsNotNull(defaultViewDataTypes);
- var defaultViews = (StringCollection)settings["defaultViews"];
+ var defaultViews = (StringCollection) settings["defaultViews"];
Assert.IsNotNull(defaultViews);
- var lastVisitedPath = (string)settings["lastVisitedPath"];
+ var lastVisitedPath = (string) settings["lastVisitedPath"];
Assert.IsNotNull(lastVisitedPath);
- var startPageName = (string)settings["startPageName"];
+ var startPageName = (string) settings["startPageName"];
Assert.IsNotNull(startPageName);
- var showStartPage = (bool)settings["showStartPage"];
+ var showStartPage = (bool) settings["showStartPage"];
Assert.IsNotNull(showStartPage);
- var showSplashScreen = (bool)settings["showSplashScreen"];
+ var showSplashScreen = (bool) settings["showSplashScreen"];
Assert.IsNotNull(showSplashScreen);
}
}
Index: Core/Common/test/Core.Common.Integration.Test/Ringtoets/Application.Ringtoets/GuiCoreIntegrationTest.cs
===================================================================
diff -u -r151bab16a7ebc1bffc0621ab56c6dc219db1e90f -rce792554075b8bfb2723bbdab4b3bdcb6cc58d6f
--- Core/Common/test/Core.Common.Integration.Test/Ringtoets/Application.Ringtoets/GuiCoreIntegrationTest.cs (.../GuiCoreIntegrationTest.cs) (revision 151bab16a7ebc1bffc0621ab56c6dc219db1e90f)
+++ Core/Common/test/Core.Common.Integration.Test/Ringtoets/Application.Ringtoets/GuiCoreIntegrationTest.cs (.../GuiCoreIntegrationTest.cs) (revision ce792554075b8bfb2723bbdab4b3bdcb6cc58d6f)
@@ -21,17 +21,14 @@
using System.Windows.Controls;
using System.Windows.Threading;
-using Core.Common.Base.Plugin;
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 Ringtoets.Integration.Plugin;
namespace Core.Common.Integration.Test.Ringtoets.Application.Ringtoets
@@ -53,40 +50,37 @@
[Test]
[RequiresSTA]
- public void StartGuiWithToolboxDoesNotCrash()
+ public void Run_GuiWithRingtoetsPlugin_DoesNotCrash()
{
var mocks = new MockRepository();
var projectStore = mocks.Stub();
mocks.ReplayAll();
- using (var gui = new GuiCore(new MainWindow(), projectStore, new ApplicationCore(), new GuiCoreSettings()))
+ using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings()))
{
- var applicationCore = gui.ApplicationCore;
-
- applicationCore.AddPlugin(new RingtoetsApplicationPlugin());
-
+ gui.Plugins.Add(new RingtoetsGuiPlugin());
gui.Run();
}
mocks.VerifyAll();
}
[Test]
[RequiresSTA]
- public void StartWithCommonPluginsShouldBeFast()
+ public void Run_StartWithCommonPlugins_RunsFasterThanThreshold()
{
TestHelper.AssertIsFasterThan(7500, StartWithCommonPlugins);
}
[Test]
[RequiresSTA]
- public void GuiSelectionIsSetToProjectAfterStartWithProjectExplorer()
+ public void Run_GuiWithProjectExplorerPlugin_SelectionIsSetToProjectExplorer()
{
// initialize
var mocks = new MockRepository();
var projectStore = mocks.Stub();
mocks.ReplayAll();
- using (var gui = new GuiCore(new MainWindow(), projectStore, new ApplicationCore(), new GuiCoreSettings()))
+ using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings()))
{
gui.Plugins.Add(new ProjectExplorerGuiPlugin());
gui.Run();
@@ -106,7 +100,7 @@
var projectStore = mocks.Stub();
mocks.ReplayAll();
- using (var gui = new GuiCore(new MainWindow(), projectStore, new ApplicationCore(), new GuiCoreSettings()))
+ using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings()))
{
gui.Run();
int callCount = 0;
@@ -122,11 +116,9 @@
var projectStore = mocks.Stub();
mocks.ReplayAll();
- using (var gui = new GuiCore(new MainWindow(), projectStore, new ApplicationCore(), new GuiCoreSettings()))
+ using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings()))
{
- var applicationCore = gui.ApplicationCore;
-
- applicationCore.AddPlugin(new RingtoetsApplicationPlugin());
+ gui.Plugins.Add(new RingtoetsGuiPlugin());
gui.Plugins.Add(new ProjectExplorerGuiPlugin());
gui.Run();
Index: Core/Plugins/test/Core.Plugins.DotSpatial.Test/DotSpatialGuiPluginTest.cs
===================================================================
diff -u -r223b2a4edc4ac816051c7eeecb735c34a6246574 -rce792554075b8bfb2723bbdab4b3bdcb6cc58d6f
--- Core/Plugins/test/Core.Plugins.DotSpatial.Test/DotSpatialGuiPluginTest.cs (.../DotSpatialGuiPluginTest.cs) (revision 223b2a4edc4ac816051c7eeecb735c34a6246574)
+++ Core/Plugins/test/Core.Plugins.DotSpatial.Test/DotSpatialGuiPluginTest.cs (.../DotSpatialGuiPluginTest.cs) (revision ce792554075b8bfb2723bbdab4b3bdcb6cc58d6f)
@@ -23,7 +23,6 @@
using System.Linq;
using System.Windows;
using System.Windows.Threading;
-using Core.Common.Base.Plugin;
using Core.Common.Base.Storage;
using Core.Common.Controls.Views;
using Core.Common.Gui;
@@ -138,7 +137,7 @@
var projectStore = mocks.Stub();
mocks.ReplayAll();
- using (var gui = new GuiCore(new MainWindow(), projectStore, new ApplicationCore(), new GuiCoreSettings()))
+ using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings()))
{
var plugin = new DotSpatialGuiPlugin();
var testMapView = new TestMapView();
Index: Core/Plugins/test/Core.Plugins.OxyPlot.Test/OxyPlotGuiPluginTest.cs
===================================================================
diff -u -r223b2a4edc4ac816051c7eeecb735c34a6246574 -rce792554075b8bfb2723bbdab4b3bdcb6cc58d6f
--- Core/Plugins/test/Core.Plugins.OxyPlot.Test/OxyPlotGuiPluginTest.cs (.../OxyPlotGuiPluginTest.cs) (revision 223b2a4edc4ac816051c7eeecb735c34a6246574)
+++ Core/Plugins/test/Core.Plugins.OxyPlot.Test/OxyPlotGuiPluginTest.cs (.../OxyPlotGuiPluginTest.cs) (revision ce792554075b8bfb2723bbdab4b3bdcb6cc58d6f)
@@ -23,7 +23,6 @@
using System.Linq;
using System.Windows;
using System.Windows.Threading;
-using Core.Common.Base.Plugin;
using Core.Common.Base.Storage;
using Core.Common.Controls.Views;
using Core.Common.Gui;
@@ -134,7 +133,7 @@
var projectStore = mocks.Stub();
mocks.ReplayAll();
- using (var gui = new GuiCore(new MainWindow(), projectStore, new ApplicationCore(), new GuiCoreSettings()))
+ using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings()))
{
var plugin = new OxyPlotGuiPlugin();
var testChartView = new TestChartView();
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsGuiPluginTest.cs
===================================================================
diff -u -r6fefc4422dcc5076f0ff430f73d829a6670f0285 -rce792554075b8bfb2723bbdab4b3bdcb6cc58d6f
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsGuiPluginTest.cs (.../RingtoetsGuiPluginTest.cs) (revision 6fefc4422dcc5076f0ff430f73d829a6670f0285)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsGuiPluginTest.cs (.../RingtoetsGuiPluginTest.cs) (revision ce792554075b8bfb2723bbdab4b3bdcb6cc58d6f)
@@ -84,7 +84,7 @@
var projectStore = mocks.Stub();
mocks.ReplayAll();
- using (var gui = new GuiCore(new MainWindow(), projectStore, new ApplicationCore(), new GuiCoreSettings()))
+ using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings()))
{
using (var ringtoetsGuiPlugin = new RingtoetsGuiPlugin())
{
@@ -114,7 +114,7 @@
var testDataDir = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.HydraRing.IO, "HydraulicBoundaryLocationReader");
var testDataPath = Path.Combine(testDataDir, "complete.sqlite");
- using (var gui = new GuiCore(new MainWindow(), projectStore, new ApplicationCore(), new GuiCoreSettings()))
+ using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings()))
{
using (var ringtoetsGuiPlugin = new RingtoetsGuiPlugin())
{
@@ -151,7 +151,7 @@
var projectStore = mocks.Stub();
mocks.ReplayAll();
- using (var gui = new GuiCore(new MainWindow(), projectStore, new ApplicationCore(), new GuiCoreSettings()))
+ using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings()))
{
using (var ringtoetsGuiPlugin = new RingtoetsGuiPlugin())
{