Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/DikeProfiles/DikeProfileDataReader.cs =================================================================== diff -u -r57634f535a347ce49c2491f114d7238d5387c7a8 -rf17b6b3fc9a23b521185b7a3ee5398571a4f1fa7 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/DikeProfiles/DikeProfileDataReader.cs (.../DikeProfileDataReader.cs) (revision 57634f535a347ce49c2491f114d7238d5387c7a8) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/DikeProfiles/DikeProfileDataReader.cs (.../DikeProfileDataReader.cs) (revision f17b6b3fc9a23b521185b7a3ee5398571a4f1fa7) @@ -646,7 +646,7 @@ { lineNumber++; text = ReadLineAndHandleIOExceptions(reader, lineNumber); - if (text == null) + if (string.IsNullOrWhiteSpace(text)) { string message = string.Format(Resources.DikeProfileDataReader_TryReadDikeRoughnessPoints_DikeCount_0_does_not_correspond_ExpectedCount_1_, i, numberOfPoints); @@ -729,7 +729,13 @@ /// not valid. private RoughnessPoint ReadRoughnessPoint(string text, int lineNumber) { - Match roughnessSectionDataMatch = new Regex(@"^(\s*)?(?.+?)?(\s+(?.+?)?(\s+(?.+?)?)?)?\s*$").Match(text); + Match roughnessSectionDataMatch = new Regex(@"^(\s*)?(?\S+)\s+(?\S+)\s+(?\S+)\s*$").Match(text); + if (!roughnessSectionDataMatch.Success) + { + string message = string.Format(Resources.DikeProfileDataReader_ReadRoughnessPoint_Line_0_not_x_y_roughness_definition, + text); + throw CreateCriticalFileReadException(lineNumber, message); + } string readLocalXText = roughnessSectionDataMatch.Groups["localx"].Value; double localX = ParseRoughnessPointParameter(readLocalXText, Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Properties/Resources.Designer.cs =================================================================== diff -u -r57634f535a347ce49c2491f114d7238d5387c7a8 -rf17b6b3fc9a23b521185b7a3ee5398571a4f1fa7 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 57634f535a347ce49c2491f114d7238d5387c7a8) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision f17b6b3fc9a23b521185b7a3ee5398571a4f1fa7) @@ -208,6 +208,15 @@ } /// + /// Looks up a localized string similar to De ingelezen regel ('{0}') is geen 'X Y ruwheid' definitie.. + /// + internal static string DikeProfileDataReader_ReadRoughnessPoint_Line_0_not_x_y_roughness_definition { + get { + return ResourceManager.GetString("DikeProfileDataReader_ReadRoughnessPoint_Line_0_not_x_y_roughness_definition", resourceCulture); + } + } + + /// /// Looks up a localized string similar to De ingelezen ruwheid ('{0}') moet binnen het bereik [{1}, 1] vallen.. /// internal static string DikeProfileDataReader_ReadRoughnessPoint_Roughness_0_must_be_in_range_LowerLimit_1_ { @@ -284,7 +293,7 @@ } /// - /// Looks up a localized string similar to De ingelezen ID ({'0'}) bevat spaties, welke niet zijn toegestaan.. + /// Looks up a localized string similar to De ingelezen ID ('{0}') bevat spaties, welke niet zijn toegestaan.. /// internal static string DikeProfileDataReader_ValidateId_Id_0_has_unsupported_white_space { get { Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Properties/Resources.resx =================================================================== diff -u -r57634f535a347ce49c2491f114d7238d5387c7a8 -rf17b6b3fc9a23b521185b7a3ee5398571a4f1fa7 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Properties/Resources.resx (.../Resources.resx) (revision 57634f535a347ce49c2491f114d7238d5387c7a8) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Properties/Resources.resx (.../Resources.resx) (revision f17b6b3fc9a23b521185b7a3ee5398571a4f1fa7) @@ -240,4 +240,7 @@ Voorlandgeometrie punten dienen X-coördinaten te hebben die monotoon strikt toenemend zijn. + + De ingelezen regel ('{0}') is geen 'X Y ruwheid' definitie. + \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/DikeProfiles/DikeProfileDataReaderTest.cs =================================================================== diff -u -r57634f535a347ce49c2491f114d7238d5387c7a8 -rf17b6b3fc9a23b521185b7a3ee5398571a4f1fa7 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/DikeProfiles/DikeProfileDataReaderTest.cs (.../DikeProfileDataReaderTest.cs) (revision 57634f535a347ce49c2491f114d7238d5387c7a8) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/DikeProfiles/DikeProfileDataReaderTest.cs (.../DikeProfileDataReaderTest.cs) (revision f17b6b3fc9a23b521185b7a3ee5398571a4f1fa7) @@ -524,23 +524,11 @@ [Test] [TestCase("faulty_unparsableDijk_X.prfl", 18, "X-coördinaat", "suhf")] - [TestCase("faulty_unparsableDijk_X_noValue1.prfl", 18, "X-coördinaat", "")] - [TestCase("faulty_unparsableDijk_X_noValue2.prfl", 18, "X-coördinaat", "")] [TestCase("faulty_unparsableDijk_Z.prfl", 20, "Z-coördinaat", "o;jfhe;lhtvwposiu")] - [TestCase("faulty_unparsableDijk_Z_noValue1.prfl", 20, "Z-coördinaat", "")] - [TestCase("faulty_unparsableDijk_Z_noValue2.prfl", 20, "Z-coördinaat", "")] [TestCase("faulty_unparsableDijk_Roughness.prfl", 17, "ruwheid", "dr;tjn")] - [TestCase("faulty_unparsableDijk_Roughness_noValue1.prfl", 17, "ruwheid", "")] - [TestCase("faulty_unparsableDijk_Roughness_noValue2.prfl", 17, "ruwheid", "")] [TestCase("faulty_unparsableVoorland_X.prfl", 10, "X-coördinaat", "glkjdhflgkjhsk")] - [TestCase("faulty_unparsableVoorland_X_noValue1.prfl", 11, "X-coördinaat", "")] - [TestCase("faulty_unparsableVoorland_X_noValue2.prfl", 12, "X-coördinaat", "")] [TestCase("faulty_unparsableVoorland_Z.prfl", 12, "Z-coördinaat", "lijfhsliufghkj")] - [TestCase("faulty_unparsableVoorland_Z_noValue1.prfl", 10, "Z-coördinaat", "")] - [TestCase("faulty_unparsableVoorland_Z_noValue2.prfl", 11, "Z-coördinaat", "")] - [TestCase("faulty_unparsableVoorland_Roughness.prfl", 10, "ruwheid", ";lsduglk wab")] - [TestCase("faulty_unparsableVoorland_Roughness_noValue1.prfl", 11, "ruwheid", "")] - [TestCase("faulty_unparsableVoorland_Roughness_noValue2.prfl", 12, "ruwheid", "")] + [TestCase("faulty_unparsableVoorland_Roughness.prfl", 10, "ruwheid", ";lsduglkwab")] public void ReadDikeProfileData_UnparsableRoughnessPoints_ThrowsCriticalFileReadException( string faultyFileName, int expectedLineNumber, string expectedParameterName, string expectedReadText) { @@ -550,6 +538,26 @@ } [Test] + [TestCase("faulty_unparsableDijk_Z_noValue1.prfl", 20, "18.000\t\t\t")] + [TestCase("faulty_unparsableDijk_Z_noValue2.prfl", 20, "18.000")] + [TestCase("faulty_unparsableDijk_Roughness_noValue1.prfl", 17, "-18.000\t-6.000\t\t\t")] + [TestCase("faulty_unparsableDijk_Roughness_noValue2.prfl", 17, "-18.000\t-6.000")] + [TestCase("faulty_unparsableDijk_tooManyValues.prfl", 14, "0.000\t0.000\t1.000\t12.34")] + [TestCase("faulty_unparsableVoorland_X_noValue1.prfl", 11, "\t\t\t\t\t")] + [TestCase("faulty_unparsableVoorland_X_noValue2.prfl", 12, "")] + [TestCase("faulty_unparsableVoorland_Z_noValue1.prfl", 10, "-150.000\t\t\t\t")] + [TestCase("faulty_unparsableVoorland_Z_noValue2.prfl", 11, "-100.000")] + [TestCase("faulty_unparsableVoorland_Roughness_noValue1.prfl", 11, "-100.000\t-6.000\t\t\t\t")] + [TestCase("faulty_unparsableVoorland_Roughness_noValue2.prfl", 12, "-18.000\t-6.000")] + [TestCase("faulty_unparsableVoorland_tooManyValues.prfl", 11, "18.000\t6.000\t1.000\t985.345")] + public void ReadDikeProfileData_NoRoughnessPointDefinition_ThrowsCriticalFileReadException( + string faultyFileName, int expectedLineNumber, string expectedReadText) + { + string expectedMessage = string.Format("De ingelezen regel ('{0}') is geen 'X Y ruwheid' definitie.", expectedReadText); + ReadFileAndExpectCriticalFileReadException(faultyFileName, expectedLineNumber, expectedMessage); + } + + [Test] [TestCase("faulty_unparsableDijk_X_Overflow1.prfl", 18, "X-coördinaat", "99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999")] [TestCase("faulty_unparsableDijk_X_Overflow2.prfl", 18, "X-coördinaat", "-44444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444")] [TestCase("faulty_unparsableDijk_Z_Overflow1.prfl", 19, "Z-coördinaat", "88888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888.8")] @@ -571,11 +579,16 @@ } [Test] - public void ReadDikeProfileData_FileWithMissingDikePoints_ThrowsCriticalFileReadException() + [TestCase("faulty_unparsableDijk_missingElements.prfl", 19, 2, 4)] + [TestCase("faulty_unparsableDijk_X_noValue1.prfl", 18, 1, 4)] + [TestCase("faulty_unparsableDijk_X_noValue2.prfl", 18, 1, 4)] + public void ReadDikeProfileData_FileWithMissingDikePoints_ThrowsCriticalFileReadException( + string faultyFileName, int expectedLineNumber, int actualCount, int expectedCount) { - string expectedMessage = "Het aantal dijk punten in het bestand ('2') komt niet overeen met de aangegeven hoeveelheid dijk punten (4)."; - ReadFileAndExpectCriticalFileReadException("faulty_unparsableDijk_missingElements.prfl", - 19, expectedMessage); + string expectedMessage = string.Format("Het aantal dijk punten in het bestand ('{0}') komt niet overeen met de aangegeven hoeveelheid dijk punten ({1}).", + actualCount, expectedCount); + ReadFileAndExpectCriticalFileReadException(faultyFileName, + expectedLineNumber, expectedMessage); } [Test] @@ -615,9 +628,9 @@ } [Test] - public void ReadDikeProfileData_FileWithOverflowForeshoreCount_ThrowsCriticalFileReadException() + public void ReadDikeProfileData_FileWithNegativeForeshoreCount_ThrowsCriticalFileReadException() { - string expectedMessage = "Het ingelezen aantal geometriepunten voorland (-1) mag niet negatief zijn."; + string expectedMessage = "Het ingelezen aantal geometriepunten voorland ('-1') mag niet negatief zijn."; ReadFileAndExpectCriticalFileReadException("faulty_voorlandCountNegative.prfl", 9, expectedMessage); } Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/DikeProfiles/faulty_unparsableDijk_tooManyValues.prfl =================================================================== diff -u --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/DikeProfiles/faulty_unparsableDijk_tooManyValues.prfl (revision 0) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/DikeProfiles/faulty_unparsableDijk_tooManyValues.prfl (revision f17b6b3fc9a23b521185b7a3ee5398571a4f1fa7) @@ -0,0 +1,22 @@ +VERSIE 4.0 +ID profiel001 + +RICHTING 330 + +DAM 0 +DAMHOOGTE 0 + +VOORLAND 0 + +DAMWAND 0 +KRUINHOOGTE 6 +DIJK 2 +0.000 0.000 1.000 12.34 +18.000 6.000 1.000 + +MEMO +Verkenning prfl format: +Basis: +geen dam +geen voorland +recht talud Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/DikeProfiles/faulty_unparsableVoorland_Roughness.prfl =================================================================== diff -u -r02b9c1938c77fec1599daf755bc1e7e70598621c -rf17b6b3fc9a23b521185b7a3ee5398571a4f1fa7 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/DikeProfiles/faulty_unparsableVoorland_Roughness.prfl (.../faulty_unparsableVoorland_Roughness.prfl) (revision 02b9c1938c77fec1599daf755bc1e7e70598621c) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/DikeProfiles/faulty_unparsableVoorland_Roughness.prfl (.../faulty_unparsableVoorland_Roughness.prfl) (revision f17b6b3fc9a23b521185b7a3ee5398571a4f1fa7) @@ -7,7 +7,7 @@ DAMHOOGTE 0.5 VOORLAND 3 --150.000 -9.000 ;lsduglk wab +-150.000 -9.000 ;lsduglkwab -100.000 -6.000 1.000 -18.000 -6.000 1.000 Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/DikeProfiles/faulty_unparsableVoorland_tooManyValues.prfl =================================================================== diff -u --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/DikeProfiles/faulty_unparsableVoorland_tooManyValues.prfl (revision 0) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/DikeProfiles/faulty_unparsableVoorland_tooManyValues.prfl (revision f17b6b3fc9a23b521185b7a3ee5398571a4f1fa7) @@ -0,0 +1,24 @@ +VERSIE 4.0 +ID profiel001 + +RICHTING 330 + +DAM 0 +DAMHOOGTE 0 + +VOORLAND 2 +0.000 0.000 1.000 +18.000 6.000 1.000 985.345 + +DAMWAND 0 +KRUINHOOGTE 6 +DIJK 2 +0.000 0.000 1.000 +18.000 6.000 1.000 + +MEMO +Verkenning prfl format: +Basis: +geen dam +geen voorland +recht talud