Index: Ringtoets/Common/src/Ringtoets.Common.IO/ReferenceLineMetaImporter.cs =================================================================== diff -u -r1de82b61e03283a14d380a48cd718ec65a98432d -r1537ed6c8364e79f9b4c869c95e3d9398a55a572 --- Ringtoets/Common/src/Ringtoets.Common.IO/ReferenceLineMetaImporter.cs (.../ReferenceLineMetaImporter.cs) (revision 1de82b61e03283a14d380a48cd718ec65a98432d) +++ Ringtoets/Common/src/Ringtoets.Common.IO/ReferenceLineMetaImporter.cs (.../ReferenceLineMetaImporter.cs) (revision 1537ed6c8364e79f9b4c869c95e3d9398a55a572) @@ -84,9 +84,7 @@ private void ValidateAndConnectTo(string folderpath) { - ValidateDirectory(folderpath); - - var files = Directory.GetFiles(folderpath, "*.shp"); + var files = GetShapeFilesInFolder(folderpath); if (files.Length == 0) { var message = new FileReaderErrorMessageBuilder( @@ -103,7 +101,7 @@ } } - private static void ValidateDirectory(string path) + private static string[] GetShapeFilesInFolder(string path) { if (String.IsNullOrWhiteSpace(path)) { @@ -113,7 +111,7 @@ try { - Path.GetFullPath(path); + return Directory.GetFiles(path, "*.shp"); } catch (ArgumentException e) { Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/ReferenceLineMetaImporterTest.cs =================================================================== diff -u -r1de82b61e03283a14d380a48cd718ec65a98432d -r1537ed6c8364e79f9b4c869c95e3d9398a55a572 --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/ReferenceLineMetaImporterTest.cs (.../ReferenceLineMetaImporterTest.cs) (revision 1de82b61e03283a14d380a48cd718ec65a98432d) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/ReferenceLineMetaImporterTest.cs (.../ReferenceLineMetaImporterTest.cs) (revision 1537ed6c8364e79f9b4c869c95e3d9398a55a572) @@ -74,19 +74,38 @@ public void Constructor_FilePathTooLong_ThrowsCriticalFileReadException() { // Setup - string pathToEmptyFolder = Path.Combine(testDataPath, new string('A', 260)); + string pathTooLong = Path.Combine(testDataPath, new string('A', 260)); // Call - TestDelegate call = () => new ReferenceLineMetaImporter(pathToEmptyFolder); + TestDelegate call = () => new ReferenceLineMetaImporter(pathTooLong); // Assert var expectedExceptionMessage = string.Format("Fout bij het lezen van bestand '{0}': De folder locatie is ongeldig.", - pathToEmptyFolder); + pathTooLong); CriticalFileReadException exception = Assert.Throws(call); Assert.AreEqual(expectedExceptionMessage, exception.Message); } [Test] + public void Constructor_FilePathDoesNotExist_ThrowsCriticalFileReadException() + { + // Setup + string pathToNonExistingFolder = Path.Combine(testDataPath, "I do not exist"); + + // Precondition + Assert.IsFalse(Directory.Exists(pathToNonExistingFolder)); + + // Call + TestDelegate call = () => new ReferenceLineMetaImporter(pathToNonExistingFolder); + + // Assert + var expectedExceptionMessage = string.Format("Fout bij het lezen van bestand '{0}': De folder locatie is ongeldig.", + pathToNonExistingFolder); + CriticalFileReadException exception = Assert.Throws(call); + Assert.AreEqual(expectedExceptionMessage, exception.Message); + } + + [Test] public void Constructor_EmptyFolder_ThrowsCriticalFileReadException() { // Setup