Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Data/GeneralGrassCoverErosionOutwardsInput.cs =================================================================== diff -u -rc43715cf3e6dce0c427b10c4852d5ae54e6d668d -r50ecb5a95c088a636ec38ce3c5f2fc8addcd67e3 --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Data/GeneralGrassCoverErosionOutwardsInput.cs (.../GeneralGrassCoverErosionOutwardsInput.cs) (revision c43715cf3e6dce0c427b10c4852d5ae54e6d668d) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Data/GeneralGrassCoverErosionOutwardsInput.cs (.../GeneralGrassCoverErosionOutwardsInput.cs) (revision 50ecb5a95c088a636ec38ce3c5f2fc8addcd67e3) @@ -20,7 +20,6 @@ // All rights reserved. using System; -using Core.Common.Base.Storage; using Ringtoets.Common.Data.Properties; namespace Ringtoets.GrassCoverErosionOutwards.Data @@ -38,8 +37,26 @@ public GeneralGrassCoverErosionOutwardsInput() { n = 2; + A = 1.0; + B = 0.67; + C = 0.0; } + /// + /// Gets the 'a' parameter used in wave conditions calculations. + /// + public double A { get; private set; } + + /// + /// Gets the 'b' parameter used in wave conditions calculations. + /// + public double B { get; private set; } + + /// + /// Gets the 'c' parameter used in wave conditions calculations. + /// + public double C { get; private set; } + #region Probability assessment /// Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Service/GrassCoverErosionOutwardsDataSynchronizationService.cs =================================================================== diff -u --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Service/GrassCoverErosionOutwardsDataSynchronizationService.cs (revision 0) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Service/GrassCoverErosionOutwardsDataSynchronizationService.cs (revision 50ecb5a95c088a636ec38ce3c5f2fc8addcd67e3) @@ -0,0 +1,49 @@ +// 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 Ringtoets.GrassCoverErosionOutwards.Data; + +namespace Ringtoets.GrassCoverErosionOutwards.Service +{ + /// + /// Service for synchronizing grass cover erosion outwards data. + /// + public static class GrassCoverErosionOutwardsDataSynchronizationService + { + /// + /// Clears the output of the given . + /// + /// The + /// to clear the output for. + /// Thrown when + /// is null. + public static void ClearWaveConditionsCalculationOutput(GrassCoverErosionOutwardsWaveConditionsCalculation calculation) + { + if (calculation == null) + { + throw new ArgumentNullException("calculation"); + } + + calculation.Output = null; + } + } +} \ No newline at end of file Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Service/GrassCoverErosionOutwardsWaveConditionsCalculationActivity.cs =================================================================== diff -u -r85e95a2b6e8fd7a873ba166ddfba608f2466a40c -r50ecb5a95c088a636ec38ce3c5f2fc8addcd67e3 --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Service/GrassCoverErosionOutwardsWaveConditionsCalculationActivity.cs (.../GrassCoverErosionOutwardsWaveConditionsCalculationActivity.cs) (revision 85e95a2b6e8fd7a873ba166ddfba608f2466a40c) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Service/GrassCoverErosionOutwardsWaveConditionsCalculationActivity.cs (.../GrassCoverErosionOutwardsWaveConditionsCalculationActivity.cs) (revision 50ecb5a95c088a636ec38ce3c5f2fc8addcd67e3) @@ -21,11 +21,17 @@ using System; using System.Collections.Generic; +using System.Linq; using Core.Common.Base.Service; +using log4net; using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Service; using Ringtoets.GrassCoverErosionOutwards.Data; +using Ringtoets.GrassCoverErosionOutwards.Service.Properties; using Ringtoets.HydraRing.Calculation.Activities; using Ringtoets.Revetment.Data; +using Ringtoets.Revetment.Service; +using RingtoetsCommonServiceResources = Ringtoets.Common.Service.Properties.Resources; namespace Ringtoets.GrassCoverErosionOutwards.Service { @@ -34,6 +40,8 @@ /// public class GrassCoverErosionOutwardsWaveConditionsCalculationActivity : HydraRingActivity> { + private static readonly ILog log = LogManager.GetLogger(typeof(GrassCoverErosionOutwardsWaveConditionsCalculationActivity)); + private readonly GrassCoverErosionOutwardsWaveConditionsCalculation calculation; private readonly string hlcdDirectory; private readonly GrassCoverErosionOutwardsFailureMechanism failureMechanism; @@ -79,12 +87,65 @@ protected override void OnRun() { - throw new System.NotImplementedException(); + PerformRun(() => true, + () => GrassCoverErosionOutwardsDataSynchronizationService.ClearWaveConditionsCalculationOutput(calculation), + () => + { + log.Info(string.Format(RingtoetsCommonServiceResources.Calculation_Subject_0_started_Time_1_, + calculation.Name, + DateTimeService.CurrentTimeAsString)); + + List outputs = new List(); + + var a = failureMechanism.GeneralInput.A; + var b = failureMechanism.GeneralInput.B; + var c = failureMechanism.GeneralInput.C; + var norm = assessmentSection.FailureMechanismContribution.Norm; + + foreach (var waterLevel in calculation.InputParameters.WaterLevels) + { + log.Info(string.Format(Resources.GrassCoverErosionOutwardsWaveConditionsCalculationActivity_OnRun_Subject_0_for_waterlevel_1_started_time_2_, + calculation.Name, + waterLevel, + DateTimeService.CurrentTimeAsString)); + + ProgressText = string.Format(Resources.GrassCoverErosionOutwardsWaveConditionsCalculationActivity_OnRun_Calculate_waterlevel_0_, waterLevel); + + var output = WaveConditionsCalculationService.Instance.Calculate(waterLevel, + a, + b, + c, + norm, + calculation.InputParameters, + hlcdDirectory, + assessmentSection.Id, + calculation.Name); + + if (output != null) + { + outputs.Add(output); + } + + log.Info(string.Format(Resources.GrassCoverErosionOutwardsWaveConditionsCalculationActivity_OnRun_Subject_0_for_waterlevel_1_ended_time_2_, + calculation.Name, + waterLevel, + DateTimeService.CurrentTimeAsString)); + } + + log.Info(string.Format(RingtoetsCommonServiceResources.Calculation_Subject_0_ended_Time_1_, + calculation.Name, + DateTimeService.CurrentTimeAsString)); + + return outputs.Any() ? outputs : null; + }); } protected override void OnFinish() { - throw new System.NotImplementedException(); + PerformFinish(() => + { + calculation.Output = new GrassCoverErosionOutwardsWaveConditionsOutput(Output); + }); } } } \ No newline at end of file Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Service/Properties/AssemblyInfo.cs =================================================================== diff -u -rdd4547d2d3f85e30136f6dc7c238dd3553f2aade -r50ecb5a95c088a636ec38ce3c5f2fc8addcd67e3 --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Service/Properties/AssemblyInfo.cs (.../AssemblyInfo.cs) (revision dd4547d2d3f85e30136f6dc7c238dd3553f2aade) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Service/Properties/AssemblyInfo.cs (.../AssemblyInfo.cs) (revision 50ecb5a95c088a636ec38ce3c5f2fc8addcd67e3) @@ -20,8 +20,10 @@ // All rights reserved. using System.Reflection; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; [assembly: AssemblyTitle("Ringtoets.GrassCoverErosionOutwards.Service")] [assembly: AssemblyProduct("Ringtoets.GrassCoverErosionOutwards.Service")] +[assembly: InternalsVisibleTo("Ringtoets.GrassCoverErosionOutwards.Integration.Test")] [assembly: Guid("6f3d8bc0-d294-40a0-91e8-9f260ce5e9d4")] \ No newline at end of file Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Service/Properties/Resources.Designer.cs =================================================================== diff -u -r06b2840a2bb64c0960c8ac29322b5a0971c73c77 -r50ecb5a95c088a636ec38ce3c5f2fc8addcd67e3 --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Service/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 06b2840a2bb64c0960c8ac29322b5a0971c73c77) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Service/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 50ecb5a95c088a636ec38ce3c5f2fc8addcd67e3) @@ -22,7 +22,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.42000 +// Runtime Version:4.0.30319.17929 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -118,5 +118,35 @@ return ResourceManager.GetString("GrassCoverErosionOutwardsPlugin_Name_DesignWaterLevel_for_location_0_", resourceCulture); } } + + /// + /// Looks up a localized string similar to Waterstand {0} berekenen.. + /// + public static string GrassCoverErosionOutwardsWaveConditionsCalculationActivity_OnRun_Calculate_waterlevel_0_ { + get { + return ResourceManager.GetString("GrassCoverErosionOutwardsWaveConditionsCalculationActivity_OnRun_Calculate_waterl" + + "evel_0_", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Berekening '{0}' voor waterstand '{1}' beëindigd om: {2}. + /// + public static string GrassCoverErosionOutwardsWaveConditionsCalculationActivity_OnRun_Subject_0_for_waterlevel_1_ended_time_2_ { + get { + return ResourceManager.GetString("GrassCoverErosionOutwardsWaveConditionsCalculationActivity_OnRun_Subject_0_for_wa" + + "terlevel_1_ended_time_2_", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Berekening '{0}' voor waterstand '{1}' gestart om: {2}. + /// + public static string GrassCoverErosionOutwardsWaveConditionsCalculationActivity_OnRun_Subject_0_for_waterlevel_1_started_time_2_ { + get { + return ResourceManager.GetString("GrassCoverErosionOutwardsWaveConditionsCalculationActivity_OnRun_Subject_0_for_wa" + + "terlevel_1_started_time_2_", resourceCulture); + } + } } } Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Service/Properties/Resources.resx =================================================================== diff -u -r06b2840a2bb64c0960c8ac29322b5a0971c73c77 -r50ecb5a95c088a636ec38ce3c5f2fc8addcd67e3 --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Service/Properties/Resources.resx (.../Resources.resx) (revision 06b2840a2bb64c0960c8ac29322b5a0971c73c77) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Service/Properties/Resources.resx (.../Resources.resx) (revision 50ecb5a95c088a636ec38ce3c5f2fc8addcd67e3) @@ -129,4 +129,13 @@ Waterstand bij doorsnede-eis voor locatie {0} + + Waterstand {0} berekenen. + + + Berekening '{0}' voor waterstand '{1}' beëindigd om: {2} + + + Berekening '{0}' voor waterstand '{1}' gestart om: {2} + \ No newline at end of file Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Service/Ringtoets.GrassCoverErosionOutwards.Service.csproj =================================================================== diff -u -r85e95a2b6e8fd7a873ba166ddfba608f2466a40c -r50ecb5a95c088a636ec38ce3c5f2fc8addcd67e3 --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Service/Ringtoets.GrassCoverErosionOutwards.Service.csproj (.../Ringtoets.GrassCoverErosionOutwards.Service.csproj) (revision 85e95a2b6e8fd7a873ba166ddfba608f2466a40c) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Service/Ringtoets.GrassCoverErosionOutwards.Service.csproj (.../Ringtoets.GrassCoverErosionOutwards.Service.csproj) (revision 50ecb5a95c088a636ec38ce3c5f2fc8addcd67e3) @@ -32,13 +32,18 @@ AllRules.ruleset + + ..\..\..\..\packages\log4net.2.0.4\lib\net40-full\log4net.dll + True + Properties\GlobalAssembly.cs + @@ -52,6 +57,7 @@ Copying.licenseheader + @@ -79,6 +85,11 @@ Ringtoets.Revetment.Data False + + {2331235F-1E56-4344-ACC2-191C22A39594} + Ringtoets.Revetment.Service + False + {E7225477-577F-4A17-B7EC-6721158E1543} Ringtoets.GrassCoverErosionOutwards.Data Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Service/packages.config =================================================================== diff -u --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Service/packages.config (revision 0) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Service/packages.config (revision 50ecb5a95c088a636ec38ce3c5f2fc8addcd67e3) @@ -0,0 +1,27 @@ + + + + + + \ No newline at end of file Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Data.Test/GeneralGrassCoverErosionOutwardsInputTest.cs =================================================================== diff -u -rc43715cf3e6dce0c427b10c4852d5ae54e6d668d -r50ecb5a95c088a636ec38ce3c5f2fc8addcd67e3 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Data.Test/GeneralGrassCoverErosionOutwardsInputTest.cs (.../GeneralGrassCoverErosionOutwardsInputTest.cs) (revision c43715cf3e6dce0c427b10c4852d5ae54e6d668d) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Data.Test/GeneralGrassCoverErosionOutwardsInputTest.cs (.../GeneralGrassCoverErosionOutwardsInputTest.cs) (revision 50ecb5a95c088a636ec38ce3c5f2fc8addcd67e3) @@ -37,6 +37,9 @@ // Assert Assert.AreEqual(2, inputParameters.N); + Assert.AreEqual(1.0, inputParameters.A); + Assert.AreEqual(0.67, inputParameters.B); + Assert.AreEqual(0.0, inputParameters.C); } [Test] Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Integration.Test/GrassCoverErosionOutwardsWaveConditionsCalculationActivityIntegrationTest.cs =================================================================== diff -u --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Integration.Test/GrassCoverErosionOutwardsWaveConditionsCalculationActivityIntegrationTest.cs (revision 0) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Integration.Test/GrassCoverErosionOutwardsWaveConditionsCalculationActivityIntegrationTest.cs (revision 50ecb5a95c088a636ec38ce3c5f2fc8addcd67e3) @@ -0,0 +1,305 @@ +// 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.Collections.Generic; +using System.IO; +using System.Linq; +using Core.Common.Base.Data; +using Core.Common.Base.Geometry; +using Core.Common.Base.Service; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.DikeProfiles; +using Ringtoets.GrassCoverErosionOutwards.Data; +using Ringtoets.GrassCoverErosionOutwards.Service; +using Ringtoets.GrassCoverErosionOutwards.Service.Properties; +using Ringtoets.HydraRing.Calculation.TestUtil; +using Ringtoets.Integration.Data; +using Ringtoets.Integration.Plugin.FileImporters; +using Ringtoets.Revetment.Service.TestUtil; + +namespace Ringtoets.GrassCoverErosionOutwards.Integration.Test +{ + [TestFixture] + public class GrassCoverErosionOutwardsWaveConditionsCalculationActivityIntegrationTest + { + private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.Service, "HydraRingCalculation"); + + [Test] + public void OnRun_NoWaterLevels_LogStartAndEnd() + { + // Setup + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + ImportHydraulicBoundaryDatabase(assessmentSection); + + var calculation = new GrassCoverErosionOutwardsWaveConditionsCalculation + { + InputParameters = + { + HydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001), + ForeshoreProfile = CreateForeshoreProfile(), + UseForeshore = true, + UseBreakWater = true, + StepSize = (RoundedDouble) 0.5, + LowerBoundaryRevetment = (RoundedDouble) 5.3, + UpperBoundaryRevetment = (RoundedDouble) 10, + UpperBoundaryWaterLevels = (RoundedDouble) 5.4, + LowerBoundaryWaterLevels = (RoundedDouble) 5 + } + }; + + var activity = new GrassCoverErosionOutwardsWaveConditionsCalculationActivity(calculation, + testDataPath, + assessmentSection.GrassCoverErosionOutwards, + assessmentSection); + + using (new HydraRingCalculationServiceConfig()) + using (new WaveConditionsCalculationServiceConfig()) + { + // Call + Action call = () => activity.Run(); + + // Assert + TestHelper.AssertLogMessages(call, messages => + { + var msgs = messages.ToArray(); + Assert.AreEqual(2, msgs.Length); + StringAssert.StartsWith(string.Format("Berekening van '{0}' gestart om: ", calculation.Name), msgs[0]); + StringAssert.StartsWith(string.Format("Berekening van '{0}' beëindigd om: ", calculation.Name), msgs[1]); + }); + Assert.AreEqual(ActivityState.Failed, activity.State); + } + } + + [Test] + public void OnRun_CalculationWithWaterLevels_PerformCalculationAndLogStartAndEnd() + { + // Setup + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + ImportHydraulicBoundaryDatabase(assessmentSection); + + var calculation = GetValidCalculation(assessmentSection); + + var activity = new GrassCoverErosionOutwardsWaveConditionsCalculationActivity(calculation, + testDataPath, + assessmentSection.GrassCoverErosionOutwards, + assessmentSection); + + using (new HydraRingCalculationServiceConfig()) + using (new WaveConditionsCalculationServiceConfig()) + { + // Call + Action call = () => activity.Run(); + + // Assert + TestHelper.AssertLogMessages(call, messages => + { + var msgs = messages.ToArray(); + Assert.AreEqual(8, msgs.Length); + StringAssert.StartsWith(string.Format("Berekening van '{0}' gestart om: ", calculation.Name), msgs[0]); + + int i = 0; + foreach (var waterLevel in calculation.InputParameters.WaterLevels) + { + StringAssert.StartsWith(string.Format("Berekening '{0}' voor waterstand '{1}' gestart om: ", calculation.Name, waterLevel), msgs[i + 1]); + StringAssert.StartsWith(string.Format("Berekening '{0}' voor waterstand '{1}' beëindigd om: ", calculation.Name, waterLevel), msgs[i + 2]); + i = i + 2; + } + + StringAssert.StartsWith(string.Format("Berekening van '{0}' beëindigd om: ", calculation.Name), msgs[7]); + }); + Assert.AreEqual(ActivityState.Executed, activity.State); + } + } + + [Test] + public void OnRun_CalculationWithWaterLevelsCannotPerformCalculation_LogStartAndErrorAndEnd() + { + // Setup + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + ImportHydraulicBoundaryDatabase(assessmentSection); + + var calculation = GetValidCalculation(assessmentSection); + + var activity = new GrassCoverErosionOutwardsWaveConditionsCalculationActivity(calculation, + testDataPath, + assessmentSection.GrassCoverErosionOutwards, + assessmentSection); + + using (new HydraRingCalculationServiceConfig()) + { + // Call + Action call = () => activity.Run(); + + // Assert + TestHelper.AssertLogMessages(call, messages => + { + var msgs = messages.ToArray(); + Assert.AreEqual(11, msgs.Length); + StringAssert.StartsWith(string.Format("Berekening van '{0}' gestart om: ", calculation.Name), msgs[0]); + + int i = 0; + foreach (var waterLevel in calculation.InputParameters.WaterLevels) + { + StringAssert.StartsWith(string.Format("Berekening '{0}' voor waterstand '{1}' gestart om: ", calculation.Name, waterLevel), msgs[i + 1]); + Assert.AreEqual(string.Format("Berekening '{0}' voor waterstand '{1}' is niet gelukt.", calculation.Name, waterLevel), msgs[i + 2]); + StringAssert.StartsWith(string.Format("Berekening '{0}' voor waterstand '{1}' beëindigd om: ", calculation.Name, waterLevel), msgs[i + 3]); + + i = i + 3; + } + + StringAssert.StartsWith(string.Format("Berekening van '{0}' beëindigd om: ", calculation.Name), msgs[10]); + }); + Assert.AreEqual(ActivityState.Failed, activity.State); + } + } + + [Test] + public void OnRun_Always_SetProgressTexts() + { + // Setup + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + ImportHydraulicBoundaryDatabase(assessmentSection); + + var calculation = GetValidCalculation(assessmentSection); + + var activity = new GrassCoverErosionOutwardsWaveConditionsCalculationActivity(calculation, + testDataPath, + assessmentSection.GrassCoverErosionOutwards, + assessmentSection); + + using (new HydraRingCalculationServiceConfig()) + { + List progessTexts = new List(); + activity.ProgressChanged += (sender, args) => { progessTexts.Add(activity.ProgressText); }; + + // Call + activity.Run(); + + // Assert + foreach (var waterLevel in calculation.InputParameters.WaterLevels) + { + var text = string.Format(Resources.GrassCoverErosionOutwardsWaveConditionsCalculationActivity_OnRun_Calculate_waterlevel_0_, waterLevel); + CollectionAssert.Contains(progessTexts, text); + } + } + } + + [Test] + public void OnFinish_CalculationPerformed_SetsOutput() + { + // Setup + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + ImportHydraulicBoundaryDatabase(assessmentSection); + + var calculation = GetValidCalculation(assessmentSection); + + var activity = new GrassCoverErosionOutwardsWaveConditionsCalculationActivity(calculation, + testDataPath, + assessmentSection.GrassCoverErosionOutwards, + assessmentSection); + + using (new HydraRingCalculationServiceConfig()) + using (new WaveConditionsCalculationServiceConfig()) + { + activity.Run(); + + // Call + activity.Finish(); + + // Assert + Assert.IsNotNull(calculation.Output); + Assert.AreEqual(3, calculation.Output.Items.Count()); + } + } + + [Test] + public void OnFinish_CalculationFailed_OutputNull() + { + // Setup + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + ImportHydraulicBoundaryDatabase(assessmentSection); + + var calculation = GetValidCalculation(assessmentSection); + + var activity = new GrassCoverErosionOutwardsWaveConditionsCalculationActivity(calculation, + testDataPath, + assessmentSection.GrassCoverErosionOutwards, + assessmentSection); + + using (new HydraRingCalculationServiceConfig()) + { + activity.Run(); + + // Call + activity.Finish(); + + // Assert + Assert.IsNull(calculation.Output); + } + } + + private static GrassCoverErosionOutwardsWaveConditionsCalculation GetValidCalculation(AssessmentSection assessmentSection) + { + var calculation = new GrassCoverErosionOutwardsWaveConditionsCalculation + { + InputParameters = + { + HydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001), + ForeshoreProfile = CreateForeshoreProfile(), + UseForeshore = true, + UseBreakWater = true, + StepSize = (RoundedDouble) 0.5, + LowerBoundaryRevetment = (RoundedDouble) 4, + UpperBoundaryRevetment = (RoundedDouble) 10, + UpperBoundaryWaterLevels = (RoundedDouble) 8, + LowerBoundaryWaterLevels = (RoundedDouble) 7.1 + } + }; + calculation.InputParameters.HydraulicBoundaryLocation.DesignWaterLevel = (RoundedDouble) 9.3; + return calculation; + } + + private void ImportHydraulicBoundaryDatabase(AssessmentSection assessmentSection) + { + string validFilePath = Path.Combine(testDataPath, "HRD dutch coast south.sqlite"); + + using (var importer = new HydraulicBoundaryDatabaseImporter()) + { + importer.Import(assessmentSection, validFilePath); + } + } + + private static ForeshoreProfile CreateForeshoreProfile() + { + return new ForeshoreProfile(new Point2D(0, 0), + new[] + { + new Point2D(3.3, 4.4), + new Point2D(5.5, 6.6) + }, + new BreakWater(BreakWaterType.Dam, 10.0), + new ForeshoreProfile.ConstructionProperties()); + } + } +} \ No newline at end of file Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Integration.Test/Ringtoets.GrassCoverErosionOutwards.Integration.Test.csproj =================================================================== diff -u -raac499c97ccf17315df116d9d8a962bc1cbd009b -r50ecb5a95c088a636ec38ce3c5f2fc8addcd67e3 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Integration.Test/Ringtoets.GrassCoverErosionOutwards.Integration.Test.csproj (.../Ringtoets.GrassCoverErosionOutwards.Integration.Test.csproj) (revision aac499c97ccf17315df116d9d8a962bc1cbd009b) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Integration.Test/Ringtoets.GrassCoverErosionOutwards.Integration.Test.csproj (.../Ringtoets.GrassCoverErosionOutwards.Integration.Test.csproj) (revision 50ecb5a95c088a636ec38ce3c5f2fc8addcd67e3) @@ -43,20 +43,82 @@ + + ..\..\..\..\packages\System.Data.SQLite.Core.1.0.99.0\lib\net40\System.Data.SQLite.dll + True + Properties\GlobalAssembly.cs + Copying.licenseheader + + + {3bbfd65b-b277-4e50-ae6d-bd24c3434609} + Core.Common.Base + + + {D749EE4C-CE50-4C17-BF01-9A953028C126} + Core.Common.TestUtil + + + {d4200f43-3f72-4f42-af0a-8ced416a38ec} + Ringtoets.Common.Data + + + {888d4097-8bc2-4703-9fb1-8744c94d525e} + Ringtoets.HydraRing.Calculation + + + {70f8cc9c-5bc8-4fb2-b201-eae7fa8088c2} + Ringtoets.HydraRing.Data + + + {74CBA865-9338-447F-BAD9-28312446AE84} + Ringtoets.HydraRing.Calculation.TestUtil + + + {11F1F874-45AF-43E4-8AE5-15A5C9593E28} + Ringtoets.Integration.Data + + + {C8383B76-B3F1-4E6E-B56C-527B469FA20A} + Ringtoets.Integration.Plugin + + + {87c2c553-c0bc-40bf-b1ea-b83bff357f27} + Ringtoets.Revetment.Data + + + {EA416DD2-1633-439E-8512-B9933E37B9C5} + Ringtoets.Revetment.Service.TestUtil + + + {E7225477-577F-4A17-B7EC-6721158E1543} + Ringtoets.GrassCoverErosionOutwards.Data + + + {18E9F7C8-3170-4E9D-8D9F-1378225EED90} + Ringtoets.GrassCoverErosionOutwards.Service + + + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + +