Index: Ringtoets/Common/src/Ringtoets.Common.Service/DesignWaterLevelCalculationService.cs
===================================================================
diff -u -r78815b3a2e147742759aedddf28c0ada6fb76152 -r61659778ac6e2436b9112e9ff33ccdd2e0b90afe
--- Ringtoets/Common/src/Ringtoets.Common.Service/DesignWaterLevelCalculationService.cs (.../DesignWaterLevelCalculationService.cs) (revision 78815b3a2e147742759aedddf28c0ada6fb76152)
+++ Ringtoets/Common/src/Ringtoets.Common.Service/DesignWaterLevelCalculationService.cs (.../DesignWaterLevelCalculationService.cs) (revision 61659778ac6e2436b9112e9ff33ccdd2e0b90afe)
@@ -28,12 +28,14 @@
using log4net;
using Ringtoets.Common.Data.Hydraulics;
using Ringtoets.Common.IO.HydraRing;
+using Ringtoets.Common.Service.IllustrationPoints;
using Ringtoets.Common.Service.MessageProviders;
using Ringtoets.Common.Service.Properties;
using Ringtoets.HydraRing.Calculation.Calculator;
using Ringtoets.HydraRing.Calculation.Calculator.Factory;
using Ringtoets.HydraRing.Calculation.Data.Input.Hydraulics;
using Ringtoets.HydraRing.Calculation.Exceptions;
+using HydraGeneralResult = Ringtoets.HydraRing.Calculation.Parsers.IllustrationPoints.GeneralResult;
namespace Ringtoets.Common.Service
{
@@ -114,7 +116,8 @@
{
AssessmentLevelCalculationInput calculationInput = CreateInput(designWaterLevelCalculation, norm, hydraulicBoundaryDatabaseFilePath);
- if (designWaterLevelCalculation.GetCalculateIllustrationPoints())
+ bool calculateIllustrationPoints = designWaterLevelCalculation.GetCalculateIllustrationPoints();
+ if (calculateIllustrationPoints)
{
calculator.CalculateWithIllustrationPoints(calculationInput);
}
@@ -123,12 +126,20 @@
calculator.Calculate(calculationInput);
}
- if (!canceled && string.IsNullOrEmpty(calculator.LastErrorFileContent))
+ if (canceled || !string.IsNullOrEmpty(calculator.LastErrorFileContent))
{
- designWaterLevelCalculation.SetOutput(
- CreateHydraulicBoundaryLocationOutput(
- messageProvider, designWaterLevelCalculation.GetName(), calculationInput.Beta, norm, calculator.Converged));
+ return;
}
+
+ HydraulicBoundaryLocationOutput hydraulicBoundaryLocationOutput = CreateHydraulicBoundaryLocationOutput(
+ messageProvider, designWaterLevelCalculation.GetName(), calculationInput.Beta, norm, calculator.Converged);
+
+ if (calculateIllustrationPoints)
+ {
+ SetIllustrationPointsResult(hydraulicBoundaryLocationOutput, calculator.IllustrationPointsResult);
+ }
+
+ designWaterLevelCalculation.SetOutput(hydraulicBoundaryLocationOutput);
}
catch (HydraRingCalculationException)
{
@@ -171,6 +182,15 @@
canceled = true;
}
+ private static void SetIllustrationPointsResult(HydraulicBoundaryLocationOutput hydraulicBoundaryLocationOutput,
+ HydraGeneralResult generalResult)
+ {
+ if (generalResult != null)
+ {
+ hydraulicBoundaryLocationOutput.SetIllustrationPoints(GeneralResultConverter.CreateGeneralResult(generalResult));
+ }
+ }
+
///
/// Creates the output of the calculation.
///
Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/IllustrationPoints/TestGeneralResult.cs
===================================================================
diff -u -r853509ec4de49576e9627ec0bf148aa32e04e461 -r61659778ac6e2436b9112e9ff33ccdd2e0b90afe
--- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/IllustrationPoints/TestGeneralResult.cs (.../TestGeneralResult.cs) (revision 853509ec4de49576e9627ec0bf148aa32e04e461)
+++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/IllustrationPoints/TestGeneralResult.cs (.../TestGeneralResult.cs) (revision 61659778ac6e2436b9112e9ff33ccdd2e0b90afe)
@@ -30,7 +30,7 @@
public class TestGeneralResult : GeneralResult
{
///
- /// Creates a .
+ /// Creates a new instance of .
///
public TestGeneralResult()
: base(0,
Index: Ringtoets/Common/test/Ringtoets.Common.Service.Test/DesignWaterLevelCalculationServiceTest.cs
===================================================================
diff -u -r78815b3a2e147742759aedddf28c0ada6fb76152 -r61659778ac6e2436b9112e9ff33ccdd2e0b90afe
--- Ringtoets/Common/test/Ringtoets.Common.Service.Test/DesignWaterLevelCalculationServiceTest.cs (.../DesignWaterLevelCalculationServiceTest.cs) (revision 78815b3a2e147742759aedddf28c0ada6fb76152)
+++ Ringtoets/Common/test/Ringtoets.Common.Service.Test/DesignWaterLevelCalculationServiceTest.cs (.../DesignWaterLevelCalculationServiceTest.cs) (revision 61659778ac6e2436b9112e9ff33ccdd2e0b90afe)
@@ -25,15 +25,16 @@
using Core.Common.TestUtil;
using NUnit.Framework;
using Rhino.Mocks;
-using Rhino.Mocks.Constraints;
using Ringtoets.Common.Data.Hydraulics;
+using Ringtoets.Common.Data.TestUtil.IllustrationPoints;
using Ringtoets.Common.Service.MessageProviders;
using Ringtoets.Common.Service.TestUtil;
using Ringtoets.HydraRing.Calculation.Calculator.Factory;
using Ringtoets.HydraRing.Calculation.Data.Input;
using Ringtoets.HydraRing.Calculation.Data.Input.Hydraulics;
using Ringtoets.HydraRing.Calculation.Exceptions;
using Ringtoets.HydraRing.Calculation.TestUtil.Calculator;
+using TestGeneralResult = Ringtoets.HydraRing.Calculation.TestUtil.IllustrationPoints.TestGeneralResult;
namespace Ringtoets.Common.Service.Test
{
@@ -146,8 +147,7 @@
}
[Test]
- public void Calculate_ValidDesignWaterLevelCalculation_StartsCalculationWithRightParameters(
- [Values(true, false)] bool withIllustrationPoints)
+ public void Calculate_ValidDesignWaterLevelCalculation_StartsCalculationWithRightParameters()
{
// Setup
string validFilePath = Path.Combine(testDataPath, validFile);
@@ -165,8 +165,12 @@
var calculation = mockRepository.Stub();
calculation.Stub(c => c.GetName()).Return(locationName);
calculation.Expect(c => c.GetId()).Return(id);
- calculation.Expect(c => c.SetOutput(null)).Constraints(new TypeOf(typeof(HydraulicBoundaryLocationOutput)));
- calculation.Expect(c => c.GetCalculateIllustrationPoints()).Return(withIllustrationPoints);
+ calculation.Expect(c => c.SetOutput(null)).IgnoreArguments().WhenCalled(invocation =>
+ {
+ var result = (HydraulicBoundaryLocationOutput) invocation.Arguments.Single();
+ Assert.IsFalse(result.HasIllustrationPoints);
+ });
+ calculation.Expect(c => c.GetCalculateIllustrationPoints()).Return(false);
var calculationMessageProviderStub = mockRepository.Stub();
calculationMessageProviderStub.Stub(calc => calc.GetCalculationName(locationName)).Return(string.Empty);
@@ -186,12 +190,64 @@
AssertInput(expectedInput, calculator.ReceivedInputs.Single());
Assert.IsFalse(calculator.IsCanceled);
- Assert.AreEqual(withIllustrationPoints, calculator.CalculatedWithIllustrationPoints);
+ Assert.IsFalse(calculator.CalculatedWithIllustrationPoints);
}
mockRepository.VerifyAll();
}
[Test]
+ public void Calculate_ValidDesignWaterLevelCalculationWithIllustrationPoints_StartsCalculationWithRightParameters()
+ {
+ // Setup
+ string validFilePath = Path.Combine(testDataPath, validFile);
+
+ const long id = 100;
+ const string locationName = "punt_flw_ 1";
+ const double norm = 1.0 / 30;
+
+ var calculator = new TestDesignWaterLevelCalculator
+ {
+ IllustrationPointsResult = new TestGeneralResult()
+ };
+
+ var mockRepository = new MockRepository();
+ var calculatorFactory = mockRepository.StrictMock();
+ calculatorFactory.Expect(cf => cf.CreateDesignWaterLevelCalculator(testDataPath)).Return(calculator);
+
+ var calculation = mockRepository.Stub();
+ calculation.Stub(c => c.GetName()).Return(locationName);
+ calculation.Expect(c => c.GetId()).Return(id);
+ calculation.Expect(c => c.SetOutput(null)).IgnoreArguments().WhenCalled(invocation =>
+ {
+ var result = (HydraulicBoundaryLocationOutput) invocation.Arguments.Single();
+ Assert.IsTrue(result.HasIllustrationPoints);
+ });
+ calculation.Expect(c => c.GetCalculateIllustrationPoints()).Return(true);
+
+ var calculationMessageProviderStub = mockRepository.Stub();
+ calculationMessageProviderStub.Stub(calc => calc.GetCalculationName(locationName)).Return(string.Empty);
+ calculationMessageProviderStub.Stub(calc => calc.GetCalculatedNotConvergedMessage(locationName)).Return(string.Empty);
+ mockRepository.ReplayAll();
+
+ using (new HydraRingCalculatorFactoryConfig(calculatorFactory))
+ {
+ // Call
+ new DesignWaterLevelCalculationService().Calculate(calculation,
+ validFilePath,
+ norm,
+ calculationMessageProviderStub);
+
+ // Assert
+ AssessmentLevelCalculationInput expectedInput = CreateInput(id, norm);
+ AssertInput(expectedInput, calculator.ReceivedInputs.Single());
+ Assert.IsFalse(calculator.IsCanceled);
+
+ Assert.IsTrue(calculator.CalculatedWithIllustrationPoints);
+ }
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
public void Calculate_CancelCalculationWithValidInput_CancelsCalculator()
{
// Setup
Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.TestUtil.Test/IllustrationPoints/TestGeneralResultTest.cs
===================================================================
diff -u
--- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.TestUtil.Test/IllustrationPoints/TestGeneralResultTest.cs (revision 0)
+++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.TestUtil.Test/IllustrationPoints/TestGeneralResultTest.cs (revision 61659778ac6e2436b9112e9ff33ccdd2e0b90afe)
@@ -0,0 +1,61 @@
+// 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 NUnit.Framework;
+using Ringtoets.HydraRing.Calculation.Parsers.IllustrationPoints;
+using Ringtoets.HydraRing.Calculation.TestUtil.IllustrationPoints;
+
+namespace Ringtoets.HydraRing.Calculation.TestUtil.Test.IllustrationPoints
+{
+ [TestFixture]
+ public class TestGeneralResultTest
+ {
+ [Test]
+ public void Constructor_ExpectedProperties()
+ {
+ // Call
+ var generalResult = new TestGeneralResult();
+
+ // Assert
+ Assert.IsInstanceOf(generalResult);
+ Assert.AreEqual(0, generalResult.Beta);
+
+ var expectedWindDirection = new WindDirection
+ {
+ Name = "TestWindDirection"
+ };
+ AssertWindDirection(expectedWindDirection, generalResult.GoverningWind);
+ Assert.IsEmpty(generalResult.Stochasts);
+ Assert.IsEmpty(generalResult.IllustrationPoints);
+ }
+
+ private static void AssertWindDirection(WindDirection expected, WindDirection actual)
+ {
+ if (expected == null)
+ {
+ Assert.IsNull(actual);
+ return;
+ }
+ Assert.AreEqual(expected.Name, actual.Name);
+ Assert.AreEqual(expected.Angle, actual.Angle);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.TestUtil.Test/Ringtoets.HydraRing.Calculation.TestUtil.Test.csproj
===================================================================
diff -u -r6a5d7b40b7ba4dcb73e393075338352d194e97c2 -r61659778ac6e2436b9112e9ff33ccdd2e0b90afe
--- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.TestUtil.Test/Ringtoets.HydraRing.Calculation.TestUtil.Test.csproj (.../Ringtoets.HydraRing.Calculation.TestUtil.Test.csproj) (revision 6a5d7b40b7ba4dcb73e393075338352d194e97c2)
+++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.TestUtil.Test/Ringtoets.HydraRing.Calculation.TestUtil.Test.csproj (.../Ringtoets.HydraRing.Calculation.TestUtil.Test.csproj) (revision 61659778ac6e2436b9112e9ff33ccdd2e0b90afe)
@@ -53,6 +53,7 @@
Properties\GlobalAssembly.cs
+
Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.TestUtil/IllustrationPoints/TestGeneralResult.cs
===================================================================
diff -u
--- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.TestUtil/IllustrationPoints/TestGeneralResult.cs (revision 0)
+++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.TestUtil/IllustrationPoints/TestGeneralResult.cs (revision 61659778ac6e2436b9112e9ff33ccdd2e0b90afe)
@@ -0,0 +1,47 @@
+// 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.Collections.Generic;
+using System.Linq;
+using Ringtoets.HydraRing.Calculation.Parsers.IllustrationPoints;
+
+namespace Ringtoets.HydraRing.Calculation.TestUtil.IllustrationPoints
+{
+ ///
+ /// A simple general result which can be used for testing.
+ ///
+ public class TestGeneralResult : GeneralResult
+ {
+ ///
+ /// Creates a new instance of .
+ ///
+ public TestGeneralResult()
+ {
+ Beta = 0;
+ GoverningWind = new WindDirection
+ {
+ Name = "TestWindDirection"
+ };
+ Stochasts = Enumerable.Empty();
+ IllustrationPoints = new Dictionary();
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.TestUtil/Ringtoets.HydraRing.Calculation.TestUtil.csproj
===================================================================
diff -u -r6c049c504e7f599a8cebb26ae37fcd82b03782f2 -r61659778ac6e2436b9112e9ff33ccdd2e0b90afe
--- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.TestUtil/Ringtoets.HydraRing.Calculation.TestUtil.csproj (.../Ringtoets.HydraRing.Calculation.TestUtil.csproj) (revision 6c049c504e7f599a8cebb26ae37fcd82b03782f2)
+++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.TestUtil/Ringtoets.HydraRing.Calculation.TestUtil.csproj (.../Ringtoets.HydraRing.Calculation.TestUtil.csproj) (revision 61659778ac6e2436b9112e9ff33ccdd2e0b90afe)
@@ -55,6 +55,7 @@
+