Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Service/HydraRingCalculationService.cs =================================================================== diff -u -rde737ee4b24659d188bb137d385572159bc099ff -r08e96a88960a9e011a8547c7ec851b8a73480554 --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Service/HydraRingCalculationService.cs (.../HydraRingCalculationService.cs) (revision de737ee4b24659d188bb137d385572159bc099ff) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Service/HydraRingCalculationService.cs (.../HydraRingCalculationService.cs) (revision 08e96a88960a9e011a8547c7ec851b8a73480554) @@ -30,7 +30,7 @@ namespace Ringtoets.HydraRing.Calculation.Service { /// - /// Static class that provides methods for performing Hydra-Ring calculations. + /// Service that provides methods for performing Hydra-Ring calculations. /// public static class HydraRingCalculationService { @@ -49,7 +49,7 @@ // Create a Hydra-Ring configuration service var hydraRingConfigurationService = new HydraRingConfigurationService(ringId, timeIntegrationSchemeType, uncertaintiesType); - hydraRingConfigurationService.AddHydraRingCalculation(hydraRingCalculationInput); + hydraRingConfigurationService.AddHydraRingCalculationInput(hydraRingCalculationInput); // Calculation file names var outputFileName = "designTable.txt"; Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Service/HydraRingConfigurationService.cs =================================================================== diff -u -rc23da0cb282e2e64a20e057d4110a25d4dee5826 -r08e96a88960a9e011a8547c7ec851b8a73480554 --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Service/HydraRingConfigurationService.cs (.../HydraRingConfigurationService.cs) (revision c23da0cb282e2e64a20e057d4110a25d4dee5826) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Service/HydraRingConfigurationService.cs (.../HydraRingConfigurationService.cs) (revision 08e96a88960a9e011a8547c7ec851b8a73480554) @@ -31,7 +31,7 @@ namespace Ringtoets.HydraRing.Calculation.Service { /// - /// Container for all configurations that are necessary for performing a Hydra-Ring calculation. + /// Service for generating the database initialization script that is necessary for performing Hydra-Ring calculations. /// The following Hydra-Ring features are not exposed (yet): /// /// @@ -70,9 +70,9 @@ /// /// Creates a new instance of the class. /// - /// The id of the ring to perform the configured Hydra-Ring calculations for. - /// The to use while executing the configured Hydra-Ring calculations. - /// The to use while executing the configured Hydra-Ring calculations. + /// The id of the ring to perform Hydra-Ring calculations for. + /// The to use while performing Hydra-Ring calculations. + /// The to use while performing Hydra-Ring calculations. public HydraRingConfigurationService(string ringId, HydraRingTimeIntegrationSchemeType timeIntegrationSchemeType, HydraRingUncertaintiesType uncertaintiesType) { hydraRingCalculationInputs = new List(); @@ -83,7 +83,7 @@ } /// - /// Gets the id of the ring to perform the configured Hydra-Ring calculations for. + /// Gets the id of the ring to perform Hydra-Ring calculations for. /// public string RingId { @@ -94,7 +94,7 @@ } /// - /// Gets the to use while executing the configured Hydra-Ring calculations. + /// Gets the to use while performing Hydra-Ring calculations. /// public HydraRingTimeIntegrationSchemeType? TimeIntegrationSchemeType { @@ -105,7 +105,7 @@ } /// - /// Gets the to use while executing the configured Hydra-Ring calculations. + /// Gets the to use while performing Hydra-Ring calculations. /// public HydraRingUncertaintiesType? UncertaintiesType { @@ -116,19 +116,18 @@ } /// - /// Adds a Hydra-Ring calculation to the . + /// Adds Hydra-Ring calculation input to the configuration. /// - /// The container that holds all data for configuring the calculation. - public void AddHydraRingCalculation(HydraRingCalculationInput hydraRingCalculationInput) + /// The calculation input to add to the configuration. + public void AddHydraRingCalculationInput(HydraRingCalculationInput hydraRingCalculationInput) { hydraRingCalculationInputs.Add(hydraRingCalculationInput); } /// - /// Generates a database creation script that can be used to perform a Hydra-Ring calculation. + /// Generates the database creation script necessary for performing Hydra-Ring calculations. /// /// The database creation script. - /// Thrown when one of the relevant input properties is not set. public string GenerateDataBaseCreationScript() { var configurationDictionary = new Dictionary>(); @@ -701,7 +700,7 @@ return string.Join(Environment.NewLine, lines); } - private double? GetHydraRingValue(double value) + private static double? GetHydraRingValue(double value) { return !double.IsNaN(value) ? value : defaultHydraRingValue; } Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Service/HydraRingConfigurationServiceIntegrationTest.cs =================================================================== diff -u -rde737ee4b24659d188bb137d385572159bc099ff -r08e96a88960a9e011a8547c7ec851b8a73480554 --- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Service/HydraRingConfigurationServiceIntegrationTest.cs (.../HydraRingConfigurationServiceIntegrationTest.cs) (revision de737ee4b24659d188bb137d385572159bc099ff) +++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Service/HydraRingConfigurationServiceIntegrationTest.cs (.../HydraRingConfigurationServiceIntegrationTest.cs) (revision 08e96a88960a9e011a8547c7ec851b8a73480554) @@ -35,7 +35,7 @@ { var hydraRingConfigurationService = new HydraRingConfigurationService("34-1", HydraRingTimeIntegrationSchemeType.FBC, HydraRingUncertaintiesType.All); - hydraRingConfigurationService.AddHydraRingCalculation(new AssessmentLevelCalculationInput(700004, 3.29053)); + hydraRingConfigurationService.AddHydraRingCalculationInput(new AssessmentLevelCalculationInput(700004, 3.29053)); var expectedCreationScript = "DELETE FROM [HydraulicModels];" + Environment.NewLine + "INSERT INTO [HydraulicModels] VALUES (1, 1, 'WTI 2017');" + Environment.NewLine + Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Service/HydraRingConfigurationServiceTest.cs =================================================================== diff -u -rde737ee4b24659d188bb137d385572159bc099ff -r08e96a88960a9e011a8547c7ec851b8a73480554 --- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Service/HydraRingConfigurationServiceTest.cs (.../HydraRingConfigurationServiceTest.cs) (revision de737ee4b24659d188bb137d385572159bc099ff) +++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Service/HydraRingConfigurationServiceTest.cs (.../HydraRingConfigurationServiceTest.cs) (revision 08e96a88960a9e011a8547c7ec851b8a73480554) @@ -44,41 +44,41 @@ } [Test] - public void GenerateDataBaseCreationScript_NonDefaultHydraRingConfiguration_ReturnsExpectedCreationScript() + public void GenerateDataBaseCreationScript_SingleHydraRingCalculationInputAddedToConfiguration_ReturnsExpectedCreationScript() { var hydraRingConfigurationService = new HydraRingConfigurationService("34-1", HydraRingTimeIntegrationSchemeType.NTI, HydraRingUncertaintiesType.Model); - hydraRingConfigurationService.AddHydraRingCalculation(new HydraRingCalculationInputImplementation(700004)); + hydraRingConfigurationService.AddHydraRingCalculationInput(new HydraRingCalculationInputImplementation(1, 700004)); var expectedCreationScript = "DELETE FROM [HydraulicModels];" + Environment.NewLine + "INSERT INTO [HydraulicModels] VALUES (3, 2, 'WTI 2017');" + Environment.NewLine + Environment.NewLine + "DELETE FROM [Sections];" + Environment.NewLine + - "INSERT INTO [Sections] VALUES (9999, 1, 1, 'LocationName', 'LocationName', 2.2, 3.3, 5.5, 6.6, 700004, 700004, 100, 7.7, 4.4);" + Environment.NewLine + + "INSERT INTO [Sections] VALUES (1, 1, 1, 'LocationName', 'LocationName', 2.2, 3.3, 5.5, 6.6, 700004, 700004, 100, 7.7, 4.4);" + Environment.NewLine + Environment.NewLine + "DELETE FROM [DesignTables];" + Environment.NewLine + - "INSERT INTO [DesignTables] VALUES (9999, 1, 1, 1, 4, 26, 0, 0, 0, 0, 0, 50, 1.1);" + Environment.NewLine + + "INSERT INTO [DesignTables] VALUES (1, 1, 1, 1, 4, 26, 0, 0, 0, 0, 0, 50, 1.1);" + Environment.NewLine + Environment.NewLine + "DELETE FROM [Numerics];" + Environment.NewLine + - "INSERT INTO [Numerics] VALUES (9999, 1, 1, 1, 1, 1, 4, 50, 0.15, 0.01, 0.01, 0.01, 2, 1, 20000, 100000, 0.1, -6, 6, 25);" + Environment.NewLine + + "INSERT INTO [Numerics] VALUES (1, 1, 1, 1, 1, 1, 4, 50, 0.15, 0.01, 0.01, 0.01, 2, 1, 20000, 100000, 0.1, -6, 6, 25);" + Environment.NewLine + Environment.NewLine + "DELETE FROM [VariableDatas];" + Environment.NewLine + - "INSERT INTO [VariableDatas] VALUES (9999, 1, 1, 1, 26, 2.2, 0, 0, 0, 0, 0, 0, 0, 300);" + Environment.NewLine + - "INSERT INTO [VariableDatas] VALUES (9999, 1, 1, 1, 26, 22.2, 0, 0, 0, 0, 0, 1, 0, 300);" + Environment.NewLine + - "INSERT INTO [VariableDatas] VALUES (9999, 1, 1, 1, 26, 0, 2, 333.3, 444.4, 0, 0, 0, 0, 300);" + Environment.NewLine + - "INSERT INTO [VariableDatas] VALUES (9999, 1, 1, 1, 26, 0, 2, 3333.3, 0, 0, 0, 1, 4444.4, 300);" + Environment.NewLine + - "INSERT INTO [VariableDatas] VALUES (9999, 1, 1, 1, 26, 0, 4, 33333.3, 44444.4, 55555.5, 0, 0, 0, 300);" + Environment.NewLine + - "INSERT INTO [VariableDatas] VALUES (9999, 1, 1, 1, 26, 0, 4, 333333.3, 0, 555555.5, 0, 1, 444444.4, 300);" + Environment.NewLine + + "INSERT INTO [VariableDatas] VALUES (1, 1, 1, 1, 26, 2.2, 0, 0, 0, 0, 0, 0, 0, 300);" + Environment.NewLine + + "INSERT INTO [VariableDatas] VALUES (1, 1, 1, 1, 26, 22.2, 0, 0, 0, 0, 0, 1, 0, 300);" + Environment.NewLine + + "INSERT INTO [VariableDatas] VALUES (1, 1, 1, 1, 26, 0, 2, 333.3, 444.4, 0, 0, 0, 0, 300);" + Environment.NewLine + + "INSERT INTO [VariableDatas] VALUES (1, 1, 1, 1, 26, 0, 2, 3333.3, 0, 0, 0, 1, 4444.4, 300);" + Environment.NewLine + + "INSERT INTO [VariableDatas] VALUES (1, 1, 1, 1, 26, 0, 4, 33333.3, 44444.4, 55555.5, 0, 0, 0, 300);" + Environment.NewLine + + "INSERT INTO [VariableDatas] VALUES (1, 1, 1, 1, 26, 0, 4, 333333.3, 0, 555555.5, 0, 1, 444444.4, 300);" + Environment.NewLine + Environment.NewLine + "DELETE FROM [CalculationProfiles];" + Environment.NewLine + - "INSERT INTO [CalculationProfiles] VALUES (9999, 1, 1.1, 2.2, 3.3);" + Environment.NewLine + - "INSERT INTO [CalculationProfiles] VALUES (9999, 2, 11.1, 22.2, 33.3);" + Environment.NewLine + + "INSERT INTO [CalculationProfiles] VALUES (1, 1, 1.1, 2.2, 3.3);" + Environment.NewLine + + "INSERT INTO [CalculationProfiles] VALUES (1, 2, 11.1, 22.2, 33.3);" + Environment.NewLine + Environment.NewLine + "DELETE FROM [SectionFaultTreeModels];" + Environment.NewLine + - "INSERT INTO [SectionFaultTreeModels] VALUES (9999, 1, 1, 1, 1);" + Environment.NewLine + + "INSERT INTO [SectionFaultTreeModels] VALUES (1, 1, 1, 1, 1);" + Environment.NewLine + Environment.NewLine + "DELETE FROM [SectionSubMechanismModels];" + Environment.NewLine + - "INSERT INTO [SectionSubMechanismModels] VALUES (9999, 1, 1, 1, 1, 1234);" + Environment.NewLine + + "INSERT INTO [SectionSubMechanismModels] VALUES (1, 1, 1, 1, 1, 1234);" + Environment.NewLine + Environment.NewLine + "DELETE FROM [Fetches];" + Environment.NewLine + Environment.NewLine + @@ -113,10 +113,113 @@ Assert.AreEqual(expectedCreationScript, creationScript); } + [Test] + public void GenerateDataBaseCreationScript_MultipleHydraRingCalculationInputsAddedToConfiguration_ReturnsExpectedCreationScript() + { + var hydraRingConfigurationService = new HydraRingConfigurationService("34-1", HydraRingTimeIntegrationSchemeType.NTI, HydraRingUncertaintiesType.Model); + + hydraRingConfigurationService.AddHydraRingCalculationInput(new HydraRingCalculationInputImplementation(1, 700004)); + hydraRingConfigurationService.AddHydraRingCalculationInput(new HydraRingCalculationInputImplementation(2, 700005)); + hydraRingConfigurationService.AddHydraRingCalculationInput(new HydraRingCalculationInputImplementation(3, 700006)); + + var expectedCreationScript = "DELETE FROM [HydraulicModels];" + Environment.NewLine + + "INSERT INTO [HydraulicModels] VALUES (3, 2, 'WTI 2017');" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [Sections];" + Environment.NewLine + + "INSERT INTO [Sections] VALUES (1, 1, 1, 'LocationName', 'LocationName', 2.2, 3.3, 5.5, 6.6, 700004, 700004, 100, 7.7, 4.4);" + Environment.NewLine + + "INSERT INTO [Sections] VALUES (2, 1, 1, 'LocationName', 'LocationName', 2.2, 3.3, 5.5, 6.6, 700005, 700005, 100, 7.7, 4.4);" + Environment.NewLine + + "INSERT INTO [Sections] VALUES (3, 1, 1, 'LocationName', 'LocationName', 2.2, 3.3, 5.5, 6.6, 700006, 700006, 100, 7.7, 4.4);" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [DesignTables];" + Environment.NewLine + + "INSERT INTO [DesignTables] VALUES (1, 1, 1, 1, 4, 26, 0, 0, 0, 0, 0, 50, 1.1);" + Environment.NewLine + + "INSERT INTO [DesignTables] VALUES (2, 1, 1, 1, 4, 26, 0, 0, 0, 0, 0, 50, 1.1);" + Environment.NewLine + + "INSERT INTO [DesignTables] VALUES (3, 1, 1, 1, 4, 26, 0, 0, 0, 0, 0, 50, 1.1);" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [Numerics];" + Environment.NewLine + + "INSERT INTO [Numerics] VALUES (1, 1, 1, 1, 1, 1, 4, 50, 0.15, 0.01, 0.01, 0.01, 2, 1, 20000, 100000, 0.1, -6, 6, 25);" + Environment.NewLine + + "INSERT INTO [Numerics] VALUES (2, 1, 1, 1, 1, 1, 4, 50, 0.15, 0.01, 0.01, 0.01, 2, 1, 20000, 100000, 0.1, -6, 6, 25);" + Environment.NewLine + + "INSERT INTO [Numerics] VALUES (3, 1, 1, 1, 1, 1, 4, 50, 0.15, 0.01, 0.01, 0.01, 2, 1, 20000, 100000, 0.1, -6, 6, 25);" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [VariableDatas];" + Environment.NewLine + + "INSERT INTO [VariableDatas] VALUES (1, 1, 1, 1, 26, 2.2, 0, 0, 0, 0, 0, 0, 0, 300);" + Environment.NewLine + + "INSERT INTO [VariableDatas] VALUES (1, 1, 1, 1, 26, 22.2, 0, 0, 0, 0, 0, 1, 0, 300);" + Environment.NewLine + + "INSERT INTO [VariableDatas] VALUES (1, 1, 1, 1, 26, 0, 2, 333.3, 444.4, 0, 0, 0, 0, 300);" + Environment.NewLine + + "INSERT INTO [VariableDatas] VALUES (1, 1, 1, 1, 26, 0, 2, 3333.3, 0, 0, 0, 1, 4444.4, 300);" + Environment.NewLine + + "INSERT INTO [VariableDatas] VALUES (1, 1, 1, 1, 26, 0, 4, 33333.3, 44444.4, 55555.5, 0, 0, 0, 300);" + Environment.NewLine + + "INSERT INTO [VariableDatas] VALUES (1, 1, 1, 1, 26, 0, 4, 333333.3, 0, 555555.5, 0, 1, 444444.4, 300);" + Environment.NewLine + + "INSERT INTO [VariableDatas] VALUES (2, 1, 1, 1, 26, 2.2, 0, 0, 0, 0, 0, 0, 0, 300);" + Environment.NewLine + + "INSERT INTO [VariableDatas] VALUES (2, 1, 1, 1, 26, 22.2, 0, 0, 0, 0, 0, 1, 0, 300);" + Environment.NewLine + + "INSERT INTO [VariableDatas] VALUES (2, 1, 1, 1, 26, 0, 2, 333.3, 444.4, 0, 0, 0, 0, 300);" + Environment.NewLine + + "INSERT INTO [VariableDatas] VALUES (2, 1, 1, 1, 26, 0, 2, 3333.3, 0, 0, 0, 1, 4444.4, 300);" + Environment.NewLine + + "INSERT INTO [VariableDatas] VALUES (2, 1, 1, 1, 26, 0, 4, 33333.3, 44444.4, 55555.5, 0, 0, 0, 300);" + Environment.NewLine + + "INSERT INTO [VariableDatas] VALUES (2, 1, 1, 1, 26, 0, 4, 333333.3, 0, 555555.5, 0, 1, 444444.4, 300);" + Environment.NewLine + + "INSERT INTO [VariableDatas] VALUES (3, 1, 1, 1, 26, 2.2, 0, 0, 0, 0, 0, 0, 0, 300);" + Environment.NewLine + + "INSERT INTO [VariableDatas] VALUES (3, 1, 1, 1, 26, 22.2, 0, 0, 0, 0, 0, 1, 0, 300);" + Environment.NewLine + + "INSERT INTO [VariableDatas] VALUES (3, 1, 1, 1, 26, 0, 2, 333.3, 444.4, 0, 0, 0, 0, 300);" + Environment.NewLine + + "INSERT INTO [VariableDatas] VALUES (3, 1, 1, 1, 26, 0, 2, 3333.3, 0, 0, 0, 1, 4444.4, 300);" + Environment.NewLine + + "INSERT INTO [VariableDatas] VALUES (3, 1, 1, 1, 26, 0, 4, 33333.3, 44444.4, 55555.5, 0, 0, 0, 300);" + Environment.NewLine + + "INSERT INTO [VariableDatas] VALUES (3, 1, 1, 1, 26, 0, 4, 333333.3, 0, 555555.5, 0, 1, 444444.4, 300);" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [CalculationProfiles];" + Environment.NewLine + + "INSERT INTO [CalculationProfiles] VALUES (1, 1, 1.1, 2.2, 3.3);" + Environment.NewLine + + "INSERT INTO [CalculationProfiles] VALUES (1, 2, 11.1, 22.2, 33.3);" + Environment.NewLine + + "INSERT INTO [CalculationProfiles] VALUES (2, 1, 1.1, 2.2, 3.3);" + Environment.NewLine + + "INSERT INTO [CalculationProfiles] VALUES (2, 2, 11.1, 22.2, 33.3);" + Environment.NewLine + + "INSERT INTO [CalculationProfiles] VALUES (3, 1, 1.1, 2.2, 3.3);" + Environment.NewLine + + "INSERT INTO [CalculationProfiles] VALUES (3, 2, 11.1, 22.2, 33.3);" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [SectionFaultTreeModels];" + Environment.NewLine + + "INSERT INTO [SectionFaultTreeModels] VALUES (1, 1, 1, 1, 1);" + Environment.NewLine + + "INSERT INTO [SectionFaultTreeModels] VALUES (2, 1, 1, 1, 1);" + Environment.NewLine + + "INSERT INTO [SectionFaultTreeModels] VALUES (3, 1, 1, 1, 1);" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [SectionSubMechanismModels];" + Environment.NewLine + + "INSERT INTO [SectionSubMechanismModels] VALUES (1, 1, 1, 1, 1, 1234);" + Environment.NewLine + + "INSERT INTO [SectionSubMechanismModels] VALUES (2, 1, 1, 1, 1, 1234);" + Environment.NewLine + + "INSERT INTO [SectionSubMechanismModels] VALUES (3, 1, 1, 1, 1, 1234);" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [Fetches];" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [AreaPoints];" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [PresentationSections];" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [Profiles];" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [ForelandModels];" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [Forelands];" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [ProbabilityAlternatives];" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [SetUpHeights];" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [CalcWindDirections];" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [Swells];" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [WaveReductions];" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [Areas];" + Environment.NewLine + + "INSERT INTO [Areas] VALUES (1, '1', 'Nederland');" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [Projects];" + Environment.NewLine + + "INSERT INTO [Projects] VALUES (1, 'WTI 2017', 'Ringtoets calculation');" + Environment.NewLine; + + var creationScript = hydraRingConfigurationService.GenerateDataBaseCreationScript(); + + Assert.AreEqual(expectedCreationScript, creationScript); + } + private class HydraRingCalculationInputImplementation : HydraRingCalculationInput { - public HydraRingCalculationInputImplementation(int hydraulicBoundaryLocationId) : base(hydraulicBoundaryLocationId) {} + private readonly int sectionId; + public HydraRingCalculationInputImplementation(int sectionId, int hydraulicBoundaryLocationId) : base(hydraulicBoundaryLocationId) + { + this.sectionId = sectionId; + } + public override HydraRingFailureMechanismType FailureMechanismType { get @@ -137,7 +240,7 @@ { get { - return new HydraRingDikeSection(9999, "LocationName", 2.2, 3.3, 4.4, 5.5, 6.6, 7.7); + return new HydraRingDikeSection(sectionId, "LocationName", 2.2, 3.3, 4.4, 5.5, 6.6, 7.7); } }