Index: Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.IO/Exporters/MacroStabilityInwardsCalculationExporter.cs
===================================================================
diff -u -r529a84a6ff2d31723d5782991e8b6e28b61d8651 -r064fb2c63f6035167b27a1d25de4de655959bbb7
--- Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.IO/Exporters/MacroStabilityInwardsCalculationExporter.cs (.../MacroStabilityInwardsCalculationExporter.cs) (revision 529a84a6ff2d31723d5782991e8b6e28b61d8651)
+++ Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.IO/Exporters/MacroStabilityInwardsCalculationExporter.cs (.../MacroStabilityInwardsCalculationExporter.cs) (revision 064fb2c63f6035167b27a1d25de4de655959bbb7)
@@ -20,6 +20,7 @@
// All rights reserved.
using System;
+using Components.Persistence.Stability;
using Core.Common.Base.IO;
using Core.Common.Util;
using Riskeer.MacroStabilityInwards.Data;
@@ -37,8 +38,10 @@
/// Creates a new instance of .
///
/// The calculation to export.
+ /// The persistence factory to use.
/// The file path to export to.
- /// Thrown when is null.
+ /// Thrown when or
+ /// is null.
/// Thrown when is invalid.
/// A valid path:
///
@@ -47,13 +50,20 @@
/// - does not contain an invalid character,
/// - does not end with a directory or path separator (empty file name).
///
- public MacroStabilityInwardsCalculationExporter(MacroStabilityInwardsCalculation calculation, string filePath)
+ public MacroStabilityInwardsCalculationExporter(MacroStabilityInwardsCalculation calculation,
+ IPersistenceFactory persistenceFactory,
+ string filePath)
{
if (calculation == null)
{
throw new ArgumentNullException(nameof(calculation));
}
+ if (persistenceFactory == null)
+ {
+ throw new ArgumentNullException(nameof(persistenceFactory));
+ }
+
IOUtils.ValidateFilePath(filePath);
this.filePath = filePath;
Index: Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.IO/Riskeer.MacroStabilityInwards.IO.csproj
===================================================================
diff -u -r42ca5fa567ea7172e3ecd027038501909d4dbbe1 -r064fb2c63f6035167b27a1d25de4de655959bbb7
--- Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.IO/Riskeer.MacroStabilityInwards.IO.csproj (.../Riskeer.MacroStabilityInwards.IO.csproj) (revision 42ca5fa567ea7172e3ecd027038501909d4dbbe1)
+++ Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.IO/Riskeer.MacroStabilityInwards.IO.csproj (.../Riskeer.MacroStabilityInwards.IO.csproj) (revision 064fb2c63f6035167b27a1d25de4de655959bbb7)
@@ -1,6 +1,9 @@
+
+ ..\..\..\..\lib\Plugins\Wti\Components.Persistence.Stability.dll
+
Index: Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Plugin/MacroStabilityInwardsPlugin.cs
===================================================================
diff -u -r3cc23c40d1904a58a7d4ded98d4785c70a3d6d40 -r064fb2c63f6035167b27a1d25de4de655959bbb7
--- Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Plugin/MacroStabilityInwardsPlugin.cs (.../MacroStabilityInwardsPlugin.cs) (revision 3cc23c40d1904a58a7d4ded98d4785c70a3d6d40)
+++ Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Plugin/MacroStabilityInwardsPlugin.cs (.../MacroStabilityInwardsPlugin.cs) (revision 064fb2c63f6035167b27a1d25de4de655959bbb7)
@@ -23,6 +23,7 @@
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
+using Components.Persistence.Stability;
using Core.Common.Base;
using Core.Common.Base.Data;
using Core.Common.Controls.TreeView;
@@ -171,7 +172,9 @@
{
Name = Resources.MacroStabilityInwardsCalculationExporter_DisplayName,
Extension = Resources.Stix_file_filter_extension,
- CreateFileExporter = (context, filePath) => new MacroStabilityInwardsCalculationExporter(context.WrappedData, filePath),
+ CreateFileExporter = (context, filePath) => new MacroStabilityInwardsCalculationExporter(context.WrappedData,
+ new PersistenceFactory(),
+ filePath),
IsEnabled = context => context.WrappedData.HasOutput,
GetExportPath = () => ExportHelper.GetFilePath(GetInquiryHelper(), new FileFilterGenerator(Resources.Stix_file_filter_extension,
Resources.Stix_file_filter_description))
Index: Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Plugin/Riskeer.MacroStabilityInwards.Plugin.csproj
===================================================================
diff -u -reab9e44ec463eca0edfb6281e367ff3fbd69b5f5 -r064fb2c63f6035167b27a1d25de4de655959bbb7
--- Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Plugin/Riskeer.MacroStabilityInwards.Plugin.csproj (.../Riskeer.MacroStabilityInwards.Plugin.csproj) (revision eab9e44ec463eca0edfb6281e367ff3fbd69b5f5)
+++ Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Plugin/Riskeer.MacroStabilityInwards.Plugin.csproj (.../Riskeer.MacroStabilityInwards.Plugin.csproj) (revision 064fb2c63f6035167b27a1d25de4de655959bbb7)
@@ -1,6 +1,9 @@
+
+ ..\..\..\..\lib\Plugins\Wti\Components.Persistence.Stability.dll
+
Index: Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.IO.Test/Exporters/MacroStabilityInwardsCalculationExporterTest.cs
===================================================================
diff -u -r529a84a6ff2d31723d5782991e8b6e28b61d8651 -r064fb2c63f6035167b27a1d25de4de655959bbb7
--- Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.IO.Test/Exporters/MacroStabilityInwardsCalculationExporterTest.cs (.../MacroStabilityInwardsCalculationExporterTest.cs) (revision 529a84a6ff2d31723d5782991e8b6e28b61d8651)
+++ Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.IO.Test/Exporters/MacroStabilityInwardsCalculationExporterTest.cs (.../MacroStabilityInwardsCalculationExporterTest.cs) (revision 064fb2c63f6035167b27a1d25de4de655959bbb7)
@@ -20,9 +20,11 @@
// All rights reserved.
using System;
+using Components.Persistence.Stability;
using Core.Common.Base.IO;
using Core.Common.TestUtil;
using NUnit.Framework;
+using Rhino.Mocks;
using Riskeer.MacroStabilityInwards.Data;
using Riskeer.MacroStabilityInwards.IO.Exporters;
@@ -34,46 +36,81 @@
[Test]
public void Constructor_ExpectedValues()
{
+ // Setup
+ var mocks = new MockRepository();
+ var persistenceFactory = mocks.Stub();
+ mocks.ReplayAll();
+
// Call
- var exporter = new MacroStabilityInwardsCalculationExporter(new MacroStabilityInwardsCalculation(), "ValidFilePath");
+ var exporter = new MacroStabilityInwardsCalculationExporter(new MacroStabilityInwardsCalculation(), persistenceFactory, "ValidFilePath");
// Assert
Assert.IsInstanceOf(exporter);
+ mocks.VerifyAll();
}
[Test]
public void Constructor_CalculationNull_ThrowsArgumentNullException()
{
+ // Setup
+ var mocks = new MockRepository();
+ var persistenceFactory = mocks.Stub();
+ mocks.ReplayAll();
+
// Call
- void Call() => new MacroStabilityInwardsCalculationExporter(null, string.Empty);
+ void Call() => new MacroStabilityInwardsCalculationExporter(null, persistenceFactory, string.Empty);
// Assert
var exception = Assert.Throws(Call);
Assert.AreEqual("calculation", exception.ParamName);
+ mocks.VerifyAll();
}
[Test]
+ public void Constructor_PersistenceFactoryNull_ThrowsArgumentNullException()
+ {
+ // Call
+ void Call() => new MacroStabilityInwardsCalculationExporter(new MacroStabilityInwardsCalculation(), null, string.Empty);
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("persistenceFactory", exception.ParamName);
+ }
+
+ [Test]
[TestCaseSource(typeof(InvalidPathHelper), nameof(InvalidPathHelper.InvalidPaths))]
public void Constructor_FilePathInvalid_ThrowsArgumentException(string filePath)
{
+ // Setup
+ var mocks = new MockRepository();
+ var persistenceFactory = mocks.Stub();
+ mocks.ReplayAll();
+
+
// Call
- void Call() => new MacroStabilityInwardsCalculationExporter(new MacroStabilityInwardsCalculation(), filePath);
+ void Call() => new MacroStabilityInwardsCalculationExporter(new MacroStabilityInwardsCalculation(), persistenceFactory, filePath);
// Assert
Assert.Throws(Call);
+ mocks.VerifyAll();
}
[Test]
public void Export_Always_ReturnsFalse()
{
// Setup
- var exporter = new MacroStabilityInwardsCalculationExporter(new MacroStabilityInwardsCalculation(), "ValidFilePath");
+ var mocks = new MockRepository();
+ var persistenceFactory = mocks.Stub();
+ mocks.ReplayAll();
+ var exporter = new MacroStabilityInwardsCalculationExporter(new MacroStabilityInwardsCalculation(), persistenceFactory, "ValidFilePath");
+
// Call
bool exportResult = exporter.Export();
// Assert
Assert.IsFalse(exportResult);
+ mocks.VerifyAll();
}
}
}
\ No newline at end of file
Index: Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.IO.Test/Riskeer.MacroStabilityInwards.IO.Test.csproj
===================================================================
diff -u -r47b7983d2d492ec39f76e69914431447fa72f376 -r064fb2c63f6035167b27a1d25de4de655959bbb7
--- Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.IO.Test/Riskeer.MacroStabilityInwards.IO.Test.csproj (.../Riskeer.MacroStabilityInwards.IO.Test.csproj) (revision 47b7983d2d492ec39f76e69914431447fa72f376)
+++ Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.IO.Test/Riskeer.MacroStabilityInwards.IO.Test.csproj (.../Riskeer.MacroStabilityInwards.IO.Test.csproj) (revision 064fb2c63f6035167b27a1d25de4de655959bbb7)
@@ -6,6 +6,9 @@
+
+ ..\..\..\..\lib\Plugins\Wti\Components.Persistence.Stability.dll
+