Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Parsers/HydraRingDatabaseParseHelper.cs =================================================================== diff -u -r64d60335b1deab4bafd37f78f3514660cc4afb27 -re73c8b159778b281ecb275512f42da65c0d02e9d --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Parsers/HydraRingDatabaseParseHelper.cs (.../HydraRingDatabaseParseHelper.cs) (revision 64d60335b1deab4bafd37f78f3514660cc4afb27) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Parsers/HydraRingDatabaseParseHelper.cs (.../HydraRingDatabaseParseHelper.cs) (revision e73c8b159778b281ecb275512f42da65c0d02e9d) @@ -56,17 +56,33 @@ { using (var reader = new HydraRingDatabaseReader(workingDirectory, query, sectionId)) { - return reader.ReadLine(); + return ReadLineFromReader(exceptionMessage, reader); } } catch (SQLiteException e) { throw new HydraRingFileParserException(Resources.Parse_Cannot_read_result_in_output_file, e); } - catch (HydraRingDatabaseReaderException e) + } + + /// + /// Tries to read a result from the reader and throws an exception if no row could be read. + /// + /// The message to use in the exception when reading fails. + /// The reader to read a row from. + /// A single row from the reader. + /// Thrown when no row could be read from the reader + /// . + private static Dictionary ReadLineFromReader(string exceptionMessage, HydraRingDatabaseReader reader) + { + Dictionary result = reader.ReadLine(); + + if (result != null) { - throw new HydraRingFileParserException(exceptionMessage, e); + return result; } + + throw new HydraRingFileParserException(exceptionMessage); } private static void ValidateParameters(string workingDirectory, Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Parsers/IllustrationPoints/GeneralResult.cs =================================================================== diff -u --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Parsers/IllustrationPoints/GeneralResult.cs (revision 0) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Parsers/IllustrationPoints/GeneralResult.cs (revision e73c8b159778b281ecb275512f42da65c0d02e9d) @@ -0,0 +1,52 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.Collections.Generic; + +namespace Ringtoets.HydraRing.Calculation.Parsers.IllustrationPoints +{ + /// + /// The general illustration points result. + /// + public class GeneralResult + { + /// + /// Gets or sets the general beta value. + /// + public double Beta { get; set; } + + /// + /// Gets or sets the governing wind direction. + /// + public WindDirection GoverningWind { get; set; } + + /// + /// Gets or sets the general alpha values. + /// + public IEnumerable Stochasts { get; set; } + + /// + /// Gets or sets the tree of illustration points for each + /// wind direction and closing situation. + /// + public IEnumerable IllustrationPoints { get; set; } + } +} \ No newline at end of file Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Parsers/IllustrationPoints/IIllustrationPoint.cs =================================================================== diff -u --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Parsers/IllustrationPoints/IIllustrationPoint.cs (revision 0) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Parsers/IllustrationPoints/IIllustrationPoint.cs (revision e73c8b159778b281ecb275512f42da65c0d02e9d) @@ -0,0 +1,28 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +namespace Ringtoets.HydraRing.Calculation.Parsers.IllustrationPoints +{ + public interface IIllustrationPoint + { + + } +} \ No newline at end of file Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Parsers/IllustrationPoints/IllustrationPointQueries.cs =================================================================== diff -u --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Parsers/IllustrationPoints/IllustrationPointQueries.cs (revision 0) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Parsers/IllustrationPoints/IllustrationPointQueries.cs (revision e73c8b159778b281ecb275512f42da65c0d02e9d) @@ -0,0 +1,95 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +namespace Ringtoets.HydraRing.Calculation.Parsers.IllustrationPoints +{ + public static class IllustrationPointQueries + { + public static readonly string ClosingSituations = + $"SELECT {IllustrationPointsDatabaseConstants.ClosingSituationId}, " + + "ClosingSituationName " + + "FROM ClosingSituations;"; + + public static readonly string WindDirections = + $"SELECT WindDirections.{IllustrationPointsDatabaseConstants.WindDirectionId}, " + + $"{IllustrationPointsDatabaseConstants.WindDirectionName}, " + + $"{IllustrationPointsDatabaseConstants.WindDirectionAngle}, " + + $"WindDirections.WindDirectionId = GoverningWind.WindDirectionId as {IllustrationPointsDatabaseConstants.IsGoverning} " + + "FROM WindDirections " + + "JOIN GoverningWind " + + "WHERE OuterIterationId = (SELECT MAX(OuterIterationID) FROM GoverningWind);"; + + public static readonly string GeneralAlphaValues = + $"SELECT {IllustrationPointsDatabaseConstants.StochastName}, " + + $"{IllustrationPointsDatabaseConstants.AlphaValue}, " + + $"{IllustrationPointsDatabaseConstants.Duration} " + + "FROM DesignAlpha " + + "JOIN Stochasts USING(StochastId) " + + "WHERE LevelTypeId = 3 " + + "AND OuterIterationId = (SELECT MAX(OuterIterationId) FROM DesignAlpha) " + + "AND PeriodId = (SELECT MIN(PeriodId) FROM DesignAlpha);"; + + public static readonly string GeneralBetaValues = + $"SELECT {IllustrationPointsDatabaseConstants.BetaValue} " + + "FROM DesignBeta " + + "WHERE LevelTypeId = 3 " + + "AND OuterIterationId = (SELECT MAX(OuterIterationId) FROM DesignAlpha) " + + "AND PeriodId = (SELECT MIN(PeriodId) FROM DesignAlpha);"; + + public static readonly string RecursiveFaultTree = + "WITH RECURSIVE " + + "child_of(" + + $"{IllustrationPointsDatabaseConstants.RecursiveFaultTreeId}, " + + $"{IllustrationPointsDatabaseConstants.RecursiveFaultTreeChildId}, " + + $"{IllustrationPointsDatabaseConstants.RecursiveFaultTreeType}, " + + $"{IllustrationPointsDatabaseConstants.RecursiveFaultTreeCombine}" + + ") AS(" + + "SELECT FaultTreeId, Id1, Type1, CombinFunction " + + "FROM FaultTrees " + + "UNION " + + "SELECT FaultTreeId, Id2, Type2, CombinFunction " + + "FROM FaultTrees)," + + $"children(" + + $"{IllustrationPointsDatabaseConstants.RecursiveFaultTreeParentId}, " + + $"{IllustrationPointsDatabaseConstants.RecursiveFaultTreeId}, " + + $"{IllustrationPointsDatabaseConstants.RecursiveFaultTreeType}, " + + $"{IllustrationPointsDatabaseConstants.RecursiveFaultTreeCombine}" + + $") AS(" + + $"SELECT {IllustrationPointsDatabaseConstants.RecursiveFaultTreeId}, " + + $"{IllustrationPointsDatabaseConstants.RecursiveFaultTreeChildId}, " + + $"child_of.{IllustrationPointsDatabaseConstants.RecursiveFaultTreeType}, " + + $"child_of.{IllustrationPointsDatabaseConstants.RecursiveFaultTreeCombine} " + + "FROM child_of " + + "WHERE id NOT IN " + + $"(SELECT {IllustrationPointsDatabaseConstants.RecursiveFaultTreeChildId} FROM child_of) " + + "UNION ALL " + + "SELECT id, child_id, child_of.type, child_of.combine " + + "FROM child_of " + + $"JOIN children USING({IllustrationPointsDatabaseConstants.RecursiveFaultTreeId}) " + + $"WHERE children.{IllustrationPointsDatabaseConstants.RecursiveFaultTreeType} = \"faulttree\") " + + "SELECT " + + $"{IllustrationPointsDatabaseConstants.RecursiveFaultTreeParentId}, " + + $"{IllustrationPointsDatabaseConstants.RecursiveFaultTreeId}, " + + $"{IllustrationPointsDatabaseConstants.RecursiveFaultTreeType}, " + + $"{IllustrationPointsDatabaseConstants.RecursiveFaultTreeCombine} " + + $"FROM children;"; + } +} \ No newline at end of file Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Parsers/IllustrationPoints/IllustrationPointsDatabaseConstants.cs =================================================================== diff -u --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Parsers/IllustrationPoints/IllustrationPointsDatabaseConstants.cs (revision 0) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Parsers/IllustrationPoints/IllustrationPointsDatabaseConstants.cs (revision e73c8b159778b281ecb275512f42da65c0d02e9d) @@ -0,0 +1,46 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +namespace Ringtoets.HydraRing.Calculation.Parsers.IllustrationPoints +{ + public static class IllustrationPointsDatabaseConstants + { + public const string ClosingSituationId = "ClosingSituationId"; + public const string ClosingSituationName = "ClosingSituationName"; + + public const string WindDirectionId = "WindDirectionId"; + public const string WindDirectionName = "WindDirectionName"; + public const string WindDirectionAngle = "WindDirectionAngle"; + public const string IsGoverning = "IsGoverning"; + + public const string StochastName = "StochastName"; + public const string AlphaValue = "AlphaValue"; + public const string Duration = "Duration"; + + public const string BetaValue = "BetaValue"; + + public const string RecursiveFaultTreeId = "id"; + public const string RecursiveFaultTreeChildId = "childId"; + public const string RecursiveFaultTreeType = "type"; + public const string RecursiveFaultTreeCombine = "combine"; + public const string RecursiveFaultTreeParentId = "parentId"; + } +} \ No newline at end of file Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Parsers/IllustrationPoints/IllustrationPointsParser.cs =================================================================== diff -u --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Parsers/IllustrationPoints/IllustrationPointsParser.cs (revision 0) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Parsers/IllustrationPoints/IllustrationPointsParser.cs (revision e73c8b159778b281ecb275512f42da65c0d02e9d) @@ -0,0 +1,140 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.Generic; +using System.Data.SQLite; +using System.Linq; +using Ringtoets.HydraRing.Calculation.Exceptions; +using Ringtoets.HydraRing.Calculation.Properties; +using Ringtoets.HydraRing.Calculation.Readers; + +namespace Ringtoets.HydraRing.Calculation.Parsers.IllustrationPoints +{ + public class IllustrationPointsParser : IHydraRingFileParser + { + public GeneralResult Output = new GeneralResult(); + + private IDictionary windDirections; + private IDictionary closingSituations; + + public void Parse(string workingDirectory, int sectionId) + { + string query = string.Concat( + IllustrationPointQueries.ClosingSituations, + IllustrationPointQueries.WindDirections, + IllustrationPointQueries.GeneralAlphaValues, + IllustrationPointQueries.GeneralBetaValues); + + try + { + using (var reader = new HydraRingDatabaseReader(workingDirectory, query, sectionId)) + { + ParseResultsFromReader(reader); + } + } + catch (SQLiteException e) + { + throw new HydraRingFileParserException(Resources.Parse_Cannot_read_result_in_output_file, e); + } + catch (HydraRingDatabaseReaderException e) + { + throw new HydraRingFileParserException("Er konden geen illustratiepunten worden uitgelezen.", e); + } + } + + private void ParseResultsFromReader(HydraRingDatabaseReader reader) + { + ParseClosingSituations(reader); + reader.NextResult(); + ParseWindDirections(reader); + reader.NextResult(); + ParseAlphaValues(reader); + reader.NextResult(); + ParseBetaValue(reader); + } + + private void ParseBetaValue(HydraRingDatabaseReader reader) + { + IEnumerable> betaValues = GetIterator(reader).TakeWhile(r => r != null).ToArray(); + if (betaValues.Count() != 1) + { + throw new HydraRingFileParserException("Ongeldig aantal beta-waarden gevonden in de uitvoer database."); + } + Output.Beta = Convert.ToDouble(betaValues.First()[IllustrationPointsDatabaseConstants.BetaValue]); + } + + private void ParseAlphaValues(HydraRingDatabaseReader reader) + { + IEnumerable> alphaValues = GetIterator(reader).TakeWhile(r => r != null).ToArray(); + Output.Stochasts = alphaValues.Select(a => new Stochast + { + Name = Convert.ToString(a[IllustrationPointsDatabaseConstants.StochastName]), + Duration = Convert.ToDouble(a[IllustrationPointsDatabaseConstants.Duration]), + Alpha= Convert.ToDouble(a[IllustrationPointsDatabaseConstants.AlphaValue]) + }); + } + + private void ParseClosingSituations(HydraRingDatabaseReader reader) + { + IEnumerable> readClosingSituations = GetIterator(reader).TakeWhile(r => r != null).ToArray(); + closingSituations = readClosingSituations.ToDictionary( + r => Convert.ToInt32(r[IllustrationPointsDatabaseConstants.ClosingSituationId]), + r => Convert.ToString(r[IllustrationPointsDatabaseConstants.ClosingSituationName])); + } + + private void ParseWindDirections(HydraRingDatabaseReader reader) + { + IEnumerable> readWindDirections = GetIterator(reader).TakeWhile(r => r != null).ToArray(); + windDirections = new Dictionary(); + + foreach (Dictionary readWindDirection in readWindDirections) + { + int key = Convert.ToInt32(readWindDirection[IllustrationPointsDatabaseConstants.WindDirectionId]); + string name = Convert.ToString(readWindDirection[IllustrationPointsDatabaseConstants.WindDirectionName]); + double angle = Convert.ToDouble(readWindDirection[IllustrationPointsDatabaseConstants.WindDirectionAngle]); + bool isGoverning = Convert.ToBoolean(readWindDirection[IllustrationPointsDatabaseConstants.IsGoverning]); + + var windDirection = new WindDirection + { + Name = name, + Angle = angle + }; + windDirections[key] = windDirection; + + if (isGoverning) + { + Output.GoverningWind = windDirection; + } + } + } + + private static IEnumerable> GetIterator(HydraRingDatabaseReader reader) + { + Dictionary nextLine = reader.ReadLine(); + while (nextLine != null) + { + yield return nextLine; + nextLine = reader.ReadLine(); + } + } + } +} \ No newline at end of file Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Parsers/IllustrationPoints/Stochast.cs =================================================================== diff -u --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Parsers/IllustrationPoints/Stochast.cs (revision 0) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Parsers/IllustrationPoints/Stochast.cs (revision e73c8b159778b281ecb275512f42da65c0d02e9d) @@ -0,0 +1,44 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +namespace Ringtoets.HydraRing.Calculation.Parsers.IllustrationPoints +{ + /// + /// Container of alpha value definitions read from Hydra-Ringt output database. + /// + public class Stochast + { + /// + /// Gets or sets the name. + /// + public string Name { get; set; } + + /// + /// Gets or sets the duration. + /// + public double Duration { get; set; } + + /// + /// Getst he alpha value. + /// + public double Alpha { get; set; } + } +} \ No newline at end of file Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Parsers/IllustrationPoints/WindDirection.cs =================================================================== diff -u --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Parsers/IllustrationPoints/WindDirection.cs (revision 0) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Parsers/IllustrationPoints/WindDirection.cs (revision e73c8b159778b281ecb275512f42da65c0d02e9d) @@ -0,0 +1,39 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +namespace Ringtoets.HydraRing.Calculation.Parsers.IllustrationPoints +{ + /// + /// A wind direction for which illustration points are determined. + /// + public class WindDirection + { + /// + /// Gets or sets the descriptive name. + /// + public string Name { get; set; } + + /// + /// Gets or sets the angle. + /// + public double Angle { get; set; } + } +} \ No newline at end of file Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Properties/Resources.Designer.cs =================================================================== diff -u -r64d60335b1deab4bafd37f78f3514660cc4afb27 -re73c8b159778b281ecb275512f42da65c0d02e9d --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 64d60335b1deab4bafd37f78f3514660cc4afb27) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision e73c8b159778b281ecb275512f42da65c0d02e9d) @@ -129,15 +129,6 @@ } /// - /// Looks up a localized string similar to Er is geen resultaat gevonden in de Hydra-Ring uitvoerdatabase.. - /// - internal static string HydraRingDatabaseReader_ReadLine_No_result_found_in_output_file { - get { - return ResourceManager.GetString("HydraRingDatabaseReader_ReadLine_No_result_found_in_output_file", resourceCulture); - } - } - - /// /// Looks up a localized string similar to Er is geen resultaat voor overslag en overloop gevonden in de Hydra-Ring uitvoerdatabase.. /// internal static string OvertoppingCalculationWaveHeightParser_No_overtopping_found_in_output_file { Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Properties/Resources.resx =================================================================== diff -u -r0a9f50b4c382d49930b77076c658edf370c7a24e -re73c8b159778b281ecb275512f42da65c0d02e9d --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Properties/Resources.resx (.../Resources.resx) (revision 0a9f50b4c382d49930b77076c658edf370c7a24e) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Properties/Resources.resx (.../Resources.resx) (revision e73c8b159778b281ecb275512f42da65c0d02e9d) @@ -132,9 +132,6 @@ Er is geen resultaat voor convergentie gevonden in de Hydra-Ring uitvoerdatabase. - - Er is geen resultaat gevonden in de Hydra-Ring uitvoerdatabase. - Er zijn geen berekende hydraulische randvoorwaarden voor duinen gevonden in de Hydra-Ring uitvoerdatabase. Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Readers/HydraRingDatabaseReader.cs =================================================================== diff -u -r64d60335b1deab4bafd37f78f3514660cc4afb27 -re73c8b159778b281ecb275512f42da65c0d02e9d --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Readers/HydraRingDatabaseReader.cs (.../HydraRingDatabaseReader.cs) (revision 64d60335b1deab4bafd37f78f3514660cc4afb27) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Readers/HydraRingDatabaseReader.cs (.../HydraRingDatabaseReader.cs) (revision e73c8b159778b281ecb275512f42da65c0d02e9d) @@ -85,9 +85,8 @@ /// Executes the query on the database and reads the next row. /// /// A with the key - /// of the column and the value. - /// Thrown when - /// an error encounters while reading the database. + /// of the column and the value. Or null if no row could + /// be read from the reader. public Dictionary ReadLine() { if (reader.Read()) @@ -102,7 +101,7 @@ return results; } - throw new HydraRingDatabaseReaderException(Resources.HydraRingDatabaseReader_ReadLine_No_result_found_in_output_file); + return null; } public void Dispose() @@ -159,5 +158,15 @@ { connection.Open(); } + + /// + /// Progresses the reader to the next result in the data set. + /// + /// true if there was another result in the data set, false + /// otherwise. + public bool NextResult() + { + return reader.NextResult(); + } } } \ No newline at end of file Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Ringtoets.HydraRing.Calculation.csproj =================================================================== diff -u -r547e6a16b5e70f0ca02efea0e86cc744d572a588 -re73c8b159778b281ecb275512f42da65c0d02e9d --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Ringtoets.HydraRing.Calculation.csproj (.../Ringtoets.HydraRing.Calculation.csproj) (revision 547e6a16b5e70f0ca02efea0e86cc744d572a588) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Ringtoets.HydraRing.Calculation.csproj (.../Ringtoets.HydraRing.Calculation.csproj) (revision e73c8b159778b281ecb275512f42da65c0d02e9d) @@ -111,6 +111,13 @@ + + + + + + + Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Parsers/ConvergenceParserTest.cs =================================================================== diff -u -r64d60335b1deab4bafd37f78f3514660cc4afb27 -re73c8b159778b281ecb275512f42da65c0d02e9d --- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Parsers/ConvergenceParserTest.cs (.../ConvergenceParserTest.cs) (revision 64d60335b1deab4bafd37f78f3514660cc4afb27) +++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Parsers/ConvergenceParserTest.cs (.../ConvergenceParserTest.cs) (revision e73c8b159778b281ecb275512f42da65c0d02e9d) @@ -105,7 +105,6 @@ // Assert var exception = Assert.Throws(test); Assert.AreEqual("Er is geen resultaat voor convergentie gevonden in de Hydra-Ring uitvoerdatabase.", exception.Message); - Assert.IsInstanceOf(exception.InnerException); } [Test] @@ -121,7 +120,6 @@ // Assert var exception = Assert.Throws(test); Assert.AreEqual("Er is geen resultaat voor convergentie gevonden in de Hydra-Ring uitvoerdatabase.", exception.Message); - Assert.IsInstanceOf(exception.InnerException); } [Test] Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Parsers/DunesBoundaryConditionsCalculationParserTest.cs =================================================================== diff -u -r64d60335b1deab4bafd37f78f3514660cc4afb27 -re73c8b159778b281ecb275512f42da65c0d02e9d --- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Parsers/DunesBoundaryConditionsCalculationParserTest.cs (.../DunesBoundaryConditionsCalculationParserTest.cs) (revision 64d60335b1deab4bafd37f78f3514660cc4afb27) +++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Parsers/DunesBoundaryConditionsCalculationParserTest.cs (.../DunesBoundaryConditionsCalculationParserTest.cs) (revision e73c8b159778b281ecb275512f42da65c0d02e9d) @@ -107,7 +107,6 @@ // Assert var exception = Assert.Throws(test); Assert.AreEqual("Er zijn geen berekende hydraulische randvoorwaarden voor duinen gevonden in de Hydra-Ring uitvoerdatabase.", exception.Message); - Assert.IsInstanceOf(exception.InnerException); } [Test] @@ -163,7 +162,6 @@ // Assert var exception = Assert.Throws(test); Assert.AreEqual("Er zijn geen berekende hydraulische randvoorwaarden voor duinen gevonden in de Hydra-Ring uitvoerdatabase.", exception.Message); - Assert.IsInstanceOf(exception.InnerException); } [Test] Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Parsers/ExceedanceProbabilityCalculationParserTest.cs =================================================================== diff -u -r64d60335b1deab4bafd37f78f3514660cc4afb27 -re73c8b159778b281ecb275512f42da65c0d02e9d --- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Parsers/ExceedanceProbabilityCalculationParserTest.cs (.../ExceedanceProbabilityCalculationParserTest.cs) (revision 64d60335b1deab4bafd37f78f3514660cc4afb27) +++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Parsers/ExceedanceProbabilityCalculationParserTest.cs (.../ExceedanceProbabilityCalculationParserTest.cs) (revision e73c8b159778b281ecb275512f42da65c0d02e9d) @@ -107,7 +107,6 @@ // Assert var exception = Assert.Throws(test); Assert.AreEqual("Er is geen resultaat voor de betrouwbaarheidsindex van de faalkans gevonden in de Hydra-Ring uitvoerdatabase.", exception.Message); - Assert.IsInstanceOf(exception.InnerException); } [Test] @@ -123,7 +122,6 @@ // Assert var exception = Assert.Throws(test); Assert.AreEqual("Er is geen resultaat voor de betrouwbaarheidsindex van de faalkans gevonden in de Hydra-Ring uitvoerdatabase.", exception.Message); - Assert.IsInstanceOf(exception.InnerException); } [Test] Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Parsers/IllustrationPoints/IllustrationPointsParserTest.cs =================================================================== diff -u --- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Parsers/IllustrationPoints/IllustrationPointsParserTest.cs (revision 0) +++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Parsers/IllustrationPoints/IllustrationPointsParserTest.cs (revision e73c8b159778b281ecb275512f42da65c0d02e9d) @@ -0,0 +1,144 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Data.SQLite; +using System.IO; +using System.Linq; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.HydraRing.Calculation.Exceptions; +using Ringtoets.HydraRing.Calculation.Parsers; +using Ringtoets.HydraRing.Calculation.Parsers.IllustrationPoints; + +namespace Ringtoets.HydraRing.Calculation.Test.Parsers.IllustrationPoints +{ + [TestFixture] + public class IllustrationPointsParserTest + { + private readonly string testDirectory = Path.Combine(TestHelper.GetTestDataPath(TestDataPath.Ringtoets.HydraRing.Calculation, "Parsers"), + nameof(IllustrationPointsParser)); + + [Test] + public void DefaultConstructor_CreatesNewParserInstance() + { + // Call + var parser = new IllustrationPointsParser(); + + // Assert + Assert.IsInstanceOf(parser); + } + + [Test] + public void Parse_WorkingDirectoryNull_ThrowsArgumentNullException() + { + // Setup + var parser = new IllustrationPointsParser(); + + // Call + TestDelegate test = () => parser.Parse(null, 0); + + // Assert + Assert.Throws(test); + } + + [Test] + public void Parse_WithWorkingDirectoryWithoutExpectedFile_ThrowsHydraRingFileParserException() + { + // Setup + string path = Path.Combine(testDirectory, "EmptyWorkingDirectory"); + var parser = new IllustrationPointsParser(); + + // Call + TestDelegate test = () => parser.Parse(path, 1); + + // Assert + var exception = Assert.Throws(test); + Assert.IsInstanceOf(exception.InnerException); + } + + [Test] + public void Parse_WithWorkingDirectoryWithInvalidOutputFile_ThrowsHydraRingFileParserException() + { + // Setup + string path = Path.Combine(testDirectory, "InvalidFile"); + var parser = new IllustrationPointsParser(); + + // Call + TestDelegate test = () => parser.Parse(path, 1); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("Er kon geen resultaat gelezen worden uit de Hydra-Ring uitvoerdatabase.", exception.Message); + Assert.IsInstanceOf(exception.InnerException); + } + + [Test] + public void Parse_WithWorkingDirectoryWithEmptyFile_ThrowsHydraRingFileParserException() + { + // Setup + string path = Path.Combine(testDirectory, "EmptyDatabase"); + var parser = new IllustrationPointsParser(); + + // Call + TestDelegate test = () => parser.Parse(path, 1); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("Er kon geen resultaat gelezen worden uit de Hydra-Ring uitvoerdatabase.", exception.Message); + Assert.IsInstanceOf(exception.InnerException); + } + + [Test] + public void Parse_ValidDataForOtherSection_ThrowsHydraRingFileParserException() + { + // Setup + string path = Path.Combine(testDirectory, "ValidOutputSection1"); + var parser = new IllustrationPointsParser(); + + // Call + TestDelegate test = () => parser.Parse(path, 2); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("Er kon geen resultaat gelezen worden uit de Hydra-Ring uitvoerdatabase.", exception.Message); + Assert.IsInstanceOf(exception.InnerException); + } + + [Test] + public void Parse_ValidData_SetsOutputAsExpected() + { + // Setup + string path = Path.Combine(testDirectory, "ValidOutputSection1"); + var parser = new IllustrationPointsParser(); + + // Call + parser.Parse(path, 1); + + // Assert + GeneralResult generalResult = parser.Output; + Assert.NotNull(generalResult); + Assert.NotNull(generalResult.GoverningWind); + Assert.AreEqual(1.19513, generalResult.Beta); + Assert.AreEqual(46, generalResult.Stochasts.Count()); + } + } +} \ No newline at end of file Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Parsers/ReliabilityIndexCalculationParserTest.cs =================================================================== diff -u -r64d60335b1deab4bafd37f78f3514660cc4afb27 -re73c8b159778b281ecb275512f42da65c0d02e9d --- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Parsers/ReliabilityIndexCalculationParserTest.cs (.../ReliabilityIndexCalculationParserTest.cs) (revision 64d60335b1deab4bafd37f78f3514660cc4afb27) +++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Parsers/ReliabilityIndexCalculationParserTest.cs (.../ReliabilityIndexCalculationParserTest.cs) (revision e73c8b159778b281ecb275512f42da65c0d02e9d) @@ -107,7 +107,6 @@ // Assert var exception = Assert.Throws(test); Assert.AreEqual("Er is geen resultaat voor de betrouwbaarheidsindex van de berekende kans van voorkomen gevonden in de Hydra-Ring uitvoerdatabase.", exception.Message); - Assert.IsInstanceOf(exception.InnerException); } [Test] @@ -123,7 +122,6 @@ // Assert var exception = Assert.Throws(test); Assert.AreEqual("Er is geen resultaat voor de betrouwbaarheidsindex van de berekende kans van voorkomen gevonden in de Hydra-Ring uitvoerdatabase.", exception.Message); - Assert.IsInstanceOf(exception.InnerException); } [Test] Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Parsers/WaveConditionsCalculationParserTest.cs =================================================================== diff -u -r64d60335b1deab4bafd37f78f3514660cc4afb27 -re73c8b159778b281ecb275512f42da65c0d02e9d --- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Parsers/WaveConditionsCalculationParserTest.cs (.../WaveConditionsCalculationParserTest.cs) (revision 64d60335b1deab4bafd37f78f3514660cc4afb27) +++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Parsers/WaveConditionsCalculationParserTest.cs (.../WaveConditionsCalculationParserTest.cs) (revision e73c8b159778b281ecb275512f42da65c0d02e9d) @@ -107,7 +107,6 @@ // Assert var exception = Assert.Throws(test); Assert.AreEqual("Er zijn geen berekende golfcondities gevonden in de Hydra-Ring uitvoerdatabase.", exception.Message); - Assert.IsInstanceOf(exception.InnerException); } [Test] @@ -163,7 +162,6 @@ // Assert var exception = Assert.Throws(test); Assert.AreEqual("Er zijn geen berekende golfcondities gevonden in de Hydra-Ring uitvoerdatabase.", exception.Message); - Assert.IsInstanceOf(exception.InnerException); } [Test] Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Readers/HydraRingDatabaseReaderTest.cs =================================================================== diff -u -r64d60335b1deab4bafd37f78f3514660cc4afb27 -re73c8b159778b281ecb275512f42da65c0d02e9d --- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Readers/HydraRingDatabaseReaderTest.cs (.../HydraRingDatabaseReaderTest.cs) (revision 64d60335b1deab4bafd37f78f3514660cc4afb27) +++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Readers/HydraRingDatabaseReaderTest.cs (.../HydraRingDatabaseReaderTest.cs) (revision e73c8b159778b281ecb275512f42da65c0d02e9d) @@ -20,6 +20,7 @@ // All rights reserved. using System; +using System.Collections.Generic; using System.Data.SQLite; using System.IO; using Core.Common.TestUtil; @@ -112,19 +113,18 @@ } [Test] - public void Execute_EmptyDatabase_ThrowHydraRingDatabaseReaderException() + public void ReadLine_EmptyDatabase_ReturnsNull() { // Setup string directory = Path.Combine(testDirectory, emptyDatabase); using (var reader = new HydraRingDatabaseReader(directory, query, 1)) { // Call - TestDelegate test = () => reader.ReadLine(); + Dictionary result = reader.ReadLine(); // Assert - var exception = Assert.Throws(test); - Assert.AreEqual("Er is geen resultaat gevonden in de Hydra-Ring uitvoerdatabase.", exception.Message); + Assert.IsNull(result); } } } Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Ringtoets.HydraRing.Calculation.Test.csproj =================================================================== diff -u -rb5aaaf16698b5af5d9285277587a55043c271ac4 -re73c8b159778b281ecb275512f42da65c0d02e9d --- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Ringtoets.HydraRing.Calculation.Test.csproj (.../Ringtoets.HydraRing.Calculation.Test.csproj) (revision b5aaaf16698b5af5d9285277587a55043c271ac4) +++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Ringtoets.HydraRing.Calculation.Test.csproj (.../Ringtoets.HydraRing.Calculation.Test.csproj) (revision e73c8b159778b281ecb275512f42da65c0d02e9d) @@ -110,6 +110,7 @@ + Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/test-data/Parsers/IllustrationPointsParser/EmptyDatabase/1-output.sqlite =================================================================== diff -u Binary files differ Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/test-data/Parsers/IllustrationPointsParser/InvalidFile/1-output.sqlite =================================================================== diff -u --- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/test-data/Parsers/IllustrationPointsParser/InvalidFile/1-output.sqlite (revision 0) +++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/test-data/Parsers/IllustrationPointsParser/InvalidFile/1-output.sqlite (revision e73c8b159778b281ecb275512f42da65c0d02e9d) @@ -0,0 +1 @@ \ No newline at end of file Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/test-data/Parsers/IllustrationPointsParser/ValidOutputSection1/1-output.sqlite =================================================================== diff -u Binary files differ