Index: Ringtoets/Common/test/Ringtoets.Common.Service.Test/Ringtoets.Common.Service.Test.csproj
===================================================================
diff -u -rd3b14a0f327184e0239e5239c826805c565fe8be -r9a47425d33d7daef8270633eaff0314dbd4d55be
--- Ringtoets/Common/test/Ringtoets.Common.Service.Test/Ringtoets.Common.Service.Test.csproj (.../Ringtoets.Common.Service.Test.csproj) (revision d3b14a0f327184e0239e5239c826805c565fe8be)
+++ Ringtoets/Common/test/Ringtoets.Common.Service.Test/Ringtoets.Common.Service.Test.csproj (.../Ringtoets.Common.Service.Test.csproj) (revision 9a47425d33d7daef8270633eaff0314dbd4d55be)
@@ -52,6 +52,7 @@
+
Index: Ringtoets/Common/test/Ringtoets.Common.Service.Test/TargetProbabilityCalculationServiceTest.cs
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.Service.Test/TargetProbabilityCalculationServiceTest.cs (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.Service.Test/TargetProbabilityCalculationServiceTest.cs (revision 9a47425d33d7daef8270633eaff0314dbd4d55be)
@@ -0,0 +1,136 @@
+// 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.IO;
+using System.Linq;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Ringtoets.Common.Service.TestUtil;
+
+namespace Ringtoets.Common.Service.Test
+{
+ [TestFixture]
+ public class TargetProbabilityCalculationServiceTest
+ {
+ private const double validNorm = 0.005;
+ private static readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.Service, "HydraRingCalculation");
+ private static readonly string validFilePath = Path.Combine(testDataPath, "HRD dutch coast south.sqlite");
+ private static readonly string validPreprocessorDirectory = TestHelper.GetScratchPadPath();
+ private static readonly TargetProbabilityCalculationService calculationService = new TestTargetProbabilityCalculationService();
+
+ [Test]
+ public void Validate_ValidParameters_ReturnsTrue()
+ {
+ // Setup
+ var valid = false;
+
+ // Call
+ Action call = () => valid = calculationService.Validate(validFilePath,
+ validPreprocessorDirectory,
+ validNorm);
+
+ // Assert
+ TestHelper.AssertLogMessages(call, messages =>
+ {
+ string[] msgs = messages.ToArray();
+ Assert.AreEqual(2, msgs.Length);
+ CalculationServiceTestHelper.AssertValidationStartMessage(msgs[0]);
+ CalculationServiceTestHelper.AssertValidationEndMessage(msgs[1]);
+ });
+ Assert.IsTrue(valid);
+ }
+
+ [Test]
+ public void Validate_InvalidHydraulicBoundaryDatabasePath_LogsErrorAndReturnsFalse()
+ {
+ // Setup
+ string notValidFilePath = Path.Combine(testDataPath, "notexisting.sqlite");
+ var valid = true;
+
+ // Call
+ Action call = () => valid = calculationService.Validate(notValidFilePath,
+ validPreprocessorDirectory,
+ validNorm);
+
+ // Assert
+ TestHelper.AssertLogMessages(call, messages =>
+ {
+ string[] msgs = messages.ToArray();
+ Assert.AreEqual(3, msgs.Length);
+ CalculationServiceTestHelper.AssertValidationStartMessage(msgs[0]);
+ StringAssert.StartsWith("Herstellen van de verbinding met de hydraulische randvoorwaardendatabase is mislukt. Fout bij het lezen van bestand", msgs[1]);
+ CalculationServiceTestHelper.AssertValidationEndMessage(msgs[2]);
+ });
+ Assert.IsFalse(valid);
+ }
+
+ [Test]
+ public void Validate_ValidHydraulicBoundaryDatabaseWithoutSettings_LogsErrorAndReturnsFalse()
+ {
+ // Setup
+ string notValidFilePath = Path.Combine(testDataPath, "HRD nosettings.sqlite");
+ var valid = false;
+
+ // Call
+ Action call = () => valid = calculationService.Validate(notValidFilePath,
+ validPreprocessorDirectory,
+ validNorm);
+
+ // Assert
+ TestHelper.AssertLogMessages(call, messages =>
+ {
+ string[] msgs = messages.ToArray();
+ Assert.AreEqual(3, msgs.Length);
+ CalculationServiceTestHelper.AssertValidationStartMessage(msgs[0]);
+ StringAssert.StartsWith("Herstellen van de verbinding met de hydraulische randvoorwaardendatabase is mislukt. Fout bij het lezen van bestand", msgs[1]);
+ CalculationServiceTestHelper.AssertValidationEndMessage(msgs[2]);
+ });
+ Assert.IsFalse(valid);
+ }
+
+ [Test]
+ public void Validate_InvalidPreprocessorDirectory_LogsErrorAndReturnsFalse()
+ {
+ // Setup
+ const string invalidPreprocessorDirectory = "NonExistingPreprocessorDirectory";
+ var valid = true;
+
+ // Call
+ Action call = () => valid = calculationService.Validate(validFilePath,
+ invalidPreprocessorDirectory,
+ validNorm);
+
+ // Assert
+ TestHelper.AssertLogMessages(call, messages =>
+ {
+ string[] msgs = messages.ToArray();
+ Assert.AreEqual(3, msgs.Length);
+ CalculationServiceTestHelper.AssertValidationStartMessage(msgs[0]);
+ Assert.AreEqual("De bestandsmap waar de preprocessor bestanden opslaat is ongeldig. De bestandsmap bestaat niet.", msgs[1]);
+ CalculationServiceTestHelper.AssertValidationEndMessage(msgs[2]);
+ });
+ Assert.IsFalse(valid);
+ }
+
+ private class TestTargetProbabilityCalculationService : TargetProbabilityCalculationService {}
+ }
+}
\ No newline at end of file
Index: Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Service.Test/Ringtoets.DuneErosion.Service.Test.csproj
===================================================================
diff -u -r7d7a01ed91dd10bc4795528179b5f35e5f59f1bd -r9a47425d33d7daef8270633eaff0314dbd4d55be
--- Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Service.Test/Ringtoets.DuneErosion.Service.Test.csproj (.../Ringtoets.DuneErosion.Service.Test.csproj) (revision 7d7a01ed91dd10bc4795528179b5f35e5f59f1bd)
+++ Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Service.Test/Ringtoets.DuneErosion.Service.Test.csproj (.../Ringtoets.DuneErosion.Service.Test.csproj) (revision 9a47425d33d7daef8270633eaff0314dbd4d55be)
@@ -47,6 +47,10 @@
{D4200F43-3F72-4F42-AF0A-8CED416A38EC}
Ringtoets.Common.Data
+
+ {D951D6DA-FE83-4920-9FDB-63BF96480B54}
+ Ringtoets.Common.Service
+
{4843D6E5-066F-4795-94F5-1D53932DD03C}
Ringtoets.Common.Data.TestUtil