Index: Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.IO/Exporters/MacroStabilityInwardsCalculationGroupExporter.cs =================================================================== diff -u -r1742a934260056f525c94f9cfc443346dd2dfb70 -r4ccc3643ea3e07ee0989fca27cb1590fe9e5a20b --- Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.IO/Exporters/MacroStabilityInwardsCalculationGroupExporter.cs (.../MacroStabilityInwardsCalculationGroupExporter.cs) (revision 1742a934260056f525c94f9cfc443346dd2dfb70) +++ Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.IO/Exporters/MacroStabilityInwardsCalculationGroupExporter.cs (.../MacroStabilityInwardsCalculationGroupExporter.cs) (revision 4ccc3643ea3e07ee0989fca27cb1590fe9e5a20b) @@ -1,5 +1,6 @@ using System; using Core.Common.Base.IO; +using Core.Common.Util; using Riskeer.Common.Data.Calculation; namespace Riskeer.MacroStabilityInwards.IO.Exporters @@ -17,18 +18,22 @@ /// /// The calculation group to export. /// The folder path to export to. - /// Thrown when any parameter is null. + /// Thrown when is null. + /// Thrown when is invalid. + /// A valid path: + /// is not empty or null, + /// does not consist out of only whitespace characters, + /// does not contain an invalid character, + /// is not too long. + /// public MacroStabilityInwardsCalculationGroupExporter(CalculationGroup calculationGroup, string folderPath) { if (calculationGroup == null) { throw new ArgumentNullException(nameof(calculationGroup)); } - if (folderPath == null) - { - throw new ArgumentNullException(nameof(folderPath)); - } + IOUtils.ValidateFolderPath(folderPath); this.calculationGroup = calculationGroup; this.folderPath = folderPath; Index: Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.IO.Test/Exporters/MacroStabilityInwardsCalculationGroupExporterTest.cs =================================================================== diff -u -r5a910b0291a79821e74d771fc294976a690e92ad -r4ccc3643ea3e07ee0989fca27cb1590fe9e5a20b --- Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.IO.Test/Exporters/MacroStabilityInwardsCalculationGroupExporterTest.cs (.../MacroStabilityInwardsCalculationGroupExporterTest.cs) (revision 5a910b0291a79821e74d771fc294976a690e92ad) +++ Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.IO.Test/Exporters/MacroStabilityInwardsCalculationGroupExporterTest.cs (.../MacroStabilityInwardsCalculationGroupExporterTest.cs) (revision 4ccc3643ea3e07ee0989fca27cb1590fe9e5a20b) @@ -1,5 +1,6 @@ using System; using Core.Common.Base.IO; +using Core.Common.TestUtil; using NUnit.Framework; using Riskeer.Common.Data.Calculation; using Riskeer.MacroStabilityInwards.IO.Exporters; @@ -13,7 +14,7 @@ public void Constructor_ExpectedValues() { // Call - var exporter = new MacroStabilityInwardsCalculationGroupExporter(new CalculationGroup(), string.Empty); + var exporter = new MacroStabilityInwardsCalculationGroupExporter(new CalculationGroup(), "ValidFolderPath"); // Assert Assert.IsInstanceOf(exporter); @@ -31,21 +32,24 @@ } [Test] - public void Constructor_FolderPathNull_ThrowsArgumentNullException() + [TestCase(null)] + [TestCase("")] + [TestCase(" ")] + [TestCase("C:\\Not:Valid")] + public void Constructor_InvalidFolderPath_ThrowsArgumentException(string folderPath) { // Call - void Call() => new MacroStabilityInwardsCalculationGroupExporter(new CalculationGroup(), null); + void Call() => new MacroStabilityInwardsCalculationGroupExporter(new CalculationGroup(), folderPath); // Assert - var exception = Assert.Throws(Call); - Assert.AreEqual("folderPath", exception.ParamName); + Assert.Throws(Call); } [Test] public void Export_Always_ReturnsFalse() { // Setup - var exporter = new MacroStabilityInwardsCalculationGroupExporter(new CalculationGroup(), string.Empty); + var exporter = new MacroStabilityInwardsCalculationGroupExporter(new CalculationGroup(), "ValidFolderPath"); // Call bool exportResult = exporter.Export();