Index: Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs =================================================================== diff -u -r1fa1ff1080811742abffbd23346b23cf1a8aef3d -rda8e78c538a77ceea5a0709122e9e28ef573507b --- Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 1fa1ff1080811742abffbd23346b23cf1a8aef3d) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision da8e78c538a77ceea5a0709122e9e28ef573507b) @@ -1571,6 +1571,66 @@ } /// + /// Looks up a localized string similar to Kan geen ondergrondmodellen lezen. Mogelijk bestaat de '{0}' tabel niet.. + /// + public static string SoilDatabaseConstraintsReader_VerifyConstraints_Can_not_read_StochasticSoilModel_Perhaps_table_missing { + get { + return ResourceManager.GetString("SoilDatabaseConstraintsReader_VerifyConstraints_Can_not_read_StochasticSoilModel_" + + "Perhaps_table_missing", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Kan geen ondergrondschematisaties lezen. Mogelijk bestaat de '{0}' tabel niet.. + /// + public static string SoilDatabaseConstraintsReader_VerifyConstraints_Can_not_read_StochasticSoilProfile_Perhaps_table_missing { + get { + return ResourceManager.GetString("SoilDatabaseConstraintsReader_VerifyConstraints_Can_not_read_StochasticSoilProfil" + + "e_Perhaps_table_missing", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Er zijn stochastische ondergrondschematisaties zonder geldige kans van voorkomen.. + /// + public static string SoilDatabaseConstraintsReader_VerifyConstraints_Invalid_StochasticSoilProfile_probability { + get { + return ResourceManager.GetString("SoilDatabaseConstraintsReader_VerifyConstraints_Invalid_StochasticSoilProfile_pro" + + "bability", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Namen van ondergrondmodellen zijn niet uniek.. + /// + public static string SoilDatabaseConstraintsReader_VerifyConstraints_Non_unique_StochasticSoilModel_names { + get { + return ResourceManager.GetString("SoilDatabaseConstraintsReader_VerifyConstraints_Non_unique_StochasticSoilModel_na" + + "mes", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Onverwachte fout tijdens het verifiëren van unieke ondergrondmodelnamen.. + /// + public static string SoilDatabaseConstraintsReader_VerifyConstraints_Unexpected_error_while_verifying_unique_StochasticSoilModel_names { + get { + return ResourceManager.GetString("SoilDatabaseConstraintsReader_VerifyConstraints_Unexpected_error_while_verifying_" + + "unique_StochasticSoilModel_names", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Onverwachte fout tijdens het verifiëren van kansen van voorkomen voor profielen.. + /// + public static string SoilDatabaseConstraintsReader_VerifyConstraints_Unexpected_error_while_verifying_valid_StochasticSoilProfile_probability { + get { + return ResourceManager.GetString("SoilDatabaseConstraintsReader_VerifyConstraints_Unexpected_error_while_verifying_" + + "valid_StochasticSoilProfile_probability", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Kritieke fout opgetreden bij het uitlezen van waardes uit kolommen in de database.. /// public static string SoilProfileReader_Critical_Unexpected_value_on_column { Index: Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx =================================================================== diff -u -r1fa1ff1080811742abffbd23346b23cf1a8aef3d -rda8e78c538a77ceea5a0709122e9e28ef573507b --- Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx (.../Resources.resx) (revision 1fa1ff1080811742abffbd23346b23cf1a8aef3d) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx (.../Resources.resx) (revision da8e78c538a77ceea5a0709122e9e28ef573507b) @@ -797,4 +797,22 @@ De database heeft niet de vereiste versie informatie. Vereiste versie is '{0}'. + + Kan geen ondergrondmodellen lezen. Mogelijk bestaat de '{0}' tabel niet. + + + Namen van ondergrondmodellen zijn niet uniek. + + + Onverwachte fout tijdens het verifiëren van unieke ondergrondmodelnamen. + + + Er zijn stochastische ondergrondschematisaties zonder geldige kans van voorkomen. + + + Onverwachte fout tijdens het verifiëren van kansen van voorkomen voor profielen. + + + Kan geen ondergrondschematisaties lezen. Mogelijk bestaat de '{0}' tabel niet. + \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj =================================================================== diff -u -r866f2505f3d89a2a96a810d18419c840946d0d3b -rda8e78c538a77ceea5a0709122e9e28ef573507b --- Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj (.../Ringtoets.Common.IO.csproj) (revision 866f2505f3d89a2a96a810d18419c840946d0d3b) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj (.../Ringtoets.Common.IO.csproj) (revision da8e78c538a77ceea5a0709122e9e28ef573507b) @@ -117,6 +117,8 @@ + + Index: Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/Schema/StochasticSoilModelTableDefinitions.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/Schema/StochasticSoilModelTableDefinitions.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/Schema/StochasticSoilModelTableDefinitions.cs (revision da8e78c538a77ceea5a0709122e9e28ef573507b) @@ -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.Common.IO.SoilProfile.Schema +{ + /// + /// Defines the table and column names of the table 'StochasticSoilModel' in the DSoil-Model database. + /// + internal static class StochasticSoilModelTableDefinitions + { + /// + /// Gets the name of the table. + /// + public const string TableName = "StochasticSoilModel"; + + /// + /// Gets the name of the stochastic soil model name column. + /// + public const string StochasticSoilModelName = "SSM_Name"; + + /// + /// Gets the name of the alias used for identifying if segments are unique. + /// + public const string AreSegmentsUnique = "AreSegmentsUnique"; + } +} \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/Schema/StochasticSoilProfileTableDefinitions.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/Schema/StochasticSoilProfileTableDefinitions.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/Schema/StochasticSoilProfileTableDefinitions.cs (revision da8e78c538a77ceea5a0709122e9e28ef573507b) @@ -0,0 +1,60 @@ +// 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.Common.IO.SoilProfile.Schema +{ + /// + /// Defines the table and column names of the table 'StochasticSoilProfile' in the DSoil-Model database. + /// + internal static class StochasticSoilProfileTableDefinitions + { + /// + /// Gets the name of the table. + /// + public const string TableName = "StochasticSoilProfile"; + + /// + /// Gets the name of the stochastic soil model id column. + /// + public const string StochasticSoilModelId = "SSM_ID"; + + /// + /// Gets the name of the stochastic soil profile 1D id column. + /// + public const string SoilProfile1DId = "SP1D_ID"; + + /// + /// Gets the name of the stochastic soil profile 2D id column. + /// + public const string SoilProfile2DId = "SP2D_ID"; + + /// + /// Gets the name of the stochastic soil profile probability column. + /// + public const string Probability = "Probability"; + + /// + /// Gets the name of the alias used for identifying if the database consists only of + /// valid probabilities. + /// + public const string AllProbabilitiesValid = "AllProbabilitiesValid"; + } +} \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/SoilDatabaseConstraintsReader.cs =================================================================== diff -u -r866f2505f3d89a2a96a810d18419c840946d0d3b -rda8e78c538a77ceea5a0709122e9e28ef573507b --- Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/SoilDatabaseConstraintsReader.cs (.../SoilDatabaseConstraintsReader.cs) (revision 866f2505f3d89a2a96a810d18419c840946d0d3b) +++ Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/SoilDatabaseConstraintsReader.cs (.../SoilDatabaseConstraintsReader.cs) (revision da8e78c538a77ceea5a0709122e9e28ef573507b) @@ -19,8 +19,14 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; +using System.Data; +using System.Data.SQLite; using Core.Common.Base.IO; using Core.Common.IO.Readers; +using Core.Common.Utils.Builders; +using Ringtoets.Common.IO.Properties; +using Ringtoets.Common.IO.SoilProfile.Schema; namespace Ringtoets.Common.IO.SoilProfile { @@ -34,10 +40,117 @@ /// which will use the as its source. /// /// The path of the database file to open. - /// Thrown when: + /// Thrown when: + /// /// The contains invalid characters. /// No file could be found at . - /// + /// + /// public SoilDatabaseConstraintsReader(string databaseFilePath) : base(databaseFilePath) {} + + /// + /// Verifies that the database meets required constraints. + /// + /// Thrown when: + /// + /// Required information for constraint evaluation could not be read; + /// The database segment names are not unique. + /// + /// + public void VerifyConstraints() + { + try + { + ReadUniqueSegements(); + } + catch (SQLiteException exception) + { + throw new CriticalFileReadException( + BuildMessageWithPath(string.Format( + Resources.SoilDatabaseConstraintsReader_VerifyConstraints_Can_not_read_StochasticSoilModel_Perhaps_table_missing, + StochasticSoilModelTableDefinitions.TableName)), + exception); + } + + try + { + ReadAllProbabilitiesValid(); + } + catch (SQLiteException exception) + { + throw new CriticalFileReadException( + BuildMessageWithPath(string.Format( + Resources.SoilDatabaseConstraintsReader_VerifyConstraints_Can_not_read_StochasticSoilProfile_Perhaps_table_missing, + StochasticSoilProfileTableDefinitions.TableName)), + exception); + } + } + + /// + /// Verifies that the segments in the database are unique. + /// + /// Thrown when the execution the query failed. + /// Thrown when: + /// + /// The database segments could not be read; + /// The database segments are not unique. + /// + /// + private void ReadUniqueSegements() + { + string query = SoilDatabaseQueryBuilder.GetSoilModelNamesUniqueQuery(); + using (IDataReader dataReader = CreateDataReader(query)) + { + if (!dataReader.Read()) + { + throw new CriticalFileReadException( + BuildMessageWithPath(Resources.SoilDatabaseConstraintsReader_VerifyConstraints_Unexpected_error_while_verifying_unique_StochasticSoilModel_names)); + } + if (!Convert.ToBoolean(dataReader[StochasticSoilModelTableDefinitions.AreSegmentsUnique])) + { + throw new CriticalFileReadException( + BuildMessageWithPath(Resources.SoilDatabaseConstraintsReader_VerifyConstraints_Non_unique_StochasticSoilModel_names)); + } + } + } + + /// + /// Verifies that the probabilities in the database are valid. + /// + /// Thrown when the execution the query failed. + /// Thrown when: + /// + /// The probabilities could not be read. + /// One or more probabilities are not valid. + /// A valid probability: + /// + /// has a value in the interval [0.0, 1.0]; + /// is not null. + /// + /// + /// + /// + private void ReadAllProbabilitiesValid() + { + string checkSegmentNameUniqueness = SoilDatabaseQueryBuilder.GetStochasticSoilProfileProbabilitiesValidQuery(); + using (IDataReader dataReader = CreateDataReader(checkSegmentNameUniqueness)) + { + if (!dataReader.Read()) + { + throw new CriticalFileReadException( + BuildMessageWithPath(Resources.SoilDatabaseConstraintsReader_VerifyConstraints_Unexpected_error_while_verifying_valid_StochasticSoilProfile_probability)); + } + if (!Convert.ToBoolean(dataReader[StochasticSoilProfileTableDefinitions.AllProbabilitiesValid])) + { + throw new CriticalFileReadException( + BuildMessageWithPath(Resources.SoilDatabaseConstraintsReader_VerifyConstraints_Invalid_StochasticSoilProfile_probability)); + } + } + } + + private string BuildMessageWithPath(string innerMessage) + { + return new FileReaderErrorMessageBuilder(Path).Build(innerMessage); + } } } \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/SoilDatabaseQueryBuilder.cs =================================================================== diff -u -r1fa1ff1080811742abffbd23346b23cf1a8aef3d -rda8e78c538a77ceea5a0709122e9e28ef573507b --- Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/SoilDatabaseQueryBuilder.cs (.../SoilDatabaseQueryBuilder.cs) (revision 1fa1ff1080811742abffbd23346b23cf1a8aef3d) +++ Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/SoilDatabaseQueryBuilder.cs (.../SoilDatabaseQueryBuilder.cs) (revision da8e78c538a77ceea5a0709122e9e28ef573507b) @@ -41,5 +41,37 @@ $"WHERE {MetaTableDefinitions.Key} = 'VERSION' " + $"AND {MetaTableDefinitions.Value} = @{MetaTableDefinitions.Value};"; } + + /// + /// Returns the SQL query to execute to check if segment names in the DSoil-Model database + /// are unique. + /// + /// The SQL query to execute. + public static string GetSoilModelNamesUniqueQuery() + { + return string.Format( + "SELECT [All].nameCount == [Distinct].nameCount AS {0} " + + "FROM (SELECT COUNT({1}) nameCount FROM {2}) AS [All] " + + "JOIN (SELECT COUNT(DISTINCT {1}) nameCount FROM {2}) AS [Distinct];", + StochasticSoilModelTableDefinitions.AreSegmentsUnique, + StochasticSoilModelTableDefinitions.StochasticSoilModelName, + StochasticSoilModelTableDefinitions.TableName); + } + + /// + /// Returns the SQL query to execute to check if the probabilities of the stochastic + /// soil profiles are valid. + /// + /// The SQL query to execute. + public static string GetStochasticSoilProfileProbabilitiesValidQuery() + { + return string.Format( + "SELECT COUNT({1}) == 0 AS {0} " + + "FROM {2} " + + "WHERE {1} NOT BETWEEN 0 AND 1 OR {1} ISNULL;", + StochasticSoilProfileTableDefinitions.AllProbabilitiesValid, + StochasticSoilProfileTableDefinitions.Probability, + StochasticSoilProfileTableDefinitions.TableName); + } } } \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilDatabaseConstraintsReaderTest.cs =================================================================== diff -u -r866f2505f3d89a2a96a810d18419c840946d0d3b -rda8e78c538a77ceea5a0709122e9e28ef573507b --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilDatabaseConstraintsReaderTest.cs (.../SoilDatabaseConstraintsReaderTest.cs) (revision 866f2505f3d89a2a96a810d18419c840946d0d3b) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilDatabaseConstraintsReaderTest.cs (.../SoilDatabaseConstraintsReaderTest.cs) (revision da8e78c538a77ceea5a0709122e9e28ef573507b) @@ -82,5 +82,94 @@ Assert.IsTrue(TestHelper.CanOpenFileForWrite(dbFile)); } + + [Test] + public void VerifyConstraints_MissingStochasticSoilModelTable_ThrowsCriticalFileReadException() + { + // Setup + string dbFile = Path.Combine(testDataPath, "missingStochasticSoilModelTable.soil"); + + using (var versionReader = new SoilDatabaseConstraintsReader(dbFile)) + { + // Call + TestDelegate test = () => versionReader.VerifyConstraints(); + + // Assert + var exception = Assert.Throws(test); + + string expectedMessage = new FileReaderErrorMessageBuilder(dbFile).Build( + "Kan geen ondergrondmodellen lezen. Mogelijk bestaat de 'StochasticSoilModel' tabel niet."); + Assert.AreEqual(expectedMessage, exception.Message); + } + + Assert.IsTrue(TestHelper.CanOpenFileForWrite(dbFile)); + } + + [Test] + public void VerifyConstraints_MissingStochasticSoilProfileTable_ThrowsCriticalFileReadException() + { + // Setup + string dbFile = Path.Combine(testDataPath, "missingStochasticSoilProfileTable.soil"); + + using (var versionReader = new SoilDatabaseConstraintsReader(dbFile)) + { + // Call + TestDelegate test = () => versionReader.VerifyConstraints(); + + // Assert + var exception = Assert.Throws(test); + + string expectedMessage = new FileReaderErrorMessageBuilder(dbFile).Build( + "Kan geen ondergrondschematisaties lezen. Mogelijk bestaat de 'StochasticSoilProfile' tabel niet."); + Assert.AreEqual(expectedMessage, exception.Message); + } + + Assert.IsTrue(TestHelper.CanOpenFileForWrite(dbFile)); + } + + [Test] + public void VerifyConstraints_NonUniqueSoilModelNames_ThrowsCriticalFileReadException() + { + // Setup + string dbFile = Path.Combine(testDataPath, "nonUniqueSoilModelNames.soil"); + + using (var versionReader = new SoilDatabaseConstraintsReader(dbFile)) + { + // Call + TestDelegate test = () => versionReader.VerifyConstraints(); + + // Assert + var exception = Assert.Throws(test); + + string expectedMessage = new FileReaderErrorMessageBuilder(dbFile).Build( + "Namen van ondergrondmodellen zijn niet uniek."); + Assert.AreEqual(expectedMessage, exception.Message); + } + + Assert.IsTrue(TestHelper.CanOpenFileForWrite(dbFile)); + } + + [Test] + public void VerifyConstraints_MissingStochasticSoilProfileProbability_ThrowsCriticalFileReadException() + { + // Setup + string dbFile = Path.Combine(testDataPath, "missingStochasticSoilProfileProbability.soil"); + + // Call + using (var versionReader = new SoilDatabaseConstraintsReader(dbFile)) + { + // Call + TestDelegate test = () => versionReader.VerifyConstraints(); + + // Assert + var exception = Assert.Throws(test); + + string expectedMessage = new FileReaderErrorMessageBuilder(dbFile).Build( + "Er zijn stochastische ondergrondschematisaties zonder geldige kans van voorkomen."); + Assert.AreEqual(expectedMessage, exception.Message); + } + + Assert.IsTrue(TestHelper.CanOpenFileForWrite(dbFile)); + } } } \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilDatabaseQueryBuilderTest.cs =================================================================== diff -u -r1fa1ff1080811742abffbd23346b23cf1a8aef3d -rda8e78c538a77ceea5a0709122e9e28ef573507b --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilDatabaseQueryBuilderTest.cs (.../SoilDatabaseQueryBuilderTest.cs) (revision 1fa1ff1080811742abffbd23346b23cf1a8aef3d) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilDatabaseQueryBuilderTest.cs (.../SoilDatabaseQueryBuilderTest.cs) (revision da8e78c538a77ceea5a0709122e9e28ef573507b) @@ -40,5 +40,32 @@ "AND Value = @Value;"; Assert.AreEqual(expectedQuery, query); } + + [Test] + public void GetSoilModelNamesUniqueQuery_Always_ReturnsExpectedValues() + { + // Call + string query = SoilDatabaseQueryBuilder.GetSoilModelNamesUniqueQuery(); + + // Assert + const string expectedQuery = + "SELECT [All].nameCount == [Distinct].nameCount AS AreSegmentsUnique " + + "FROM (SELECT COUNT(SSM_Name) nameCount FROM StochasticSoilModel) AS [All] " + + "JOIN (SELECT COUNT(DISTINCT SSM_Name) nameCount FROM StochasticSoilModel) AS [Distinct];"; + Assert.AreEqual(expectedQuery, query); + } + + [Test] + public void GetStochasticSoilProfileProbabilitiesDefinedQuery_Always_ReturnsExpectedValues() + { + // Call + string query = SoilDatabaseQueryBuilder.GetStochasticSoilProfileProbabilitiesValidQuery(); + + // Assert + const string expectedQuery = "SELECT COUNT(Probability) == 0 AS HasNoInvalidProbabilities " + + "FROM StochasticSoilProfile " + + "WHERE Probability NOT BETWEEN 0 AND 1 OR Probability ISNULL;"; + Assert.AreEqual(expectedQuery, query); + } } } \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/StochasticSoilModelReaderTest.cs =================================================================== diff -u -r190069e93048bfb7abe5a190ada915e4b4e782b0 -rda8e78c538a77ceea5a0709122e9e28ef573507b --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/StochasticSoilModelReaderTest.cs (.../StochasticSoilModelReaderTest.cs) (revision 190069e93048bfb7abe5a190ada915e4b4e782b0) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/StochasticSoilModelReaderTest.cs (.../StochasticSoilModelReaderTest.cs) (revision da8e78c538a77ceea5a0709122e9e28ef573507b) @@ -86,14 +86,14 @@ [Test] [TestCase("text.txt")] [TestCase("empty.soil")] - public void Constructor_IncorrectFormatFileOrInvalidSchema_ThrowsCriticalFileReadException(string dbName) + public void Initialize_IncorrectFormatFileOrInvalidSchema_ThrowsCriticalFileReadException(string dbName) { // Setup string dbFile = Path.Combine(testDataPath, dbName); - // Call using (var reader = new StochasticSoilModelReader(dbFile)) { + // Call TestDelegate test = () => reader.Initialize(); // Assert @@ -108,14 +108,14 @@ } [Test] - public void Constructor_IncorrectVersion_ThrowsCriticalFileReadException() + public void Initialize_IncorrectVersion_ThrowsCriticalFileReadException() { // Setup string dbFile = Path.Combine(testDataPath, "incorrectVersion.soil"); - // Call using (var reader = new StochasticSoilModelReader(dbFile)) { + // Call TestDelegate test = () => reader.Initialize(); // Assert @@ -127,6 +127,7 @@ $"Vereiste versie is '{version}'."); Assert.AreEqual(expectedMessage, exception.Message); } + Assert.IsTrue(TestHelper.CanOpenFileForWrite(dbFile)); } } Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/test-data/SoilDatabaseConstraintsReader/missingStochasticSoilModelTable.soil =================================================================== diff -u Binary files differ Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/test-data/SoilDatabaseConstraintsReader/missingStochasticSoilProfileProbability.soil =================================================================== diff -u Binary files differ Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/test-data/SoilDatabaseConstraintsReader/missingStochasticSoilProfileTable.soil =================================================================== diff -u Binary files differ Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/test-data/SoilDatabaseConstraintsReader/nonUniqueSoilModelNames.soil =================================================================== diff -u Binary files differ