Index: Core/Common/src/Core.Common.Base/ApplicationPlugin.cs =================================================================== diff -u -rd16e3d83eef732ee256e77dcfce6538dfc63791d -r94089092d09a870d9da9260f5b0cfa187581c407 --- Core/Common/src/Core.Common.Base/ApplicationPlugin.cs (.../ApplicationPlugin.cs) (revision d16e3d83eef732ee256e77dcfce6538dfc63791d) +++ Core/Common/src/Core.Common.Base/ApplicationPlugin.cs (.../ApplicationPlugin.cs) (revision 94089092d09a870d9da9260f5b0cfa187581c407) @@ -10,7 +10,7 @@ /// /// Gets or sets the application. /// - public virtual IApplication Application { get; set; } + public virtual RingtoetsApplication Application { get; set; } /// /// Activates the application plugin. Index: Core/Common/src/Core.Common.Base/Core.Common.Base.csproj =================================================================== diff -u -r48e5d632b4f0c1124a7e574430c6030a290105ce -r94089092d09a870d9da9260f5b0cfa187581c407 --- Core/Common/src/Core.Common.Base/Core.Common.Base.csproj (.../Core.Common.Base.csproj) (revision 48e5d632b4f0c1124a7e574430c6030a290105ce) +++ Core/Common/src/Core.Common.Base/Core.Common.Base.csproj (.../Core.Common.Base.csproj) (revision 94089092d09a870d9da9260f5b0cfa187581c407) @@ -102,7 +102,6 @@ - Fisheye: Tag 94089092d09a870d9da9260f5b0cfa187581c407 refers to a dead (removed) revision in file `Core/Common/src/Core.Common.Base/IApplication.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Core/Common/src/Core.Common.Base/Properties/Resources.Designer.cs =================================================================== diff -u -r622c20f6fc0b693b67a3e57b2ece939823002c62 -r94089092d09a870d9da9260f5b0cfa187581c407 --- Core/Common/src/Core.Common.Base/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 622c20f6fc0b693b67a3e57b2ece939823002c62) +++ Core/Common/src/Core.Common.Base/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 94089092d09a870d9da9260f5b0cfa187581c407) @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.34209 +// Runtime Version:4.0.30319.18063 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -216,42 +216,6 @@ } /// - /// Looks up a localized string similar to Registreren van exporteer routine {0}.. - /// - internal static string RingtoetsApplication_RegisterExporters_Registering_exporter_0_ { - get { - return ResourceManager.GetString("RingtoetsApplication_RegisterExporters_Registering_exporter_0_", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Registratie van de exporteer routines.... - /// - internal static string RingtoetsApplication_RegisterExporters_Registering_exporters { - get { - return ResourceManager.GetString("RingtoetsApplication_RegisterExporters_Registering_exporters", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Registreren van importeer routine {0}.. - /// - internal static string RingtoetsApplication_RegisterImporters_Registering_importer_0_ { - get { - return ResourceManager.GetString("RingtoetsApplication_RegisterImporters_Registering_importer_0_", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Registratie van de importeer routines.... - /// - internal static string RingtoetsApplication_RegisterImporters_Registering_importers { - get { - return ResourceManager.GetString("RingtoetsApplication_RegisterImporters_Registering_importers", resourceCulture); - } - } - - /// /// Looks up a localized string similar to Activeer plugins.... /// internal static string RingtoetsApplication_Run_Activating_plugins { Index: Core/Common/src/Core.Common.Base/Properties/Resources.resx =================================================================== diff -u -r622c20f6fc0b693b67a3e57b2ece939823002c62 -r94089092d09a870d9da9260f5b0cfa187581c407 --- Core/Common/src/Core.Common.Base/Properties/Resources.resx (.../Resources.resx) (revision 622c20f6fc0b693b67a3e57b2ece939823002c62) +++ Core/Common/src/Core.Common.Base/Properties/Resources.resx (.../Resources.resx) (revision 94089092d09a870d9da9260f5b0cfa187581c407) @@ -144,18 +144,6 @@ Alle plugins zijn geactiveerd. - - Registreren van importeer routine {0}. - - - Registratie van de exporteer routines... - - - Registreren van exporteer routine {0}. - - - Registratie van de importeer routines... - Activiteit is '{0}'. 'Initialize()' moet aangeroepen worden voor 'Execute()'. Index: Core/Common/src/Core.Common.Base/RingtoetsApplication.cs =================================================================== diff -u -r622c20f6fc0b693b67a3e57b2ece939823002c62 -r94089092d09a870d9da9260f5b0cfa187581c407 --- Core/Common/src/Core.Common.Base/RingtoetsApplication.cs (.../RingtoetsApplication.cs) (revision 622c20f6fc0b693b67a3e57b2ece939823002c62) +++ Core/Common/src/Core.Common.Base/RingtoetsApplication.cs (.../RingtoetsApplication.cs) (revision 94089092d09a870d9da9260f5b0cfa187581c407) @@ -19,7 +19,7 @@ namespace Core.Common.Base { - public class RingtoetsApplication : IApplication + public class RingtoetsApplication : IDisposable { public event Action AfterRun; @@ -32,8 +32,6 @@ public event Action ProjectSaved; private static readonly ILog log = LogManager.GetLogger(typeof(RingtoetsApplication)); - private readonly IList fileImporters = new List(); - private readonly IList fileExporters = new List(); public Action WaitMethod; @@ -105,7 +103,7 @@ } } - public IList Plugins { get; set; } + public IList Plugins { get; private set; } public IActivityRunner ActivityRunner { get; set; } @@ -129,15 +127,15 @@ { get { - return fileImporters; + return Plugins.SelectMany(plugin => plugin.GetFileImporters()); } } public IEnumerable FileExporters { get { - return fileExporters; + return Plugins.SelectMany(plugin => plugin.GetFileExporters()); } } @@ -214,9 +212,6 @@ log.Info(Properties.Resources.RingtoetsApplication_Run_Activating_plugins); ActivatePlugins(); - RegisterImporters(); - RegisterExporters(); - log.Info(Properties.Resources.RingtoetsApplication_Run_Waiting_until_all_plugins_are_activated); Project = projectBeingCreated; // opens project in application @@ -396,30 +391,6 @@ } } - private void RegisterImporters() - { - log.Debug(Properties.Resources.RingtoetsApplication_RegisterImporters_Registering_importers); - - foreach (var fileImporter in Plugins.SelectMany(plugin => plugin.GetFileImporters())) - { - fileImporters.Add(fileImporter); - - log.DebugFormat(Properties.Resources.RingtoetsApplication_RegisterImporters_Registering_importer_0_, fileImporter.Name); - } - } - - private void RegisterExporters() - { - log.Debug(Properties.Resources.RingtoetsApplication_RegisterExporters_Registering_exporters); - - foreach (var fileExporter in Plugins.SelectMany(plugin => plugin.GetFileExporters())) - { - fileExporters.Add(fileExporter); - - log.DebugFormat(Properties.Resources.RingtoetsApplication_RegisterExporters_Registering_exporter_0_, fileExporter.Name); - } - } - private void Dispose(bool disposing) { if (!disposed) Index: Core/Common/src/Core.Common.Gui/IGui.cs =================================================================== diff -u -rce485d2ea1e537a2d9be33d46a282e5bfa2abdcc -r94089092d09a870d9da9260f5b0cfa187581c407 --- Core/Common/src/Core.Common.Gui/IGui.cs (.../IGui.cs) (revision ce485d2ea1e537a2d9be33d46a282e5bfa2abdcc) +++ Core/Common/src/Core.Common.Gui/IGui.cs (.../IGui.cs) (revision 94089092d09a870d9da9260f5b0cfa187581c407) @@ -22,7 +22,7 @@ /// /// Gets or sets Application wrapped by the current Gui. /// - IApplication Application { get; set; } + RingtoetsApplication Application { get; set; } /// /// Gets or sets CommandHandler. Index: Core/Common/src/Core.Common.Gui/RingtoetsGui.cs =================================================================== diff -u -r622c20f6fc0b693b67a3e57b2ece939823002c62 -r94089092d09a870d9da9260f5b0cfa187581c407 --- Core/Common/src/Core.Common.Gui/RingtoetsGui.cs (.../RingtoetsGui.cs) (revision 622c20f6fc0b693b67a3e57b2ece939823002c62) +++ Core/Common/src/Core.Common.Gui/RingtoetsGui.cs (.../RingtoetsGui.cs) (revision 94089092d09a870d9da9260f5b0cfa187581c407) @@ -41,7 +41,7 @@ private static RingtoetsGui instance; private static string instanceCreationStackTrace; - private IApplication application; + private RingtoetsApplication application; private MainWindow mainWindow; private object selection; @@ -94,7 +94,7 @@ public Action OnMainWindowLoaded { get; set; } - public IApplication Application + public RingtoetsApplication Application { get { Index: Core/Common/test/Core.Common.Integration.Tests/Ringtoets/Application.Ringtoets/GuiImportHandlerTest.cs =================================================================== diff -u -rf1c02b2d47dc561deec70a24128d8dd49d9bed6a -r94089092d09a870d9da9260f5b0cfa187581c407 --- Core/Common/test/Core.Common.Integration.Tests/Ringtoets/Application.Ringtoets/GuiImportHandlerTest.cs (.../GuiImportHandlerTest.cs) (revision f1c02b2d47dc561deec70a24128d8dd49d9bed6a) +++ Core/Common/test/Core.Common.Integration.Tests/Ringtoets/Application.Ringtoets/GuiImportHandlerTest.cs (.../GuiImportHandlerTest.cs) (revision 94089092d09a870d9da9260f5b0cfa187581c407) @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.IO; using System.Linq; using System.Windows.Forms; using Core.Common.Base; @@ -21,7 +20,7 @@ { private MockRepository mocks; private IGui gui; - private IApplication realApp; + private RingtoetsApplication realApp; private readonly ApplicationPlugin commonToolsPlugin = new CommonToolsApplicationPlugin(); @@ -69,28 +68,21 @@ [Test] public void FileFilteringWorks() { - var application = mocks.Stub(); + var plugin = mocks.Stub(); var fileImporter = mocks.Stub(); var targetItemImporter = mocks.Stub(); - var plugin = mocks.Stub(); - application.Stub(a => a.Plugins).Return(new[] + plugin.Expect(p => p.GetFileImporters()).Return(new[] { - plugin - }); - application.Stub(a => a.ProjectFilePath).Return(Directory.GetCurrentDirectory()).Repeat.Any(); - gui.Application = application; - - IEnumerable importers = new[] - { targetItemImporter, fileImporter - }; + }).Repeat.Any(); fileImporter.Expect(fi => fi.SupportedItemTypes).Return(new[] { typeof(Int64) }).Repeat.Any(); + fileImporter.Expect(fi => fi.FileFilter).Return("known|*.bla").Repeat.Any(); fileImporter.Expect(fi => fi.Name).Return("1").Repeat.Any(); fileImporter.Expect(fi => fi.CanImportOn(null)).IgnoreArguments().Return(true).Repeat.Any(); @@ -99,14 +91,17 @@ { typeof(Int64) }).Repeat.Any(); + targetItemImporter.Expect(fi => fi.FileFilter).Return("known|*.ext").Repeat.Any(); targetItemImporter.Expect(fi => fi.Name).Return("2").Repeat.Any(); targetItemImporter.Expect(fi => fi.CanImportOn(null)).IgnoreArguments().Return(true).Repeat.Any(); - application.Expect(a => a.FileImporters).IgnoreArguments().Repeat.Any().Return(importers); - mocks.ReplayAll(); + var application = new RingtoetsApplication { Plugins = { plugin } }; + + gui.Application = application; + var guiImportHandler = new GuiImportHandler(gui); var one = (long) 1.0; @@ -131,34 +126,28 @@ [Test] public void NonRootLevelImportersAreNotReturnedForNullType() { - var application = mocks.Stub(); + var plugin = mocks.Stub(); var fileImporter = mocks.Stub(); var targetItemImporter = mocks.Stub(); var targetItemImporter2 = mocks.Stub(); - var plugin = mocks.Stub(); - application.Stub(a => a.Plugins).Return(new[] + plugin.Expect(p => p.GetFileImporters()).Return(new[] { - plugin - }); - application.Stub(a => a.ProjectFilePath).Return(Directory.GetCurrentDirectory()).Repeat.Any(); - gui.Application = application; - - IEnumerable importers = new[] - { fileImporter, targetItemImporter, targetItemImporter2 - }; + }); fileImporter.Expect(fi => fi.CanImportOnRootLevel).Return(false); targetItemImporter.Expect(fi => fi.CanImportOnRootLevel).Return(false); targetItemImporter2.Expect(fi => fi.CanImportOnRootLevel).Return(true); - application.Expect(a => a.FileImporters).IgnoreArguments().Repeat.Any().Return(importers); - mocks.ReplayAll(); + var application = new RingtoetsApplication { Plugins = { plugin } }; + + gui.Application = application; + var guiImportHandler = new GuiImportHandler(gui); var fileImporters = guiImportHandler.GetImporters(null); @@ -172,19 +161,17 @@ [Test] public void TargetItemFileImporterAreReturnedWhenMatch() { - var application = mocks.Stub(); + var plugin = mocks.Stub(); var fileImporter = mocks.Stub(); var targetItemImporter = mocks.Stub(); var targetItemImporterWhereCanImportIsFalse = mocks.Stub(); - application.Stub(a => a.ProjectFilePath).Return(Directory.GetCurrentDirectory()).Repeat.Any(); - gui.Application = application; - IEnumerable importers = new[] + plugin.Expect(p => p.GetFileImporters()).Return(new[] { fileImporter, targetItemImporter, targetItemImporterWhereCanImportIsFalse - }; + }); fileImporter.Expect(fi => fi.SupportedItemTypes).Return(new[] { @@ -204,10 +191,12 @@ }); targetItemImporterWhereCanImportIsFalse.Expect(fi => fi.CanImportOn(null)).IgnoreArguments().Return(false).Repeat.Any(); - application.Expect(a => a.FileImporters).IgnoreArguments().Repeat.Any().Return(importers); - mocks.ReplayAll(); + var application = new RingtoetsApplication { Plugins = { plugin } }; + + gui.Application = application; + var guiImportHandler = new GuiImportHandler(gui); var fileImporters = guiImportHandler.GetImporters((long) 1.0); @@ -218,37 +207,28 @@ } [Test] - public void TargetItemFileImporterCanMatchOnSubtype() + public void TargetItemFileImporterCanMatchOnSubtype() // Note: Test verifies that an importer for type A matches on type B if B implements A { - //test verifies that an importer for type A matches on type B if B implements A - - var application = mocks.Stub(); - var targetItemImporter = mocks.Stub(); var plugin = mocks.Stub(); + var targetItemImporter = mocks.Stub(); - application.Stub(a => a.Plugins).Return(new[] + plugin.Expect(p => p.GetFileImporters()).Return(new[] { - plugin + targetItemImporter }); - application.Stub(a => a.ProjectFilePath).Return(Directory.GetCurrentDirectory()).Repeat.Any(); - gui.Application = application; - - IEnumerable importers = new[] - { - targetItemImporter - }; - targetItemImporter.Expect(fi => fi.SupportedItemTypes).Return(new[] { typeof(IList) }); targetItemImporter.Expect(fi => fi.CanImportOn(null)).IgnoreArguments().Return(true).Repeat.Any(); - application.Expect(a => a.FileImporters).IgnoreArguments().Repeat.Any().Return(importers); - mocks.ReplayAll(); + var application = new RingtoetsApplication { Plugins = { plugin } }; + + gui.Application = application; + var guiImportHandler = new GuiImportHandler(gui); //get importers for subtype @@ -265,34 +245,28 @@ [Test] public void AllPluginsAreSearchedForFileImportersAndOnlyMatchingImportersAreReturned() { - var application = mocks.Stub(); + var plugin = mocks.Stub(); var fileImporter1 = mocks.Stub(); var fileImporter2 = mocks.Stub(); var fileImporter3 = mocks.Stub(); - var plugin1 = mocks.Stub(); - application.Stub(a => a.Plugins).Return(new[] + plugin.Expect(p => p.GetFileImporters()).Return(new[] { - plugin1 - }); - application.Stub(a => a.ProjectFilePath).Return(Directory.GetCurrentDirectory()).Repeat.Any(); - gui.Application = application; - - IEnumerable importers = new[] - { fileImporter1, fileImporter2, fileImporter3 - }; + }); fileImporter1.Expect(fi => fi.SupportedItemTypes).Return(new[] { typeof(Int32) }); + fileImporter2.Expect(fi => fi.SupportedItemTypes).Return(new[] { typeof(Int64) }); + fileImporter3.Expect(fi => fi.SupportedItemTypes).Return(new[] { typeof(Int16) @@ -302,10 +276,12 @@ fileImporter2.Expect(fi => fi.CanImportOn(null)).IgnoreArguments().Return(true).Repeat.Any(); fileImporter3.Expect(fi => fi.CanImportOn(null)).IgnoreArguments().Return(true).Repeat.Any(); - application.Expect(a => a.FileImporters).Repeat.Any().Return(importers).Repeat.Once(); - mocks.ReplayAll(); + var application = new RingtoetsApplication { Plugins = { plugin } }; + + gui.Application = application; + var guiImportHandler = new GuiImportHandler(gui); var fileImporters = guiImportHandler.GetImporters((long) 1.0); Index: Core/Common/test/Core.Common.Tests/Core.Common.Tests.csproj =================================================================== diff -u -r3aa69a0ff858d591479a1b33ef1ad36ae76a5052 -r94089092d09a870d9da9260f5b0cfa187581c407 --- Core/Common/test/Core.Common.Tests/Core.Common.Tests.csproj (.../Core.Common.Tests.csproj) (revision 3aa69a0ff858d591479a1b33ef1ad36ae76a5052) +++ Core/Common/test/Core.Common.Tests/Core.Common.Tests.csproj (.../Core.Common.Tests.csproj) (revision 94089092d09a870d9da9260f5b0cfa187581c407) @@ -115,7 +115,6 @@ ToolWindowTestControl.cs - UserControl Index: Core/Common/test/Core.Common.Tests/Core/RingtoetsApplicationTest.cs =================================================================== diff -u -ree60be046a1b4e4151bb567e9a9c3ab0876d3b55 -r94089092d09a870d9da9260f5b0cfa187581c407 --- Core/Common/test/Core.Common.Tests/Core/RingtoetsApplicationTest.cs (.../RingtoetsApplicationTest.cs) (revision ee60be046a1b4e4151bb567e9a9c3ab0876d3b55) +++ Core/Common/test/Core.Common.Tests/Core/RingtoetsApplicationTest.cs (.../RingtoetsApplicationTest.cs) (revision 94089092d09a870d9da9260f5b0cfa187581c407) @@ -50,8 +50,6 @@ Expect.Call(plugin.Application = null).IgnoreArguments(); Expect.Call(plugin.Deactivate); Expect.Call(plugin.GetDataItemInfos()).Return(new List()).Repeat.Any(); - Expect.Call(plugin.GetFileImporters()).Return(new List()); - Expect.Call(plugin.GetFileExporters()).Return(new List()); plugin.Activate(); LastCall.Repeat.Once(); Index: Core/Common/test/Core.Common.Tests/Gui/ImportActivityTest.cs =================================================================== diff -u -r8546b20b128723309b8b663858f32b7e399f75d8 -r94089092d09a870d9da9260f5b0cfa187581c407 --- Core/Common/test/Core.Common.Tests/Gui/ImportActivityTest.cs (.../ImportActivityTest.cs) (revision 8546b20b128723309b8b663858f32b7e399f75d8) +++ Core/Common/test/Core.Common.Tests/Gui/ImportActivityTest.cs (.../ImportActivityTest.cs) (revision 94089092d09a870d9da9260f5b0cfa187581c407) @@ -1,4 +1,3 @@ -using System.Linq; using Core.Common.Base; using Core.Common.Base.Workflow; using Core.Common.Gui; @@ -15,14 +14,10 @@ [Test] public void FileImportActivity() { - // wrap importer by activity var gui = mockRepository.Stub(); - var app = mockRepository.Stub(); + var project = new Project("test"); - gui.Application = app; - app.Expect(a => a.Project).Return(project).Repeat.Any(); - var importer = mockRepository.Stub(); var fileImportActivity = new FileImportActivity(importer) { @@ -40,6 +35,13 @@ mockRepository.ReplayAll(); + var app = new RingtoetsApplication + { + Project = project + }; + + gui.Application = app; + // expect some reporting while processing each file fileImportActivity.OnImportFinished += (sender, importedObject, theImporter) => { @@ -50,7 +52,9 @@ fileImportActivity.Initialize(); fileImportActivity.Execute(); - Assert.AreEqual(3, app.Project.Items.Count()); + Assert.AreEqual(3, app.Project.Items.Count); + + mockRepository.VerifyAll(); } } } \ No newline at end of file Index: Core/Common/test/Core.Common.Tests/Gui/RingtoetsGuiTests.cs =================================================================== diff -u -r4e08a66b9a5e271df99e1056f928cf8adf8d9cd6 -r94089092d09a870d9da9260f5b0cfa187581c407 --- Core/Common/test/Core.Common.Tests/Gui/RingtoetsGuiTests.cs (.../RingtoetsGuiTests.cs) (revision 4e08a66b9a5e271df99e1056f928cf8adf8d9cd6) +++ Core/Common/test/Core.Common.Tests/Gui/RingtoetsGuiTests.cs (.../RingtoetsGuiTests.cs) (revision 94089092d09a870d9da9260f5b0cfa187581c407) @@ -1,5 +1,5 @@ +using Core.Common.Base; using Core.Common.Gui; -using Core.Common.Tests.TestObjects; using Core.Common.TestUtils; using log4net.Core; using NUnit.Framework; @@ -40,14 +40,19 @@ [Test] public void DisposingGuiDisposesApplication() { - var testApplication = new TestApplication(); - gui.Application = testApplication; + // Setup + var ringtoetsApplication = new RingtoetsApplication(); - //action! + gui.Application = ringtoetsApplication; + + // Precondition + Assert.IsNotNull(ringtoetsApplication.Plugins); + + // Call gui.Dispose(); - //assert - Assert.AreEqual(1, testApplication.DisposeCallCount); + // Assert + Assert.IsNull(ringtoetsApplication.Plugins); } [Test] Fisheye: Tag 94089092d09a870d9da9260f5b0cfa187581c407 refers to a dead (removed) revision in file `Core/Common/test/Core.Common.Tests/TestObjects/TestApplication.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Core/Plugins/src/Core.Plugins.ProjectExplorer/ProjectTreeView.cs =================================================================== diff -u -r113fd0fac19ed2f327ae9faa016f25660785b5ce -r94089092d09a870d9da9260f5b0cfa187581c407 --- Core/Plugins/src/Core.Plugins.ProjectExplorer/ProjectTreeView.cs (.../ProjectTreeView.cs) (revision 113fd0fac19ed2f327ae9faa016f25660785b5ce) +++ Core/Plugins/src/Core.Plugins.ProjectExplorer/ProjectTreeView.cs (.../ProjectTreeView.cs) (revision 94089092d09a870d9da9260f5b0cfa187581c407) @@ -18,7 +18,7 @@ { private readonly TreeView treeView; private GuiPlugin guiPlugin; - private IApplication app; + private RingtoetsApplication app; private IGui gui; private Project project; Index: Core/Plugins/test/Core.Plugins.CommonTools.Tests/CommonToolsGuiPluginTest.cs =================================================================== diff -u -r2a90c0c1be6114f72af65c42f0a6f334b30e4755 -r94089092d09a870d9da9260f5b0cfa187581c407 --- Core/Plugins/test/Core.Plugins.CommonTools.Tests/CommonToolsGuiPluginTest.cs (.../CommonToolsGuiPluginTest.cs) (revision 2a90c0c1be6114f72af65c42f0a6f334b30e4755) +++ Core/Plugins/test/Core.Plugins.CommonTools.Tests/CommonToolsGuiPluginTest.cs (.../CommonToolsGuiPluginTest.cs) (revision 94089092d09a870d9da9260f5b0cfa187581c407) @@ -21,7 +21,7 @@ public void ChartLegendViewIsUpdatedForCurrentActiveView() { var gui = mocks.Stub(); - gui.Application = mocks.Stub(); + gui.Application = mocks.Stub(); var pluginGui = new CommonToolsGuiPlugin(); var mainWindow = mocks.Stub(); var toolWindowViews = new TestViewList(); Index: Core/Plugins/test/Core.Plugins.ProjectExplorer.Tests/ProjectExplorerPluginGuiTest.cs =================================================================== diff -u -r2a90c0c1be6114f72af65c42f0a6f334b30e4755 -r94089092d09a870d9da9260f5b0cfa187581c407 --- Core/Plugins/test/Core.Plugins.ProjectExplorer.Tests/ProjectExplorerPluginGuiTest.cs (.../ProjectExplorerPluginGuiTest.cs) (revision 2a90c0c1be6114f72af65c42f0a6f334b30e4755) +++ Core/Plugins/test/Core.Plugins.ProjectExplorer.Tests/ProjectExplorerPluginGuiTest.cs (.../ProjectExplorerPluginGuiTest.cs) (revision 94089092d09a870d9da9260f5b0cfa187581c407) @@ -12,70 +12,62 @@ [TestFixture] public class ProjectExplorerPluginGuiTest { - private readonly MockRepository mocks = new MockRepository(); - private IApplication app; private IGui gui; - + private MockRepository mocks; + private RingtoetsApplication app; private ITreeNodePresenter mockNodePresenter; private ProjectExplorerGuiPlugin projectExplorerPluginGui; [SetUp] public void SetUp() { - app = mocks.Stub(); + mocks = new MockRepository(); gui = mocks.Stub(); var settings = mocks.Stub(); var plugin = mocks.Stub(); var pluginGui = mocks.Stub(); - projectExplorerPluginGui = new ProjectExplorerGuiPlugin { Gui = gui }; settings["showHiddenDataItems"] = true; - app.UserSettings = settings; - app.Settings = new NameValueCollection(); - app.Settings["IsProjectExplorerSorted"] = "false"; - - var project = new Project(); - Expect.Call(app.Project).Return(project).Repeat.Any(); - - gui.Application = app; Expect.Call(gui.ToolWindowViews).Return(mocks.Stub()); Expect.Call(gui.DocumentViews).Return(mocks.Stub()); Expect.Call(gui.Plugins).Return(new List { projectExplorerPluginGui, pluginGui }).Repeat.Any(); - plugin.Application = app; - //create and register a custom np mockNodePresenter = mocks.Stub(); Expect.Call(pluginGui.GetProjectTreeViewNodePresenters()).Return(new[] { mockNodePresenter }); - app.Stub(a => a.Plugins).Return(new[] + mocks.ReplayAll(); + + app = new RingtoetsApplication { - plugin - }); - app.Stub(a => a.ProjectOpened += null).IgnoreArguments().Repeat.Any(); - app.Stub(a => a.ProjectOpened -= null).IgnoreArguments().Repeat.Any(); - app.Stub(a => a.ProjectClosing += null).IgnoreArguments().Repeat.Any(); - app.Stub(a => a.ProjectClosing -= null).IgnoreArguments().Repeat.Any(); - app.Stub(a => a.ProjectSaving += null).IgnoreArguments().Repeat.Any(); - app.Stub(a => a.ProjectSaving -= null).IgnoreArguments().Repeat.Any(); - app.Stub(a => a.ProjectSaved += null).IgnoreArguments().Repeat.Any(); - app.Stub(a => a.ProjectSaved -= null).IgnoreArguments().Repeat.Any(); + Project = new Project(), + Plugins = { plugin }, + UserSettings = settings, + Settings = new NameValueCollection { { "IsProjectExplorerSorted", "false" } } + }; - mocks.ReplayAll(); + gui.Application = app; + plugin.Application = app; } + [TearDown] + public void TearDown() + { + mocks.VerifyAll(); + } + [Test] public void RegisteringTreeNodeAddsToTreeView() { Index: Core/Plugins/test/Core.Plugins.ProjectExplorer.Tests/ProjectTreeViewTest.cs =================================================================== diff -u -rb7740a20087463e213caab7a0a6d8d33bdf3f3ef -r94089092d09a870d9da9260f5b0cfa187581c407 --- Core/Plugins/test/Core.Plugins.ProjectExplorer.Tests/ProjectTreeViewTest.cs (.../ProjectTreeViewTest.cs) (revision b7740a20087463e213caab7a0a6d8d33bdf3f3ef) +++ Core/Plugins/test/Core.Plugins.ProjectExplorer.Tests/ProjectTreeViewTest.cs (.../ProjectTreeViewTest.cs) (revision 94089092d09a870d9da9260f5b0cfa187581c407) @@ -9,33 +9,32 @@ [TestFixture] public class ProjectTreeViewTest { - private static readonly MockRepository mocks = new MockRepository(); - - [SetUp] - public void SetUp() {} - - [Test] + [Test] public void Init() { + var mocks = new MockRepository(); var gui = mocks.Stub(); - var app = mocks.StrictMock(); + var documentViews = mocks.Stub(); var settings = mocks.Stub(); - var documentViews = mocks.Stub(); - gui.Application = app; Expect.Call(gui.DocumentViews).Return(documentViews).Repeat.Any(); - // in case of mock - Expect.Call(app.UserSettings).Return(settings).Repeat.Any(); mocks.ReplayAll(); + var app = new RingtoetsApplication { UserSettings = settings }; + + gui.Application = app; + var pluginGui = new ProjectExplorerGuiPlugin { Gui = gui }; var projectTreeView = new ProjectTreeView(pluginGui); + Assert.IsNotNull(projectTreeView); + + mocks.VerifyAll(); } } } \ No newline at end of file Index: Core/Plugins/test/Core.Plugins.SharpMapGis.Tests/Forms/MapLegendViewTest.cs =================================================================== diff -u -rf1c02b2d47dc561deec70a24128d8dd49d9bed6a -r94089092d09a870d9da9260f5b0cfa187581c407 --- Core/Plugins/test/Core.Plugins.SharpMapGis.Tests/Forms/MapLegendViewTest.cs (.../MapLegendViewTest.cs) (revision f1c02b2d47dc561deec70a24128d8dd49d9bed6a) +++ Core/Plugins/test/Core.Plugins.SharpMapGis.Tests/Forms/MapLegendViewTest.cs (.../MapLegendViewTest.cs) (revision 94089092d09a870d9da9260f5b0cfa187581c407) @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.IO; using System.Windows.Forms; using Core.Common.Base; @@ -126,13 +125,12 @@ Expect.Call(gui.ToolWindowViews).Return(mocks.Stub()).Repeat.Any(); Expect.Call(gui.DocumentViews).Repeat.Any().Return(mocks.Stub()); - var app = mocks.Stub(); - var project = new Project(); - Expect.Call(app.Project).Repeat.Any().Return(project); - Expect.Call(app.FileExporters).Repeat.Any().Return(new List()); + mocks.ReplayAll(); + + var app = new RingtoetsApplication { Project = new Project() }; + gui.Application = app; - mocks.ReplayAll(); guiPlugin.Gui = gui; guiPlugin.Activate(); Index: Core/Plugins/test/Core.Plugins.SharpMapGis.Tests/Forms/MapTreeViewNodePresenterTest.cs =================================================================== diff -u -r2a90c0c1be6114f72af65c42f0a6f334b30e4755 -r94089092d09a870d9da9260f5b0cfa187581c407 --- Core/Plugins/test/Core.Plugins.SharpMapGis.Tests/Forms/MapTreeViewNodePresenterTest.cs (.../MapTreeViewNodePresenterTest.cs) (revision 2a90c0c1be6114f72af65c42f0a6f334b30e4755) +++ Core/Plugins/test/Core.Plugins.SharpMapGis.Tests/Forms/MapTreeViewNodePresenterTest.cs (.../MapTreeViewNodePresenterTest.cs) (revision 94089092d09a870d9da9260f5b0cfa187581c407) @@ -45,7 +45,7 @@ //create mocks because we are only testing presenter here var guiPlugin = mocks.Stub(); var gui = mocks.Stub(); - var app = mocks.Stub(); + var app = mocks.Stub(); tv = mocks.Stub(); gui.Application = app; Index: Core/Plugins/test/Core.Plugins.SharpMapGis.Tests/SharpMapGisGuiPluginTest.cs =================================================================== diff -u -ra939049a7a018633d948ac4a735c382af423a299 -r94089092d09a870d9da9260f5b0cfa187581c407 --- Core/Plugins/test/Core.Plugins.SharpMapGis.Tests/SharpMapGisGuiPluginTest.cs (.../SharpMapGisGuiPluginTest.cs) (revision a939049a7a018633d948ac4a735c382af423a299) +++ Core/Plugins/test/Core.Plugins.SharpMapGis.Tests/SharpMapGisGuiPluginTest.cs (.../SharpMapGisGuiPluginTest.cs) (revision 94089092d09a870d9da9260f5b0cfa187581c407) @@ -1,4 +1,3 @@ -using System.Collections.Generic; using System.Windows.Forms; using Core.Common.Base; using Core.Common.Gui; @@ -12,32 +11,21 @@ [TestFixture] public class SharpMapGisGuiPluginTest { - private MockRepository mocks; - - [SetUp] - public void Setup() - { - mocks = new MockRepository(); - } - /// /// Returns a contextmenu in case the data is a vectorlayer. /// [Test] public void GetContextMenuTest() { + var mocks = new MockRepository(); var gui = mocks.Stub(); var viewManager = mocks.Stub(); - var application = mocks.Stub(); var project = new Project(); var sharpMapGisPluginGui = new SharpMapGisGuiPlugin { Gui = gui }; - Expect.Call(application.Project).Return(project).Repeat.Any(); - Expect.Call(application.FileExporters).Return(new List()).Repeat.Any(); - gui.Application = application; Expect.Call(gui.ToolWindowViews).Return(viewManager).Repeat.Any(); Expect.Call(gui.DocumentViews).Return(viewManager).Repeat.Any(); Expect.Call(gui.Plugins).Return(new[] @@ -52,6 +40,10 @@ mocks.ReplayAll(); + var application = new RingtoetsApplication { Project = project }; + + gui.Application = application; + sharpMapGisPluginGui.Gui = gui; sharpMapGisPluginGui.InitializeMapLegend(); Index: Ringtoets/Demo/test/Ringtoets.Demo.Test/Commands/AddNewDemoDikeAssessmentSectionCommandTest.cs =================================================================== diff -u -r3479f17e22ed8f8f44470972f85f9478707af683 -r94089092d09a870d9da9260f5b0cfa187581c407 --- Ringtoets/Demo/test/Ringtoets.Demo.Test/Commands/AddNewDemoDikeAssessmentSectionCommandTest.cs (.../AddNewDemoDikeAssessmentSectionCommandTest.cs) (revision 3479f17e22ed8f8f44470972f85f9478707af683) +++ Ringtoets/Demo/test/Ringtoets.Demo.Test/Commands/AddNewDemoDikeAssessmentSectionCommandTest.cs (.../AddNewDemoDikeAssessmentSectionCommandTest.cs) (revision 94089092d09a870d9da9260f5b0cfa187581c407) @@ -1,13 +1,9 @@ using System.Linq; - using Core.Common.Base; using Core.Common.Controls; using Core.Common.Gui; - using NUnit.Framework; - using Rhino.Mocks; - using Ringtoets.Demo.Commands; using Ringtoets.Integration.Data; using Ringtoets.Piping.Calculation; @@ -40,15 +36,20 @@ var project = new Project(); var mocks = new MockRepository(); - var applicationMock = mocks.Stub(); - applicationMock.Stub(a => a.Project).Return(project); + var guiMock = mocks.Stub(); - guiMock.Application = applicationMock; var observerMock = mocks.StrictMock(); observerMock.Expect(o => o.UpdateObserver()); mocks.ReplayAll(); + var ringtoetsApplication = new RingtoetsApplication + { + Project = project + }; + + guiMock.Application = ringtoetsApplication; + var command = new AddNewDemoDikeAssessmentSectionCommand { Gui = guiMock Index: Ringtoets/Demo/test/Ringtoets.Demo.Test/Commands/AddNewDemoDuneAssessmentSectionCommandTest.cs =================================================================== diff -u -re45c4de1ffabe66b3b49123abc2e4e6c951435f5 -r94089092d09a870d9da9260f5b0cfa187581c407 --- Ringtoets/Demo/test/Ringtoets.Demo.Test/Commands/AddNewDemoDuneAssessmentSectionCommandTest.cs (.../AddNewDemoDuneAssessmentSectionCommandTest.cs) (revision e45c4de1ffabe66b3b49123abc2e4e6c951435f5) +++ Ringtoets/Demo/test/Ringtoets.Demo.Test/Commands/AddNewDemoDuneAssessmentSectionCommandTest.cs (.../AddNewDemoDuneAssessmentSectionCommandTest.cs) (revision 94089092d09a870d9da9260f5b0cfa187581c407) @@ -1,13 +1,8 @@ -using System.Linq; - -using Core.Common.Base; +using Core.Common.Base; using Core.Common.Controls; using Core.Common.Gui; - using NUnit.Framework; - using Rhino.Mocks; - using Ringtoets.Demo.Commands; using Ringtoets.Integration.Data; @@ -34,18 +29,21 @@ public void Execute_GuiIsProperlyInitialized_AddNewDuneAssessmentSectionWithDemoDataToRootProject() { // Setup - var project = new Project(); - var mocks = new MockRepository(); - var applicationMock = mocks.Stub(); - applicationMock.Stub(a => a.Project).Return(project); var guiMock = mocks.Stub(); - guiMock.Application = applicationMock; - var observerMock = mocks.StrictMock(); + observerMock.Expect(o => o.UpdateObserver()); mocks.ReplayAll(); + var project = new Project(); + var ringtoetsApplication = new RingtoetsApplication + { + Project = project + }; + + guiMock.Application = ringtoetsApplication; + var command = new AddNewDemoDuneAssessmentSectionCommand { Gui = guiMock @@ -58,7 +56,7 @@ // Assert Assert.AreEqual(1, project.Items.Count); - var demoAssessmentSection = (DuneAssessmentSection)project.Items[0]; + var demoAssessmentSection = (DuneAssessmentSection) project.Items[0]; Assert.AreEqual("Demo duintraject", demoAssessmentSection.Name); mocks.VerifyAll(); } Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsGuiPluginTest.cs =================================================================== diff -u -r80ebf3911f46c8fde95702b7723e4457b4fd80ea -r94089092d09a870d9da9260f5b0cfa187581c407 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsGuiPluginTest.cs (.../RingtoetsGuiPluginTest.cs) (revision 80ebf3911f46c8fde95702b7723e4457b4fd80ea) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsGuiPluginTest.cs (.../RingtoetsGuiPluginTest.cs) (revision 94089092d09a870d9da9260f5b0cfa187581c407) @@ -1,15 +1,11 @@ using System; using System.Linq; - using Core.Common.Base; using Core.Common.Base.Workflow; using Core.Common.Controls; using Core.Common.Gui; - using NUnit.Framework; - using Rhino.Mocks; - using Ringtoets.Common.Forms.NodePresenters; using Ringtoets.Integration.Data; using Ringtoets.Integration.Forms.NodePresenters; @@ -58,17 +54,25 @@ { // setup var mocks = new MockRepository(); - var application = mocks.Stub(); - application.Stub(a => a.ActivityRunner).Return(mocks.Stub()); + var activityRunnerStub = mocks.Stub(); var guiStub = mocks.Stub(); guiStub.CommandHandler = mocks.Stub(); - guiStub.Application = application; mocks.ReplayAll(); - using (var guiPlugin = new RingtoetsGuiPlugin { Gui = guiStub }) + var application = new RingtoetsApplication { + ActivityRunner = activityRunnerStub + }; + + guiStub.Application = application; + + using (var guiPlugin = new RingtoetsGuiPlugin + { + Gui = guiStub + }) + { // call ITreeNodePresenter[] nodePresenters = guiPlugin.GetProjectTreeViewNodePresenters().ToArray(); Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/PipingGuiPluginTest.cs =================================================================== diff -u -rca5e60f150095bbe4b6919062dc98a5d2b71c77e -r94089092d09a870d9da9260f5b0cfa187581c407 --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/PipingGuiPluginTest.cs (.../PipingGuiPluginTest.cs) (revision ca5e60f150095bbe4b6919062dc98a5d2b71c77e) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/PipingGuiPluginTest.cs (.../PipingGuiPluginTest.cs) (revision 94089092d09a870d9da9260f5b0cfa187581c407) @@ -4,17 +4,12 @@ using Core.Common.Base.Workflow; using Core.Common.Controls; using Core.Common.Gui; - using NUnit.Framework; - using Rhino.Mocks; - using Ringtoets.Piping.Data; - using Ringtoets.Piping.Forms.NodePresenters; using Ringtoets.Piping.Forms.PresentationObjects; using Ringtoets.Piping.Forms.PropertyClasses; - using GuiPluginResources = Ringtoets.Piping.Plugin.Properties.Resources; namespace Ringtoets.Piping.Plugin.Test @@ -84,17 +79,25 @@ { // setup var mocks = new MockRepository(); - var application = mocks.Stub(); - application.Stub(a => a.ActivityRunner).Return(mocks.Stub()); + var activityRunnerStub = mocks.Stub(); var guiStub = mocks.Stub(); guiStub.CommandHandler = mocks.Stub(); - guiStub.Application = application; mocks.ReplayAll(); - using (var guiPlugin = new PipingGuiPlugin { Gui = guiStub }) + var application = new RingtoetsApplication { + ActivityRunner = activityRunnerStub + }; + + guiStub.Application = application; + + using (var guiPlugin = new PipingGuiPlugin + { + Gui = guiStub + }) + { // call ITreeNodePresenter[] nodePresenters = guiPlugin.GetProjectTreeViewNodePresenters().ToArray();