Index: Core/Common/src/Core.Common.Gui/GuiCore.cs
===================================================================
diff -u -re9b8aa3e972b9f07a3201f143c26de0e3f082d49 -r2b99c96f2860546a73cfac8d8fb6a208998850da
--- Core/Common/src/Core.Common.Gui/GuiCore.cs (.../GuiCore.cs) (revision e9b8aa3e972b9f07a3201f143c26de0e3f082d49)
+++ Core/Common/src/Core.Common.Gui/GuiCore.cs (.../GuiCore.cs) (revision 2b99c96f2860546a73cfac8d8fb6a208998850da)
@@ -120,6 +120,7 @@
}
MainWindow = mainWindow;
+ ProjectStore = projectStore;
FixedSettings = fixedSettings;
isAlreadyRunningInstanceOfIGui = true;
@@ -148,6 +149,8 @@
public IPropertyResolver PropertyResolver { get; private set; }
+ public IStoreProject ProjectStore { get; }
+
#region Implementation: ISettingsOwner
public GuiCoreSettings FixedSettings { get; }
Index: Core/Common/src/Core.Common.Gui/IGui.cs
===================================================================
diff -u -r6cdb90fc3f89fe0c44b62d3be7266a0090a6b891 -r2b99c96f2860546a73cfac8d8fb6a208998850da
--- Core/Common/src/Core.Common.Gui/IGui.cs (.../IGui.cs) (revision 6cdb90fc3f89fe0c44b62d3be7266a0090a6b891)
+++ Core/Common/src/Core.Common.Gui/IGui.cs (.../IGui.cs) (revision 2b99c96f2860546a73cfac8d8fb6a208998850da)
@@ -20,6 +20,7 @@
// All rights reserved.
using System;
+using Core.Common.Base.Storage;
using Core.Common.Gui.Commands;
using Core.Common.Gui.ContextMenu;
using Core.Common.Gui.Forms.PropertyGridView;
@@ -43,6 +44,11 @@
IPropertyResolver PropertyResolver { get; }
///
+ /// Gets the object responsible for perform storage actions.
+ ///
+ IStoreProject ProjectStore { get; }
+
+ ///
/// Terminates the application.
///
void ExitApplication();
Index: Riskeer/Integration/src/Riskeer.Integration.Plugin/Merge/AssessmentSectionProvider.cs
===================================================================
diff -u -r86594ccd7329d320872573a1d066fe18959d3cea -r2b99c96f2860546a73cfac8d8fb6a208998850da
--- Riskeer/Integration/src/Riskeer.Integration.Plugin/Merge/AssessmentSectionProvider.cs (.../AssessmentSectionProvider.cs) (revision 86594ccd7329d320872573a1d066fe18959d3cea)
+++ Riskeer/Integration/src/Riskeer.Integration.Plugin/Merge/AssessmentSectionProvider.cs (.../AssessmentSectionProvider.cs) (revision 2b99c96f2860546a73cfac8d8fb6a208998850da)
@@ -22,11 +22,11 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
+using Core.Common.Base.Storage;
using Core.Common.Gui.Forms.ProgressDialog;
using Riskeer.Integration.Data;
using Riskeer.Integration.Data.Merge;
using Riskeer.Integration.Service.Merge;
-using Riskeer.Storage.Core;
namespace Riskeer.Integration.Plugin.Merge
{
@@ -36,21 +36,29 @@
public class AssessmentSectionProvider : IAssessmentSectionProvider
{
private readonly IWin32Window viewParent;
+ private readonly IStoreProject projectStorage;
///
/// Initializes a new instance of .
///
/// The parent of the view.
- /// Thrown when
+ /// /// Class responsible for loading the project.
+ /// Thrown when any parameter
/// is null.
- public AssessmentSectionProvider(IWin32Window viewParent)
+ public AssessmentSectionProvider(IWin32Window viewParent, IStoreProject projectStorage)
{
if (viewParent == null)
{
throw new ArgumentNullException(nameof(viewParent));
}
+ if (projectStorage == null)
+ {
+ throw new ArgumentNullException(nameof(projectStorage));
+ }
+
this.viewParent = viewParent;
+ this.projectStorage = projectStorage;
}
public IEnumerable GetAssessmentSections(string filePath)
@@ -64,7 +72,7 @@
ActivityProgressDialogRunner.Run(viewParent,
LoadAssessmentSectionsActivityFactory.CreateLoadAssessmentSectionsActivity(
- assessmentSectionsOwner, new LoadAssessmentSectionService(new StorageSqLite()),
+ assessmentSectionsOwner, new LoadAssessmentSectionService(projectStorage),
filePath));
if (assessmentSectionsOwner.AssessmentSections == null)
Index: Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerPlugin.cs
===================================================================
diff -u -rb2e674342e62c30bb8f78c89ca5cd450c8c6cc2e -r2b99c96f2860546a73cfac8d8fb6a208998850da
--- Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerPlugin.cs (.../RiskeerPlugin.cs) (revision b2e674342e62c30bb8f78c89ca5cd450c8c6cc2e)
+++ Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerPlugin.cs (.../RiskeerPlugin.cs) (revision 2b99c96f2860546a73cfac8d8fb6a208998850da)
@@ -273,7 +273,7 @@
assessmentSectionFromFileCommandHandler = new AssessmentSectionFromFileCommandHandler(Gui.MainWindow, Gui, Gui.DocumentViewController);
hydraulicBoundaryLocationCalculationGuiService = new HydraulicBoundaryLocationCalculationGuiService(Gui.MainWindow);
assessmentSectionMerger = new AssessmentSectionMerger(new AssessmentSectionMergeFilePathProvider(GetInquiryHelper()),
- new AssessmentSectionProvider(Gui.MainWindow),
+ new AssessmentSectionProvider(Gui.MainWindow, Gui.ProjectStore),
new AssessmentSectionMergeComparer(),
new AssessmentSectionMergeDataProviderDialog(Gui.MainWindow),
new AssessmentSectionMergeHandler(Gui.ViewCommands));
Index: Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/Merge/AssessmentSectionProviderTest.cs
===================================================================
diff -u -r56d072b8342f3e54ba89124ab918bd1529e257a3 -r2b99c96f2860546a73cfac8d8fb6a208998850da
--- Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/Merge/AssessmentSectionProviderTest.cs (.../AssessmentSectionProviderTest.cs) (revision 56d072b8342f3e54ba89124ab918bd1529e257a3)
+++ Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/Merge/AssessmentSectionProviderTest.cs (.../AssessmentSectionProviderTest.cs) (revision 2b99c96f2860546a73cfac8d8fb6a208998850da)
@@ -24,12 +24,14 @@
using System.IO;
using System.Linq;
using System.Windows.Forms;
+using Core.Common.Base.Storage;
using Core.Common.TestUtil;
using NUnit.Extensions.Forms;
using NUnit.Framework;
using Rhino.Mocks;
using Riskeer.Integration.Data;
using Riskeer.Integration.Plugin.Merge;
+using Riskeer.Storage.Core;
namespace Riskeer.Integration.Plugin.Test.Merge
{
@@ -44,10 +46,11 @@
// Setup
var mocks = new MockRepository();
var viewParent = mocks.Stub();
+ var projectStorage = mocks.Stub();
mocks.ReplayAll();
// Call
- var provider = new AssessmentSectionProvider(viewParent);
+ var provider = new AssessmentSectionProvider(viewParent, projectStorage);
// Assert
Assert.IsInstanceOf(provider);
@@ -57,29 +60,51 @@
[Test]
public void Constructor_ViewParentNull_ThrowsArgumentNullException()
{
+ // Setup
+ var mocks = new MockRepository();
+ var projectStorage = mocks.Stub();
+ mocks.ReplayAll();
+
// Call
- TestDelegate call = () => new AssessmentSectionProvider(null);
+ void Call() => new AssessmentSectionProvider(null, projectStorage);
// Assert
- var exception = Assert.Throws(call);
+ var exception = Assert.Throws(Call);
Assert.AreEqual("viewParent", exception.ParamName);
}
[Test]
+ public void Constructor_ProjectStorageNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var viewParent = mocks.Stub();
+ mocks.ReplayAll();
+
+ // Call
+ void Call() => new AssessmentSectionProvider(viewParent, null);
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("projectStorage", exception.ParamName);
+ }
+
+ [Test]
public void GetAssessmentSections_FilePathNull_ThrowsArgumentNullException()
{
// Setup
var mocks = new MockRepository();
var viewParent = mocks.Stub();
+ var projectStorage = mocks.Stub();
mocks.ReplayAll();
- var provider = new AssessmentSectionProvider(viewParent);
+ var provider = new AssessmentSectionProvider(viewParent, projectStorage);
// Call
- TestDelegate call = () => provider.GetAssessmentSections(null);
+ void Call() => provider.GetAssessmentSections(null);
// Assert
- var exception = Assert.Throws(call);
+ var exception = Assert.Throws(Call);
Assert.AreEqual("filePath", exception.ParamName);
mocks.VerifyAll();
}
@@ -90,20 +115,21 @@
// Setup
var mocks = new MockRepository();
var viewParent = mocks.Stub();
+ var projectStorage = mocks.Stub();
mocks.ReplayAll();
- var provider = new AssessmentSectionProvider(viewParent);
+ var provider = new AssessmentSectionProvider(viewParent, projectStorage);
DialogBoxHandler = (name, wnd) =>
{
// Expect an activity dialog which is automatically closed
};
// Call
- TestDelegate call = () => provider.GetAssessmentSections("filePath");
+ void Call() => provider.GetAssessmentSections("filePath");
// Assert
- Assert.Throws(call);
+ Assert.Throws(Call);
mocks.VerifyAll();
}
@@ -115,7 +141,7 @@
var viewParent = mocks.Stub();
mocks.ReplayAll();
- var provider = new AssessmentSectionProvider(viewParent);
+ var provider = new AssessmentSectionProvider(viewParent, new StorageSqLite());
string filePath = Path.Combine(testDataPath, "project.risk");
DialogBoxHandler = (name, wnd) =>