Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Ringtoets.Piping.IO.Test.csproj =================================================================== diff -u -rd8d7d3d24763ec06d36322d9a57996a83a64653b -r9a9a99ad27ee6fdcd22f0df408b868816502647e --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Ringtoets.Piping.IO.Test.csproj (.../Ringtoets.Piping.IO.Test.csproj) (revision d8d7d3d24763ec06d36322d9a57996a83a64653b) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Ringtoets.Piping.IO.Test.csproj (.../Ringtoets.Piping.IO.Test.csproj) (revision 9a9a99ad27ee6fdcd22f0df408b868816502647e) @@ -79,6 +79,7 @@ + Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilDatabaseConstraintsReaderTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilDatabaseConstraintsReaderTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilDatabaseConstraintsReaderTest.cs (revision 9a9a99ad27ee6fdcd22f0df408b868816502647e) @@ -0,0 +1,92 @@ +// Copyright (C) Stichting Deltares 2016. 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.IO.Exceptions; +using Core.Common.TestUtil; +using Core.Common.Utils.Builders; +using NUnit.Framework; +using Ringtoets.Piping.IO.SoilProfile; +using UtilsResources = Core.Common.Utils.Properties.Resources; + +namespace Ringtoets.Piping.IO.Test.SoilProfile +{ + [TestFixture] + public class SoilDatabaseConstraintsReaderTest + { + private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Piping.IO, "SoilDatabaseConstraintsReader"); + + [Test] + public void Constructor_NonExistingPath_ThrowsCriticalFileReadException() + { + // Setup + var testFile = Path.Combine(testDataPath, "none.soil"); + + // Call + TestDelegate test = () => { using (new SoilDatabaseConstraintsReader(testFile)) { } }; + + // Assert + CriticalFileReadException exception = Assert.Throws(test); + string expectedMessage = new FileReaderErrorMessageBuilder(testFile).Build(UtilsResources.Error_File_does_not_exist); + Assert.AreEqual(expectedMessage, exception.Message); + } + + [Test] + [TestCase(null)] + [TestCase("")] + public void Constructor_FileNullOrEmpty_ThrowsCriticalFileReadException(string fileName) + { + // Setup + var expectedMessage = $"Fout bij het lezen van bestand '{fileName}': bestandspad mag niet leeg of ongedefinieerd zijn."; + // Call + TestDelegate test = () => { using (new SoilDatabaseConstraintsReader(fileName)) { } }; + + // Assert + CriticalFileReadException exception = Assert.Throws(test); + Assert.AreEqual(expectedMessage, exception.Message); + } + + [Test] + [TestCase("nonUniqueSoilModelNames.soil")] + public void Constructor_NonUniqueSoilModelNames_ThrowsCriticalFileReadException(string dbName) + { + // Setup + string dbFile = Path.Combine(testDataPath, dbName); + string expectedMessage = new FileReaderErrorMessageBuilder(dbFile). + Build("Namen van ondergrondmodellen zijn niet uniek."); + + // Precondition + Assert.IsTrue(TestHelper.CanOpenFileForWrite(dbFile), "Precondition: file can be opened for edits."); + + // Call + using (var versionReader = new SoilDatabaseConstraintsReader(dbFile)) + { + // Call + TestDelegate test = () => versionReader.VerifyConstraints(); + + // Assert + CriticalFileReadException exception = Assert.Throws(test); + Assert.AreEqual(expectedMessage, exception.Message); + } + Assert.IsTrue(TestHelper.CanOpenFileForWrite(dbFile)); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/StochasticSoilModelReaderTest.cs =================================================================== diff -u -re1a8e98d60853beefbdb8c84e70f14165680ad7b -r9a9a99ad27ee6fdcd22f0df408b868816502647e --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/StochasticSoilModelReaderTest.cs (.../StochasticSoilModelReaderTest.cs) (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/StochasticSoilModelReaderTest.cs (.../StochasticSoilModelReaderTest.cs) (revision 9a9a99ad27ee6fdcd22f0df408b868816502647e) @@ -93,11 +93,10 @@ } [Test] - [TestCase("withoutSoilModelTables.soil")] - public void Constructor_InvalidSchemaThatPassesValidation_ThrowsCriticalFileReadException(string dbName) + public void Constructor_InvalidSchemaThatPassesValidation_ThrowsCriticalFileReadException() { // Setup - string dbFile = Path.Combine(testDataPath, dbName); + string dbFile = Path.Combine(testDataPath, "withoutSoilModelTables.soil"); string expectedMessage = new FileReaderErrorMessageBuilder(dbFile). Build("Kan geen ondergrondmodellen lezen. Mogelijk bestaat de 'Segment' tabel niet."); @@ -114,11 +113,11 @@ } [Test] - [TestCase("nonUniqueSoilModelNames.soil")] - public void Constructor_NonUniqueSoilModelNames_ThrowsCriticalFileReadException(string dbName) + public void Constructor_NonUniqueSoilModelNames_ThrowsCriticalFileReadException() { // Setup - string dbFile = Path.Combine(testDataPath, dbName); + string path = Path.Combine(TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Piping.IO.Path, "SoilDatabaseConstraintsReader")); + string dbFile = Path.Combine(path, "nonUniqueSoilModelNames.soil"); string expectedMessage = new FileReaderErrorMessageBuilder(dbFile). Build("Namen van ondergrondmodellen zijn niet uniek."); Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/SoilDatabaseConstraintsReader/nonUniqueSoilModelNames.soil =================================================================== diff -u Binary files differ Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/StochasticSoilModelDatabaseReader/nonUniqueSoilModelNames.soil =================================================================== diff -u -re1a8e98d60853beefbdb8c84e70f14165680ad7b -r9a9a99ad27ee6fdcd22f0df408b868816502647e Binary files differ