Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj =================================================================== diff -u -r4b095752c115dd672400da5a4acc1560e4c9ce2c -r183d1e7ed095ea4e8024068bc4ddfcf3ac6997d3 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 4b095752c115dd672400da5a4acc1560e4c9ce2c) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 183d1e7ed095ea4e8024068bc4ddfcf3ac6997d3) @@ -68,7 +68,7 @@ - + Code Fisheye: Tag 183d1e7ed095ea4e8024068bc4ddfcf3ac6997d3 refers to a dead (removed) revision in file `Application/Ringtoets/src/Application.Ringtoets.Storage/Create/HeightStructures/HeightStructuresCalculationCreateExtensions.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/StructuresCalculationCreateExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/StructuresCalculationCreateExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/StructuresCalculationCreateExtensions.cs (revision 183d1e7ed095ea4e8024068bc4ddfcf3ac6997d3) @@ -0,0 +1,119 @@ +// 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 Application.Ringtoets.Storage.DbContext; +using Core.Common.Utils.Extensions; +using Ringtoets.Common.Data.Structures; +using Ringtoets.HeightStructures.Data; + +namespace Application.Ringtoets.Storage.Create +{ + /// + /// Extension methods for related + /// to creating structures calculation entities. + /// + internal static class StructuresCalculationCreateExtensions + { + /// + /// Creates a based + /// on the information of the . + /// + /// The calculation to create a database entity for. + /// The object keeping track of create operations. + /// The index at where resides + /// in its parent container. + /// A new . + /// Thrown when is null. + internal static HeightStructuresCalculationEntity Create(this StructuresCalculation calculation, PersistenceRegistry registry, int order) + { + if (registry == null) + { + throw new ArgumentNullException("registry"); + } + + var entity = new HeightStructuresCalculationEntity + { + Name = calculation.Name.DeepClone(), + Comments = calculation.Comments.DeepClone(), + Order = order + }; + SetInputValues(entity, calculation.InputParameters, registry); + + if (calculation.HasOutput) + { + entity.HeightStructuresOutputEntities.Add(calculation.Output.Create(registry)); + } + + registry.Register(entity, calculation); + + return entity; + } + + private static void SetInputValues(HeightStructuresCalculationEntity entity, HeightStructuresInput input, PersistenceRegistry registry) + { + if (input.HydraulicBoundaryLocation != null) + { + entity.HydraulicLocationEntity = registry.Get(input.HydraulicBoundaryLocation); + } + if (input.Structure != null) + { + entity.HeightStructureEntity = registry.Get(input.Structure); + } + if (input.ForeshoreProfile != null) + { + entity.ForeshoreProfileEntity = registry.Get(input.ForeshoreProfile); + } + entity.StructureNormalOrientation = input.StructureNormalOrientation.Value.ToNaNAsNull(); + + entity.ModelFactorSuperCriticalFlowMean = input.ModelFactorSuperCriticalFlow.Mean.Value.ToNaNAsNull(); + + entity.AllowedLevelIncreaseStorageMean = input.AllowedLevelIncreaseStorage.Mean.Value.ToNaNAsNull(); + entity.AllowedLevelIncreaseStorageStandardDeviation = input.AllowedLevelIncreaseStorage.StandardDeviation.Value.ToNaNAsNull(); + + entity.StorageStructureAreaMean = input.StorageStructureArea.Mean.Value.ToNaNAsNull(); + entity.StorageStructureAreaCoefficientOfVariation = input.StorageStructureArea.CoefficientOfVariation.Value.ToNaNAsNull(); + + entity.FlowWidthAtBottomProtectionMean = input.FlowWidthAtBottomProtection.Mean.Value.ToNaNAsNull(); + entity.FlowWidthAtBottomProtectionStandardDeviation = input.FlowWidthAtBottomProtection.StandardDeviation.Value.ToNaNAsNull(); + + entity.CriticalOvertoppingDischargeMean = input.CriticalOvertoppingDischarge.Mean.Value.ToNaNAsNull(); + entity.CriticalOvertoppingDischargeCoefficientOfVariation = input.CriticalOvertoppingDischarge.CoefficientOfVariation.Value.ToNaNAsNull(); + + entity.FailureProbabilityStructureWithErosion = input.FailureProbabilityStructureWithErosion; + + entity.WidthFlowAperturesMean = input.WidthFlowApertures.Mean.Value.ToNaNAsNull(); + entity.WidthFlowAperturesCoefficientOfVariation = input.WidthFlowApertures.CoefficientOfVariation.Value.ToNaNAsNull(); + + entity.StormDurationMean = input.StormDuration.Mean.Value.ToNaNAsNull(); + + entity.LevelCrestStructureMean = input.LevelCrestStructure.Mean.Value.ToNaNAsNull(); + entity.LevelCrestStructureStandardDeviation = input.LevelCrestStructure.StandardDeviation.Value.ToNaNAsNull(); + + entity.DeviationWaveDirection = input.DeviationWaveDirection.Value.ToNaNAsNull(); + + entity.BreakWaterHeight = input.BreakWater.Height.Value.ToNaNAsNull(); + entity.BreakWaterType = Convert.ToInt16(input.BreakWater.Type); + entity.UseBreakWater = Convert.ToByte(input.UseBreakWater); + entity.UseForeshore = Convert.ToByte(input.UseForeshore); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj =================================================================== diff -u -r4b095752c115dd672400da5a4acc1560e4c9ce2c -r183d1e7ed095ea4e8024068bc4ddfcf3ac6997d3 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 4b095752c115dd672400da5a4acc1560e4c9ce2c) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 183d1e7ed095ea4e8024068bc4ddfcf3ac6997d3) @@ -84,7 +84,7 @@ - + Code Fisheye: Tag 183d1e7ed095ea4e8024068bc4ddfcf3ac6997d3 refers to a dead (removed) revision in file `Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/HeightStructures/HeightStructuresCalculationCreateExtensionsTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/StructuresCalculationCreateExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/StructuresCalculationCreateExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/StructuresCalculationCreateExtensionsTest.cs (revision 183d1e7ed095ea4e8024068bc4ddfcf3ac6997d3) @@ -0,0 +1,364 @@ +// 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 Application.Ringtoets.Storage.Create; +using Application.Ringtoets.Storage.DbContext; +using Application.Ringtoets.Storage.TestUtil; +using Core.Common.Base.Data; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.Common.Data.DikeProfiles; +using Ringtoets.Common.Data.Probability; +using Ringtoets.Common.Data.Structures; +using Ringtoets.HeightStructures.Data; +using Ringtoets.HeightStructures.Data.TestUtil; +using Ringtoets.HydraRing.Data; + +namespace Application.Ringtoets.Storage.Test.Create +{ + [TestFixture] + public class StructuresCalculationCreateExtensionsTest + { + [Test] + public void Create_PersistenceRegistryNull_ThrowArgumentNullException() + { + // Setup + var calculation = new StructuresCalculation(); + + // Call + TestDelegate call = () => calculation.Create(null, 0); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("registry", paramName); + } + + [Test] + [TestCase("I have no comments", null, 0, 827364)] + [TestCase("I have a comment", "I am comment", 98, 231)] + public void Create_ValidCalculation_ReturnEntity(string name, string comments, int order, int randomSeed) + { + // Setup + var random = new Random(randomSeed); + + var calculation = new StructuresCalculation + { + Name = name, + Comments = comments, + InputParameters = + { + StructureNormalOrientation = (RoundedDouble) random.GetFromRange(0, 360), + ModelFactorSuperCriticalFlow = + { + Mean = (RoundedDouble) random.GetFromRange(-9999.9999, 9999.9999) + }, + AllowedLevelIncreaseStorage = + { + Mean = (RoundedDouble) random.GetFromRange(1e-6, 9999.9999), + StandardDeviation = (RoundedDouble) random.GetFromRange(1e-6, 9999.9999) + }, + StorageStructureArea = + { + Mean = (RoundedDouble) random.GetFromRange(1e-6, 9999.9999), + CoefficientOfVariation = (RoundedDouble) random.GetFromRange(1e-6, 9999.9999) + }, + FlowWidthAtBottomProtection = + { + Mean = (RoundedDouble) random.GetFromRange(1e-6, 9999.9999), + StandardDeviation = (RoundedDouble) random.GetFromRange(1e-6, 9999.9999) + }, + CriticalOvertoppingDischarge = + { + Mean = (RoundedDouble) random.GetFromRange(1e-6, 9999.9999), + CoefficientOfVariation = (RoundedDouble) random.GetFromRange(1e-6, 9999.9999) + }, + FailureProbabilityStructureWithErosion = random.NextDouble(), + WidthFlowApertures = + { + Mean = (RoundedDouble) random.GetFromRange(-9999.9999, 9999.9999), + CoefficientOfVariation = (RoundedDouble) random.GetFromRange(1e-6, 9999.9999) + }, + StormDuration = + { + Mean = (RoundedDouble) random.GetFromRange(1e-6, 9999.9999), + CoefficientOfVariation = (RoundedDouble) random.GetFromRange(1e-6, 9999.9999) + }, + DeviationWaveDirection = (RoundedDouble) random.NextDouble(), + LevelCrestStructure = + { + Mean = (RoundedDouble) random.GetFromRange(-9999.9999, 9999.9999), + StandardDeviation = (RoundedDouble) random.GetFromRange(1e-6, 9999.9999) + }, + UseBreakWater = true, + UseForeshore = false, + BreakWater = + { + Height = (RoundedDouble) random.NextDouble(), + Type = BreakWaterType.Dam + } + } + }; + + var registry = new PersistenceRegistry(); + + // Call + HeightStructuresCalculationEntity entity = calculation.Create(registry, order); + + // Assert + Assert.AreEqual(0, entity.HeightStructuresCalculationEntityId); + Assert.AreEqual(name, entity.Name); + Assert.AreEqual(comments, entity.Comments); + Assert.AreEqual(order, entity.Order); + + HeightStructuresInput input = calculation.InputParameters; + Assert.AreEqual(input.StructureNormalOrientation.Value, entity.StructureNormalOrientation); + Assert.AreEqual(input.ModelFactorSuperCriticalFlow.Mean.Value, entity.ModelFactorSuperCriticalFlowMean); + Assert.AreEqual(input.AllowedLevelIncreaseStorage.Mean.Value, entity.AllowedLevelIncreaseStorageMean); + Assert.AreEqual(input.AllowedLevelIncreaseStorage.StandardDeviation.Value, entity.AllowedLevelIncreaseStorageStandardDeviation); + Assert.AreEqual(input.StorageStructureArea.Mean.Value, entity.StorageStructureAreaMean); + Assert.AreEqual(input.StorageStructureArea.CoefficientOfVariation.Value, entity.StorageStructureAreaCoefficientOfVariation); + Assert.AreEqual(input.FlowWidthAtBottomProtection.Mean.Value, entity.FlowWidthAtBottomProtectionMean); + Assert.AreEqual(input.FlowWidthAtBottomProtection.StandardDeviation.Value, entity.FlowWidthAtBottomProtectionStandardDeviation); + Assert.AreEqual(input.CriticalOvertoppingDischarge.Mean.Value, entity.CriticalOvertoppingDischargeMean); + Assert.AreEqual(input.CriticalOvertoppingDischarge.CoefficientOfVariation.Value, entity.CriticalOvertoppingDischargeCoefficientOfVariation); + Assert.AreEqual(input.FailureProbabilityStructureWithErosion, entity.FailureProbabilityStructureWithErosion); + Assert.AreEqual(input.WidthFlowApertures.Mean.Value, entity.WidthFlowAperturesMean); + Assert.AreEqual(input.WidthFlowApertures.CoefficientOfVariation.Value, entity.WidthFlowAperturesCoefficientOfVariation); + Assert.AreEqual(input.StormDuration.Mean.Value, entity.StormDurationMean); + + Assert.AreEqual(input.LevelCrestStructure.Mean.Value, entity.LevelCrestStructureMean); + Assert.AreEqual(input.LevelCrestStructure.StandardDeviation.Value, entity.LevelCrestStructureStandardDeviation); + Assert.AreEqual(input.DeviationWaveDirection.Value, entity.DeviationWaveDirection); + + Assert.IsNull(entity.CalculationGroupEntity); + Assert.IsNull(entity.ForeshoreProfileEntityId); + Assert.IsNull(entity.HeightStructureEntityId); + Assert.IsNull(entity.HydraulicLocationEntityId); + + Assert.AreEqual(input.BreakWater.Height.Value, entity.BreakWaterHeight); + Assert.AreEqual((short) input.BreakWater.Type, entity.BreakWaterType); + Assert.AreEqual(Convert.ToByte(input.UseBreakWater), entity.UseBreakWater); + Assert.AreEqual(Convert.ToByte(input.UseForeshore), entity.UseForeshore); + } + + [Test] + public void Create_NaNParameters_EntityWithNullFields() + { + // Setup + var calculation = new StructuresCalculation + { + InputParameters = + { + StructureNormalOrientation = RoundedDouble.NaN, + ModelFactorSuperCriticalFlow = + { + Mean = RoundedDouble.NaN + }, + AllowedLevelIncreaseStorage = + { + Mean = RoundedDouble.NaN, + StandardDeviation = RoundedDouble.NaN + }, + StorageStructureArea = + { + Mean = RoundedDouble.NaN, + CoefficientOfVariation = RoundedDouble.NaN + }, + FlowWidthAtBottomProtection = + { + Mean = RoundedDouble.NaN, + StandardDeviation = RoundedDouble.NaN + }, + CriticalOvertoppingDischarge = + { + Mean = RoundedDouble.NaN, + CoefficientOfVariation = RoundedDouble.NaN + }, + WidthFlowApertures = + { + Mean = RoundedDouble.NaN, + CoefficientOfVariation = RoundedDouble.NaN + }, + StormDuration = + { + Mean = RoundedDouble.NaN, + CoefficientOfVariation = RoundedDouble.NaN + }, + LevelCrestStructure = + { + Mean = RoundedDouble.NaN, + StandardDeviation = RoundedDouble.NaN + }, + DeviationWaveDirection = RoundedDouble.NaN, + BreakWater = + { + Height = RoundedDouble.NaN + } + } + }; + var registry = new PersistenceRegistry(); + + // Call + HeightStructuresCalculationEntity entity = calculation.Create(registry, 0); + + // Assert + Assert.IsNull(entity.StructureNormalOrientation); + Assert.IsNull(entity.ModelFactorSuperCriticalFlowMean); + Assert.IsNull(entity.AllowedLevelIncreaseStorageMean); + Assert.IsNull(entity.AllowedLevelIncreaseStorageStandardDeviation); + Assert.IsNull(entity.StorageStructureAreaMean); + Assert.IsNull(entity.StorageStructureAreaCoefficientOfVariation); + Assert.IsNull(entity.FlowWidthAtBottomProtectionMean); + Assert.IsNull(entity.FlowWidthAtBottomProtectionStandardDeviation); + Assert.IsNull(entity.CriticalOvertoppingDischargeMean); + Assert.IsNull(entity.CriticalOvertoppingDischargeCoefficientOfVariation); + Assert.IsNull(entity.WidthFlowAperturesMean); + Assert.IsNull(entity.WidthFlowAperturesCoefficientOfVariation); + Assert.IsNull(entity.StormDurationMean); + Assert.IsNull(entity.DeviationWaveDirection); + Assert.IsNull(entity.LevelCrestStructureMean); + Assert.IsNull(entity.LevelCrestStructureStandardDeviation); + + Assert.IsNull(entity.BreakWaterHeight); + } + + [Test] + public void Create_StringPropertiesDoNotShareReference() + { + // Setup + const string name = "A"; + const string comment = "B"; + var calculation = new StructuresCalculation + { + Name = name, + Comments = comment + }; + + var registry = new PersistenceRegistry(); + + // Call + HeightStructuresCalculationEntity entity = calculation.Create(registry, 0); + + // Assert + Assert.AreNotSame(name, entity.Name, + "To create stable binary representations/fingerprints, it's really important that strings are not shared."); + Assert.AreEqual(name, entity.Name); + + Assert.AreNotSame(comment, entity.Comments, + "To create stable binary representations/fingerprints, it's really important that strings are not shared."); + Assert.AreEqual(comment, entity.Comments); + } + + [Test] + public void Create_CalculationWithAlreadySavedHydraulicBoundaryLocation_ReturnEntityWithHydraulicLocationEntity() + { + // Setup + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "A", 1, 1); + var calculation = new StructuresCalculation + { + InputParameters = + { + HydraulicBoundaryLocation = hydraulicBoundaryLocation + } + }; + + var hydraulicLocationEntity = new HydraulicLocationEntity(); + var registry = new PersistenceRegistry(); + registry.Register(hydraulicLocationEntity, hydraulicBoundaryLocation); + + // Call + HeightStructuresCalculationEntity entity = calculation.Create(registry, 0); + + // Assert + Assert.AreSame(hydraulicLocationEntity, entity.HydraulicLocationEntity); + } + + [Test] + public void Create_CalculationWithAlreadySavedHeightStructure_ReturnEntityWithHeightStructureEntity() + { + // Setup + var heightStructure = new TestHeightStructure(); + var calculation = new StructuresCalculation + { + InputParameters = + { + Structure = heightStructure + } + }; + + var heightStructureEntity = new HeightStructureEntity(); + var registry = new PersistenceRegistry(); + registry.Register(heightStructureEntity, heightStructure); + + // Call + HeightStructuresCalculationEntity entity = calculation.Create(registry, 0); + + // Assert + Assert.AreSame(heightStructureEntity, entity.HeightStructureEntity); + } + + [Test] + public void Create_CalculationWithAlreadySavedForeshoreProfile_ReturnEntityWithForeshoreProfileEntity() + { + // Setup + var foreshoreProfile = new TestForeshoreProfile(); + var calculation = new StructuresCalculation + { + InputParameters = + { + ForeshoreProfile = foreshoreProfile + } + }; + + var foreshoreProfileEntity = new ForeshoreProfileEntity(); + var registry = new PersistenceRegistry(); + registry.Register(foreshoreProfileEntity, foreshoreProfile); + + // Call + HeightStructuresCalculationEntity entity = calculation.Create(registry, 0); + + // Assert + Assert.AreSame(foreshoreProfileEntity, entity.ForeshoreProfileEntity); + } + + [Test] + public void Create_CalculationWithOutput_ReturnEntity() + { + // Setup + var random = new Random(159); + var calculation = new StructuresCalculation + { + Output = new ProbabilityAssessmentOutput(random.NextDouble(), random.NextDouble(), + random.NextDouble(), random.NextDouble(), + random.NextDouble()) + }; + + var registry = new PersistenceRegistry(); + + // Call + HeightStructuresCalculationEntity entity = calculation.Create(registry, 0); + + // Assert + Assert.AreEqual(1, entity.HeightStructuresOutputEntities.Count); + } + } +} \ No newline at end of file Index: Demo/Ringtoets/test/Demo.Ringtoets.Test/Commands/AddNewDemoAssessmentSectionCommandTest.cs =================================================================== diff -u -r5d36087eefd43dcb327163ef5e9c4e52407ccc96 -r183d1e7ed095ea4e8024068bc4ddfcf3ac6997d3 --- Demo/Ringtoets/test/Demo.Ringtoets.Test/Commands/AddNewDemoAssessmentSectionCommandTest.cs (.../AddNewDemoAssessmentSectionCommandTest.cs) (revision 5d36087eefd43dcb327163ef5e9c4e52407ccc96) +++ Demo/Ringtoets/test/Demo.Ringtoets.Test/Commands/AddNewDemoAssessmentSectionCommandTest.cs (.../AddNewDemoAssessmentSectionCommandTest.cs) (revision 183d1e7ed095ea4e8024068bc4ddfcf3ac6997d3) @@ -282,7 +282,7 @@ Assert.AreEqual(1, demoAssessmentSection.HeightStructures.CalculationsGroup.Children.Count); StructuresCalculation calculation = demoAssessmentSection.HeightStructures - .CalculationsGroup.GetCalculations() + .Calculations .OfType>() .First(); AssertExpectedHeightStructuresInput(calculation.InputParameters); @@ -327,7 +327,7 @@ Assert.AreEqual(1, demoAssessmentSection.ClosingStructures.CalculationsGroup.Children.Count); StructuresCalculation calculation = demoAssessmentSection.ClosingStructures - .CalculationsGroup.GetCalculations() + .Calculations .OfType>() .First(); AssertExpectedClosingStructuresInput(calculation.InputParameters); @@ -474,7 +474,7 @@ Assert.AreEqual(1, demoAssessmentSection.StabilityPointStructures.CalculationsGroup.Children.Count); AssertExpectedStabilityPointStructureValues(demoAssessmentSection.StabilityPointStructures.StabilityPointStructures[0]); StructuresCalculation calculation = demoAssessmentSection.StabilityPointStructures - .CalculationsGroup.GetCalculations() + .Calculations .OfType>() .First(); AssertExpectedStabilityPointStructuresInput(calculation.InputParameters); Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Data/ClosingStructuresFailureMechanism.cs =================================================================== diff -u -rab20c4eb4ca81bd3845d50210d2bdb301177af6a -r183d1e7ed095ea4e8024068bc4ddfcf3ac6997d3 --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Data/ClosingStructuresFailureMechanism.cs (.../ClosingStructuresFailureMechanism.cs) (revision ab20c4eb4ca81bd3845d50210d2bdb301177af6a) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Data/ClosingStructuresFailureMechanism.cs (.../ClosingStructuresFailureMechanism.cs) (revision 183d1e7ed095ea4e8024068bc4ddfcf3ac6997d3) @@ -56,7 +56,7 @@ { get { - return CalculationsGroup.GetCalculations().OfType>(); + return CalculationsGroup.GetCalculations().Cast>(); } } Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs =================================================================== diff -u -r60233a739e6b40a3182f53bb9ebd923703bd745c -r183d1e7ed095ea4e8024068bc4ddfcf3ac6997d3 --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs (.../ClosingStructuresPlugin.cs) (revision 60233a739e6b40a3182f53bb9ebd923703bd745c) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs (.../ClosingStructuresPlugin.cs) (revision 183d1e7ed095ea4e8024068bc4ddfcf3ac6997d3) @@ -24,7 +24,6 @@ using System.Drawing; using System.Linq; using System.Windows.Forms; -using Core.Common.Base; using Core.Common.Controls.TreeView; using Core.Common.Gui.ContextMenu; using Core.Common.Gui.Forms.ProgressDialog; @@ -446,8 +445,7 @@ private StrictContextMenuItem CreateGenerateClosingStructuresCalculationsItem(ClosingStructuresCalculationGroupContext nodeData) { - ObservableList closingStructures = nodeData.FailureMechanism.ClosingStructures; - bool structuresAvailable = closingStructures.Any(); + bool structuresAvailable = nodeData.FailureMechanism.ClosingStructures.Any(); string closingStructuresCalculationGroupContextToolTip = structuresAvailable ? RingtoetsCommonFormsResources.StructuresPlugin_Generate_calculations_for_selected_structures @@ -456,7 +454,7 @@ return new StrictContextMenuItem(RingtoetsCommonFormsResources.CalculationsGroup_Generate_calculations, closingStructuresCalculationGroupContextToolTip, RingtoetsCommonFormsResources.GenerateScenariosIcon, - (sender, args) => { ShowClosingStructuresSelectionDialog(nodeData); }) + (sender, args) => ShowClosingStructuresSelectionDialog(nodeData)) { Enabled = structuresAvailable }; Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Service/ClosingStructuresCalculationActivity.cs =================================================================== diff -u -r3e2b418a9bbc27e2e990b15325b1350e6d56dc3d -r183d1e7ed095ea4e8024068bc4ddfcf3ac6997d3 --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Service/ClosingStructuresCalculationActivity.cs (.../ClosingStructuresCalculationActivity.cs) (revision 3e2b418a9bbc27e2e990b15325b1350e6d56dc3d) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Service/ClosingStructuresCalculationActivity.cs (.../ClosingStructuresCalculationActivity.cs) (revision 183d1e7ed095ea4e8024068bc4ddfcf3ac6997d3) @@ -86,7 +86,7 @@ protected override void PerformCalculation() { - ClosingStructuresDataSynchronizationService.ClearCalculationOutput(calculation); + calculation.ClearOutput(); calculationService.Calculate(calculation, assessmentSection, Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Service/ClosingStructuresDataSynchronizationService.cs =================================================================== diff -u -r2ebc37cd8cfea18e73b2db4975be5a48272ba9ba -r183d1e7ed095ea4e8024068bc4ddfcf3ac6997d3 --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Service/ClosingStructuresDataSynchronizationService.cs (.../ClosingStructuresDataSynchronizationService.cs) (revision 2ebc37cd8cfea18e73b2db4975be5a48272ba9ba) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Service/ClosingStructuresDataSynchronizationService.cs (.../ClosingStructuresDataSynchronizationService.cs) (revision 183d1e7ed095ea4e8024068bc4ddfcf3ac6997d3) @@ -56,29 +56,12 @@ .Where(c => c.HasOutput) .ToArray(); - affectedItems.ForEachElementDo(ClearCalculationOutput); + affectedItems.ForEachElementDo(item => item.ClearOutput()); return affectedItems; } /// - /// Clears the output of the given . - /// - /// The to clear - /// the output for. - /// Thrown when - /// is null. - public static void ClearCalculationOutput(StructuresCalculation calculation) - { - if (calculation == null) - { - throw new ArgumentNullException("calculation"); - } - - calculation.Output = null; - } - - /// /// Clears the for all the calculations in /// the . /// @@ -130,7 +113,7 @@ if (calculation.HasOutput) { - ClearCalculationOutput(calculation); + calculation.ClearOutput(); calculationChanged = true; } Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/ClosingStructuresFailureMechanismTest.cs =================================================================== diff -u -rab20c4eb4ca81bd3845d50210d2bdb301177af6a -r183d1e7ed095ea4e8024068bc4ddfcf3ac6997d3 --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/ClosingStructuresFailureMechanismTest.cs (.../ClosingStructuresFailureMechanismTest.cs) (revision ab20c4eb4ca81bd3845d50210d2bdb301177af6a) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/ClosingStructuresFailureMechanismTest.cs (.../ClosingStructuresFailureMechanismTest.cs) (revision 183d1e7ed095ea4e8024068bc4ddfcf3ac6997d3) @@ -114,7 +114,6 @@ { new CalculationGroup(), new StructuresCalculation(), - mocks.StrictMock(), new StructuresCalculation() } } Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Service.Test/ClosingStructureDataSynchronizationServiceTest.cs =================================================================== diff -u -rab20c4eb4ca81bd3845d50210d2bdb301177af6a -r183d1e7ed095ea4e8024068bc4ddfcf3ac6997d3 --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Service.Test/ClosingStructureDataSynchronizationServiceTest.cs (.../ClosingStructureDataSynchronizationServiceTest.cs) (revision ab20c4eb4ca81bd3845d50210d2bdb301177af6a) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Service.Test/ClosingStructureDataSynchronizationServiceTest.cs (.../ClosingStructureDataSynchronizationServiceTest.cs) (revision 183d1e7ed095ea4e8024068bc4ddfcf3ac6997d3) @@ -81,17 +81,6 @@ } [Test] - public void ClearCalculationOutput_CalculationNull_ThrowsArgumentNullException() - { - // Call - TestDelegate test = () => ClosingStructuresDataSynchronizationService.ClearCalculationOutput(null); - - // Assert - var exception = Assert.Throws(test); - Assert.AreEqual("calculation", exception.ParamName); - } - - [Test] public void ClearCalculationOutput_WithCalculation_ClearsOutput() { // Setup @@ -101,7 +90,7 @@ }; // Call - ClosingStructuresDataSynchronizationService.ClearCalculationOutput(calculation); + calculation.ClearOutput(); // Assert Assert.IsNull(calculation.Output); Index: Ringtoets/Common/src/Ringtoets.Common.Data/Structures/IStructuresCalculationInput.cs =================================================================== diff -u -re4e785f127ce9a2d0d1734c1b51e02d910a31bbe -r183d1e7ed095ea4e8024068bc4ddfcf3ac6997d3 --- Ringtoets/Common/src/Ringtoets.Common.Data/Structures/IStructuresCalculationInput.cs (.../IStructuresCalculationInput.cs) (revision e4e785f127ce9a2d0d1734c1b51e02d910a31bbe) +++ Ringtoets/Common/src/Ringtoets.Common.Data/Structures/IStructuresCalculationInput.cs (.../IStructuresCalculationInput.cs) (revision 183d1e7ed095ea4e8024068bc4ddfcf3ac6997d3) @@ -23,8 +23,15 @@ namespace Ringtoets.Common.Data.Structures { + /// + /// Interface describing an object that is the input to a structures calculation. + /// + /// public interface IStructuresCalculationInput : ICalculationInput where T: StructureBase { + /// + /// Gets the structure. + /// T Structure { get; } } } \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Data/Structures/StructuresFailureMechanismSectionResult.cs =================================================================== diff -u -re4e785f127ce9a2d0d1734c1b51e02d910a31bbe -r183d1e7ed095ea4e8024068bc4ddfcf3ac6997d3 --- Ringtoets/Common/src/Ringtoets.Common.Data/Structures/StructuresFailureMechanismSectionResult.cs (.../StructuresFailureMechanismSectionResult.cs) (revision e4e785f127ce9a2d0d1734c1b51e02d910a31bbe) +++ Ringtoets/Common/src/Ringtoets.Common.Data/Structures/StructuresFailureMechanismSectionResult.cs (.../StructuresFailureMechanismSectionResult.cs) (revision 183d1e7ed095ea4e8024068bc4ddfcf3ac6997d3) @@ -29,6 +29,8 @@ /// This class holds the information of the result of the /// for a structures assessment. /// + /// This class is generic with {T} specifying the type op structure + /// whose calculation is chosen to be representative for the whole section. public class StructuresFailureMechanismSectionResult : FailureMechanismSectionResult where T : ICalculationInput, new() { /// Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/StructureSelectionDialogTest.cs =================================================================== diff -u -r86984ca293c30b4f9b47da7825cbae1404fffe08 -r183d1e7ed095ea4e8024068bc4ddfcf3ac6997d3 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/StructureSelectionDialogTest.cs (.../StructureSelectionDialogTest.cs) (revision 86984ca293c30b4f9b47da7825cbae1404fffe08) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/StructureSelectionDialogTest.cs (.../StructureSelectionDialogTest.cs) (revision 183d1e7ed095ea4e8024068bc4ddfcf3ac6997d3) @@ -79,8 +79,10 @@ [Test] public void Constructor_DataGridViewCorrectlyInitialized() { - // Setup & Call + // Setup using (var viewParent = new Form()) + + // Call using (var dialog = new StructureSelectionDialog(viewParent, Enumerable.Empty())) { dialog.Show(); @@ -119,8 +121,9 @@ }; var structure = new TestStructure(constructionProperties); - // Call using (var viewParent = new Form()) + + // Call using (var dialog = new StructureSelectionDialog(viewParent, new[] { structure Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/HeightStructuresFailureMechanism.cs =================================================================== diff -u -rab20c4eb4ca81bd3845d50210d2bdb301177af6a -r183d1e7ed095ea4e8024068bc4ddfcf3ac6997d3 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/HeightStructuresFailureMechanism.cs (.../HeightStructuresFailureMechanism.cs) (revision ab20c4eb4ca81bd3845d50210d2bdb301177af6a) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/HeightStructuresFailureMechanism.cs (.../HeightStructuresFailureMechanism.cs) (revision 183d1e7ed095ea4e8024068bc4ddfcf3ac6997d3) @@ -55,7 +55,7 @@ { get { - return CalculationsGroup.GetCalculations().OfType>(); + return CalculationsGroup.GetCalculations().Cast>(); } } Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Views/HeightStructuresScenariosView.cs =================================================================== diff -u -re4e785f127ce9a2d0d1734c1b51e02d910a31bbe -r183d1e7ed095ea4e8024068bc4ddfcf3ac6997d3 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Views/HeightStructuresScenariosView.cs (.../HeightStructuresScenariosView.cs) (revision e4e785f127ce9a2d0d1734c1b51e02d910a31bbe) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Views/HeightStructuresScenariosView.cs (.../HeightStructuresScenariosView.cs) (revision 183d1e7ed095ea4e8024068bc4ddfcf3ac6997d3) @@ -130,7 +130,7 @@ ICalculation[] calculations = data.GetCalculations().ToArray(); Dictionary> calculationsPerSegment = - StructuresHelper.CollectCalculationsPerSection(failureMechanism.Sections, calculations.OfType>()); + StructuresHelper.CollectCalculationsPerSection(failureMechanism.Sections, calculations.Cast>()); List scenarioRows = FailureMechanism.SectionResults.Select(sectionResult => new HeightStructuresScenarioRow(sectionResult)).ToList(); Fisheye: Tag 183d1e7ed095ea4e8024068bc4ddfcf3ac6997d3 refers to a dead (removed) revision in file `Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/Properties/Resources.Designer.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 183d1e7ed095ea4e8024068bc4ddfcf3ac6997d3 refers to a dead (removed) revision in file `Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/Properties/Resources.resx'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/Ringtoets.HeightStructures.Plugin.csproj =================================================================== diff -u -re4e785f127ce9a2d0d1734c1b51e02d910a31bbe -r183d1e7ed095ea4e8024068bc4ddfcf3ac6997d3 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/Ringtoets.HeightStructures.Plugin.csproj (.../Ringtoets.HeightStructures.Plugin.csproj) (revision e4e785f127ce9a2d0d1734c1b51e02d910a31bbe) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/Ringtoets.HeightStructures.Plugin.csproj (.../Ringtoets.HeightStructures.Plugin.csproj) (revision 183d1e7ed095ea4e8024068bc4ddfcf3ac6997d3) @@ -43,11 +43,6 @@ - - True - True - Resources.resx - @@ -136,13 +131,6 @@ Copying.licenseheader - - - ResXFileCodeGenerator - Resources.Designer.cs - Designer - -