Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/Readers/ConfigurationReaderTest.cs
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.IO.Test/Readers/ConfigurationReaderTest.cs (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/Readers/ConfigurationReaderTest.cs (revision 24f0b189764d40cc8ee7e9efd62ee6c6ea8c7b5f)
@@ -0,0 +1,161 @@
+// 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;
+using System.IO;
+using System.Xml;
+using System.Xml.Linq;
+using Core.Common.IO.Exceptions;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Ringtoets.Common.IO.Readers;
+
+namespace Ringtoets.Common.IO.Test.Readers
+{
+ [TestFixture]
+ public class ConfigurationReaderTest
+ {
+ private readonly string testDirectoryPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO,
+ "ConfigurationReader");
+
+ [Test]
+ [TestCase("")]
+ [TestCase(" ")]
+ [TestCase(null)]
+ public void Constructor_NoFilePath_ThrowArgumentException(string invalidFilePath)
+ {
+ // Call
+ TestDelegate call = () => new TestConfigurationReader(invalidFilePath, "");
+
+ // Assert
+ string expectedMessage = $"Fout bij het lezen van bestand '{invalidFilePath}': bestandspad mag niet leeg of ongedefinieerd zijn.";
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage);
+ }
+
+ [Test]
+ public void Constructor_FilePathHasInvalidPathCharacter_ThrowArgumentException()
+ {
+ // Setup
+ char[] invalidPathChars = Path.GetInvalidPathChars();
+
+ string validFilePath = Path.Combine(testDirectoryPath, "validConfiguration.xml");
+ string invalidFilePath = validFilePath.Replace("Config", invalidPathChars[3].ToString());
+
+ // Call
+ TestDelegate call = () => new TestConfigurationReader(invalidFilePath, "");
+
+ // Assert
+ string expectedMessage = $"Fout bij het lezen van bestand '{invalidFilePath}': "
+ + "er zitten ongeldige tekens in het bestandspad. Alle tekens in het bestandspad moeten geldig zijn.";
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage);
+ }
+
+ [Test]
+ public void Constructor_FilePathIsActuallyDirectoryPath_ThrowArgumentException()
+ {
+ // Setup
+ string invalidFilePath = Path.Combine(testDirectoryPath, Path.DirectorySeparatorChar.ToString());
+
+ // Call
+ TestDelegate call = () => new TestConfigurationReader(invalidFilePath, "");
+
+ // Assert
+ string expectedMessage = $"Fout bij het lezen van bestand '{invalidFilePath}': bestandspad mag niet verwijzen naar een lege bestandsnaam.";
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage);
+ }
+
+ [Test]
+ public void Constructor_FileDoesNotExist_ThrowCriticalFileReadException()
+ {
+ // Setup
+ string invalidFilePath = Path.Combine(testDirectoryPath, "notExisting.xml");
+
+ // Call
+ TestDelegate call = () => new TestConfigurationReader(invalidFilePath, "");
+
+ // Assert
+ string expectedMessage = $"Fout bij het lezen van bestand '{invalidFilePath}': het bestand bestaat niet.";
+ string message = Assert.Throws(call).Message;
+ Assert.AreEqual(expectedMessage, message);
+ }
+
+ [Test]
+ [TestCase("empty.xml")]
+ [TestCase("textContent.xml")]
+ [TestCase("invalidXmlContent.xml")]
+ public void Constructor_FileDoesNotContainValidXml_ThrowCriticalFileReadException(string fileName)
+ {
+ // Setup
+ string filePath = Path.Combine(testDirectoryPath, fileName);
+
+ // Call
+ TestDelegate call = () => new TestConfigurationReader(filePath, "");
+
+ // Assert
+ string expectedMessage = $"Fout bij het lezen van bestand '{filePath}': het bestand kon niet worden geopend. Mogelijk is het bestand corrupt of in gebruik door een andere applicatie.";
+ var exception = Assert.Throws(call);
+ Assert.AreEqual(expectedMessage, exception.Message);
+ Assert.IsInstanceOf(exception.InnerException);
+ }
+
+ [Test]
+ public void Constructor_FileInUse_ThrowCriticalFileReadException()
+ {
+ // Setup
+ string path = TestHelper.GetScratchPadPath($"{nameof(ConfigurationReaderTest)}.{nameof(Constructor_FileInUse_ThrowCriticalFileReadException)}");
+
+ using (var fileDisposeHelper = new FileDisposeHelper(path))
+ {
+ fileDisposeHelper.LockFiles();
+
+ // Call
+ TestDelegate call = () => new TestConfigurationReader(path, "");
+
+ // Assert
+ string expectedMessage = $"Fout bij het lezen van bestand '{path}': het bestand kon niet worden geopend. Mogelijk is het bestand corrupt of in gebruik door een andere applicatie.";
+ var exception = Assert.Throws(call);
+ Assert.AreEqual(expectedMessage, exception.Message);
+ Assert.IsInstanceOf(exception.InnerException);
+ }
+ }
+
+ private class TestConfigurationReader : ConfigurationReader
+ {
+ public TestConfigurationReader(string xmlFilePath, string schemaString)
+ : base(xmlFilePath, schemaString) {}
+
+ protected override TestReadConfigurationItem ParseCalculationElement(XElement calculationElement)
+ {
+ return new TestReadConfigurationItem("Test");
+ }
+ }
+
+ private class TestReadConfigurationItem : IReadConfigurationItem
+ {
+ public TestReadConfigurationItem(string name)
+ {
+ Name = name;
+ }
+
+ public string Name { get; }
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj
===================================================================
diff -u -r59fcd17973dee55b14a079325767f28e8cb535c2 -r24f0b189764d40cc8ee7e9efd62ee6c6ea8c7b5f
--- Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj (.../Ringtoets.Common.IO.Test.csproj) (revision 59fcd17973dee55b14a079325767f28e8cb535c2)
+++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj (.../Ringtoets.Common.IO.Test.csproj) (revision 24f0b189764d40cc8ee7e9efd62ee6c6ea8c7b5f)
@@ -50,6 +50,8 @@
..\..\..\..\packages\System.Data.SQLite.Core.1.0.104.0\lib\net40\System.Data.SQLite.dll
True
+
+
@@ -76,6 +78,7 @@
+
Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/test-data/ConfigurationReader/empty.xml
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.IO.Test/test-data/ConfigurationReader/empty.xml (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/test-data/ConfigurationReader/empty.xml (revision 24f0b189764d40cc8ee7e9efd62ee6c6ea8c7b5f)
@@ -0,0 +1 @@
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/test-data/ConfigurationReader/invalidXmlContent.xml
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.IO.Test/test-data/ConfigurationReader/invalidXmlContent.xml (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/test-data/ConfigurationReader/invalidXmlContent.xml (revision 24f0b189764d40cc8ee7e9efd62ee6c6ea8c7b5f)
@@ -0,0 +1,37 @@
+
+
+
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/test-data/ConfigurationReader/textContent.xml
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.IO.Test/test-data/ConfigurationReader/textContent.xml (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/test-data/ConfigurationReader/textContent.xml (revision 24f0b189764d40cc8ee7e9efd62ee6c6ea8c7b5f)
@@ -0,0 +1 @@
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur faucibus finibus magna, sed pellentesque lorem imperdiet nec. Mauris porttitor nisl blandit placerat aliquet. Aliquam nisl arcu, pretium ut erat quis, congue sagittis odio. Maecenas felis ante, dictum aliquet laoreet ac, consectetur ac purus. Donec non tristique libero, ut vulputate est. Fusce hendrerit justo eu vehicula dignissim. Duis auctor velit vitae vestibulum bibendum. Proin nec pharetra est, id ultricies sem. Aliquam dignissim blandit accumsan. Phasellus bibendum magna sed vestibulum dictum. Nullam vel ipsum quis turpis pulvinar convallis a et lectus. Maecenas eros orci, suscipit id elementum et, fringilla eget ligula. Nulla elit tellus, varius a nisl eget, ornare tempor libero.
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/test-data/ConfigurationReader/validConfiguration.xml
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.IO.Test/test-data/ConfigurationReader/validConfiguration.xml (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/test-data/ConfigurationReader/validConfiguration.xml (revision 24f0b189764d40cc8ee7e9efd62ee6c6ea8c7b5f)
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Readers/PipingConfigurationReaderTest.cs
===================================================================
diff -u -rb0021f2db39d2455a22c14bd3708ff2fc2a9e817 -r24f0b189764d40cc8ee7e9efd62ee6c6ea8c7b5f
--- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Readers/PipingConfigurationReaderTest.cs (.../PipingConfigurationReaderTest.cs) (revision b0021f2db39d2455a22c14bd3708ff2fc2a9e817)
+++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Readers/PipingConfigurationReaderTest.cs (.../PipingConfigurationReaderTest.cs) (revision 24f0b189764d40cc8ee7e9efd62ee6c6ea8c7b5f)
@@ -19,11 +19,9 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
-using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
-using System.Xml;
using System.Xml.Schema;
using Core.Common.IO.Exceptions;
using Core.Common.TestUtil;
@@ -161,107 +159,6 @@
}
[Test]
- [TestCase("")]
- [TestCase(" ")]
- [TestCase(null)]
- public void Constructor_NoFilePath_ThrowArgumentException(string invalidFilePath)
- {
- // Call
- TestDelegate call = () => new PipingConfigurationReader(invalidFilePath);
-
- // Assert
- string expectedMessage = $"Fout bij het lezen van bestand '{invalidFilePath}': bestandspad mag niet leeg of ongedefinieerd zijn.";
- TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage);
- }
-
- [Test]
- public void Constructor_FilePathHasInvalidPathCharacter_ThrowArgumentException()
- {
- // Setup
- char[] invalidPathChars = Path.GetInvalidPathChars();
-
- string validFilePath = Path.Combine(testDirectoryPath, "validPipingConfiguration.xml");
- string invalidFilePath = validFilePath.Replace("Piping", invalidPathChars[3].ToString());
-
- // Call
- TestDelegate call = () => new PipingConfigurationReader(invalidFilePath);
-
- // Assert
- string expectedMessage = $"Fout bij het lezen van bestand '{invalidFilePath}': "
- + "er zitten ongeldige tekens in het bestandspad. Alle tekens in het bestandspad moeten geldig zijn.";
- TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage);
- }
-
- [Test]
- public void Constructor_FilePathIsActuallyDirectoryPath_ThrowArgumentException()
- {
- // Setup
- string invalidFilePath = Path.Combine(testDirectoryPath, Path.DirectorySeparatorChar.ToString());
-
- // Call
- TestDelegate call = () => new PipingConfigurationReader(invalidFilePath);
-
- // Assert
- string expectedMessage = $"Fout bij het lezen van bestand '{invalidFilePath}': bestandspad mag niet verwijzen naar een lege bestandsnaam.";
- TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage);
- }
-
- [Test]
- public void Constructor_FileDoesNotExist_ThrowCriticalFileReadException()
- {
- // Setup
- string invalidFilePath = Path.Combine(testDirectoryPath, "notExisting.xml");
-
- // Call
- TestDelegate call = () => new PipingConfigurationReader(invalidFilePath);
-
- // Assert
- string expectedMessage = $"Fout bij het lezen van bestand '{invalidFilePath}': het bestand bestaat niet.";
- string message = Assert.Throws(call).Message;
- Assert.AreEqual(expectedMessage, message);
- }
-
- [Test]
- [TestCase("empty.xml")]
- [TestCase("textContent.xml")]
- [TestCase("invalidXmlContent.xml")]
- public void Constructor_FileDoesNotContainValidXml_ThrowCriticalFileReadException(string fileName)
- {
- // Setup
- string filePath = Path.Combine(testDirectoryPath, fileName);
-
- // Call
- TestDelegate call = () => new PipingConfigurationReader(filePath);
-
- // Assert
- string expectedMessage = $"Fout bij het lezen van bestand '{filePath}': het bestand kon niet worden geopend. Mogelijk is het bestand corrupt of in gebruik door een andere applicatie.";
- var exception = Assert.Throws(call);
- Assert.AreEqual(expectedMessage, exception.Message);
- Assert.IsInstanceOf(exception.InnerException);
- }
-
- [Test]
- public void Constructor_FileInUse_ThrowCriticalFileReadException()
- {
- // Setup
- string path = TestHelper.GetScratchPadPath($"{nameof(PipingConfigurationReaderTest)}.{nameof(Constructor_FileInUse_ThrowCriticalFileReadException)}");
-
- using (var fileDisposeHelper = new FileDisposeHelper(path))
- {
- fileDisposeHelper.LockFiles();
-
- // Call
- TestDelegate call = () => new PipingConfigurationReader(path);
-
- // Assert
- string expectedMessage = $"Fout bij het lezen van bestand '{path}': het bestand kon niet worden geopend. Mogelijk is het bestand corrupt of in gebruik door een andere applicatie.";
- var exception = Assert.Throws(call);
- Assert.AreEqual(expectedMessage, exception.Message);
- Assert.IsInstanceOf(exception.InnerException);
- }
- }
-
- [Test]
[TestCaseSource(nameof(InvalidConfigurations))]
public void Constructor_FileInvalidBasedOnSchemaDefinition_ThrowCriticalFileReadException(string fileName, string expectedParsingMessage)
{
Fisheye: Tag 24f0b189764d40cc8ee7e9efd62ee6c6ea8c7b5f refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingConfigurationReader/empty.xml'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 24f0b189764d40cc8ee7e9efd62ee6c6ea8c7b5f refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingConfigurationReader/invalidXmlContent.xml'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 24f0b189764d40cc8ee7e9efd62ee6c6ea8c7b5f refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingConfigurationReader/textContent.xml'.
Fisheye: No comparison available. Pass `N' to diff?