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