Fisheye: Tag ca294adc98299b17393265233305360300e8b0ef refers to a dead (removed) revision in file `Ringtoets/Common/src/Ringtoets.Common.Forms/Helpers/HydraulicBoundaryLocationCalculationActivityFactory.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj =================================================================== diff -u -r5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2 -rca294adc98299b17393265233305360300e8b0ef --- Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision ca294adc98299b17393265233305360300e8b0ef) @@ -51,7 +51,6 @@ - Index: Ringtoets/Common/src/Ringtoets.Common.Service/DesignWaterLevelCalculationActivity.cs =================================================================== diff -u -r003b310b793fee62006d0f16af019269c86fb3bc -rca294adc98299b17393265233305360300e8b0ef --- Ringtoets/Common/src/Ringtoets.Common.Service/DesignWaterLevelCalculationActivity.cs (.../DesignWaterLevelCalculationActivity.cs) (revision 003b310b793fee62006d0f16af019269c86fb3bc) +++ Ringtoets/Common/src/Ringtoets.Common.Service/DesignWaterLevelCalculationActivity.cs (.../DesignWaterLevelCalculationActivity.cs) (revision ca294adc98299b17393265233305360300e8b0ef) @@ -28,7 +28,7 @@ /// /// for running a design water level calculation. /// - public class DesignWaterLevelCalculationActivity : CalculatableActivity + internal class DesignWaterLevelCalculationActivity : CalculatableActivity { private readonly double norm; private readonly string hydraulicBoundaryDatabaseFilePath; Index: Ringtoets/Common/src/Ringtoets.Common.Service/HydraulicBoundaryLocationCalculationActivityFactory.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.Service/HydraulicBoundaryLocationCalculationActivityFactory.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.Service/HydraulicBoundaryLocationCalculationActivityFactory.cs (revision ca294adc98299b17393265233305360300e8b0ef) @@ -0,0 +1,104 @@ +// 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.Collections.Generic; +using System.Linq; +using Ringtoets.Common.Data.Hydraulics; + +namespace Ringtoets.Common.Service +{ + /// + /// This class defines factory methods that can be used to create instances of for + /// hydraulic boundary location calculations. + /// + public static class HydraulicBoundaryLocationCalculationActivityFactory + { + /// + /// Creates a collection of for wave height calculations + /// based on the given parameters. + /// + /// The path of the hydraulic boundary database file. + /// The preprocessor directory. + /// The collection of to create + /// the activities for. + /// The norm to use during the calculations. + /// The category boundary name for the calculations. + /// A collection of . + /// Thrown when is null. + /// Thrown when is null or empty. + public static IEnumerable CreateWaveHeightCalculationActivities( + string hydraulicBoundaryDatabaseFilePath, + string preprocessorDirectory, + IEnumerable calculations, + double norm, + string categoryBoundaryName) + { + if (calculations == null) + { + throw new ArgumentNullException(nameof(calculations)); + } + + if (categoryBoundaryName == null) + { + throw new ArgumentNullException(nameof(categoryBoundaryName)); + } + + return calculations.Select(calculation => new WaveHeightCalculationActivity(calculation, + hydraulicBoundaryDatabaseFilePath, + preprocessorDirectory, + norm, + categoryBoundaryName)).ToArray(); + } + + /// + /// Creates a collection of for design water level calculations + /// based on the given parameters. + /// + /// The path of the hydraulic boundary database file. + /// The preprocessor directory. + /// The collection of to create + /// the activities for. + /// The norm to use during the calculations. + /// The category boundary name to use for the activities. + /// A collection of . + /// Thrown when is null. + /// Thrown when is null or empty. + public static IEnumerable CreateDesignWaterLevelCalculationActivities( + string hydraulicBoundaryDatabaseFilePath, + string preprocessorDirectory, + IEnumerable calculations, + double norm, + string categoryBoundaryName) + { + if (calculations == null) + { + throw new ArgumentNullException(nameof(calculations)); + } + + return calculations.Select(calculation => new DesignWaterLevelCalculationActivity(calculation, + hydraulicBoundaryDatabaseFilePath, + preprocessorDirectory, + norm, + categoryBoundaryName)).ToArray(); + } + } +} \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Service/Properties/AssemblyInfo.cs =================================================================== diff -u -r0819cf01b494097b764677be8dd47853e38fc223 -rca294adc98299b17393265233305360300e8b0ef --- Ringtoets/Common/src/Ringtoets.Common.Service/Properties/AssemblyInfo.cs (.../AssemblyInfo.cs) (revision 0819cf01b494097b764677be8dd47853e38fc223) +++ Ringtoets/Common/src/Ringtoets.Common.Service/Properties/AssemblyInfo.cs (.../AssemblyInfo.cs) (revision ca294adc98299b17393265233305360300e8b0ef) @@ -20,6 +20,8 @@ // All rights reserved. using System.Reflection; +using System.Runtime.CompilerServices; [assembly: AssemblyTitle("Ringtoets.Common.Service")] -[assembly: AssemblyProduct("Ringtoets.Common.Service")] \ No newline at end of file +[assembly: AssemblyProduct("Ringtoets.Common.Service")] +[assembly: InternalsVisibleTo("Ringtoets.Common.Service.Test")] \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Service/Ringtoets.Common.Service.csproj =================================================================== diff -u -r4aca01a706f23d3ba928d2c5fd405681bc3ba55d -rca294adc98299b17393265233305360300e8b0ef --- Ringtoets/Common/src/Ringtoets.Common.Service/Ringtoets.Common.Service.csproj (.../Ringtoets.Common.Service.csproj) (revision 4aca01a706f23d3ba928d2c5fd405681bc3ba55d) +++ Ringtoets/Common/src/Ringtoets.Common.Service/Ringtoets.Common.Service.csproj (.../Ringtoets.Common.Service.csproj) (revision ca294adc98299b17393265233305360300e8b0ef) @@ -16,6 +16,7 @@ + Index: Ringtoets/Common/src/Ringtoets.Common.Service/WaveHeightCalculationActivity.cs =================================================================== diff -u -r003b310b793fee62006d0f16af019269c86fb3bc -rca294adc98299b17393265233305360300e8b0ef --- Ringtoets/Common/src/Ringtoets.Common.Service/WaveHeightCalculationActivity.cs (.../WaveHeightCalculationActivity.cs) (revision 003b310b793fee62006d0f16af019269c86fb3bc) +++ Ringtoets/Common/src/Ringtoets.Common.Service/WaveHeightCalculationActivity.cs (.../WaveHeightCalculationActivity.cs) (revision ca294adc98299b17393265233305360300e8b0ef) @@ -28,7 +28,7 @@ /// /// for running a water height calculation. /// - public class WaveHeightCalculationActivity : CalculatableActivity + internal class WaveHeightCalculationActivity : CalculatableActivity { private readonly double norm; private readonly string hydraulicBoundaryDatabaseFilePath; Fisheye: Tag ca294adc98299b17393265233305360300e8b0ef refers to a dead (removed) revision in file `Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Helpers/HydraulicBoundaryLocationCalculationActivityFactoryTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj =================================================================== diff -u -r5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2 -rca294adc98299b17393265233305360300e8b0ef --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision ca294adc98299b17393265233305360300e8b0ef) @@ -60,7 +60,6 @@ - Index: Ringtoets/Common/test/Ringtoets.Common.Service.Test/HydraulicBoundaryLocationCalculationActivityFactoryTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.Service.Test/HydraulicBoundaryLocationCalculationActivityFactoryTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.Service.Test/HydraulicBoundaryLocationCalculationActivityFactoryTest.cs (revision ca294adc98299b17393265233305360300e8b0ef) @@ -0,0 +1,200 @@ +// 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.Collections.Generic; +using System.IO; +using System.Linq; +using Core.Common.Base.Service; +using Core.Common.TestUtil; +using Core.Common.Util; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.Hydraulics; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Service.TestUtil; +using Ringtoets.HydraRing.Calculation.Calculator.Factory; +using Ringtoets.HydraRing.Calculation.Data.Input.Hydraulics; +using Ringtoets.HydraRing.Calculation.TestUtil.Calculator; + +namespace Ringtoets.Common.Service.Test +{ + [TestFixture] + public class HydraulicBoundaryLocationCalculationActivityFactoryTest + { + 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(); + + [Test] + public void CreateWaveHeightCalculationActivities_CalculationsNull_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => HydraulicBoundaryLocationCalculationActivityFactory.CreateWaveHeightCalculationActivities( + string.Empty, + string.Empty, + null, + new Random(12).NextDouble(), + "A"); + + // Assert + string paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("calculations", paramName); + } + + [Test] + public void CreateWaveHeightCalculationActivities_WithValidData_ReturnsExpectedActivity() + { + // Setup + const string locationName = "locationName"; + const string categoryBoundaryName = "A"; + const double norm = 1.0 / 30; + + var calculator = new TestWaveHeightCalculator + { + Converged = true + }; + + var mocks = new MockRepository(); + var calculatorFactory = mocks.StrictMock(); + calculatorFactory.Expect(cf => cf.CreateWaveHeightCalculator(testDataPath, validPreprocessorDirectory)).Return(calculator); + + mocks.ReplayAll(); + + var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(locationName); + + // Call + IEnumerable activities = HydraulicBoundaryLocationCalculationActivityFactory.CreateWaveHeightCalculationActivities( + validFilePath, + validPreprocessorDirectory, + new[] + { + new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation) + }, + norm, + categoryBoundaryName); + + // Assert + CollectionAssert.AllItemsAreInstancesOfType(activities, typeof(WaveHeightCalculationActivity)); + + CalculatableActivity activity = activities.Single(); + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + { + Action call = () => activity.Run(); + + TestHelper.AssertLogMessages(call, m => + { + string[] messages = m.ToArray(); + Assert.AreEqual(6, messages.Length); + Assert.AreEqual($"Golfhoogte berekenen voor locatie 'locationName' (Categorie {categoryBoundaryName}) is gestart.", messages[0]); + CalculationServiceTestHelper.AssertValidationStartMessage(messages[1]); + CalculationServiceTestHelper.AssertValidationEndMessage(messages[2]); + CalculationServiceTestHelper.AssertCalculationStartMessage(messages[3]); + StringAssert.StartsWith("Golfhoogte berekening is uitgevoerd op de tijdelijke locatie", messages[4]); + CalculationServiceTestHelper.AssertCalculationEndMessage(messages[5]); + }); + WaveHeightCalculationInput waveHeightCalculationInput = calculator.ReceivedInputs.Single(); + + Assert.AreEqual(hydraulicBoundaryLocation.Id, waveHeightCalculationInput.HydraulicBoundaryLocationId); + Assert.AreEqual(StatisticsConverter.ProbabilityToReliability(norm), waveHeightCalculationInput.Beta); + } + + Assert.AreEqual(ActivityState.Executed, activity.State); + mocks.VerifyAll(); + } + + [Test] + public void CreateDesignWaterLevelCalculationActivities_CalculationsNull_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => HydraulicBoundaryLocationCalculationActivityFactory.CreateDesignWaterLevelCalculationActivities( + string.Empty, + string.Empty, + null, + new Random(12).NextDouble(), + "A"); + + // Assert + string paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("calculations", paramName); + } + + [Test] + public void CreateDesignWaterLevelCalculationActivities_WithValidData_ReturnsExpectedActivity() + { + // Setup + const string locationName = "locationName"; + const string categoryBoundaryName = "A"; + const double norm = 1.0 / 30; + + var calculator = new TestDesignWaterLevelCalculator + { + Converged = true + }; + + var mocks = new MockRepository(); + var calculatorFactory = mocks.StrictMock(); + calculatorFactory.Expect(cf => cf.CreateDesignWaterLevelCalculator(testDataPath, validPreprocessorDirectory)).Return(calculator); + mocks.ReplayAll(); + + var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(locationName); + + // Call + IEnumerable activities = HydraulicBoundaryLocationCalculationActivityFactory.CreateDesignWaterLevelCalculationActivities( + validFilePath, + validPreprocessorDirectory, + new[] + { + new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation) + }, + norm, + categoryBoundaryName); + + // Assert + CollectionAssert.AllItemsAreInstancesOfType(activities, typeof(DesignWaterLevelCalculationActivity)); + + CalculatableActivity activity = activities.Single(); + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + { + Action call = () => activity.Run(); + + TestHelper.AssertLogMessages(call, m => + { + string[] messages = m.ToArray(); + Assert.AreEqual(6, messages.Length); + Assert.AreEqual($"Waterstand berekenen voor locatie 'locationName' (Categorie {categoryBoundaryName}) is gestart.", messages[0]); + CalculationServiceTestHelper.AssertValidationStartMessage(messages[1]); + CalculationServiceTestHelper.AssertValidationEndMessage(messages[2]); + CalculationServiceTestHelper.AssertCalculationStartMessage(messages[3]); + StringAssert.StartsWith("Waterstand berekening is uitgevoerd op de tijdelijke locatie", messages[4]); + CalculationServiceTestHelper.AssertCalculationEndMessage(messages[5]); + }); + AssessmentLevelCalculationInput assessmentLevelCalculationInput = calculator.ReceivedInputs.Single(); + + Assert.AreEqual(hydraulicBoundaryLocation.Id, assessmentLevelCalculationInput.HydraulicBoundaryLocationId); + Assert.AreEqual(StatisticsConverter.ProbabilityToReliability(norm), assessmentLevelCalculationInput.Beta); + } + + Assert.AreEqual(ActivityState.Executed, activity.State); + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Service.Test/Ringtoets.Common.Service.Test.csproj =================================================================== diff -u -r4aca01a706f23d3ba928d2c5fd405681bc3ba55d -rca294adc98299b17393265233305360300e8b0ef --- Ringtoets/Common/test/Ringtoets.Common.Service.Test/Ringtoets.Common.Service.Test.csproj (.../Ringtoets.Common.Service.Test.csproj) (revision 4aca01a706f23d3ba928d2c5fd405681bc3ba55d) +++ Ringtoets/Common/test/Ringtoets.Common.Service.Test/Ringtoets.Common.Service.Test.csproj (.../Ringtoets.Common.Service.Test.csproj) (revision ca294adc98299b17393265233305360300e8b0ef) @@ -35,6 +35,7 @@ + Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs =================================================================== diff -u -r7dbedcc91cd2472b7d696e393d42b2a02a0597fd -rca294adc98299b17393265233305360300e8b0ef --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 7dbedcc91cd2472b7d696e393d42b2a02a0597fd) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision ca294adc98299b17393265233305360300e8b0ef) @@ -53,7 +53,6 @@ using Ringtoets.Common.Forms.ChangeHandlers; using Ringtoets.Common.Forms.Controls; using Ringtoets.Common.Forms.GuiServices; -using Ringtoets.Common.Forms.Helpers; using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.Forms.PropertyClasses; using Ringtoets.Common.Forms.TreeNodeInfos;