Index: Core/Common/src/Core.Common.IO/Readers/SqLiteDatabaseReaderBase.cs =================================================================== diff -u -r67284323e2785c651633d9c52049ba12a9c70e6a -r7516bd32d4eea4904a5ed0ba43a05ad8e5c868f3 --- Core/Common/src/Core.Common.IO/Readers/SqLiteDatabaseReaderBase.cs (.../SqLiteDatabaseReaderBase.cs) (revision 67284323e2785c651633d9c52049ba12a9c70e6a) +++ Core/Common/src/Core.Common.IO/Readers/SqLiteDatabaseReaderBase.cs (.../SqLiteDatabaseReaderBase.cs) (revision 7516bd32d4eea4904a5ed0ba43a05ad8e5c868f3) @@ -91,10 +91,10 @@ protected SQLiteConnection Connection { get; private set; } /// - /// Moves to and reads the next resultset in multiple row-returning SQL command. + /// Moves to and reads the next result set in multiple row-returning SQL command. /// /// The to process. - /// True if the command was successful and a new resultset is available, false otherwise. + /// True if the command was successful and a new result set is available, false otherwise. protected static bool MoveNext(IDataReader sqliteDataReader) { return sqliteDataReader.Read() || sqliteDataReader.NextResult() && sqliteDataReader.Read(); @@ -104,7 +104,7 @@ /// Creates a new , based upon and . /// /// The query to execute. - /// Parameters the is dependend on. + /// Parameters the is depended on. /// A new instance of . /// The execution of failed. protected IDataReader CreateDataReader(string queryString, params SQLiteParameter[] parameters) Index: Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj =================================================================== diff -u -r683ff9234262d9fa3bea5edc0abe35254f80e49d -r7516bd32d4eea4904a5ed0ba43a05ad8e5c868f3 --- Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj (.../Ringtoets.Common.IO.csproj) (revision 683ff9234262d9fa3bea5edc0abe35254f80e49d) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj (.../Ringtoets.Common.IO.csproj) (revision 7516bd32d4eea4904a5ed0ba43a05ad8e5c868f3) @@ -116,6 +116,8 @@ + + Index: Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/SoilDatabaseVersionReader.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/SoilDatabaseVersionReader.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/SoilDatabaseVersionReader.cs (revision 7516bd32d4eea4904a5ed0ba43a05ad8e5c868f3) @@ -0,0 +1,45 @@ +// 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 Core.Common.Base.IO; +using Core.Common.IO.Readers; + +namespace Ringtoets.Common.IO.SoilProfile +{ + /// + /// This class reads a soil database file and reads version from this database. + /// + public class SoilDatabaseVersionReader : SqLiteDatabaseReaderBase + { + /// + /// Creates a new instance of , + /// which will use the as its source. + /// + /// The path of the database file to open. + /// Thrown when: + /// The contains invalid characters. + /// No file could be found at . + /// The database version could not be read. + /// The database version is incorrect. + /// + public SoilDatabaseVersionReader(string databaseFilePath) : base(databaseFilePath) {} + } +} \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/StochasticSoilModelReader.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/StochasticSoilModelReader.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/StochasticSoilModelReader.cs (revision 7516bd32d4eea4904a5ed0ba43a05ad8e5c868f3) @@ -0,0 +1,53 @@ +// 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 Core.Common.Base.IO; +using Core.Common.IO.Readers; + +namespace Ringtoets.Common.IO.SoilProfile +{ + /// + /// This class reads a DSoil database file and reads stochastic soil model from this database. + /// + public class StochasticSoilModelReader : SqLiteDatabaseReaderBase + { + /// + /// Creates a new instance of , + /// which will use the as its source. + /// + /// The path of the database file to open. + /// Thrown when: + /// The contains invalid characters. + /// No file could be found at . + /// The database version could not be read. + /// The database version is incorrect. + /// + public StochasticSoilModelReader(string databaseFilePath) : base(databaseFilePath) + { + VerifyVersion(databaseFilePath); + } + + private void VerifyVersion(string databaseFilePath) + { + using (new SoilDatabaseVersionReader(databaseFilePath)) {} + } + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj =================================================================== diff -u -r683ff9234262d9fa3bea5edc0abe35254f80e49d -r7516bd32d4eea4904a5ed0ba43a05ad8e5c868f3 --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj (.../Ringtoets.Common.IO.Test.csproj) (revision 683ff9234262d9fa3bea5edc0abe35254f80e49d) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj (.../Ringtoets.Common.IO.Test.csproj) (revision 7516bd32d4eea4904a5ed0ba43a05ad8e5c868f3) @@ -109,6 +109,8 @@ + + Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilDatabaseVersionReaderTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilDatabaseVersionReaderTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilDatabaseVersionReaderTest.cs (revision 7516bd32d4eea4904a5ed0ba43a05ad8e5c868f3) @@ -0,0 +1,86 @@ +// 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.IO; +using Core.Common.Base.IO; +using Core.Common.IO.Readers; +using Core.Common.TestUtil; +using Core.Common.Utils.Builders; +using NUnit.Framework; +using Ringtoets.Common.IO.SoilProfile; + +namespace Ringtoets.Common.IO.Test.SoilProfile +{ + [TestFixture] + public class SoilDatabaseVersionReaderTest + { + private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, nameof(SoilDatabaseVersionReader)); + + [Test] + public void Constructor_NonExistingPath_ThrowsCriticalFileReadException() + { + // Setup + string testFile = Path.Combine(testDataPath, "does not exist"); + + // Call + TestDelegate test = () => + { + using (new SoilDatabaseVersionReader(testFile)) {} + }; + + // Assert + var exception = Assert.Throws(test); + string expectedMessage = new FileReaderErrorMessageBuilder(testFile).Build("Het bestand bestaat niet."); + Assert.AreEqual(expectedMessage, exception.Message); + } + + [Test] + [TestCaseSource(typeof(InvalidPathHelper), nameof(InvalidPathHelper.InvalidPaths))] + public void Constructor_FileNullOrEmpty_ThrowsCriticalFileReadException(string fileName) + { + // Call + TestDelegate test = () => + { + using (new SoilDatabaseVersionReader(fileName)) {} + }; + + // Assert + Assert.Throws(test); + } + + [Test] + public void Constructor_PathToExistingFile_ExpectedValues() + { + // Setup + const string dbName = "emptyschema.soil"; + string dbFile = Path.Combine(testDataPath, dbName); + + // Call + using (var reader = new SoilDatabaseVersionReader(dbFile)) + { + // Assert + Assert.AreEqual(dbFile, reader.Path); + Assert.IsInstanceOf(reader); + } + Assert.IsTrue(TestHelper.CanOpenFileForWrite(dbFile)); + } + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/StochasticSoilModelReaderTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/StochasticSoilModelReaderTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/StochasticSoilModelReaderTest.cs (revision 7516bd32d4eea4904a5ed0ba43a05ad8e5c868f3) @@ -0,0 +1,86 @@ +// 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.IO; +using Core.Common.Base.IO; +using Core.Common.IO.Readers; +using Core.Common.TestUtil; +using Core.Common.Utils.Builders; +using NUnit.Framework; +using Ringtoets.Common.IO.SoilProfile; + +namespace Ringtoets.Common.IO.Test.SoilProfile +{ + [TestFixture] + public class StochasticSoilModelReaderTest + { + private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, nameof(StochasticSoilModelReader)); + + [Test] + public void Constructor_NonExistingPath_ThrowsCriticalFileReadException() + { + // Setup + string testFile = Path.Combine(testDataPath, "does not exist"); + + // Call + TestDelegate test = () => + { + using (new StochasticSoilModelReader(testFile)) {} + }; + + // Assert + var exception = Assert.Throws(test); + string expectedMessage = new FileReaderErrorMessageBuilder(testFile).Build("Het bestand bestaat niet."); + Assert.AreEqual(expectedMessage, exception.Message); + } + + [Test] + [TestCaseSource(typeof(InvalidPathHelper), nameof(InvalidPathHelper.InvalidPaths))] + public void Constructor_FileNullOrEmpty_ThrowsCriticalFileReadException(string fileName) + { + // Call + TestDelegate test = () => + { + using (new StochasticSoilModelReader(fileName)) {} + }; + + // Assert + Assert.Throws(test); + } + + [Test] + public void Constructor_PathToExistingFile_ExpectedValues() + { + // Setup + const string dbName = "emptyschema.soil"; + string dbFile = Path.Combine(testDataPath, dbName); + + // Call + using (var reader = new StochasticSoilModelReader(dbFile)) + { + // Assert + Assert.AreEqual(dbFile, reader.Path); + Assert.IsInstanceOf(reader); + } + Assert.IsTrue(TestHelper.CanOpenFileForWrite(dbFile)); + } + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/test-data/SoilDatabaseVersionReader/empty.soil =================================================================== diff -u Binary files differ Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/test-data/SoilDatabaseVersionReader/emptyschema.soil =================================================================== diff -u Binary files differ Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/test-data/StochasticSoilModelReader/empty.soil =================================================================== diff -u Binary files differ Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/test-data/StochasticSoilModelReader/emptyschema.soil =================================================================== diff -u Binary files differ