Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj =================================================================== diff -u -r669853e6468fcf1301a64f5df1400456fe6929eb -r3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 669853e6468fcf1301a64f5df1400456fe6929eb) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6) @@ -66,6 +66,7 @@ + @@ -93,6 +94,7 @@ + @@ -255,6 +257,7 @@ Code + @@ -269,6 +272,7 @@ + @@ -331,6 +335,7 @@ + @@ -356,6 +361,7 @@ + Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsOutputCreateExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsOutputCreateExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsOutputCreateExtensions.cs (revision 3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6) @@ -0,0 +1,64 @@ +// 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 Ringtoets.GrassCoverErosionInwards.Data; + +namespace Application.Ringtoets.Storage.Create.GrassCoverErosionInwards +{ + /// + /// Extension methods for related to creating a + /// . + /// + internal static class GrassCoverErosionInwardsOutputCreateExtensions + { + /// + /// Creates a based on + /// the information of the . + /// + /// The result to create a database entity for. + /// The object keeping track of create operations. + /// A new . + /// Thrown when is null. + internal static GrassCoverErosionInwardsOutputEntity Create(this GrassCoverErosionInwardsOutput output, PersistenceRegistry registry) + { + if (registry == null) + { + throw new ArgumentNullException("registry"); + } + + var entity = new GrassCoverErosionInwardsOutputEntity + { + ProbabilisticOutputEntity = output.ProbabilisticAssessmentOutput.Create(registry), + DikeHeight = output.DikeHeight.Value.ToNaNAsNull(), + IsOvertoppingDominant = Convert.ToByte(output.IsOvertoppingDominant), + WaveHeight = output.WaveHeight.Value.ToNaNAsNull() + }; + + registry.Register(entity, output); + + return entity; + } + } +} \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PersistenceRegistry.cs =================================================================== diff -u -r5da102ed42420b0272dfd2ecdd5aaa3a9ebd251c -r3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PersistenceRegistry.cs (.../PersistenceRegistry.cs) (revision 5da102ed42420b0272dfd2ecdd5aaa3a9ebd251c) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PersistenceRegistry.cs (.../PersistenceRegistry.cs) (revision 3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6) @@ -31,6 +31,7 @@ using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.Probability; using Ringtoets.GrassCoverErosionInwards.Data; using Ringtoets.HeightStructures.Data; using Ringtoets.HydraRing.Data; @@ -57,6 +58,7 @@ private readonly Dictionary generalGrassCoverErosionInwardsInputs = new Dictionary(); private readonly Dictionary dikeProfiles = new Dictionary(); private readonly Dictionary grassCoverErosionInwardsCalculations = new Dictionary(); + private readonly Dictionary grassCoverErosionInwardsOutputs = new Dictionary(); private readonly Dictionary grassCoverErosionInwardsFailureMechanismSectionResults = new Dictionary(); private readonly Dictionary heightStructuresFailureMechanismSectionResults = new Dictionary(); private readonly Dictionary strengthStabilityLengthwiseConstructionFailureMechanismSectionResults = new Dictionary(); @@ -87,6 +89,7 @@ private readonly Dictionary surfaceLinePoints = new Dictionary(new ReferenceEqualityComparer()); private readonly Dictionary characteristicPoints = new Dictionary(new ReferenceEqualityComparer()); private readonly Dictionary pipingProbabilityAssessmentInputs = new Dictionary(new ReferenceEqualityComparer()); + private readonly Dictionary probabilisticAssessmentOutputs = new Dictionary(new ReferenceEqualityComparer()); /// /// Registers a create or update operation for and the @@ -174,6 +177,42 @@ /// Registers a create or update operation for and the /// that was constructed with the information. /// + /// The + /// to be registered. + /// The to + /// be registered. + /// Thrown when either: + /// + /// is null + /// is null + /// + public void Register(GrassCoverErosionInwardsOutputEntity entity, GrassCoverErosionInwardsOutput model) + { + Register(grassCoverErosionInwardsOutputs, entity, model); + } + + /// + /// Registers a create or update operation for and the + /// that was constructed with the information. + /// + /// The + /// to be registered. + /// The to + /// be registered. + /// Thrown when either: + /// + /// is null + /// is null + /// + public void Register(ProbabilisticOutputEntity entity, ProbabilityAssessmentOutput model) + { + Register(probabilisticAssessmentOutputs, entity, model); + } + + /// + /// Registers a create or update operation for and the + /// that was constructed with the information. + /// /// The to be registered. /// The to be registered. /// Thrown when either: @@ -932,6 +971,11 @@ grassCoverErosionInwardsCalculations[entity].StorageId = entity.GrassCoverErosionInwardsCalculationEntityId; } + foreach (var entity in grassCoverErosionInwardsOutputs.Keys) + { + grassCoverErosionInwardsOutputs[entity].StorageId = entity.GrassCoverErosionInwardsOutputId; + } + foreach (var entity in grassCoverErosionInwardsFailureMechanismSectionResults.Keys) { grassCoverErosionInwardsFailureMechanismSectionResults[entity].StorageId = entity.GrassCoverErosionInwardsSectionResultEntityId; @@ -1077,6 +1121,11 @@ pipingProbabilityAssessmentInputs[entity].StorageId = entity.PipingFailureMechanismMetaEntityId; } + foreach (var entity in probabilisticAssessmentOutputs.Keys) + { + probabilisticAssessmentOutputs[entity].StorageId = entity.ProbabilisticOutputEntityId; + } + // CharacteristicPoints do not really have a 'identity' within the object-model. // As such, no need to copy StorageId. This is already covered by surfaceLinePoints. } @@ -1175,6 +1224,17 @@ } dbContext.GrassCoverErosionInwardsCalculationEntities.RemoveRange(orphanedGrassCoverErosionInwardsCalculationEntities); + var orphanedGrassCoverErosionInwardsOutputEntities = new List(); + foreach (GrassCoverErosionInwardsOutputEntity outputEntity in dbContext.GrassCoverErosionInwardsOutputEntities + .Where(e => e.GrassCoverErosionInwardsOutputId > 0)) + { + if (!grassCoverErosionInwardsOutputs.ContainsKey(outputEntity)) + { + orphanedGrassCoverErosionInwardsOutputEntities.Add(outputEntity); + } + } + dbContext.GrassCoverErosionInwardsOutputEntities.RemoveRange(orphanedGrassCoverErosionInwardsOutputEntities); + var orphanedGrassCoverErosionInwardsSectionResultEntities = new List(); foreach (GrassCoverErosionInwardsSectionResultEntity sectionResultEntity in dbContext.GrassCoverErosionInwardsSectionResultEntities .Where(e => e.GrassCoverErosionInwardsSectionResultEntityId > 0)) @@ -1504,6 +1564,17 @@ } } dbContext.PipingFailureMechanismMetaEntities.RemoveRange(orphanedPipingFailureMechanismMetaEntities); + + var orphanedProbabilisticOutputEntities = new List(); + foreach (ProbabilisticOutputEntity outputEntity in dbContext.ProbabilisticOutputEntities + .Where(e => e.ProbabilisticOutputEntityId > 0)) + { + if (!probabilisticAssessmentOutputs.ContainsKey(outputEntity)) + { + orphanedProbabilisticOutputEntities.Add(outputEntity); + } + } + dbContext.ProbabilisticOutputEntities.RemoveRange(orphanedProbabilisticOutputEntities); } private bool ContainsValue(Dictionary collection, U model) Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/ProbabilisticAssessmentOutputCreateExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/ProbabilisticAssessmentOutputCreateExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/ProbabilisticAssessmentOutputCreateExtensions.cs (revision 3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6) @@ -0,0 +1,65 @@ +// 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 Ringtoets.Common.Data.Probability; + +namespace Application.Ringtoets.Storage.Create +{ + /// + /// Extension methods for related to creating a + /// . + /// + internal static class ProbabilisticAssessmentOutputCreateExtensions + { + /// + /// Creates a based on the information of + /// the . + /// + /// The result to create a database entity for. + /// The object keeping track of create operations. + /// A new . + /// Thrown when is null. + internal static ProbabilisticOutputEntity Create(this ProbabilityAssessmentOutput output, PersistenceRegistry registry) + { + if (registry == null) + { + throw new ArgumentNullException("registry"); + } + + var entity = new ProbabilisticOutputEntity + { + RequiredProbability = output.RequiredProbability.ToNaNAsNull(), + RequiredReliability = output.RequiredReliability.Value.ToNaNAsNull(), + Probability = output.Probability.ToNaNAsNull(), + Reliability = output.Reliability.Value.ToNaNAsNull(), + FactorOfSafety = output.FactorOfSafety.Value.ToNaNAsNull() + }; + + registry.Register(entity, output); + + return entity; + } + } +} \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/GrassCoverErosionInwards/GrassCoverErosionInwardsOutputEntityReadExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/GrassCoverErosionInwards/GrassCoverErosionInwardsOutputEntityReadExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/GrassCoverErosionInwards/GrassCoverErosionInwardsOutputEntityReadExtensions.cs (revision 3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6) @@ -0,0 +1,54 @@ +// 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 Ringtoets.GrassCoverErosionInwards.Data; + +namespace Application.Ringtoets.Storage.Read.GrassCoverErosionInwards +{ + /// + /// This class defines extension methods for read operations for a + /// based on the . + /// + internal static class GrassCoverErosionInwardsOutputEntityReadExtensions + { + /// + /// Reads the + /// and use the information to construct a . + /// + /// The + /// to create for. + /// A new . + internal static GrassCoverErosionInwardsOutput Read(this GrassCoverErosionInwardsOutputEntity entity) + { + return new GrassCoverErosionInwardsOutput(entity.WaveHeight.ToNullAsNaN(), + Convert.ToBoolean(entity.IsOvertoppingDominant), + entity.ProbabilisticOutputEntity.Read(), + entity.DikeHeight.ToNullAsNaN()) + { + StorageId = entity.GrassCoverErosionInwardsOutputId + }; + } + } +} \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ProbabilisticOutputEntityReadExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ProbabilisticOutputEntityReadExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ProbabilisticOutputEntityReadExtensions.cs (revision 3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6) @@ -0,0 +1,53 @@ +// 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 Application.Ringtoets.Storage.DbContext; + +using Ringtoets.Common.Data.Probability; + +namespace Application.Ringtoets.Storage.Read +{ + /// + /// This class defines extension methods for read operations for a + /// based on the . + /// + internal static class ProbabilisticOutputEntityReadExtensions + { + /// + /// Reads the and use the information to + /// construct a . + /// + /// The to create + /// for. + /// A new . + internal static ProbabilityAssessmentOutput Read(this ProbabilisticOutputEntity entity) + { + return new ProbabilityAssessmentOutput(entity.RequiredProbability.ToNullAsNaN(), + entity.RequiredReliability.ToNullAsNaN(), + entity.Probability.ToNullAsNaN(), + entity.Reliability.ToNullAsNaN(), + entity.FactorOfSafety.ToNullAsNaN()) + { + StorageId = entity.ProbabilisticOutputEntityId + }; + } + } +} \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/GrassCoverErosionInwards/GrassCoverErosionInwardsOutputUpdateExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/GrassCoverErosionInwards/GrassCoverErosionInwardsOutputUpdateExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/GrassCoverErosionInwards/GrassCoverErosionInwardsOutputUpdateExtensions.cs (revision 3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6) @@ -0,0 +1,74 @@ +// 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.Exceptions; +using Application.Ringtoets.Storage.Update; + +using Ringtoets.GrassCoverErosionInwards.Data; + +namespace Application.Ringtoets.Storage.Update.GrassCoverErosionInwards +{ + /// + /// Extension methods for related to + /// updating a . + /// + internal static class GrassCoverErosionInwardsOutputUpdateExtensions + { + /// + /// Updates a in the database + /// based on the information of the . + /// + /// The grass cover erosion inwards calculation output to + /// update the database entity for. + /// The object keeping track of update operations. + /// The context to obtain the existing entity from. + /// Thrown when either: + /// + /// is null + /// is null + /// + /// When + /// does not have a corresponding entity in the database. + internal static void Update(this GrassCoverErosionInwardsOutput output, PersistenceRegistry registry, IRingtoetsEntities context) + { + if (context == null) + { + throw new ArgumentNullException("context"); + } + if (registry == null) + { + throw new ArgumentNullException("registry"); + } + + GrassCoverErosionInwardsOutputEntity entity = output.GetCorrespondingEntity( + context.GrassCoverErosionInwardsOutputEntities, + o => o.GrassCoverErosionInwardsOutputId); + + output.ProbabilisticAssessmentOutput.Update(registry, context); + + registry.Register(entity, output); + } + } +} \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/ProbabilityAssessmentOutputUpdateExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/ProbabilityAssessmentOutputUpdateExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/ProbabilityAssessmentOutputUpdateExtensions.cs (revision 3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6) @@ -0,0 +1,71 @@ +// 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.Exceptions; + +using Ringtoets.Common.Data.Probability; + +namespace Application.Ringtoets.Storage.Update +{ + /// + /// Extension methods for related to + /// updating a . + /// + internal static class ProbabilityAssessmentOutputUpdateExtensions + { + /// + /// Updates a in the database + /// based on the information of the . + /// + /// The probabilistic assessment calculation output to update + /// the database entity for. + /// The object keeping track of update operations. + /// The context to obtain the existing entity from. + /// Thrown when either: + /// + /// is null + /// is null + /// + /// When + /// does not have a corresponding entity in the database. + internal static void Update(this ProbabilityAssessmentOutput output, PersistenceRegistry registry, IRingtoetsEntities context) + { + if (context == null) + { + throw new ArgumentNullException("context"); + } + if (registry == null) + { + throw new ArgumentNullException("registry"); + } + + ProbabilisticOutputEntity entity = output.GetCorrespondingEntity( + context.ProbabilisticOutputEntities, + o => o.ProbabilisticOutputEntityId); + + registry.Register(entity, output); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj =================================================================== diff -u -r669853e6468fcf1301a64f5df1400456fe6929eb -r3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 669853e6468fcf1301a64f5df1400456fe6929eb) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6) @@ -94,6 +94,7 @@ + @@ -121,6 +122,7 @@ + @@ -150,6 +152,7 @@ + @@ -164,6 +167,7 @@ + @@ -204,6 +208,7 @@ + @@ -229,6 +234,7 @@ + Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsOutputCreateExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsOutputCreateExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsOutputCreateExtensionsTest.cs (revision 3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6) @@ -0,0 +1,135 @@ +// 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.Create.GrassCoverErosionInwards; +using Application.Ringtoets.Storage.DbContext; + +using NUnit.Framework; + +using Ringtoets.Common.Data.Probability; +using Ringtoets.GrassCoverErosionInwards.Data; + +namespace Application.Ringtoets.Storage.Test.Create.GrassCoverErosionInwards +{ + [TestFixture] + public class GrassCoverErosionInwardsOutputCreateExtensionsTest + { + [Test] + public void Create_PersistenceRegistryIsNull_ThrowArgumenNullException() + { + // Setup + var probabilityAssessmentOutput = new ProbabilityAssessmentOutput(1.0, 1.0, 1.0, 1.0, 1.0); + var output = new GrassCoverErosionInwardsOutput(1.1, false, probabilityAssessmentOutput, 2.2); + + // Call + TestDelegate call = () => output.Create(null); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("registry", paramName); + } + + [Test] + public void Create_ValidInput_ReturnGrassCoverErosionInwardsOutputEntity() + { + // Setup + var probabilityAssessmentOutput = new ProbabilityAssessmentOutput(0.005, 1.0, 0.06, 0.8, 0.5); + var output = new GrassCoverErosionInwardsOutput(1.1, false, probabilityAssessmentOutput, 2.2); + + var registry = new PersistenceRegistry(); + + // Call + GrassCoverErosionInwardsOutputEntity entity = output.Create(registry); + + // Assert + Assert.AreEqual(output.DikeHeight.Value, entity.DikeHeight); + Assert.AreEqual(output.WaveHeight.Value, entity.WaveHeight); + Assert.AreEqual(Convert.ToByte(output.IsOvertoppingDominant), entity.IsOvertoppingDominant); + + Assert.AreEqual(probabilityAssessmentOutput.FactorOfSafety.Value, entity.ProbabilisticOutputEntity.FactorOfSafety); + Assert.AreEqual(probabilityAssessmentOutput.Probability, entity.ProbabilisticOutputEntity.Probability); + Assert.AreEqual(probabilityAssessmentOutput.Reliability.Value, entity.ProbabilisticOutputEntity.Reliability); + Assert.AreEqual(probabilityAssessmentOutput.RequiredProbability, entity.ProbabilisticOutputEntity.RequiredProbability); + Assert.AreEqual(probabilityAssessmentOutput.RequiredReliability.Value, entity.ProbabilisticOutputEntity.RequiredReliability); + } + + [Test] + public void Create_NaNValues_ReturnGrassCoverErosionInwardsOutputEntity() + { + // Setup + var probabilityAssessmentOutput = new ProbabilityAssessmentOutput(double.NaN, double.NaN, double.NaN, double.NaN, double.NaN); + var output = new GrassCoverErosionInwardsOutput(double.NaN, true, probabilityAssessmentOutput, double.NaN); + + var registry = new PersistenceRegistry(); + + // Call + GrassCoverErosionInwardsOutputEntity entity = output.Create(registry); + + // Assert + Assert.IsNull(entity.DikeHeight); + Assert.IsNull(entity.WaveHeight); + Assert.AreEqual(Convert.ToByte(output.IsOvertoppingDominant), entity.IsOvertoppingDominant); + + Assert.IsNull(entity.ProbabilisticOutputEntity.FactorOfSafety); + Assert.IsNull(entity.ProbabilisticOutputEntity.Probability); + Assert.IsNull(entity.ProbabilisticOutputEntity.Reliability); + Assert.IsNull(entity.ProbabilisticOutputEntity.RequiredProbability); + Assert.IsNull(entity.ProbabilisticOutputEntity.RequiredReliability); + } + + [Test] + public void Create_DikeHeightIsNull_PersistDikeHeightAsNullToRepresentNaN() + { + // Setup + var probabilityAssessmentOutput = new ProbabilityAssessmentOutput(1, 1, 1, 1, 1); + var output = new GrassCoverErosionInwardsOutput(1, true, probabilityAssessmentOutput, null); + + var registry = new PersistenceRegistry(); + + // Call + GrassCoverErosionInwardsOutputEntity entity = output.Create(registry); + + // Assert + Assert.IsNull(entity.DikeHeight); + } + + [Test] + public void Create_ValidValues_RegisterEntity() + { + // Setup + var probabilityAssessmentOutput = new ProbabilityAssessmentOutput(0.005, 1.0, 0.06, 0.8, 0.5); + var output = new GrassCoverErosionInwardsOutput(1.1, false, probabilityAssessmentOutput, 2.2); + + var registry = new PersistenceRegistry(); + + // Call + GrassCoverErosionInwardsOutputEntity entity = output.Create(registry); + + // Assert + entity.GrassCoverErosionInwardsOutputId = 984756; + registry.TransferIds(); + Assert.AreEqual(entity.GrassCoverErosionInwardsOutputId, output.StorageId); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PersistenceRegistryTest.cs =================================================================== diff -u -rb954fb6f2dd56ffb96be7b61ab129f19d879d2ab -r3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PersistenceRegistryTest.cs (.../PersistenceRegistryTest.cs) (revision b954fb6f2dd56ffb96be7b61ab129f19d879d2ab) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PersistenceRegistryTest.cs (.../PersistenceRegistryTest.cs) (revision 3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6) @@ -36,6 +36,7 @@ using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.Probability; using Ringtoets.GrassCoverErosionInwards.Data; using Ringtoets.HeightStructures.Data; using Ringtoets.HydraRing.Data; @@ -994,6 +995,64 @@ } [Test] + public void Register_WithNullGrassCoverErosionInwardsOutput_ThrowsArgumentNullException() + { + // Setup + var registry = new PersistenceRegistry(); + + // Call + TestDelegate test = () => registry.Register(new GrassCoverErosionInwardsOutputEntity(), null); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("model", paramName); + } + + [Test] + public void Register_WithNullGrassCoverErosionInwardsOutputEntity_ThrowsArgumentNullException() + { + // Setup + var registry = new PersistenceRegistry(); + var output = new GrassCoverErosionInwardsOutput(1, false, new ProbabilityAssessmentOutput(1, 1, 1, 1, 1), 1); + + // Call + TestDelegate test = () => registry.Register(null, output); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("entity", paramName); + } + + [Test] + public void Register_WithNullProbabilityAssessmentOutput_ThrowsArgumentNullException() + { + // Setup + var registry = new PersistenceRegistry(); + + // Call + TestDelegate test = () => registry.Register(new ProbabilisticOutputEntity(), null); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("model", paramName); + } + + [Test] + public void Register_WithNullProbabilisticOutputEntity_ThrowsArgumentNullException() + { + // Setup + var registry = new PersistenceRegistry(); + var output = new ProbabilityAssessmentOutput(1, 1, 1, 1, 1); + + // Call + TestDelegate test = () => registry.Register(null, output); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("entity", paramName); + } + + [Test] public void Register_WithNullGrassCoverErosionInwardsFailureMechanismSectionResult_ThrowsArgumentNullException() { // Setup @@ -1983,7 +2042,7 @@ } [Test] - public void TransferIds_WithGrassCoverErosionInwardsEntityAddedWithGrassCoverErosionInwardsCalculation_EqualGrassCoverErosionInwardsCalculationEntityIdAndGrassCoverErosionInwardsCalculationStorageId() + public void TransferIds_WithGrassCoverErosionInwardsCalculationEntityAddedWithGrassCoverErosionInwardsCalculation_EqualGrassCoverErosionInwardsCalculationEntityIdAndGrassCoverErosionInwardsCalculationStorageId() { // Setup var registry = new PersistenceRegistry(); @@ -2004,6 +2063,48 @@ } [Test] + public void TransferIds_WithGrassCoverErosionInwardsOutputEntityAddedWithGrassCoverErosionInwardsOutput_EqualGrassCoverErosionInwardsOutputEntityIdAndGrassCoverErosionInwardsOutputStorageId() + { + // Setup + var registry = new PersistenceRegistry(); + + long storageId = new Random(21).Next(1, 4000); + var entity = new GrassCoverErosionInwardsOutputEntity + { + GrassCoverErosionInwardsOutputId = storageId + }; + var model = new GrassCoverErosionInwardsOutput(1, false, new ProbabilityAssessmentOutput(1, 1, 1, 1, 1), 1); + registry.Register(entity, model); + + // Call + registry.TransferIds(); + + // Assert + Assert.AreEqual(storageId, model.StorageId); + } + + [Test] + public void TransferIds_WithProbabilisticOutputEntityAddedWithGrassCoverErosionInwardsOutput_EqualProbabilisticOutputEntityIdAndGrassCoverErosionInwardsOutputProbabilityAssessmentOutputStorageId() + { + // Setup + var registry = new PersistenceRegistry(); + + long storageId = new Random(21).Next(1, 4000); + var entity = new ProbabilisticOutputEntity + { + ProbabilisticOutputEntityId = storageId + }; + var model = new ProbabilityAssessmentOutput(1, 1, 1, 1, 1); + registry.Register(entity, model); + + // Call + registry.TransferIds(); + + // Assert + Assert.AreEqual(storageId, model.StorageId); + } + + [Test] public void TransferIds_WithGrassCoverErosionInwardsSectionResultEntityAddedWithGrassCoverErosionInwardsFailureMechanismSectionResult_EqualGrassCoverErosionInwardsSectionEntityIdAndGrassCoverErosionInwardsFailureMechanismSectionResultStorageId() { // Setup @@ -2904,6 +3005,78 @@ } [Test] + public void RemoveUntouched_GrassCoverErosionInwardsOutputEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() + { + // Setup + var mocks = new MockRepository(); + IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); + mocks.ReplayAll(); + + var orphanedEntity = new GrassCoverErosionInwardsOutputEntity + { + GrassCoverErosionInwardsOutputId = 1 + }; + var persistentEntity = new GrassCoverErosionInwardsOutputEntity + { + GrassCoverErosionInwardsOutputId = 2 + }; + dbContext.GrassCoverErosionInwardsOutputEntities.Add(orphanedEntity); + dbContext.GrassCoverErosionInwardsOutputEntities.Add(persistentEntity); + + var calculation = new GrassCoverErosionInwardsOutput(1, false, new ProbabilityAssessmentOutput(1,1,1,1,1), 1) + { + StorageId = persistentEntity.GrassCoverErosionInwardsOutputId + }; + + var registry = new PersistenceRegistry(); + registry.Register(persistentEntity, calculation); + + // Call + registry.RemoveUntouched(dbContext); + + // Assert + Assert.AreEqual(1, dbContext.GrassCoverErosionInwardsOutputEntities.Count()); + CollectionAssert.Contains(dbContext.GrassCoverErosionInwardsOutputEntities, persistentEntity); + mocks.VerifyAll(); + } + + [Test] + public void RemoveUntouched_ProbabilisticOutputEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() + { + // Setup + var mocks = new MockRepository(); + IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); + mocks.ReplayAll(); + + var orphanedEntity = new ProbabilisticOutputEntity + { + ProbabilisticOutputEntityId = 1 + }; + var persistentEntity = new ProbabilisticOutputEntity + { + ProbabilisticOutputEntityId = 2 + }; + dbContext.ProbabilisticOutputEntities.Add(orphanedEntity); + dbContext.ProbabilisticOutputEntities.Add(persistentEntity); + + var calculation = new ProbabilityAssessmentOutput(1, 1, 1, 1, 1) + { + StorageId = persistentEntity.ProbabilisticOutputEntityId + }; + + var registry = new PersistenceRegistry(); + registry.Register(persistentEntity, calculation); + + // Call + registry.RemoveUntouched(dbContext); + + // Assert + Assert.AreEqual(1, dbContext.ProbabilisticOutputEntities.Count()); + CollectionAssert.Contains(dbContext.ProbabilisticOutputEntities, persistentEntity); + mocks.VerifyAll(); + } + + [Test] public void RemoveUntouched_GrassCoverErosionInwardsSectionResultEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() { // Setup Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/ProbabilisticAssessmentOutputCreateExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/ProbabilisticAssessmentOutputCreateExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/ProbabilisticAssessmentOutputCreateExtensionsTest.cs (revision 3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6) @@ -0,0 +1,109 @@ +// 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 NUnit.Framework; + +using Ringtoets.Common.Data.Probability; + +namespace Application.Ringtoets.Storage.Test.Create +{ + [TestFixture] + public class ProbabilisticAssessmentOutputCreateExtensionsTest + { + [Test] + public void Create_PersistenceRegistryNull_ThrowArgumentNullException() + { + // Setup + var output = new ProbabilityAssessmentOutput(1, 1, 1, 1, 1); + + // Call + TestDelegate call = () => output.Create(null); + + // AssertL + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("registry", paramName); + } + + [Test] + public void Create_ValidValues_ReturnProbabilisticOutputEntity() + { + // Setup + var random = new Random(456); + var output = new ProbabilityAssessmentOutput(random.NextDouble(), random.NextDouble(), + random.NextDouble(), random.NextDouble(), + random.NextDouble()); + + var registry = new PersistenceRegistry(); + + // Call + ProbabilisticOutputEntity entity = output.Create(registry); + + // Assert + Assert.AreEqual(output.FactorOfSafety.Value, entity.FactorOfSafety); + Assert.AreEqual(output.Probability, entity.Probability); + Assert.AreEqual(output.Reliability.Value, entity.Reliability); + Assert.AreEqual(output.RequiredProbability, entity.RequiredProbability); + Assert.AreEqual(output.RequiredReliability.Value, entity.RequiredReliability); + } + + [Test] + public void Create_NaNValues_ReturnProbabilisticOutputEntityWithNullValues() + { + // Setup + var output = new ProbabilityAssessmentOutput(double.NaN, double.NaN, Double.NaN, + double.NaN, double.NaN); + + var registry = new PersistenceRegistry(); + + // Call + ProbabilisticOutputEntity entity = output.Create(registry); + + // Assert + Assert.IsNull(entity.FactorOfSafety); + Assert.IsNull(entity.Probability); + Assert.IsNull(entity.Reliability); + Assert.IsNull(entity.RequiredProbability); + Assert.IsNull(entity.RequiredReliability); + } + + [Test] + public void Create_ValidValues_RegistersEntity() + { + // Setup + var output = new ProbabilityAssessmentOutput(1,1,1,1,1); + + var registry = new PersistenceRegistry(); + + // Call + ProbabilisticOutputEntity entity = output.Create(registry); + + // Assert + entity.ProbabilisticOutputEntityId = 948576; + registry.TransferIds(); + Assert.AreEqual(entity.ProbabilisticOutputEntityId, output.StorageId); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/GrassCoverErosionInwards/GrassCoverErosionInwardsOutputEntityReadExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/GrassCoverErosionInwards/GrassCoverErosionInwardsOutputEntityReadExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/GrassCoverErosionInwards/GrassCoverErosionInwardsOutputEntityReadExtensionsTest.cs (revision 3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6) @@ -0,0 +1,114 @@ +// 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 Application.Ringtoets.Storage.Read.GrassCoverErosionInwards; + +using NUnit.Framework; + +using Ringtoets.GrassCoverErosionInwards.Data; + +namespace Application.Ringtoets.Storage.Test.Read.GrassCoverErosionInwards +{ + [TestFixture] + public class GrassCoverErosionInwardsOutputEntityReadExtensionsTest + { + [Test] + public void Read_ValidEntity_ReturnGrassCoverErosionInwardsOutput() + { + // Setup + var probabilisticOutputEntity = new ProbabilisticOutputEntity + { + ProbabilisticOutputEntityId = 95876, + Probability = 0.7, + RequiredProbability = 0.4, + RequiredReliability = 0.5, + Reliability = 0.2, + FactorOfSafety = 9.5 + }; + var entity = new GrassCoverErosionInwardsOutputEntity + { + GrassCoverErosionInwardsOutputId = 495876, + WaveHeight = 1.1, + IsOvertoppingDominant = Convert.ToByte(false), + ProbabilisticOutputEntity = probabilisticOutputEntity, + DikeHeight = 3.3 + }; + + // Call + GrassCoverErosionInwardsOutput output = entity.Read(); + + // Assert + Assert.AreEqual(entity.GrassCoverErosionInwardsOutputId, output.StorageId); + Assert.AreEqual(entity.WaveHeight, output.WaveHeight.Value); + Assert.IsFalse(output.IsOvertoppingDominant); + Assert.AreEqual(entity.DikeHeight, output.DikeHeight.Value); + + Assert.AreEqual(probabilisticOutputEntity.ProbabilisticOutputEntityId, output.ProbabilisticAssessmentOutput.StorageId); + Assert.AreEqual(probabilisticOutputEntity.FactorOfSafety, output.ProbabilisticAssessmentOutput.FactorOfSafety.Value); + Assert.AreEqual(probabilisticOutputEntity.Probability, output.ProbabilisticAssessmentOutput.Probability); + Assert.AreEqual(probabilisticOutputEntity.RequiredProbability, output.ProbabilisticAssessmentOutput.RequiredProbability); + Assert.AreEqual(probabilisticOutputEntity.Reliability, output.ProbabilisticAssessmentOutput.Reliability.Value); + Assert.AreEqual(probabilisticOutputEntity.RequiredReliability, output.ProbabilisticAssessmentOutput.RequiredReliability.Value); + } + + [Test] + public void Read_ValidEntityWithNullValues_ReturnGrassCoverErosionInwardsOutput() + { + // Setup + var probabilisticOutputEntity = new ProbabilisticOutputEntity + { + ProbabilisticOutputEntityId = 3456, + Probability = null, + RequiredProbability = null, + RequiredReliability = null, + Reliability = null, + FactorOfSafety = null + }; + var entity = new GrassCoverErosionInwardsOutputEntity + { + GrassCoverErosionInwardsOutputId = 7536, + WaveHeight = null, + IsOvertoppingDominant = Convert.ToByte(true), + ProbabilisticOutputEntity = probabilisticOutputEntity, + DikeHeight = null + }; + + // Call + GrassCoverErosionInwardsOutput output = entity.Read(); + + // Assert + Assert.AreEqual(entity.GrassCoverErosionInwardsOutputId, output.StorageId); + Assert.IsNaN(output.WaveHeight); + Assert.IsTrue(output.IsOvertoppingDominant); + Assert.IsNaN(output.DikeHeight); + + Assert.AreEqual(probabilisticOutputEntity.ProbabilisticOutputEntityId, output.ProbabilisticAssessmentOutput.StorageId); + Assert.IsNaN(output.ProbabilisticAssessmentOutput.FactorOfSafety.Value); + Assert.IsNaN(output.ProbabilisticAssessmentOutput.Probability); + Assert.IsNaN(output.ProbabilisticAssessmentOutput.RequiredProbability); + Assert.IsNaN(output.ProbabilisticAssessmentOutput.Reliability.Value); + Assert.IsNaN(output.ProbabilisticAssessmentOutput.RequiredReliability.Value); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/ProbabilisticOutputEntityReadExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/ProbabilisticOutputEntityReadExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/ProbabilisticOutputEntityReadExtensionsTest.cs (revision 3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6) @@ -0,0 +1,65 @@ +using Application.Ringtoets.Storage.DbContext; +using Application.Ringtoets.Storage.Read; + +using NUnit.Framework; + +using Ringtoets.Common.Data.Probability; + +namespace Application.Ringtoets.Storage.Test.Read +{ + [TestFixture] + public class ProbabilisticOutputEntityReadExtensionsTest + { + [Test] + public void Read_ValidEntity_ReturnGrassCoverErosionInwardsOutput() + { + // Setup + var entity = new ProbabilisticOutputEntity + { + ProbabilisticOutputEntityId = 567567, + Probability = 0.1, + RequiredProbability = 0.2, + RequiredReliability = 0.3, + Reliability = 0.4, + FactorOfSafety = 0.5 + }; + + // Call + ProbabilityAssessmentOutput output = entity.Read(); + + // Assert + Assert.AreEqual(entity.ProbabilisticOutputEntityId, output.StorageId); + Assert.AreEqual(entity.FactorOfSafety, output.FactorOfSafety.Value); + Assert.AreEqual(entity.Probability, output.Probability); + Assert.AreEqual(entity.RequiredProbability, output.RequiredProbability); + Assert.AreEqual(entity.Reliability, output.Reliability.Value); + Assert.AreEqual(entity.RequiredReliability, output.RequiredReliability.Value); + } + + [Test] + public void Read_ValidEntityWithNullValues_ReturnGrassCoverErosionInwardsOutput() + { + // Setup + var entity = new ProbabilisticOutputEntity + { + ProbabilisticOutputEntityId = 87345, + Probability = null, + RequiredProbability = null, + RequiredReliability = null, + Reliability = null, + FactorOfSafety = null + }; + + // Call + ProbabilityAssessmentOutput output = entity.Read(); + + // Assert + Assert.AreEqual(entity.ProbabilisticOutputEntityId, output.StorageId); + Assert.IsNaN(output.FactorOfSafety); + Assert.IsNaN(output.Probability); + Assert.IsNaN(output.RequiredProbability); + Assert.IsNaN(output.Reliability); + Assert.IsNaN(output.RequiredReliability); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/GrassCoverErosionInwards/GrassCoverErosionInwardsOutputUpdateExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/GrassCoverErosionInwards/GrassCoverErosionInwardsOutputUpdateExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/GrassCoverErosionInwards/GrassCoverErosionInwardsOutputUpdateExtensionsTest.cs (revision 3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6) @@ -0,0 +1,183 @@ +// 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.Exceptions; +using Application.Ringtoets.Storage.TestUtil; +using Application.Ringtoets.Storage.Update.GrassCoverErosionInwards; + +using NUnit.Framework; + +using Rhino.Mocks; + +using Ringtoets.Common.Data.Probability; +using Ringtoets.GrassCoverErosionInwards.Data; + +namespace Application.Ringtoets.Storage.Test.Update.GrassCoverErosionInwards +{ + [TestFixture] + public class GrassCoverErosionInwardsOutputUpdateExtensionsTest + { + [Test] + public void Update_PersistenceRegistryIsNull_ThrowArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var ringtoetsEntities = mocks.Stub(); + mocks.ReplayAll(); + + var output = new GrassCoverErosionInwardsOutput(1, true, new ProbabilityAssessmentOutput(1,1,1,1,1), 1); + + // Call + TestDelegate call = () => output.Update(null, ringtoetsEntities); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("registry", paramName); + mocks.VerifyAll(); + } + + [Test] + public void Update_RingtoetsEntitiesIsNull_ThrowArgumentNullException() + { + // Setup + var registry = new PersistenceRegistry(); + var output = new GrassCoverErosionInwardsOutput(1, true, new ProbabilityAssessmentOutput(1, 1, 1, 1, 1), 1); + + // Call + TestDelegate call = () => output.Update(registry, null); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("context", paramName); + } + + [Test] + public void Update_RingtoetsEntitiesWithoutGrassCoverErosionOutputEntities_ThrowEntityNotFoundException() + { + // Setup + var mocks = new MockRepository(); + var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks); + mocks.ReplayAll(); + + var registry = new PersistenceRegistry(); + + var output = new GrassCoverErosionInwardsOutput(1, true, new ProbabilityAssessmentOutput(1, 1, 1, 1, 1), 1); + + // Call + TestDelegate call = () => output.Update(registry, ringtoetsEntities); + + // Assert + Assert.Throws(call); + } + + [Test] + public void Update_RingtoetsEntitiesWithUnmatchingGrassCoverErosionOutputEntity_ThrowEntityNotFoundException() + { + // Setup + var mocks = new MockRepository(); + var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks); + mocks.ReplayAll(); + + var entity = new GrassCoverErosionInwardsOutputEntity + { + GrassCoverErosionInwardsOutputId = 23 + }; + var probabilisticOutputEntity = new ProbabilisticOutputEntity + { + ProbabilisticOutputEntityId = 12 + }; + ringtoetsEntities.GrassCoverErosionInwardsOutputEntities.Add(entity); + ringtoetsEntities.ProbabilisticOutputEntities.Add(probabilisticOutputEntity); + + var registry = new PersistenceRegistry(); + + var probabilityAssessmentOutput = new ProbabilityAssessmentOutput(1, 1, 1, 1, 1) + { + StorageId = 2 + }; + var output = new GrassCoverErosionInwardsOutput(1, true, probabilityAssessmentOutput, 1) + { + StorageId = probabilisticOutputEntity.ProbabilisticOutputEntityId + }; + + // Call + TestDelegate call = () => output.Update(registry, ringtoetsEntities); + + // Assert + Assert.Throws(call); + } + + [Test] + public void Update_RingtoetsEntitiesWithMatchingGrassCoverErosionInwardsOutputEntity_RegisterEntity() + { + // Setup + var mocks = new MockRepository(); + var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks); + mocks.ReplayAll(); + + var persistentEntity = new GrassCoverErosionInwardsOutputEntity + { + GrassCoverErosionInwardsOutputId = 23 + }; + var persistentProbabilisticOutputEntity = new ProbabilisticOutputEntity + { + ProbabilisticOutputEntityId = 12 + }; + var orphanedEntity = new GrassCoverErosionInwardsOutputEntity + { + GrassCoverErosionInwardsOutputId = 42 + }; + var orphanedProbabilisticOutputEntity = new ProbabilisticOutputEntity + { + ProbabilisticOutputEntityId = 15 + }; + ringtoetsEntities.GrassCoverErosionInwardsOutputEntities.Add(persistentEntity); + ringtoetsEntities.GrassCoverErosionInwardsOutputEntities.Add(orphanedEntity); + ringtoetsEntities.ProbabilisticOutputEntities.Add(persistentProbabilisticOutputEntity); + ringtoetsEntities.ProbabilisticOutputEntities.Add(orphanedProbabilisticOutputEntity); + + var registry = new PersistenceRegistry(); + + var probabilityAssessmentOutput = new ProbabilityAssessmentOutput(1, 1, 1, 1, 1) + { + StorageId = persistentProbabilisticOutputEntity.ProbabilisticOutputEntityId + }; + var output = new GrassCoverErosionInwardsOutput(1, true, probabilityAssessmentOutput, 1) + { + StorageId = persistentEntity.GrassCoverErosionInwardsOutputId + }; + + // Call + output.Update(registry, ringtoetsEntities); + + // Assert + registry.RemoveUntouched(ringtoetsEntities); + CollectionAssert.Contains(ringtoetsEntities.GrassCoverErosionInwardsOutputEntities, persistentEntity); + CollectionAssert.Contains(ringtoetsEntities.ProbabilisticOutputEntities, persistentProbabilisticOutputEntity); + CollectionAssert.DoesNotContain(ringtoetsEntities.GrassCoverErosionInwardsOutputEntities, orphanedEntity); + CollectionAssert.DoesNotContain(ringtoetsEntities.ProbabilisticOutputEntities, orphanedProbabilisticOutputEntity); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/ProbabilityAssessmentOutputUpdateExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/ProbabilityAssessmentOutputUpdateExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/ProbabilityAssessmentOutputUpdateExtensionsTest.cs (revision 3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6) @@ -0,0 +1,157 @@ +// 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.Exceptions; +using Application.Ringtoets.Storage.TestUtil; +using Application.Ringtoets.Storage.Update; + +using NUnit.Framework; + +using Rhino.Mocks; + +using Ringtoets.Common.Data.Probability; + +namespace Application.Ringtoets.Storage.Test.Update +{ + [TestFixture] + public class ProbabilityAssessmentOutputUpdateExtensionsTest + { + [Test] + public void Update_PersistenceRegistryIsNull_ThrowArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var ringtoetsEntities = mocks.Stub(); + mocks.ReplayAll(); + + var output = new ProbabilityAssessmentOutput(1, 1, 1, 1, 1); + + // Call + TestDelegate call = () => output.Update(null, ringtoetsEntities); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("registry", paramName); + mocks.VerifyAll(); + } + + [Test] + public void Update_RingtoetsEntitiesIsNull_ThrowArgumentNullException() + { + // Setup + var registry = new PersistenceRegistry(); + var output = new ProbabilityAssessmentOutput(1, 1, 1, 1, 1); + + // Call + TestDelegate call = () => output.Update(registry, null); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("context", paramName); + } + + [Test] + public void Update_RingtoetsEntitiesWithoutProbabilisticOutputEntities_ThrowEntityNotFoundException() + { + // Setup + var mocks = new MockRepository(); + var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks); + mocks.ReplayAll(); + + var registry = new PersistenceRegistry(); + + var output = new ProbabilityAssessmentOutput(1, 1, 1, 1, 1); + + // Call + TestDelegate call = () => output.Update(registry, ringtoetsEntities); + + // Assert + Assert.Throws(call); + } + + [Test] + public void Update_RingtoetsEntitiesWithUnmatchingProbabilisticOutputEntity_ThrowEntityNotFoundException() + { + // Setup + var mocks = new MockRepository(); + var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks); + mocks.ReplayAll(); + + var entity = new ProbabilisticOutputEntity + { + ProbabilisticOutputEntityId = 12 + }; + ringtoetsEntities.ProbabilisticOutputEntities.Add(entity); + + var registry = new PersistenceRegistry(); + + var output = new ProbabilityAssessmentOutput(1, 1, 1, 1, 1) + { + StorageId = 2 + }; + + // Call + TestDelegate call = () => output.Update(registry, ringtoetsEntities); + + // Assert + Assert.Throws(call); + } + + [Test] + public void Update_RingtoetsEntitiesWithMatchingGrassCoverErosionInwardsOutputEntity_RegisterEntity() + { + // Setup + var mocks = new MockRepository(); + var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks); + mocks.ReplayAll(); + + var persistentEntity = new ProbabilisticOutputEntity + { + ProbabilisticOutputEntityId = 12 + }; + var orphanedEntity = new ProbabilisticOutputEntity + { + ProbabilisticOutputEntityId = 17 + }; + ringtoetsEntities.ProbabilisticOutputEntities.Add(persistentEntity); + ringtoetsEntities.ProbabilisticOutputEntities.Add(orphanedEntity); + + var registry = new PersistenceRegistry(); + + var output = new ProbabilityAssessmentOutput(1, 1, 1, 1, 1) + { + StorageId = persistentEntity.ProbabilisticOutputEntityId + }; + + // Call + output.Update(registry, ringtoetsEntities); + + // Assert + registry.RemoveUntouched(ringtoetsEntities); + CollectionAssert.Contains(ringtoetsEntities.ProbabilisticOutputEntities, persistentEntity); + CollectionAssert.DoesNotContain(ringtoetsEntities.ProbabilisticOutputEntities, orphanedEntity); + } + } +} \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Data/Probability/ProbabilityAssessmentOutput.cs =================================================================== diff -u -rbe9428984d28fcbd8f6089f1c1184cd9763c18bf -r3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6 --- Ringtoets/Common/src/Ringtoets.Common.Data/Probability/ProbabilityAssessmentOutput.cs (.../ProbabilityAssessmentOutput.cs) (revision be9428984d28fcbd8f6089f1c1184cd9763c18bf) +++ Ringtoets/Common/src/Ringtoets.Common.Data/Probability/ProbabilityAssessmentOutput.cs (.../ProbabilityAssessmentOutput.cs) (revision 3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6) @@ -23,6 +23,7 @@ using Core.Common.Base; using Core.Common.Base.Data; +using Core.Common.Base.Storage; using Ringtoets.Common.Data.Calculation; @@ -33,7 +34,7 @@ /// /// This class contains the results of a probabilistic assessment calculation. /// - public class ProbabilityAssessmentOutput : Observable, ICalculationOutput + public class ProbabilityAssessmentOutput : Observable, ICalculationOutput, IStorable { private double requiredProbability; private double probability; @@ -121,5 +122,7 @@ /// Gets the factor of safety of the failure mechanism. /// public RoundedDouble FactorOfSafety { get; private set; } + + public long StorageId { get; set; } } } \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/Probability/ProbabilityAssessmentOutputTest.cs =================================================================== diff -u -rce94b8228bc7e51779b3754217580f13cb35e475 -r3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6 --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/Probability/ProbabilityAssessmentOutputTest.cs (.../ProbabilityAssessmentOutputTest.cs) (revision ce94b8228bc7e51779b3754217580f13cb35e475) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/Probability/ProbabilityAssessmentOutputTest.cs (.../ProbabilityAssessmentOutputTest.cs) (revision 3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6) @@ -22,6 +22,7 @@ using System; using Core.Common.Base; using Core.Common.Base.Data; +using Core.Common.Base.Storage; using Core.Common.TestUtil; using NUnit.Framework; @@ -50,12 +51,16 @@ // Assert Assert.IsInstanceOf(output); Assert.IsInstanceOf(output); + Assert.IsInstanceOf(output); + Assert.IsNotNull(output); Assert.AreEqual(requiredProbability, output.RequiredProbability); Assert.AreEqual(requiredReliability, output.RequiredReliability); Assert.AreEqual(probability, output.Probability); Assert.AreEqual(reliability, output.Reliability); Assert.AreEqual(factorOfSafety, output.FactorOfSafety); + + Assert.AreEqual(0, output.StorageId); } [Test] Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/GrassCoverErosionInwardsFailureMechanismSectionResult.cs =================================================================== diff -u -r8bb257bcf65291ebc7fc3b913d73bb11f40124d4 -r3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/GrassCoverErosionInwardsFailureMechanismSectionResult.cs (.../GrassCoverErosionInwardsFailureMechanismSectionResult.cs) (revision 8bb257bcf65291ebc7fc3b913d73bb11f40124d4) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/GrassCoverErosionInwardsFailureMechanismSectionResult.cs (.../GrassCoverErosionInwardsFailureMechanismSectionResult.cs) (revision 3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6) @@ -56,7 +56,7 @@ { return double.NaN; } - return Calculation.Output.Probability; + return Calculation.Output.ProbabilisticAssessmentOutput.Probability; } } Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/GrassCoverErosionInwardsOutput.cs =================================================================== diff -u -r08adf25cc7efeb88759bcba90e9881466fbf60f9 -r3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/GrassCoverErosionInwardsOutput.cs (.../GrassCoverErosionInwardsOutput.cs) (revision 08adf25cc7efeb88759bcba90e9881466fbf60f9) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/GrassCoverErosionInwardsOutput.cs (.../GrassCoverErosionInwardsOutput.cs) (revision 3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6) @@ -21,6 +21,8 @@ using Core.Common.Base; using Core.Common.Base.Data; +using Core.Common.Base.Storage; + using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.Probability; @@ -29,9 +31,8 @@ /// /// The result of a Grass Cover Erosion Inwards assessment. /// - public class GrassCoverErosionInwardsOutput : Observable, ICalculationOutput + public class GrassCoverErosionInwardsOutput : Observable, ICalculationOutput, IStorable { - private readonly ProbabilityAssessmentOutput probabilityAssessmentOutput; private readonly double? dikeHeight; /// @@ -44,9 +45,9 @@ /// The calculated dike height. public GrassCoverErosionInwardsOutput(double waveHeight, bool isOvertoppingDominant, ProbabilityAssessmentOutput probabilityAssessmentOutput, double? dikeHeight) { - IsOvertoppingDominant = isOvertoppingDominant; + IsOvertoppingDominant = isOvertoppingDominant; WaveHeight = new RoundedDouble(2, waveHeight); - this.probabilityAssessmentOutput = probabilityAssessmentOutput; + ProbabilisticAssessmentOutput = probabilityAssessmentOutput; this.dikeHeight = dikeHeight; } @@ -84,58 +85,11 @@ } /// - /// Gets the factor of safety of the failure mechanism. + /// Gets the probabilistic assessment output based on the grass cover erosion + /// inwards calculation output. /// - public RoundedDouble FactorOfSafety - { - get - { - return probabilityAssessmentOutput.FactorOfSafety; - } - } + public ProbabilityAssessmentOutput ProbabilisticAssessmentOutput { get; private set; } - /// - /// Gets the probability of failure. - /// - public double Probability - { - get - { - return probabilityAssessmentOutput.Probability; - } - } - - /// - /// Gets the reliability of the failure mechanism. - /// - public RoundedDouble Reliability - { - get - { - return probabilityAssessmentOutput.Reliability; - } - } - - /// - /// Gets the required (maximum allowed) probability of failure. - /// - public double RequiredProbability - { - get - { - return probabilityAssessmentOutput.RequiredProbability; - } - } - - /// - /// Get the required (maximum allowed) reliability of the failure mechanism. - /// - public RoundedDouble RequiredReliability - { - get - { - return probabilityAssessmentOutput.RequiredReliability; - } - } + public long StorageId { get; set; } } } \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsOutputProperties.cs =================================================================== diff -u -ra761c195a25ca9f764909e8064e933b9b5c57e01 -r3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsOutputProperties.cs (.../GrassCoverErosionInwardsOutputProperties.cs) (revision a761c195a25ca9f764909e8064e933b9b5c57e01) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsOutputProperties.cs (.../GrassCoverErosionInwardsOutputProperties.cs) (revision 3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6) @@ -43,7 +43,7 @@ { get { - return ProbabilityFormattingHelper.Format(data.RequiredProbability); + return ProbabilityFormattingHelper.Format(data.ProbabilisticAssessmentOutput.RequiredProbability); } } @@ -55,7 +55,7 @@ { get { - return data.RequiredReliability; + return data.ProbabilisticAssessmentOutput.RequiredReliability; } } @@ -67,7 +67,7 @@ { get { - return ProbabilityFormattingHelper.Format(data.Probability); + return ProbabilityFormattingHelper.Format(data.ProbabilisticAssessmentOutput.Probability); } } @@ -79,7 +79,7 @@ { get { - return data.Reliability; + return data.ProbabilisticAssessmentOutput.Reliability; } } @@ -91,7 +91,7 @@ { get { - return data.FactorOfSafety; + return data.ProbabilisticAssessmentOutput.FactorOfSafety; } } Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsFailureMechanismResultView.cs =================================================================== diff -u -r0ef0ca56191fb315c32f863ce06198d79be779be -r3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsFailureMechanismResultView.cs (.../GrassCoverErosionInwardsFailureMechanismResultView.cs) (revision 0ef0ca56191fb315c32f863ce06198d79be779be) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsFailureMechanismResultView.cs (.../GrassCoverErosionInwardsFailureMechanismResultView.cs) (revision 3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6) @@ -183,7 +183,7 @@ { if (calculation.HasOutput) { - if (double.IsNaN(calculation.Output.Probability)) + if (double.IsNaN(calculation.Output.ProbabilisticAssessmentOutput.Probability)) { return CalculationScenarioStatus.Failed; } Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsOutputTest.cs =================================================================== diff -u -r08adf25cc7efeb88759bcba90e9881466fbf60f9 -r3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsOutputTest.cs (.../GrassCoverErosionInwardsOutputTest.cs) (revision 08adf25cc7efeb88759bcba90e9881466fbf60f9) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsOutputTest.cs (.../GrassCoverErosionInwardsOutputTest.cs) (revision 3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6) @@ -21,10 +21,11 @@ using Core.Common.Base; using Core.Common.Base.Data; +using Core.Common.Base.Storage; + using NUnit.Framework; using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.Probability; -using Ringtoets.Common.Data.TestUtil; namespace Ringtoets.GrassCoverErosionInwards.Data.Test { @@ -52,17 +53,18 @@ // Assert Assert.IsInstanceOf(output); Assert.IsInstanceOf(output); + Assert.IsInstanceOf(output); + Assert.AreEqual(new RoundedDouble(2, waveHeight), output.WaveHeight); Assert.AreEqual(2, output.WaveHeight.NumberOfDecimalPlaces); Assert.AreEqual(isOvertoppingDominant, output.IsOvertoppingDominant); Assert.AreEqual(new RoundedDouble(2, dikeHeight), output.DikeHeight); Assert.AreEqual(2, output.DikeHeight.NumberOfDecimalPlaces); Assert.IsTrue(output.DikeHeightCalculated); - Assert.AreEqual(requiredProbability, output.RequiredProbability); - Assert.AreEqual(requiredReliability, output.RequiredReliability, output.RequiredReliability.GetAccuracy()); - Assert.AreEqual(probability, output.Probability); - Assert.AreEqual(reliability, output.Reliability, output.Reliability.GetAccuracy()); - Assert.AreEqual(factorOfSafety, output.FactorOfSafety, output.FactorOfSafety.GetAccuracy()); + + Assert.AreSame(probabilityAssessmentOutput, output.ProbabilisticAssessmentOutput); + + Assert.AreEqual(0, output.StorageId); } [Test] Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsFailureMechanismSectionResultRowTest.cs =================================================================== diff -u -ra761c195a25ca9f764909e8064e933b9b5c57e01 -r3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsFailureMechanismSectionResultRowTest.cs (.../GrassCoverErosionInwardsFailureMechanismSectionResultRowTest.cs) (revision a761c195a25ca9f764909e8064e933b9b5c57e01) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsFailureMechanismSectionResultRowTest.cs (.../GrassCoverErosionInwardsFailureMechanismSectionResultRowTest.cs) (revision 3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6) @@ -172,7 +172,7 @@ double assessmentLayerTwoA = resultRow.AssessmentLayerTwoA; // Assert - Assert.AreEqual(calculation.Output.Probability, assessmentLayerTwoA); + Assert.AreEqual(calculation.Output.ProbabilisticAssessmentOutput.Probability, assessmentLayerTwoA); } [Test] Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Integration.Test/GrassCoverErosionInwardsCalculationActivityIntegrationTest.cs =================================================================== diff -u -rac31032858ae5f0004edaf7a2faf8729be5af244 -r3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Integration.Test/GrassCoverErosionInwardsCalculationActivityIntegrationTest.cs (.../GrassCoverErosionInwardsCalculationActivityIntegrationTest.cs) (revision ac31032858ae5f0004edaf7a2faf8729be5af244) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Integration.Test/GrassCoverErosionInwardsCalculationActivityIntegrationTest.cs (.../GrassCoverErosionInwardsCalculationActivityIntegrationTest.cs) (revision 3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6) @@ -31,6 +31,7 @@ using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.Probability; using Ringtoets.GrassCoverErosionInwards.Data; using Ringtoets.GrassCoverErosionInwards.Service; using Ringtoets.GrassCoverErosionInwards.Service.Properties; @@ -390,11 +391,12 @@ // Assert Assert.IsNotNull(calculation.Output); - Assert.AreEqual((RoundedDouble) 0.625, calculation.Output.FactorOfSafety); - Assert.AreEqual(0.002617555933643434d, calculation.Output.Probability); - Assert.AreEqual((RoundedDouble) 2.792, calculation.Output.Reliability); - Assert.AreEqual(1.0/250000.0, calculation.Output.RequiredProbability); - Assert.AreEqual((RoundedDouble) 4.465, calculation.Output.RequiredReliability); + ProbabilityAssessmentOutput probabilisticAssessmentOutput = calculation.Output.ProbabilisticAssessmentOutput; + Assert.AreEqual((RoundedDouble) 0.625, probabilisticAssessmentOutput.FactorOfSafety); + Assert.AreEqual(0.002617555933643434d, probabilisticAssessmentOutput.Probability); + Assert.AreEqual((RoundedDouble) 2.792, probabilisticAssessmentOutput.Reliability); + Assert.AreEqual(1.0 / 250000.0, probabilisticAssessmentOutput.RequiredProbability); + Assert.AreEqual((RoundedDouble)4.465, probabilisticAssessmentOutput.RequiredReliability); Assert.IsNaN(calculation.Output.DikeHeight); Assert.IsFalse(calculation.Output.DikeHeightCalculated); mocks.VerifyAll(); @@ -472,11 +474,12 @@ // Assert Assert.IsNotNull(calculation.Output); - Assert.AreEqual((RoundedDouble) 0.625, calculation.Output.FactorOfSafety); - Assert.AreEqual(0.002617555933643434d, calculation.Output.Probability); - Assert.AreEqual((RoundedDouble) 2.792, calculation.Output.Reliability); - Assert.AreEqual(1.0/250000.0, calculation.Output.RequiredProbability); - Assert.AreEqual((RoundedDouble) 4.465, calculation.Output.RequiredReliability); + ProbabilityAssessmentOutput probabilisticAssessmentOutput = calculation.Output.ProbabilisticAssessmentOutput; + Assert.AreEqual((RoundedDouble) 0.625, probabilisticAssessmentOutput.FactorOfSafety); + Assert.AreEqual(0.002617555933643434d, probabilisticAssessmentOutput.Probability); + Assert.AreEqual((RoundedDouble)2.792, probabilisticAssessmentOutput.Reliability); + Assert.AreEqual(1.0 / 250000.0, probabilisticAssessmentOutput.RequiredProbability); + Assert.AreEqual((RoundedDouble)4.465, probabilisticAssessmentOutput.RequiredReliability); Assert.AreEqual((RoundedDouble) 6.94, calculation.Output.DikeHeight); Assert.IsTrue(calculation.Output.DikeHeightCalculated); mocks.VerifyAll();