Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj =================================================================== diff -u -r4a12b47ea94488f0716d7c61c6cefba235d7db48 -r0e4717786f2f1a865e48da9fde2089a789bfe02c --- Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 4a12b47ea94488f0716d7c61c6cefba235d7db48) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -56,6 +56,14 @@ + + + + + + + + @@ -206,6 +214,10 @@ + + + + @@ -267,6 +279,14 @@ + + + + + + + + Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/AssessmentSectionCreateExtensions.cs =================================================================== diff -u -r4a12b47ea94488f0716d7c61c6cefba235d7db48 -r0e4717786f2f1a865e48da9fde2089a789bfe02c --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/AssessmentSectionCreateExtensions.cs (.../AssessmentSectionCreateExtensions.cs) (revision 4a12b47ea94488f0716d7c61c6cefba235d7db48) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/AssessmentSectionCreateExtensions.cs (.../AssessmentSectionCreateExtensions.cs) (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -66,6 +66,10 @@ entity.FailureMechanismEntities.Add(section.MacrostabilityOutwards.Create(registry)); entity.FailureMechanismEntities.Add(section.WaveImpactAsphaltCover.Create(registry)); entity.FailureMechanismEntities.Add(section.GrassCoverErosionOutwards.Create(registry)); + entity.FailureMechanismEntities.Add(section.GrassCoverSlipOffInwards.Create(registry)); + entity.FailureMechanismEntities.Add(section.GrassCoverSlipOffOutwards.Create(registry)); + entity.FailureMechanismEntities.Add(section.Microstability.Create(registry)); + entity.FailureMechanismEntities.Add(section.PipingStructure.Create(registry)); AddEntitiesForAddStandAloneFailureMechanisms(section, entity, registry); @@ -75,11 +79,7 @@ private static void AddEntitiesForAddStandAloneFailureMechanisms(AssessmentSection section, AssessmentSectionEntity entity, PersistenceRegistry registry) { - entity.FailureMechanismEntities.Add(section.Microstability.Create(FailureMechanismType.Microstability, registry)); entity.FailureMechanismEntities.Add(section.StabilityStoneCover.Create(FailureMechanismType.StabilityStoneRevetment, registry)); - entity.FailureMechanismEntities.Add(section.GrassCoverSlipOffOutwards.Create(FailureMechanismType.GrassRevetmentSlidingOutwards, registry)); - entity.FailureMechanismEntities.Add(section.GrassCoverSlipOffInwards.Create(FailureMechanismType.GrassRevetmentSlidingInwards, registry)); - entity.FailureMechanismEntities.Add(section.PipingStructure.Create(FailureMechanismType.PipingAtStructure, registry)); entity.FailureMechanismEntities.Add(section.StrengthStabilityPointConstruction.Create(FailureMechanismType.StrengthAndStabilityPointConstruction, registry)); entity.FailureMechanismEntities.Add(section.DuneErosion.Create(FailureMechanismType.DuneErosion, registry)); } Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/GrassCoverSlipOffInwardsFailureMechanismCreateExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/GrassCoverSlipOffInwardsFailureMechanismCreateExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/GrassCoverSlipOffInwardsFailureMechanismCreateExtensions.cs (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -0,0 +1,63 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.Generic; +using Application.Ringtoets.Storage.DbContext; +using Ringtoets.Integration.Data.StandAlone; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Application.Ringtoets.Storage.Create +{ + /// + /// Extension methods for related to creating a . + /// + internal static class GrassCoverSlipOffInwardsFailureMechanismCreateExtensions + { + /// + /// Creates a based on the information of the . + /// + /// The failure mechanism to create a database entity for. + /// The object keeping track of create operations. + /// A new . + /// Thrown when is null. + internal static FailureMechanismEntity Create(this GrassCoverSlipOffInwardsFailureMechanism mechanism, PersistenceRegistry registry) + { + var entity = mechanism.Create(FailureMechanismType.GrassRevetmentSlidingInwards, registry); + AddEntitiesForSectionResults(mechanism.SectionResults, registry); + + registry.Register(entity, mechanism); + return entity; + } + + private static void AddEntitiesForSectionResults( + IEnumerable sectionResults, + PersistenceRegistry registry) + { + foreach (var failureMechanismSectionResult in sectionResults) + { + var sectionResultEntity = failureMechanismSectionResult.Create(registry); + var section = registry.Get(failureMechanismSectionResult.Section); + section.GrassCoverSlipOffInwardsSectionResultEntities.Add(sectionResultEntity); + } + } + } +} \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/GrassCoverSlipOffInwardsFailureMechanismSectionResultCreateExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/GrassCoverSlipOffInwardsFailureMechanismSectionResultCreateExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/GrassCoverSlipOffInwardsFailureMechanismSectionResultCreateExtensions.cs (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -0,0 +1,58 @@ +// 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.Integration.Data.StandAlone.SectionResults; + +namespace Application.Ringtoets.Storage.Create +{ + /// + /// Extension methods for related to creating a + /// . + /// + internal static class GrassCoverSlipOffInwardsFailureMechanismSectionResultCreateExtensions + { + /// + /// 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 GrassCoverSlipOffInwardsSectionResultEntity Create(this GrassCoverSlipOffInwardsFailureMechanismSectionResult result, PersistenceRegistry registry) + { + if (registry == null) + { + throw new ArgumentNullException("registry"); + } + var sectionResultEntity = new GrassCoverSlipOffInwardsSectionResultEntity + { + LayerOne = Convert.ToByte(result.AssessmentLayerOne), + LayerTwoA = Convert.ToByte(result.AssessmentLayerTwoA), + LayerThree = result.AssessmentLayerThree.Value.ToNullableDecimal() + }; + + registry.Register(sectionResultEntity, result); + return sectionResultEntity; + } + } +} \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/GrassCoverSlipOffOutwardsFailureMechanismCreateExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/GrassCoverSlipOffOutwardsFailureMechanismCreateExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/GrassCoverSlipOffOutwardsFailureMechanismCreateExtensions.cs (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -0,0 +1,63 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.Generic; +using Application.Ringtoets.Storage.DbContext; +using Ringtoets.Integration.Data.StandAlone; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Application.Ringtoets.Storage.Create +{ + /// + /// Extension methods for related to creating a . + /// + internal static class GrassCoverSlipOffOutwardsFailureMechanismCreateExtensions + { + /// + /// Creates a based on the information of the . + /// + /// The failure mechanism to create a database entity for. + /// The object keeping track of create operations. + /// A new . + /// Thrown when is null. + internal static FailureMechanismEntity Create(this GrassCoverSlipOffOutwardsFailureMechanism mechanism, PersistenceRegistry registry) + { + var entity = mechanism.Create(FailureMechanismType.GrassRevetmentSlidingOutwards, registry); + AddEntitiesForSectionResults(mechanism.SectionResults, registry); + + registry.Register(entity, mechanism); + return entity; + } + + private static void AddEntitiesForSectionResults( + IEnumerable sectionResults, + PersistenceRegistry registry) + { + foreach (var failureMechanismSectionResult in sectionResults) + { + var sectionResultEntity = failureMechanismSectionResult.Create(registry); + var section = registry.Get(failureMechanismSectionResult.Section); + section.GrassCoverSlipOffOutwardsSectionResultEntities.Add(sectionResultEntity); + } + } + } +} \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/GrassCoverSlipOffOutwardsFailureMechanismSectionResultCreateExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/GrassCoverSlipOffOutwardsFailureMechanismSectionResultCreateExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/GrassCoverSlipOffOutwardsFailureMechanismSectionResultCreateExtensions.cs (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -0,0 +1,58 @@ +// 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.Integration.Data.StandAlone.SectionResults; + +namespace Application.Ringtoets.Storage.Create +{ + /// + /// Extension methods for related to creating a + /// . + /// + internal static class GrassCoverSlipOffOutwardsFailureMechanismSectionResultCreateExtensions + { + /// + /// 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 GrassCoverSlipOffOutwardsSectionResultEntity Create(this GrassCoverSlipOffOutwardsFailureMechanismSectionResult result, PersistenceRegistry registry) + { + if (registry == null) + { + throw new ArgumentNullException("registry"); + } + var sectionResultEntity = new GrassCoverSlipOffOutwardsSectionResultEntity + { + LayerOne = Convert.ToByte(result.AssessmentLayerOne), + LayerTwoA = Convert.ToByte(result.AssessmentLayerTwoA), + LayerThree = result.AssessmentLayerThree.Value.ToNullableDecimal() + }; + + registry.Register(sectionResultEntity, result); + return sectionResultEntity; + } + } +} \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/MicrostabilityFailureMechanismCreateExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/MicrostabilityFailureMechanismCreateExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/MicrostabilityFailureMechanismCreateExtensions.cs (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -0,0 +1,63 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.Generic; +using Application.Ringtoets.Storage.DbContext; +using Ringtoets.Integration.Data.StandAlone; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Application.Ringtoets.Storage.Create +{ + /// + /// Extension methods for related to creating a . + /// + internal static class MicrostabilityFailureMechanismCreateExtensions + { + /// + /// Creates a based on the information of the . + /// + /// The failure mechanism to create a database entity for. + /// The object keeping track of create operations. + /// A new . + /// Thrown when is null. + internal static FailureMechanismEntity Create(this MicrostabilityFailureMechanism mechanism, PersistenceRegistry registry) + { + var entity = mechanism.Create(FailureMechanismType.Microstability, registry); + AddEntitiesForSectionResults(mechanism.SectionResults, registry); + + registry.Register(entity, mechanism); + return entity; + } + + private static void AddEntitiesForSectionResults( + IEnumerable sectionResults, + PersistenceRegistry registry) + { + foreach (var failureMechanismSectionResult in sectionResults) + { + var sectionResultEntity = failureMechanismSectionResult.Create(registry); + var section = registry.Get(failureMechanismSectionResult.Section); + section.MicrostabilitySectionResultEntities.Add(sectionResultEntity); + } + } + } +} \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/MicrostabilityFailureMechanismSectionResultCreateExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/MicrostabilityFailureMechanismSectionResultCreateExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/MicrostabilityFailureMechanismSectionResultCreateExtensions.cs (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -0,0 +1,58 @@ +// 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.Integration.Data.StandAlone.SectionResults; + +namespace Application.Ringtoets.Storage.Create +{ + /// + /// Extension methods for related to creating a + /// . + /// + internal static class MicrostabilityFailureMechanismSectionResultCreateExtensions + { + /// + /// 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 MicrostabilitySectionResultEntity Create(this MicrostabilityFailureMechanismSectionResult result, PersistenceRegistry registry) + { + if (registry == null) + { + throw new ArgumentNullException("registry"); + } + var sectionResultEntity = new MicrostabilitySectionResultEntity + { + LayerOne = Convert.ToByte(result.AssessmentLayerOne), + LayerTwoA = Convert.ToByte(result.AssessmentLayerTwoA), + LayerThree = result.AssessmentLayerThree.Value.ToNullableDecimal() + }; + + registry.Register(sectionResultEntity, result); + return sectionResultEntity; + } + } +} \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PersistenceRegistry.cs =================================================================== diff -u -r4a12b47ea94488f0716d7c61c6cefba235d7db48 -r0e4717786f2f1a865e48da9fde2089a789bfe02c --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PersistenceRegistry.cs (.../PersistenceRegistry.cs) (revision 4a12b47ea94488f0716d7c61c6cefba235d7db48) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PersistenceRegistry.cs (.../PersistenceRegistry.cs) (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -64,6 +64,10 @@ private readonly Dictionary macrostabilityOutwardsFailureMechanismSectionResults = new Dictionary(); private readonly Dictionary waveImpactAsphaltCoverFailureMechanismSectionResults = new Dictionary(); private readonly Dictionary grassCoverErosionOutwardsFailureMechanismSectionResults = new Dictionary(); + private readonly Dictionary grassCoverSlipOffInwardsFailureMechanismSectionResults = new Dictionary(); + private readonly Dictionary grassCoverSlipOffOutwardsFailureMechanismSectionResults = new Dictionary(); + private readonly Dictionary microstabilityFailureMechanismSectionResults = new Dictionary(); + private readonly Dictionary pipingStructureFailureMechanismSectionResults = new Dictionary(); private readonly Dictionary hydraulicLocations = new Dictionary(new ReferenceEqualityComparer()); private readonly Dictionary calculationGroups = new Dictionary(new ReferenceEqualityComparer()); private readonly Dictionary pipingCalculations = new Dictionary(new ReferenceEqualityComparer()); @@ -274,6 +278,70 @@ /// 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(GrassCoverSlipOffInwardsSectionResultEntity entity, GrassCoverSlipOffInwardsFailureMechanismSectionResult model) + { + Register(grassCoverSlipOffInwardsFailureMechanismSectionResults, 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(GrassCoverSlipOffOutwardsSectionResultEntity entity, GrassCoverSlipOffOutwardsFailureMechanismSectionResult model) + { + Register(grassCoverSlipOffOutwardsFailureMechanismSectionResults, 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(MicrostabilitySectionResultEntity entity, MicrostabilityFailureMechanismSectionResult model) + { + Register(microstabilityFailureMechanismSectionResults, 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(PipingStructureSectionResultEntity entity, PipingStructureFailureMechanismSectionResult model) + { + Register(pipingStructureFailureMechanismSectionResults, 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: @@ -795,6 +863,26 @@ grassCoverErosionOutwardsFailureMechanismSectionResults[entity].StorageId = entity.GrassCoverErosionOutwardsSectionResultEntityId; } + foreach (var entity in grassCoverSlipOffInwardsFailureMechanismSectionResults.Keys) + { + grassCoverSlipOffInwardsFailureMechanismSectionResults[entity].StorageId = entity.GrassCoverSlipOffInwardsSectionResultEntityId; + } + + foreach (var entity in grassCoverSlipOffOutwardsFailureMechanismSectionResults.Keys) + { + grassCoverSlipOffOutwardsFailureMechanismSectionResults[entity].StorageId = entity.GrassCoverSlipOffOutwardsSectionResultEntityId; + } + + foreach (var entity in microstabilityFailureMechanismSectionResults.Keys) + { + microstabilityFailureMechanismSectionResults[entity].StorageId = entity.MicrostabilitySectionResultEntityId; + } + + foreach (var entity in pipingStructureFailureMechanismSectionResults.Keys) + { + pipingStructureFailureMechanismSectionResults[entity].StorageId = entity.PipingStructureSectionResultEntityId; + } + foreach (var entity in hydraulicLocations.Keys) { hydraulicLocations[entity].StorageId = entity.HydraulicLocationEntityId; @@ -1030,6 +1118,50 @@ } dbContext.GrassCoverErosionOutwardsSectionResultEntities.RemoveRange(orphanedGrassCoverErosionOutwardsSectionResultEntities); + var orphanedGrassCoverSlipOffInwardsSectionResultEntities = new List(); + foreach (GrassCoverSlipOffInwardsSectionResultEntity sectionResultEntity in dbContext.GrassCoverSlipOffInwardsSectionResultEntities + .Where(e => e.GrassCoverSlipOffInwardsSectionResultEntityId > 0)) + { + if (!grassCoverSlipOffInwardsFailureMechanismSectionResults.ContainsKey(sectionResultEntity)) + { + orphanedGrassCoverSlipOffInwardsSectionResultEntities.Add(sectionResultEntity); + } + } + dbContext.GrassCoverSlipOffInwardsSectionResultEntities.RemoveRange(orphanedGrassCoverSlipOffInwardsSectionResultEntities); + + var orphanedGrassCoverSlipOffOutwardsSectionResultEntities = new List(); + foreach (GrassCoverSlipOffOutwardsSectionResultEntity sectionResultEntity in dbContext.GrassCoverSlipOffOutwardsSectionResultEntities + .Where(e => e.GrassCoverSlipOffOutwardsSectionResultEntityId > 0)) + { + if (!grassCoverSlipOffOutwardsFailureMechanismSectionResults.ContainsKey(sectionResultEntity)) + { + orphanedGrassCoverSlipOffOutwardsSectionResultEntities.Add(sectionResultEntity); + } + } + dbContext.GrassCoverSlipOffOutwardsSectionResultEntities.RemoveRange(orphanedGrassCoverSlipOffOutwardsSectionResultEntities); + + var orphanedMicrostabilitySectionResultEntities = new List(); + foreach (MicrostabilitySectionResultEntity sectionResultEntity in dbContext.MicrostabilitySectionResultEntities + .Where(e => e.MicrostabilitySectionResultEntityId > 0)) + { + if (!microstabilityFailureMechanismSectionResults.ContainsKey(sectionResultEntity)) + { + orphanedMicrostabilitySectionResultEntities.Add(sectionResultEntity); + } + } + dbContext.MicrostabilitySectionResultEntities.RemoveRange(orphanedMicrostabilitySectionResultEntities); + + var orphanedPipingStructureSectionResultEntities = new List(); + foreach (PipingStructureSectionResultEntity sectionResultEntity in dbContext.PipingStructureSectionResultEntities + .Where(e => e.PipingStructureSectionResultEntityId > 0)) + { + if (!pipingStructureFailureMechanismSectionResults.ContainsKey(sectionResultEntity)) + { + orphanedPipingStructureSectionResultEntities.Add(sectionResultEntity); + } + } + dbContext.PipingStructureSectionResultEntities.RemoveRange(orphanedPipingStructureSectionResultEntities); + var orphanedHydraulicLocationEntities = new List(); foreach (HydraulicLocationEntity hydraulicLocationEntity in dbContext.HydraulicLocationEntities .Where(e => e.HydraulicLocationEntityId > 0)) Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PipingStructureFailureMechanismCreateExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PipingStructureFailureMechanismCreateExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PipingStructureFailureMechanismCreateExtensions.cs (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -0,0 +1,63 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.Generic; +using Application.Ringtoets.Storage.DbContext; +using Ringtoets.Integration.Data.StandAlone; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Application.Ringtoets.Storage.Create +{ + /// + /// Extension methods for related to creating a . + /// + internal static class PipingStructureFailureMechanismCreateExtensions + { + /// + /// Creates a based on the information of the . + /// + /// The failure mechanism to create a database entity for. + /// The object keeping track of create operations. + /// A new . + /// Thrown when is null. + internal static FailureMechanismEntity Create(this PipingStructureFailureMechanism mechanism, PersistenceRegistry registry) + { + var entity = mechanism.Create(FailureMechanismType.PipingAtStructure, registry); + AddEntitiesForSectionResults(mechanism.SectionResults, registry); + + registry.Register(entity, mechanism); + return entity; + } + + private static void AddEntitiesForSectionResults( + IEnumerable sectionResults, + PersistenceRegistry registry) + { + foreach (var failureMechanismSectionResult in sectionResults) + { + var sectionResultEntity = failureMechanismSectionResult.Create(registry); + var section = registry.Get(failureMechanismSectionResult.Section); + section.PipingStructureSectionResultEntities.Add(sectionResultEntity); + } + } + } +} \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PipingStructureFailureMechanismSectionResultCreateExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PipingStructureFailureMechanismSectionResultCreateExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PipingStructureFailureMechanismSectionResultCreateExtensions.cs (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -0,0 +1,58 @@ +// 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.Integration.Data.StandAlone.SectionResults; + +namespace Application.Ringtoets.Storage.Create +{ + /// + /// Extension methods for related to creating a + /// . + /// + internal static class PipingStructureFailureMechanismSectionResultCreateExtensions + { + /// + /// 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 PipingStructureSectionResultEntity Create(this PipingStructureFailureMechanismSectionResult result, PersistenceRegistry registry) + { + if (registry == null) + { + throw new ArgumentNullException("registry"); + } + var sectionResultEntity = new PipingStructureSectionResultEntity + { + LayerOne = Convert.ToByte(result.AssessmentLayerOne), + LayerTwoA = Convert.ToByte(result.AssessmentLayerTwoA), + LayerThree = result.AssessmentLayerThree.Value.ToNullableDecimal() + }; + + registry.Register(sectionResultEntity, result); + return sectionResultEntity; + } + } +} \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/IRingtoetsEntities.cs =================================================================== diff -u -r4a12b47ea94488f0716d7c61c6cefba235d7db48 -r0e4717786f2f1a865e48da9fde2089a789bfe02c --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/IRingtoetsEntities.cs (.../IRingtoetsEntities.cs) (revision 4a12b47ea94488f0716d7c61c6cefba235d7db48) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/IRingtoetsEntities.cs (.../IRingtoetsEntities.cs) (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -121,6 +121,30 @@ DbSet GrassCoverErosionOutwardsSectionResultEntities { get; } /// + /// Gets a of containing + /// every entity found in the database. + /// + DbSet GrassCoverSlipOffInwardsSectionResultEntities { get; } + + /// + /// Gets a of containing + /// every entity found in the database. + /// + DbSet GrassCoverSlipOffOutwardsSectionResultEntities { get; } + + /// + /// Gets a of containing + /// every entity found in the database. + /// + DbSet MicrostabilitySectionResultEntities { get; } + + /// + /// Gets a of containing + /// every entity found in the database. + /// + DbSet PipingStructureSectionResultEntities { get; } + + /// /// Gets a of containing /// every entity found in the database. /// Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/AssessmentSectionEntityReadExtensions.cs =================================================================== diff -u -r4a12b47ea94488f0716d7c61c6cefba235d7db48 -r0e4717786f2f1a865e48da9fde2089a789bfe02c --- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/AssessmentSectionEntityReadExtensions.cs (.../AssessmentSectionEntityReadExtensions.cs) (revision 4a12b47ea94488f0716d7c61c6cefba235d7db48) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/AssessmentSectionEntityReadExtensions.cs (.../AssessmentSectionEntityReadExtensions.cs) (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -74,6 +74,10 @@ entity.ReadMacrostabilityOutwardsFailureMechanism(assessmentSection, collector); entity.ReadWaveImpactAsphaltCoverFailureMechanism(assessmentSection, collector); entity.ReadGrassCoverErosionOutwardsFailureMechanism(assessmentSection, collector); + entity.ReadGrassCoverSlipOffInwardsFailureMechanism(assessmentSection, collector); + entity.ReadGrassCoverSlipOffOutwardsFailureMechanism(assessmentSection, collector); + entity.ReadMicrostabilityFailureMechanism(assessmentSection, collector); + entity.ReadPipingStructureFailureMechanism(assessmentSection, collector); entity.ReadStandAloneFailureMechanisms(assessmentSection, collector); return assessmentSection; @@ -204,13 +208,45 @@ } } + private static void ReadGrassCoverSlipOffInwardsFailureMechanism(this AssessmentSectionEntity entity, AssessmentSection assessmentSection, ReadConversionCollector collector) + { + var grassCoverSlipOffInwardsFailureMechanismEntity = entity.FailureMechanismEntities.SingleOrDefault(fme => fme.FailureMechanismType == (int)FailureMechanismType.GrassRevetmentSlidingInwards); + if (grassCoverSlipOffInwardsFailureMechanismEntity != null) + { + grassCoverSlipOffInwardsFailureMechanismEntity.ReadAsGrassCoverSlipOffInwardsFailureMechanism(assessmentSection.GrassCoverSlipOffInwards, collector); + } + } + + private static void ReadGrassCoverSlipOffOutwardsFailureMechanism(this AssessmentSectionEntity entity, AssessmentSection assessmentSection, ReadConversionCollector collector) + { + var grassCoverSlipOffOutwardsFailureMechanismEntity = entity.FailureMechanismEntities.SingleOrDefault(fme => fme.FailureMechanismType == (int)FailureMechanismType.GrassRevetmentSlidingOutwards); + if (grassCoverSlipOffOutwardsFailureMechanismEntity != null) + { + grassCoverSlipOffOutwardsFailureMechanismEntity.ReadAsGrassCoverSlipOffOutwardsFailureMechanism(assessmentSection.GrassCoverSlipOffOutwards, collector); + } + } + + private static void ReadMicrostabilityFailureMechanism(this AssessmentSectionEntity entity, AssessmentSection assessmentSection, ReadConversionCollector collector) + { + var microstabilityFailureMechanismEntity = entity.FailureMechanismEntities.SingleOrDefault(fme => fme.FailureMechanismType == (int)FailureMechanismType.Microstability); + if (microstabilityFailureMechanismEntity != null) + { + microstabilityFailureMechanismEntity.ReadAsMicrostabilityFailureMechanism(assessmentSection.Microstability, collector); + } + } + + private static void ReadPipingStructureFailureMechanism(this AssessmentSectionEntity entity, AssessmentSection assessmentSection, ReadConversionCollector collector) + { + var pipingStructureFailureMechanismEntity = entity.FailureMechanismEntities.SingleOrDefault(fme => fme.FailureMechanismType == (int)FailureMechanismType.PipingAtStructure); + if (pipingStructureFailureMechanismEntity != null) + { + pipingStructureFailureMechanismEntity.ReadAsPipingStructureFailureMechanism(assessmentSection.PipingStructure, collector); + } + } + private static void ReadStandAloneFailureMechanisms(this AssessmentSectionEntity entity, AssessmentSection assessmentSection, ReadConversionCollector collector) { - entity.ReadStandAloneFailureMechanism(FailureMechanismType.Microstability, assessmentSection.Microstability, collector); entity.ReadStandAloneFailureMechanism(FailureMechanismType.StabilityStoneRevetment, assessmentSection.StabilityStoneCover, collector); - entity.ReadStandAloneFailureMechanism(FailureMechanismType.GrassRevetmentSlidingOutwards, assessmentSection.GrassCoverSlipOffOutwards, collector); - entity.ReadStandAloneFailureMechanism(FailureMechanismType.GrassRevetmentSlidingInwards, assessmentSection.GrassCoverSlipOffInwards, collector); - entity.ReadStandAloneFailureMechanism(FailureMechanismType.PipingAtStructure, assessmentSection.PipingStructure, collector); entity.ReadStandAloneFailureMechanism(FailureMechanismType.StrengthAndStabilityPointConstruction, assessmentSection.StrengthStabilityPointConstruction, collector); entity.ReadStandAloneFailureMechanism(FailureMechanismType.DuneErosion, assessmentSection.DuneErosion, collector); } Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/FailureMechanismEntityReadExtensions.cs =================================================================== diff -u -r4a12b47ea94488f0716d7c61c6cefba235d7db48 -r0e4717786f2f1a865e48da9fde2089a789bfe02c --- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/FailureMechanismEntityReadExtensions.cs (.../FailureMechanismEntityReadExtensions.cs) (revision 4a12b47ea94488f0716d7c61c6cefba235d7db48) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/FailureMechanismEntityReadExtensions.cs (.../FailureMechanismEntityReadExtensions.cs) (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -325,6 +325,98 @@ } /// + /// Read the and use the information to update a . + /// + /// The to create for. + /// + /// The object keeping track of read operations. + internal static void ReadAsGrassCoverSlipOffInwardsFailureMechanism(this FailureMechanismEntity entity, GrassCoverSlipOffInwardsFailureMechanism failureMechanism, ReadConversionCollector collector) + { + entity.ReadCommonFailureMechanismProperties(failureMechanism, collector); + entity.ReadGrassCoverSlipOffInwardsMechanismSectionResults(failureMechanism, collector); + } + + private static void ReadGrassCoverSlipOffInwardsMechanismSectionResults(this FailureMechanismEntity entity, GrassCoverSlipOffInwardsFailureMechanism failureMechanism, ReadConversionCollector collector) + { + foreach (var sectionResultEntity in entity.FailureMechanismSectionEntities.SelectMany(fms => fms.GrassCoverSlipOffInwardsSectionResultEntities)) + { + var failureMechanismSection = collector.Get(sectionResultEntity.FailureMechanismSectionEntity); + var result = failureMechanism.SectionResults.Single(sr => ReferenceEquals(sr.Section, failureMechanismSection)); + + sectionResultEntity.Read(result, collector); + } + } + + /// + /// Read the and use the information to update a . + /// + /// The to create for. + /// + /// The object keeping track of read operations. + internal static void ReadAsGrassCoverSlipOffOutwardsFailureMechanism(this FailureMechanismEntity entity, GrassCoverSlipOffOutwardsFailureMechanism failureMechanism, ReadConversionCollector collector) + { + entity.ReadCommonFailureMechanismProperties(failureMechanism, collector); + entity.ReadGrassCoverSlipOffOutwardsMechanismSectionResults(failureMechanism, collector); + } + + private static void ReadGrassCoverSlipOffOutwardsMechanismSectionResults(this FailureMechanismEntity entity, GrassCoverSlipOffOutwardsFailureMechanism failureMechanism, ReadConversionCollector collector) + { + foreach (var sectionResultEntity in entity.FailureMechanismSectionEntities.SelectMany(fms => fms.GrassCoverSlipOffOutwardsSectionResultEntities)) + { + var failureMechanismSection = collector.Get(sectionResultEntity.FailureMechanismSectionEntity); + var result = failureMechanism.SectionResults.Single(sr => ReferenceEquals(sr.Section, failureMechanismSection)); + + sectionResultEntity.Read(result, collector); + } + } + + /// + /// Read the and use the information to update a . + /// + /// The to create for. + /// + /// The object keeping track of read operations. + internal static void ReadAsMicrostabilityFailureMechanism(this FailureMechanismEntity entity, MicrostabilityFailureMechanism failureMechanism, ReadConversionCollector collector) + { + entity.ReadCommonFailureMechanismProperties(failureMechanism, collector); + entity.ReadMicrostabilityMechanismSectionResults(failureMechanism, collector); + } + + private static void ReadMicrostabilityMechanismSectionResults(this FailureMechanismEntity entity, MicrostabilityFailureMechanism failureMechanism, ReadConversionCollector collector) + { + foreach (var sectionResultEntity in entity.FailureMechanismSectionEntities.SelectMany(fms => fms.MicrostabilitySectionResultEntities)) + { + var failureMechanismSection = collector.Get(sectionResultEntity.FailureMechanismSectionEntity); + var result = failureMechanism.SectionResults.Single(sr => ReferenceEquals(sr.Section, failureMechanismSection)); + + sectionResultEntity.Read(result, collector); + } + } + + /// + /// Read the and use the information to update a . + /// + /// The to create for. + /// + /// The object keeping track of read operations. + internal static void ReadAsPipingStructureFailureMechanism(this FailureMechanismEntity entity, PipingStructureFailureMechanism failureMechanism, ReadConversionCollector collector) + { + entity.ReadCommonFailureMechanismProperties(failureMechanism, collector); + entity.ReadPipingStructureMechanismSectionResults(failureMechanism, collector); + } + + private static void ReadPipingStructureMechanismSectionResults(this FailureMechanismEntity entity, PipingStructureFailureMechanism failureMechanism, ReadConversionCollector collector) + { + foreach (var sectionResultEntity in entity.FailureMechanismSectionEntities.SelectMany(fms => fms.PipingStructureSectionResultEntities)) + { + var failureMechanismSection = collector.Get(sectionResultEntity.FailureMechanismSectionEntity); + var result = failureMechanism.SectionResults.Single(sr => ReferenceEquals(sr.Section, failureMechanismSection)); + + sectionResultEntity.Read(result, collector); + } + } + + /// /// Read the and use the information to update a . /// /// The to read into a . Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/GrassCoverSlipOffInwardsSectionResultEntityReadExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/GrassCoverSlipOffInwardsSectionResultEntityReadExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/GrassCoverSlipOffInwardsSectionResultEntityReadExtensions.cs (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -0,0 +1,62 @@ +// 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.Base.Data; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Application.Ringtoets.Storage.Read +{ + /// + /// This class defines extension methods for read operations for a based on the + /// . + /// + internal static class GrassCoverSlipOffInwardsSectionResultEntityReadExtensions + { + /// + /// Reads the and use the information to update a + /// . + /// + /// The to create for. + /// The target of the read operation. + /// The object keeping track of read operations. + /// A new . + /// Thrown when is null. + internal static void Read(this GrassCoverSlipOffInwardsSectionResultEntity entity, GrassCoverSlipOffInwardsFailureMechanismSectionResult sectionResult, ReadConversionCollector collector) + { + if (collector == null) + { + throw new ArgumentNullException("collector"); + } + if (sectionResult == null) + { + throw new ArgumentNullException("sectionResult"); + } + + sectionResult.StorageId = entity.GrassCoverSlipOffInwardsSectionResultEntityId; + sectionResult.AssessmentLayerOne = Convert.ToBoolean(entity.LayerOne); + sectionResult.AssessmentLayerTwoA = (AssessmentLayerTwoAResult)entity.LayerTwoA; + sectionResult.AssessmentLayerThree = (RoundedDouble)entity.LayerThree.ToNanableDouble(); + } + } +} \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/GrassCoverSlipOffOutwardsSectionResultEntityReadExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/GrassCoverSlipOffOutwardsSectionResultEntityReadExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/GrassCoverSlipOffOutwardsSectionResultEntityReadExtensions.cs (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -0,0 +1,62 @@ +// 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.Base.Data; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Application.Ringtoets.Storage.Read +{ + /// + /// This class defines extension methods for read operations for a based on the + /// . + /// + internal static class GrassCoverSlipOffOutwardsSectionResultEntityReadExtensions + { + /// + /// Reads the and use the information to update a + /// . + /// + /// The to create for. + /// The target of the read operation. + /// The object keeping track of read operations. + /// A new . + /// Thrown when is null. + internal static void Read(this GrassCoverSlipOffOutwardsSectionResultEntity entity, GrassCoverSlipOffOutwardsFailureMechanismSectionResult sectionResult, ReadConversionCollector collector) + { + if (collector == null) + { + throw new ArgumentNullException("collector"); + } + if (sectionResult == null) + { + throw new ArgumentNullException("sectionResult"); + } + + sectionResult.StorageId = entity.GrassCoverSlipOffOutwardsSectionResultEntityId; + sectionResult.AssessmentLayerOne = Convert.ToBoolean(entity.LayerOne); + sectionResult.AssessmentLayerTwoA = (AssessmentLayerTwoAResult)entity.LayerTwoA; + sectionResult.AssessmentLayerThree = (RoundedDouble)entity.LayerThree.ToNanableDouble(); + } + } +} \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/MicrostabilitySectionResultEntityReadExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/MicrostabilitySectionResultEntityReadExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/MicrostabilitySectionResultEntityReadExtensions.cs (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -0,0 +1,62 @@ +// 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.Base.Data; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Application.Ringtoets.Storage.Read +{ + /// + /// This class defines extension methods for read operations for a based on the + /// . + /// + internal static class MicrostabilitySectionResultEntityReadExtensions + { + /// + /// Reads the and use the information to update a + /// . + /// + /// The to create for. + /// The target of the read operation. + /// The object keeping track of read operations. + /// A new . + /// Thrown when is null. + internal static void Read(this MicrostabilitySectionResultEntity entity, MicrostabilityFailureMechanismSectionResult sectionResult, ReadConversionCollector collector) + { + if (collector == null) + { + throw new ArgumentNullException("collector"); + } + if (sectionResult == null) + { + throw new ArgumentNullException("sectionResult"); + } + + sectionResult.StorageId = entity.MicrostabilitySectionResultEntityId; + sectionResult.AssessmentLayerOne = Convert.ToBoolean(entity.LayerOne); + sectionResult.AssessmentLayerTwoA = (AssessmentLayerTwoAResult)entity.LayerTwoA; + sectionResult.AssessmentLayerThree = (RoundedDouble)entity.LayerThree.ToNanableDouble(); + } + } +} \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/PipingStructureSectionResultEntityReadExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/PipingStructureSectionResultEntityReadExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/PipingStructureSectionResultEntityReadExtensions.cs (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -0,0 +1,62 @@ +// 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.Base.Data; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Application.Ringtoets.Storage.Read +{ + /// + /// This class defines extension methods for read operations for a based on the + /// . + /// + internal static class PipingStructureSectionResultEntityReadExtensions + { + /// + /// Reads the and use the information to update a + /// . + /// + /// The to create for. + /// The target of the read operation. + /// The object keeping track of read operations. + /// A new . + /// Thrown when is null. + internal static void Read(this PipingStructureSectionResultEntity entity, PipingStructureFailureMechanismSectionResult sectionResult, ReadConversionCollector collector) + { + if (collector == null) + { + throw new ArgumentNullException("collector"); + } + if (sectionResult == null) + { + throw new ArgumentNullException("sectionResult"); + } + + sectionResult.StorageId = entity.PipingStructureSectionResultEntityId; + sectionResult.AssessmentLayerOne = Convert.ToBoolean(entity.LayerOne); + sectionResult.AssessmentLayerTwoA = (AssessmentLayerTwoAResult)entity.LayerTwoA; + sectionResult.AssessmentLayerThree = (RoundedDouble)entity.LayerThree.ToNanableDouble(); + } + } +} \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/GrassCoverSlipOffInwardsFailureMechanismSectionResultUpdateExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/GrassCoverSlipOffInwardsFailureMechanismSectionResultUpdateExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/GrassCoverSlipOffInwardsFailureMechanismSectionResultUpdateExtensions.cs (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -0,0 +1,72 @@ +// 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.Integration.Data.StandAlone.SectionResults; + +namespace Application.Ringtoets.Storage.Update +{ + /// + /// Extension methods for related to updating a + /// . + /// + internal static class GrassCoverSlipOffInwardsFailureMechanismSectionResultUpdateExtensions + { + /// + /// Updates a in the database based on the information of the + /// . + /// + /// The result 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 GrassCoverSlipOffInwardsFailureMechanismSectionResult result, PersistenceRegistry registry, IRingtoetsEntities context) + { + if (context == null) + { + throw new ArgumentNullException("context"); + } + if (registry == null) + { + throw new ArgumentNullException("registry"); + } + + GrassCoverSlipOffInwardsSectionResultEntity entity = result.GetCorrespondingEntity( + context.GrassCoverSlipOffInwardsSectionResultEntities, + s => s.GrassCoverSlipOffInwardsSectionResultEntityId); + + entity.LayerOne = Convert.ToByte(result.AssessmentLayerOne); + entity.LayerTwoA = Convert.ToByte(result.AssessmentLayerTwoA); + entity.LayerThree = Convert.ToDecimal(result.AssessmentLayerThree); + + registry.Register(entity, result); + } + } +} \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/GrassCoverSlipOffInwardsFailureMechanismUpdateExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/GrassCoverSlipOffInwardsFailureMechanismUpdateExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/GrassCoverSlipOffInwardsFailureMechanismUpdateExtensions.cs (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -0,0 +1,87 @@ +// 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.Integration.Data.StandAlone; + +namespace Application.Ringtoets.Storage.Update +{ + /// + /// Extension methods for related to updating a . + /// + internal static class GrassCoverSlipOffInwardsFailureMechanismUpdateExtensions + { + /// + /// Updates a in the database based on the information of the + /// . + /// + /// The mechanism 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 GrassCoverSlipOffInwardsFailureMechanism mechanism, PersistenceRegistry registry, IRingtoetsEntities context) + { + if (context == null) + { + throw new ArgumentNullException("context"); + } + if (registry == null) + { + throw new ArgumentNullException("registry"); + } + + FailureMechanismEntity entity = mechanism.GetCorrespondingEntity( + context.FailureMechanismEntities, + o => o.FailureMechanismEntityId); + + entity.IsRelevant = Convert.ToByte(mechanism.IsRelevant); + + mechanism.UpdateFailureMechanismSections(registry, entity, context); + UpdateSectionResults(mechanism, registry, context); + + registry.Register(entity, mechanism); + } + + private static void UpdateSectionResults(GrassCoverSlipOffInwardsFailureMechanism mechanism, PersistenceRegistry registry, IRingtoetsEntities context) + { + foreach (var sectionResult in mechanism.SectionResults) + { + if (sectionResult.IsNew()) + { + registry.Get(sectionResult.Section).GrassCoverSlipOffInwardsSectionResultEntities.Add(sectionResult.Create(registry)); + } + else + { + sectionResult.Update(registry, context); + } + } + } + } +} \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/GrassCoverSlipOffOutwardsFailureMechanismSectionResultUpdateExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/GrassCoverSlipOffOutwardsFailureMechanismSectionResultUpdateExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/GrassCoverSlipOffOutwardsFailureMechanismSectionResultUpdateExtensions.cs (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -0,0 +1,72 @@ +// 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.Integration.Data.StandAlone.SectionResults; + +namespace Application.Ringtoets.Storage.Update +{ + /// + /// Extension methods for related to updating a + /// . + /// + internal static class GrassCoverSlipOffOutwardsFailureMechanismSectionResultUpdateExtensions + { + /// + /// Updates a in the database based on the information of the + /// . + /// + /// The result 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 GrassCoverSlipOffOutwardsFailureMechanismSectionResult result, PersistenceRegistry registry, IRingtoetsEntities context) + { + if (context == null) + { + throw new ArgumentNullException("context"); + } + if (registry == null) + { + throw new ArgumentNullException("registry"); + } + + GrassCoverSlipOffOutwardsSectionResultEntity entity = result.GetCorrespondingEntity( + context.GrassCoverSlipOffOutwardsSectionResultEntities, + s => s.GrassCoverSlipOffOutwardsSectionResultEntityId); + + entity.LayerOne = Convert.ToByte(result.AssessmentLayerOne); + entity.LayerTwoA = Convert.ToByte(result.AssessmentLayerTwoA); + entity.LayerThree = Convert.ToDecimal(result.AssessmentLayerThree); + + registry.Register(entity, result); + } + } +} \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/GrassCoverSlipOffOutwardsFailureMechanismUpdateExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/GrassCoverSlipOffOutwardsFailureMechanismUpdateExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/GrassCoverSlipOffOutwardsFailureMechanismUpdateExtensions.cs (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -0,0 +1,87 @@ +// 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.Integration.Data.StandAlone; + +namespace Application.Ringtoets.Storage.Update +{ + /// + /// Extension methods for related to updating a . + /// + internal static class GrassCoverSlipOffOutwardsFailureMechanismUpdateExtensions + { + /// + /// Updates a in the database based on the information of the + /// . + /// + /// The mechanism 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 GrassCoverSlipOffOutwardsFailureMechanism mechanism, PersistenceRegistry registry, IRingtoetsEntities context) + { + if (context == null) + { + throw new ArgumentNullException("context"); + } + if (registry == null) + { + throw new ArgumentNullException("registry"); + } + + FailureMechanismEntity entity = mechanism.GetCorrespondingEntity( + context.FailureMechanismEntities, + o => o.FailureMechanismEntityId); + + entity.IsRelevant = Convert.ToByte(mechanism.IsRelevant); + + mechanism.UpdateFailureMechanismSections(registry, entity, context); + UpdateSectionResults(mechanism, registry, context); + + registry.Register(entity, mechanism); + } + + private static void UpdateSectionResults(GrassCoverSlipOffOutwardsFailureMechanism mechanism, PersistenceRegistry registry, IRingtoetsEntities context) + { + foreach (var sectionResult in mechanism.SectionResults) + { + if (sectionResult.IsNew()) + { + registry.Get(sectionResult.Section).GrassCoverSlipOffOutwardsSectionResultEntities.Add(sectionResult.Create(registry)); + } + else + { + sectionResult.Update(registry, context); + } + } + } + } +} \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/MicrostabilityFailureMechanismSectionResultUpdateExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/MicrostabilityFailureMechanismSectionResultUpdateExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/MicrostabilityFailureMechanismSectionResultUpdateExtensions.cs (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -0,0 +1,72 @@ +// 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.Integration.Data.StandAlone.SectionResults; + +namespace Application.Ringtoets.Storage.Update +{ + /// + /// Extension methods for related to updating a + /// . + /// + internal static class MicrostabilityFailureMechanismSectionResultUpdateExtensions + { + /// + /// Updates a in the database based on the information of the + /// . + /// + /// The result 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 MicrostabilityFailureMechanismSectionResult result, PersistenceRegistry registry, IRingtoetsEntities context) + { + if (context == null) + { + throw new ArgumentNullException("context"); + } + if (registry == null) + { + throw new ArgumentNullException("registry"); + } + + MicrostabilitySectionResultEntity entity = result.GetCorrespondingEntity( + context.MicrostabilitySectionResultEntities, + s => s.MicrostabilitySectionResultEntityId); + + entity.LayerOne = Convert.ToByte(result.AssessmentLayerOne); + entity.LayerTwoA = Convert.ToByte(result.AssessmentLayerTwoA); + entity.LayerThree = Convert.ToDecimal(result.AssessmentLayerThree); + + registry.Register(entity, result); + } + } +} \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/MicrostabilityFailureMechanismUpdateExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/MicrostabilityFailureMechanismUpdateExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/MicrostabilityFailureMechanismUpdateExtensions.cs (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -0,0 +1,87 @@ +// 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.Integration.Data.StandAlone; + +namespace Application.Ringtoets.Storage.Update +{ + /// + /// Extension methods for related to updating a . + /// + internal static class MicrostabilityFailureMechanismUpdateExtensions + { + /// + /// Updates a in the database based on the information of the + /// . + /// + /// The mechanism 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 MicrostabilityFailureMechanism mechanism, PersistenceRegistry registry, IRingtoetsEntities context) + { + if (context == null) + { + throw new ArgumentNullException("context"); + } + if (registry == null) + { + throw new ArgumentNullException("registry"); + } + + FailureMechanismEntity entity = mechanism.GetCorrespondingEntity( + context.FailureMechanismEntities, + o => o.FailureMechanismEntityId); + + entity.IsRelevant = Convert.ToByte(mechanism.IsRelevant); + + mechanism.UpdateFailureMechanismSections(registry, entity, context); + UpdateSectionResults(mechanism, registry, context); + + registry.Register(entity, mechanism); + } + + private static void UpdateSectionResults(MicrostabilityFailureMechanism mechanism, PersistenceRegistry registry, IRingtoetsEntities context) + { + foreach (var sectionResult in mechanism.SectionResults) + { + if (sectionResult.IsNew()) + { + registry.Get(sectionResult.Section).MicrostabilitySectionResultEntities.Add(sectionResult.Create(registry)); + } + else + { + sectionResult.Update(registry, context); + } + } + } + } +} \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/PipingStructureFailureMechanismSectionResultUpdateExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/PipingStructureFailureMechanismSectionResultUpdateExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/PipingStructureFailureMechanismSectionResultUpdateExtensions.cs (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -0,0 +1,72 @@ +// 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.Integration.Data.StandAlone.SectionResults; + +namespace Application.Ringtoets.Storage.Update +{ + /// + /// Extension methods for related to updating a + /// . + /// + internal static class PipingStructureFailureMechanismSectionResultUpdateExtensions + { + /// + /// Updates a in the database based on the information of the + /// . + /// + /// The result 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 PipingStructureFailureMechanismSectionResult result, PersistenceRegistry registry, IRingtoetsEntities context) + { + if (context == null) + { + throw new ArgumentNullException("context"); + } + if (registry == null) + { + throw new ArgumentNullException("registry"); + } + + PipingStructureSectionResultEntity entity = result.GetCorrespondingEntity( + context.PipingStructureSectionResultEntities, + s => s.PipingStructureSectionResultEntityId); + + entity.LayerOne = Convert.ToByte(result.AssessmentLayerOne); + entity.LayerTwoA = Convert.ToByte(result.AssessmentLayerTwoA); + entity.LayerThree = Convert.ToDecimal(result.AssessmentLayerThree); + + registry.Register(entity, result); + } + } +} \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/PipingStructureFailureMechanismUpdateExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/PipingStructureFailureMechanismUpdateExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/PipingStructureFailureMechanismUpdateExtensions.cs (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -0,0 +1,87 @@ +// 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.Integration.Data.StandAlone; + +namespace Application.Ringtoets.Storage.Update +{ + /// + /// Extension methods for related to updating a . + /// + internal static class PipingStructureFailureMechanismUpdateExtensions + { + /// + /// Updates a in the database based on the information of the + /// . + /// + /// The mechanism 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 PipingStructureFailureMechanism mechanism, PersistenceRegistry registry, IRingtoetsEntities context) + { + if (context == null) + { + throw new ArgumentNullException("context"); + } + if (registry == null) + { + throw new ArgumentNullException("registry"); + } + + FailureMechanismEntity entity = mechanism.GetCorrespondingEntity( + context.FailureMechanismEntities, + o => o.FailureMechanismEntityId); + + entity.IsRelevant = Convert.ToByte(mechanism.IsRelevant); + + mechanism.UpdateFailureMechanismSections(registry, entity, context); + UpdateSectionResults(mechanism, registry, context); + + registry.Register(entity, mechanism); + } + + private static void UpdateSectionResults(PipingStructureFailureMechanism mechanism, PersistenceRegistry registry, IRingtoetsEntities context) + { + foreach (var sectionResult in mechanism.SectionResults) + { + if (sectionResult.IsNew()) + { + registry.Get(sectionResult.Section).PipingStructureSectionResultEntities.Add(sectionResult.Create(registry)); + } + else + { + sectionResult.Update(registry, context); + } + } + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj =================================================================== diff -u -r4a12b47ea94488f0716d7c61c6cefba235d7db48 -r0e4717786f2f1a865e48da9fde2089a789bfe02c --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 4a12b47ea94488f0716d7c61c6cefba235d7db48) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -84,6 +84,14 @@ + + + + + + + + @@ -127,6 +135,10 @@ + + + + @@ -166,6 +178,14 @@ + + + + + + + + Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/GrassCoverSlipOffInwardsFailureMechanismCreateExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/GrassCoverSlipOffInwardsFailureMechanismCreateExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/GrassCoverSlipOffInwardsFailureMechanismCreateExtensionsTest.cs (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -0,0 +1,100 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Linq; +using Application.Ringtoets.Storage.Create; +using Application.Ringtoets.Storage.DbContext; +using Application.Ringtoets.Storage.TestUtil; +using NUnit.Framework; +using Ringtoets.Integration.Data.StandAlone; + +namespace Application.Ringtoets.Storage.Test.Create +{ + [TestFixture] + public class GrassCoverSlipOffInwardsFailureMechanismCreateExtensionsTest + { + [Test] + public void Create_WithoutPersistenceRegistry_ThrowsArgumentNullException() + { + // Setup + var failureMechanism = new GrassCoverSlipOffInwardsFailureMechanism(); + + // Call + TestDelegate test = () => failureMechanism.Create(null); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("registry", paramName); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void Create_WithCollectorAndPropertiesSet_ReturnsFailureMechanismEntityWithPropertiesSet(bool isRelevant) + { + // Setup + var failureMechanism = new GrassCoverSlipOffInwardsFailureMechanism + { + IsRelevant = isRelevant, + Comments = "Some text" + }; + var registry = new PersistenceRegistry(); + + // Call + var entity = failureMechanism.Create(registry); + + // Assert + Assert.IsNotNull(entity); + Assert.AreEqual((short)FailureMechanismType.GrassRevetmentSlidingInwards, entity.FailureMechanismType); + Assert.AreEqual(Convert.ToByte(isRelevant), entity.IsRelevant); + Assert.AreEqual(failureMechanism.Comments, entity.Comments); + } + + [Test] + public void Create_WithoutSections_EmptyFailureMechanismSectionEntities() + { + // Setup + var failureMechanism = new GrassCoverSlipOffInwardsFailureMechanism(); + + // Call + var entity = failureMechanism.Create(new PersistenceRegistry()); + + // Assert + Assert.IsEmpty(entity.FailureMechanismSectionEntities); + } + + [Test] + public void Create_WithSections_FailureMechanismSectionEntitiesCreated() + { + // Setup + var failureMechanism = new GrassCoverSlipOffInwardsFailureMechanism(); + failureMechanism.AddSection(new TestFailureMechanismSection()); + + // Call + var entity = failureMechanism.Create(new PersistenceRegistry()); + + // Assert + Assert.AreEqual(1, entity.FailureMechanismSectionEntities.Count); + Assert.AreEqual(1, entity.FailureMechanismSectionEntities.SelectMany(fms => fms.GrassCoverSlipOffInwardsSectionResultEntities).Count()); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/GrassCoverSlipOffInwardsFailureMechanismSectionResultCreateExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/GrassCoverSlipOffInwardsFailureMechanismSectionResultCreateExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/GrassCoverSlipOffInwardsFailureMechanismSectionResultCreateExtensionsTest.cs (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -0,0 +1,84 @@ +// 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.TestUtil; +using Core.Common.Base.Data; +using NUnit.Framework; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Application.Ringtoets.Storage.Test.Create +{ + [TestFixture] + public class GrassCoverSlipOffInwardsFailureMechanismSectionResultCreateExtensionsTest + { + [Test] + public void Create_WithoutPersistenceRegistry_ThrowsArgumentNullException() + { + // Setup + var sectionResult = new GrassCoverSlipOffInwardsFailureMechanismSectionResult(new TestFailureMechanismSection()); + + // Call + TestDelegate test = () => sectionResult.Create(null); + + // Assert + Assert.Throws(test); + } + + [Test] + public void Create_WithDifferentResults_ReturnsEntityWithExpectedResults( + [Values(true, false)] bool assessmentLayerOneResult, + [Values(AssessmentLayerTwoAResult.NotCalculated, AssessmentLayerTwoAResult.Failed)] AssessmentLayerTwoAResult assessmentLayerTwoAResult, + [Values(3.2, 4.5)] double assessmentLayerThreeResult + ) + { + // Setup + var sectionResult = new GrassCoverSlipOffInwardsFailureMechanismSectionResult(new TestFailureMechanismSection()); + sectionResult.AssessmentLayerOne = assessmentLayerOneResult; + sectionResult.AssessmentLayerTwoA = (AssessmentLayerTwoAResult) assessmentLayerTwoAResult; + sectionResult.AssessmentLayerThree = (RoundedDouble) assessmentLayerThreeResult; + + // Call + var result = sectionResult.Create(new PersistenceRegistry()); + + // Assert + Assert.AreEqual(Convert.ToByte(assessmentLayerOneResult), result.LayerOne); + Assert.AreEqual(Convert.ToDecimal(assessmentLayerTwoAResult), result.LayerTwoA); + Assert.AreEqual(Convert.ToDecimal(assessmentLayerThreeResult), result.LayerThree); + } + + [Test] + public void Create_WithNaNLevel3Result_ReturnsEntityWithExpectedResults() + { + // Setup + var sectionResult = new GrassCoverSlipOffInwardsFailureMechanismSectionResult(new TestFailureMechanismSection()); + sectionResult.AssessmentLayerThree = (RoundedDouble) double.NaN; + + // Call + var result = sectionResult.Create(new PersistenceRegistry()); + + // Assert + Assert.IsNull(result.LayerThree); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/GrassCoverSlipOffOutwardsFailureMechanismCreateExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/GrassCoverSlipOffOutwardsFailureMechanismCreateExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/GrassCoverSlipOffOutwardsFailureMechanismCreateExtensionsTest.cs (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -0,0 +1,100 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Linq; +using Application.Ringtoets.Storage.Create; +using Application.Ringtoets.Storage.DbContext; +using Application.Ringtoets.Storage.TestUtil; +using NUnit.Framework; +using Ringtoets.Integration.Data.StandAlone; + +namespace Application.Ringtoets.Storage.Test.Create +{ + [TestFixture] + public class GrassCoverSlipOffOutwardsFailureMechanismCreateExtensionsTest + { + [Test] + public void Create_WithoutPersistenceRegistry_ThrowsArgumentNullException() + { + // Setup + var failureMechanism = new GrassCoverSlipOffOutwardsFailureMechanism(); + + // Call + TestDelegate test = () => failureMechanism.Create(null); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("registry", paramName); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void Create_WithCollectorAndPropertiesSet_ReturnsFailureMechanismEntityWithPropertiesSet(bool isRelevant) + { + // Setup + var failureMechanism = new GrassCoverSlipOffOutwardsFailureMechanism + { + IsRelevant = isRelevant, + Comments = "Some text" + }; + var registry = new PersistenceRegistry(); + + // Call + var entity = failureMechanism.Create(registry); + + // Assert + Assert.IsNotNull(entity); + Assert.AreEqual((short)FailureMechanismType.GrassRevetmentSlidingOutwards, entity.FailureMechanismType); + Assert.AreEqual(Convert.ToByte(isRelevant), entity.IsRelevant); + Assert.AreEqual(failureMechanism.Comments, entity.Comments); + } + + [Test] + public void Create_WithoutSections_EmptyFailureMechanismSectionEntities() + { + // Setup + var failureMechanism = new GrassCoverSlipOffOutwardsFailureMechanism(); + + // Call + var entity = failureMechanism.Create(new PersistenceRegistry()); + + // Assert + Assert.IsEmpty(entity.FailureMechanismSectionEntities); + } + + [Test] + public void Create_WithSections_FailureMechanismSectionEntitiesCreated() + { + // Setup + var failureMechanism = new GrassCoverSlipOffOutwardsFailureMechanism(); + failureMechanism.AddSection(new TestFailureMechanismSection()); + + // Call + var entity = failureMechanism.Create(new PersistenceRegistry()); + + // Assert + Assert.AreEqual(1, entity.FailureMechanismSectionEntities.Count); + Assert.AreEqual(1, entity.FailureMechanismSectionEntities.SelectMany(fms => fms.GrassCoverSlipOffOutwardsSectionResultEntities).Count()); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/GrassCoverSlipOffOutwardsFailureMechanismSectionResultCreateExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/GrassCoverSlipOffOutwardsFailureMechanismSectionResultCreateExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/GrassCoverSlipOffOutwardsFailureMechanismSectionResultCreateExtensionsTest.cs (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -0,0 +1,84 @@ +// 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.TestUtil; +using Core.Common.Base.Data; +using NUnit.Framework; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Application.Ringtoets.Storage.Test.Create +{ + [TestFixture] + public class GrassCoverSlipOffOutwardsFailureMechanismSectionResultCreateExtensionsTest + { + [Test] + public void Create_WithoutPersistenceRegistry_ThrowsArgumentNullException() + { + // Setup + var sectionResult = new GrassCoverSlipOffOutwardsFailureMechanismSectionResult(new TestFailureMechanismSection()); + + // Call + TestDelegate test = () => sectionResult.Create(null); + + // Assert + Assert.Throws(test); + } + + [Test] + public void Create_WithDifferentResults_ReturnsEntityWithExpectedResults( + [Values(true, false)] bool assessmentLayerOneResult, + [Values(AssessmentLayerTwoAResult.NotCalculated, AssessmentLayerTwoAResult.Failed)] AssessmentLayerTwoAResult assessmentLayerTwoAResult, + [Values(3.2, 4.5)] double assessmentLayerThreeResult + ) + { + // Setup + var sectionResult = new GrassCoverSlipOffOutwardsFailureMechanismSectionResult(new TestFailureMechanismSection()); + sectionResult.AssessmentLayerOne = assessmentLayerOneResult; + sectionResult.AssessmentLayerTwoA = (AssessmentLayerTwoAResult) assessmentLayerTwoAResult; + sectionResult.AssessmentLayerThree = (RoundedDouble) assessmentLayerThreeResult; + + // Call + var result = sectionResult.Create(new PersistenceRegistry()); + + // Assert + Assert.AreEqual(Convert.ToByte(assessmentLayerOneResult), result.LayerOne); + Assert.AreEqual(Convert.ToDecimal(assessmentLayerTwoAResult), result.LayerTwoA); + Assert.AreEqual(Convert.ToDecimal(assessmentLayerThreeResult), result.LayerThree); + } + + [Test] + public void Create_WithNaNLevel3Result_ReturnsEntityWithExpectedResults() + { + // Setup + var sectionResult = new GrassCoverSlipOffOutwardsFailureMechanismSectionResult(new TestFailureMechanismSection()); + sectionResult.AssessmentLayerThree = (RoundedDouble) double.NaN; + + // Call + var result = sectionResult.Create(new PersistenceRegistry()); + + // Assert + Assert.IsNull(result.LayerThree); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/MicrostabilityFailureMechanismCreateExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/MicrostabilityFailureMechanismCreateExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/MicrostabilityFailureMechanismCreateExtensionsTest.cs (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -0,0 +1,100 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Linq; +using Application.Ringtoets.Storage.Create; +using Application.Ringtoets.Storage.DbContext; +using Application.Ringtoets.Storage.TestUtil; +using NUnit.Framework; +using Ringtoets.Integration.Data.StandAlone; + +namespace Application.Ringtoets.Storage.Test.Create +{ + [TestFixture] + public class MicrostabilityFailureMechanismCreateExtensionsTest + { + [Test] + public void Create_WithoutPersistenceRegistry_ThrowsArgumentNullException() + { + // Setup + var failureMechanism = new MicrostabilityFailureMechanism(); + + // Call + TestDelegate test = () => failureMechanism.Create(null); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("registry", paramName); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void Create_WithCollectorAndPropertiesSet_ReturnsFailureMechanismEntityWithPropertiesSet(bool isRelevant) + { + // Setup + var failureMechanism = new MicrostabilityFailureMechanism + { + IsRelevant = isRelevant, + Comments = "Some text" + }; + var registry = new PersistenceRegistry(); + + // Call + var entity = failureMechanism.Create(registry); + + // Assert + Assert.IsNotNull(entity); + Assert.AreEqual((short)FailureMechanismType.Microstability, entity.FailureMechanismType); + Assert.AreEqual(Convert.ToByte(isRelevant), entity.IsRelevant); + Assert.AreEqual(failureMechanism.Comments, entity.Comments); + } + + [Test] + public void Create_WithoutSections_EmptyFailureMechanismSectionEntities() + { + // Setup + var failureMechanism = new MicrostabilityFailureMechanism(); + + // Call + var entity = failureMechanism.Create(new PersistenceRegistry()); + + // Assert + Assert.IsEmpty(entity.FailureMechanismSectionEntities); + } + + [Test] + public void Create_WithSections_FailureMechanismSectionEntitiesCreated() + { + // Setup + var failureMechanism = new MicrostabilityFailureMechanism(); + failureMechanism.AddSection(new TestFailureMechanismSection()); + + // Call + var entity = failureMechanism.Create(new PersistenceRegistry()); + + // Assert + Assert.AreEqual(1, entity.FailureMechanismSectionEntities.Count); + Assert.AreEqual(1, entity.FailureMechanismSectionEntities.SelectMany(fms => fms.MicrostabilitySectionResultEntities).Count()); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/MicrostabilityFailureMechanismSectionResultCreateExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/MicrostabilityFailureMechanismSectionResultCreateExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/MicrostabilityFailureMechanismSectionResultCreateExtensionsTest.cs (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -0,0 +1,84 @@ +// 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.TestUtil; +using Core.Common.Base.Data; +using NUnit.Framework; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Application.Ringtoets.Storage.Test.Create +{ + [TestFixture] + public class MicrostabilityFailureMechanismSectionResultCreateExtensionsTest + { + [Test] + public void Create_WithoutPersistenceRegistry_ThrowsArgumentNullException() + { + // Setup + var sectionResult = new MicrostabilityFailureMechanismSectionResult(new TestFailureMechanismSection()); + + // Call + TestDelegate test = () => sectionResult.Create(null); + + // Assert + Assert.Throws(test); + } + + [Test] + public void Create_WithDifferentResults_ReturnsEntityWithExpectedResults( + [Values(true, false)] bool assessmentLayerOneResult, + [Values(AssessmentLayerTwoAResult.NotCalculated, AssessmentLayerTwoAResult.Failed)] AssessmentLayerTwoAResult assessmentLayerTwoAResult, + [Values(3.2, 4.5)] double assessmentLayerThreeResult + ) + { + // Setup + var sectionResult = new MicrostabilityFailureMechanismSectionResult(new TestFailureMechanismSection()); + sectionResult.AssessmentLayerOne = assessmentLayerOneResult; + sectionResult.AssessmentLayerTwoA = (AssessmentLayerTwoAResult) assessmentLayerTwoAResult; + sectionResult.AssessmentLayerThree = (RoundedDouble) assessmentLayerThreeResult; + + // Call + var result = sectionResult.Create(new PersistenceRegistry()); + + // Assert + Assert.AreEqual(Convert.ToByte(assessmentLayerOneResult), result.LayerOne); + Assert.AreEqual(Convert.ToDecimal(assessmentLayerTwoAResult), result.LayerTwoA); + Assert.AreEqual(Convert.ToDecimal(assessmentLayerThreeResult), result.LayerThree); + } + + [Test] + public void Create_WithNaNLevel3Result_ReturnsEntityWithExpectedResults() + { + // Setup + var sectionResult = new MicrostabilityFailureMechanismSectionResult(new TestFailureMechanismSection()); + sectionResult.AssessmentLayerThree = (RoundedDouble) double.NaN; + + // Call + var result = sectionResult.Create(new PersistenceRegistry()); + + // Assert + Assert.IsNull(result.LayerThree); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PersistenceRegistryTest.cs =================================================================== diff -u -rb4816e19c7167c26fad825b88dd72b59dcedc13a -r0e4717786f2f1a865e48da9fde2089a789bfe02c --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PersistenceRegistryTest.cs (.../PersistenceRegistryTest.cs) (revision b4816e19c7167c26fad825b88dd72b59dcedc13a) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PersistenceRegistryTest.cs (.../PersistenceRegistryTest.cs) (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -1158,6 +1158,146 @@ } [Test] + public void Register_WithNullGrassCoverErosionOutwardsFailureMechanismSectionResult_ThrowsArgumentNullException() + { + // Setup + var registry = new PersistenceRegistry(); + + // Call + TestDelegate test = () => registry.Register(new GrassCoverErosionOutwardsSectionResultEntity(), null); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("model", paramName); + } + + [Test] + public void Register_WithNullGrassCoverErosionOutwardsSectionResultEntity_ThrowsArgumentNullException() + { + // Setup + var registry = new PersistenceRegistry(); + + // Call + TestDelegate test = () => registry.Register(null, new GrassCoverErosionOutwardsFailureMechanismSectionResult(new TestFailureMechanismSection())); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("entity", paramName); + } + + [Test] + public void Register_WithNullGrassCoverSlipOffInwardsFailureMechanismSectionResult_ThrowsArgumentNullException() + { + // Setup + var registry = new PersistenceRegistry(); + + // Call + TestDelegate test = () => registry.Register(new GrassCoverSlipOffInwardsSectionResultEntity(), null); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("model", paramName); + } + + [Test] + public void Register_WithNullGrassCoverSlipOffInwardsSectionResultEntity_ThrowsArgumentNullException() + { + // Setup + var registry = new PersistenceRegistry(); + + // Call + TestDelegate test = () => registry.Register(null, new GrassCoverSlipOffInwardsFailureMechanismSectionResult(new TestFailureMechanismSection())); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("entity", paramName); + } + + [Test] + public void Register_WithNullGrassCoverSlipOffOutwardsFailureMechanismSectionResult_ThrowsArgumentNullException() + { + // Setup + var registry = new PersistenceRegistry(); + + // Call + TestDelegate test = () => registry.Register(new GrassCoverSlipOffOutwardsSectionResultEntity(), null); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("model", paramName); + } + + [Test] + public void Register_WithNullGrassCoverSlipOffOutwardsSectionResultEntity_ThrowsArgumentNullException() + { + // Setup + var registry = new PersistenceRegistry(); + + // Call + TestDelegate test = () => registry.Register(null, new GrassCoverSlipOffOutwardsFailureMechanismSectionResult(new TestFailureMechanismSection())); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("entity", paramName); + } + + [Test] + public void Register_WithNullMicrostabilityFailureMechanismSectionResult_ThrowsArgumentNullException() + { + // Setup + var registry = new PersistenceRegistry(); + + // Call + TestDelegate test = () => registry.Register(new MicrostabilitySectionResultEntity(), null); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("model", paramName); + } + + [Test] + public void Register_WithNullMicrostabilitySectionResultEntity_ThrowsArgumentNullException() + { + // Setup + var registry = new PersistenceRegistry(); + + // Call + TestDelegate test = () => registry.Register(null, new MicrostabilityFailureMechanismSectionResult(new TestFailureMechanismSection())); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("entity", paramName); + } + + [Test] + public void Register_WithNullPipingStructureFailureMechanismSectionResult_ThrowsArgumentNullException() + { + // Setup + var registry = new PersistenceRegistry(); + + // Call + TestDelegate test = () => registry.Register(new PipingStructureSectionResultEntity(), null); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("model", paramName); + } + + [Test] + public void Register_WithNullPipingStructureSectionResultEntity_ThrowsArgumentNullException() + { + // Setup + var registry = new PersistenceRegistry(); + + // Call + TestDelegate test = () => registry.Register(null, new PipingStructureFailureMechanismSectionResult(new TestFailureMechanismSection())); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("entity", paramName); + } + + [Test] public void Register_WithNullHydraulicLocationEntity_ThrowsArgumentNullException() { // Setup @@ -1815,6 +1955,111 @@ } [Test] + public void TransferIds_WithGrassCoverErosionOutwardsSectionResultEntityAddedWithGrassCoverErosionOutwardsFailureMechanismSectionResult_EqualGrassCoverErosionOutwardsSectionEntityIdAndGrassCoverErosionOutwardsFailureMechanismSectionResultStorageId() + { + // Setup + var registry = new PersistenceRegistry(); + + long storageId = new Random(21).Next(1,4000); + var entity = new GrassCoverErosionOutwardsSectionResultEntity + { + GrassCoverErosionOutwardsSectionResultEntityId = storageId + }; + var model = new GrassCoverErosionOutwardsFailureMechanismSectionResult(new TestFailureMechanismSection()); + registry.Register(entity, model); + + // Call + registry.TransferIds(); + + // Assert + Assert.AreEqual(storageId, model.StorageId); + } + + [Test] + public void TransferIds_WithGrassCoverSlipOffInwardsSectionResultEntityAddedWithGrassCoverSlipOffInwardsFailureMechanismSectionResult_EqualGrassCoverSlipOffInwardsSectionEntityIdAndGrassCoverSlipOffInwardsFailureMechanismSectionResultStorageId() + { + // Setup + var registry = new PersistenceRegistry(); + + long storageId = new Random(21).Next(1,4000); + var entity = new GrassCoverSlipOffInwardsSectionResultEntity + { + GrassCoverSlipOffInwardsSectionResultEntityId = storageId + }; + var model = new GrassCoverSlipOffInwardsFailureMechanismSectionResult(new TestFailureMechanismSection()); + registry.Register(entity, model); + + // Call + registry.TransferIds(); + + // Assert + Assert.AreEqual(storageId, model.StorageId); + } + + [Test] + public void TransferIds_WithGrassCoverSlipOffOutwardsSectionResultEntityAddedWithGrassCoverSlipOffOutwardsFailureMechanismSectionResult_EqualGrassCoverSlipOffOutwardsSectionEntityIdAndGrassCoverSlipOffOutwardsFailureMechanismSectionResultStorageId() + { + // Setup + var registry = new PersistenceRegistry(); + + long storageId = new Random(21).Next(1,4000); + var entity = new GrassCoverSlipOffOutwardsSectionResultEntity + { + GrassCoverSlipOffOutwardsSectionResultEntityId = storageId + }; + var model = new GrassCoverSlipOffOutwardsFailureMechanismSectionResult(new TestFailureMechanismSection()); + registry.Register(entity, model); + + // Call + registry.TransferIds(); + + // Assert + Assert.AreEqual(storageId, model.StorageId); + } + + [Test] + public void TransferIds_WithMicrostabilitySectionResultEntityAddedWithMicrostabilityFailureMechanismSectionResult_EqualMicrostabilitySectionEntityIdAndMicrostabilityFailureMechanismSectionResultStorageId() + { + // Setup + var registry = new PersistenceRegistry(); + + long storageId = new Random(21).Next(1,4000); + var entity = new MicrostabilitySectionResultEntity + { + MicrostabilitySectionResultEntityId = storageId + }; + var model = new MicrostabilityFailureMechanismSectionResult(new TestFailureMechanismSection()); + registry.Register(entity, model); + + // Call + registry.TransferIds(); + + // Assert + Assert.AreEqual(storageId, model.StorageId); + } + + [Test] + public void TransferIds_WithPipingStructureSectionResultEntityAddedWithPipingStructureFailureMechanismSectionResult_EqualPipingStructureSectionEntityIdAndPipingStructureFailureMechanismSectionResultStorageId() + { + // Setup + var registry = new PersistenceRegistry(); + + long storageId = new Random(21).Next(1,4000); + var entity = new PipingStructureSectionResultEntity + { + PipingStructureSectionResultEntityId = storageId + }; + var model = new PipingStructureFailureMechanismSectionResult(new TestFailureMechanismSection()); + registry.Register(entity, model); + + // Call + registry.TransferIds(); + + // Assert + Assert.AreEqual(storageId, model.StorageId); + } + + [Test] public void TransferIds_WithHydraulicLocationEntityAdded_EqualHydraulicLocationEntityIdAndHydraulicBoundaryLocationStorageId() { // Setup @@ -2564,6 +2809,186 @@ } [Test] + public void RemoveUntouched_GrassCoverErosionOutwardsSectionResultEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() + { + // Setup + var mocks = new MockRepository(); + IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); + mocks.ReplayAll(); + + var orphanedEntity = new GrassCoverErosionOutwardsSectionResultEntity + { + GrassCoverErosionOutwardsSectionResultEntityId = 1 + }; + var persistentEntity = new GrassCoverErosionOutwardsSectionResultEntity + { + GrassCoverErosionOutwardsSectionResultEntityId = 2 + }; + dbContext.GrassCoverErosionOutwardsSectionResultEntities.Add(orphanedEntity); + dbContext.GrassCoverErosionOutwardsSectionResultEntities.Add(persistentEntity); + + var section = new GrassCoverErosionOutwardsFailureMechanismSectionResult(new TestFailureMechanismSection()) + { + StorageId = persistentEntity.GrassCoverErosionOutwardsSectionResultEntityId + }; + + var registry = new PersistenceRegistry(); + registry.Register(persistentEntity, section); + + // Call + registry.RemoveUntouched(dbContext); + + // Assert + Assert.AreEqual(1, dbContext.GrassCoverErosionOutwardsSectionResultEntities.Count()); + CollectionAssert.Contains(dbContext.GrassCoverErosionOutwardsSectionResultEntities, persistentEntity); + mocks.VerifyAll(); + } + + [Test] + public void RemoveUntouched_GrassCoverSlipOffInwardsSectionResultEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() + { + // Setup + var mocks = new MockRepository(); + IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); + mocks.ReplayAll(); + + var orphanedEntity = new GrassCoverSlipOffInwardsSectionResultEntity + { + GrassCoverSlipOffInwardsSectionResultEntityId = 1 + }; + var persistentEntity = new GrassCoverSlipOffInwardsSectionResultEntity + { + GrassCoverSlipOffInwardsSectionResultEntityId = 2 + }; + dbContext.GrassCoverSlipOffInwardsSectionResultEntities.Add(orphanedEntity); + dbContext.GrassCoverSlipOffInwardsSectionResultEntities.Add(persistentEntity); + + var section = new GrassCoverSlipOffInwardsFailureMechanismSectionResult(new TestFailureMechanismSection()) + { + StorageId = persistentEntity.GrassCoverSlipOffInwardsSectionResultEntityId + }; + + var registry = new PersistenceRegistry(); + registry.Register(persistentEntity, section); + + // Call + registry.RemoveUntouched(dbContext); + + // Assert + Assert.AreEqual(1, dbContext.GrassCoverSlipOffInwardsSectionResultEntities.Count()); + CollectionAssert.Contains(dbContext.GrassCoverSlipOffInwardsSectionResultEntities, persistentEntity); + mocks.VerifyAll(); + } + + [Test] + public void RemoveUntouched_GrassCoverSlipOffOutwardsSectionResultEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() + { + // Setup + var mocks = new MockRepository(); + IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); + mocks.ReplayAll(); + + var orphanedEntity = new GrassCoverSlipOffOutwardsSectionResultEntity + { + GrassCoverSlipOffOutwardsSectionResultEntityId = 1 + }; + var persistentEntity = new GrassCoverSlipOffOutwardsSectionResultEntity + { + GrassCoverSlipOffOutwardsSectionResultEntityId = 2 + }; + dbContext.GrassCoverSlipOffOutwardsSectionResultEntities.Add(orphanedEntity); + dbContext.GrassCoverSlipOffOutwardsSectionResultEntities.Add(persistentEntity); + + var section = new GrassCoverSlipOffOutwardsFailureMechanismSectionResult(new TestFailureMechanismSection()) + { + StorageId = persistentEntity.GrassCoverSlipOffOutwardsSectionResultEntityId + }; + + var registry = new PersistenceRegistry(); + registry.Register(persistentEntity, section); + + // Call + registry.RemoveUntouched(dbContext); + + // Assert + Assert.AreEqual(1, dbContext.GrassCoverSlipOffOutwardsSectionResultEntities.Count()); + CollectionAssert.Contains(dbContext.GrassCoverSlipOffOutwardsSectionResultEntities, persistentEntity); + mocks.VerifyAll(); + } + + [Test] + public void RemoveUntouched_MicrostabilitySectionResultEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() + { + // Setup + var mocks = new MockRepository(); + IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); + mocks.ReplayAll(); + + var orphanedEntity = new MicrostabilitySectionResultEntity + { + MicrostabilitySectionResultEntityId = 1 + }; + var persistentEntity = new MicrostabilitySectionResultEntity + { + MicrostabilitySectionResultEntityId = 2 + }; + dbContext.MicrostabilitySectionResultEntities.Add(orphanedEntity); + dbContext.MicrostabilitySectionResultEntities.Add(persistentEntity); + + var section = new MicrostabilityFailureMechanismSectionResult(new TestFailureMechanismSection()) + { + StorageId = persistentEntity.MicrostabilitySectionResultEntityId + }; + + var registry = new PersistenceRegistry(); + registry.Register(persistentEntity, section); + + // Call + registry.RemoveUntouched(dbContext); + + // Assert + Assert.AreEqual(1, dbContext.MicrostabilitySectionResultEntities.Count()); + CollectionAssert.Contains(dbContext.MicrostabilitySectionResultEntities, persistentEntity); + mocks.VerifyAll(); + } + + [Test] + public void RemoveUntouched_PipingStructureSectionResultEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() + { + // Setup + var mocks = new MockRepository(); + IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); + mocks.ReplayAll(); + + var orphanedEntity = new PipingStructureSectionResultEntity + { + PipingStructureSectionResultEntityId = 1 + }; + var persistentEntity = new PipingStructureSectionResultEntity + { + PipingStructureSectionResultEntityId = 2 + }; + dbContext.PipingStructureSectionResultEntities.Add(orphanedEntity); + dbContext.PipingStructureSectionResultEntities.Add(persistentEntity); + + var section = new PipingStructureFailureMechanismSectionResult(new TestFailureMechanismSection()) + { + StorageId = persistentEntity.PipingStructureSectionResultEntityId + }; + + var registry = new PersistenceRegistry(); + registry.Register(persistentEntity, section); + + // Call + registry.RemoveUntouched(dbContext); + + // Assert + Assert.AreEqual(1, dbContext.PipingStructureSectionResultEntities.Count()); + CollectionAssert.Contains(dbContext.PipingStructureSectionResultEntities, persistentEntity); + mocks.VerifyAll(); + } + + [Test] public void RemoveUntouched_HydraulicLocationEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() { // Setup Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PipingStructureFailureMechanismCreateExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PipingStructureFailureMechanismCreateExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PipingStructureFailureMechanismCreateExtensionsTest.cs (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -0,0 +1,100 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Linq; +using Application.Ringtoets.Storage.Create; +using Application.Ringtoets.Storage.DbContext; +using Application.Ringtoets.Storage.TestUtil; +using NUnit.Framework; +using Ringtoets.Integration.Data.StandAlone; + +namespace Application.Ringtoets.Storage.Test.Create +{ + [TestFixture] + public class PipingStructureFailureMechanismCreateExtensionsTest + { + [Test] + public void Create_WithoutPersistenceRegistry_ThrowsArgumentNullException() + { + // Setup + var failureMechanism = new PipingStructureFailureMechanism(); + + // Call + TestDelegate test = () => failureMechanism.Create(null); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("registry", paramName); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void Create_WithCollectorAndPropertiesSet_ReturnsFailureMechanismEntityWithPropertiesSet(bool isRelevant) + { + // Setup + var failureMechanism = new PipingStructureFailureMechanism + { + IsRelevant = isRelevant, + Comments = "Some text" + }; + var registry = new PersistenceRegistry(); + + // Call + var entity = failureMechanism.Create(registry); + + // Assert + Assert.IsNotNull(entity); + Assert.AreEqual((short)FailureMechanismType.PipingAtStructure, entity.FailureMechanismType); + Assert.AreEqual(Convert.ToByte(isRelevant), entity.IsRelevant); + Assert.AreEqual(failureMechanism.Comments, entity.Comments); + } + + [Test] + public void Create_WithoutSections_EmptyFailureMechanismSectionEntities() + { + // Setup + var failureMechanism = new PipingStructureFailureMechanism(); + + // Call + var entity = failureMechanism.Create(new PersistenceRegistry()); + + // Assert + Assert.IsEmpty(entity.FailureMechanismSectionEntities); + } + + [Test] + public void Create_WithSections_FailureMechanismSectionEntitiesCreated() + { + // Setup + var failureMechanism = new PipingStructureFailureMechanism(); + failureMechanism.AddSection(new TestFailureMechanismSection()); + + // Call + var entity = failureMechanism.Create(new PersistenceRegistry()); + + // Assert + Assert.AreEqual(1, entity.FailureMechanismSectionEntities.Count); + Assert.AreEqual(1, entity.FailureMechanismSectionEntities.SelectMany(fms => fms.PipingStructureSectionResultEntities).Count()); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PipingStructureFailureMechanismSectionResultCreateExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PipingStructureFailureMechanismSectionResultCreateExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PipingStructureFailureMechanismSectionResultCreateExtensionsTest.cs (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -0,0 +1,84 @@ +// 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.TestUtil; +using Core.Common.Base.Data; +using NUnit.Framework; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Application.Ringtoets.Storage.Test.Create +{ + [TestFixture] + public class PipingStructureFailureMechanismSectionResultCreateExtensionsTest + { + [Test] + public void Create_WithoutPersistenceRegistry_ThrowsArgumentNullException() + { + // Setup + var sectionResult = new PipingStructureFailureMechanismSectionResult(new TestFailureMechanismSection()); + + // Call + TestDelegate test = () => sectionResult.Create(null); + + // Assert + Assert.Throws(test); + } + + [Test] + public void Create_WithDifferentResults_ReturnsEntityWithExpectedResults( + [Values(true, false)] bool assessmentLayerOneResult, + [Values(AssessmentLayerTwoAResult.NotCalculated, AssessmentLayerTwoAResult.Failed)] AssessmentLayerTwoAResult assessmentLayerTwoAResult, + [Values(3.2, 4.5)] double assessmentLayerThreeResult + ) + { + // Setup + var sectionResult = new PipingStructureFailureMechanismSectionResult(new TestFailureMechanismSection()); + sectionResult.AssessmentLayerOne = assessmentLayerOneResult; + sectionResult.AssessmentLayerTwoA = (AssessmentLayerTwoAResult) assessmentLayerTwoAResult; + sectionResult.AssessmentLayerThree = (RoundedDouble) assessmentLayerThreeResult; + + // Call + var result = sectionResult.Create(new PersistenceRegistry()); + + // Assert + Assert.AreEqual(Convert.ToByte(assessmentLayerOneResult), result.LayerOne); + Assert.AreEqual(Convert.ToDecimal(assessmentLayerTwoAResult), result.LayerTwoA); + Assert.AreEqual(Convert.ToDecimal(assessmentLayerThreeResult), result.LayerThree); + } + + [Test] + public void Create_WithNaNLevel3Result_ReturnsEntityWithExpectedResults() + { + // Setup + var sectionResult = new PipingStructureFailureMechanismSectionResult(new TestFailureMechanismSection()); + sectionResult.AssessmentLayerThree = (RoundedDouble) double.NaN; + + // Call + var result = sectionResult.Create(new PersistenceRegistry()); + + // Assert + Assert.IsNull(result.LayerThree); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/StorageSqLiteIntegrationTest.cs =================================================================== diff -u -r4a12b47ea94488f0716d7c61c6cefba235d7db48 -r0e4717786f2f1a865e48da9fde2089a789bfe02c --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/StorageSqLiteIntegrationTest.cs (.../StorageSqLiteIntegrationTest.cs) (revision 4a12b47ea94488f0716d7c61c6cefba235d7db48) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/StorageSqLiteIntegrationTest.cs (.../StorageSqLiteIntegrationTest.cs) (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -287,6 +287,18 @@ AssertFailureMechanismSectionResults( expectedAssessmentSection.GrassCoverErosionOutwards.SectionResults, actualAssessmentSection.GrassCoverErosionOutwards.SectionResults); + AssertFailureMechanismSectionResults( + expectedAssessmentSection.GrassCoverSlipOffInwards.SectionResults, + actualAssessmentSection.GrassCoverSlipOffInwards.SectionResults); + AssertFailureMechanismSectionResults( + expectedAssessmentSection.GrassCoverSlipOffOutwards.SectionResults, + actualAssessmentSection.GrassCoverSlipOffOutwards.SectionResults); + AssertFailureMechanismSectionResults( + expectedAssessmentSection.Microstability.SectionResults, + actualAssessmentSection.Microstability.SectionResults); + AssertFailureMechanismSectionResults( + expectedAssessmentSection.PipingStructure.SectionResults, + actualAssessmentSection.PipingStructure.SectionResults); } } @@ -484,6 +496,78 @@ } } + private void AssertFailureMechanismSectionResults(IEnumerable expectedSectionResults, IEnumerable actualSectionResults) + { + var expectedSectionResultsArray = expectedSectionResults.ToArray(); + var actualSectionResultsArray = actualSectionResults.ToArray(); + + Assert.AreEqual(expectedSectionResultsArray.Length, actualSectionResultsArray.Length); + + for (var i = 0; i < expectedSectionResultsArray.Length; i++) + { + GrassCoverSlipOffInwardsFailureMechanismSectionResult expectedSection = expectedSectionResultsArray[i]; + GrassCoverSlipOffInwardsFailureMechanismSectionResult actualSection = actualSectionResultsArray[i]; + + Assert.AreEqual(expectedSection.AssessmentLayerOne, actualSection.AssessmentLayerOne); + Assert.AreEqual(expectedSection.AssessmentLayerTwoA, actualSection.AssessmentLayerTwoA); + Assert.AreEqual(expectedSection.AssessmentLayerThree, actualSection.AssessmentLayerThree); + } + } + + private void AssertFailureMechanismSectionResults(IEnumerable expectedSectionResults, IEnumerable actualSectionResults) + { + var expectedSectionResultsArray = expectedSectionResults.ToArray(); + var actualSectionResultsArray = actualSectionResults.ToArray(); + + Assert.AreEqual(expectedSectionResultsArray.Length, actualSectionResultsArray.Length); + + for (var i = 0; i < expectedSectionResultsArray.Length; i++) + { + GrassCoverSlipOffOutwardsFailureMechanismSectionResult expectedSection = expectedSectionResultsArray[i]; + GrassCoverSlipOffOutwardsFailureMechanismSectionResult actualSection = actualSectionResultsArray[i]; + + Assert.AreEqual(expectedSection.AssessmentLayerOne, actualSection.AssessmentLayerOne); + Assert.AreEqual(expectedSection.AssessmentLayerTwoA, actualSection.AssessmentLayerTwoA); + Assert.AreEqual(expectedSection.AssessmentLayerThree, actualSection.AssessmentLayerThree); + } + } + + private void AssertFailureMechanismSectionResults(IEnumerable expectedSectionResults, IEnumerable actualSectionResults) + { + var expectedSectionResultsArray = expectedSectionResults.ToArray(); + var actualSectionResultsArray = actualSectionResults.ToArray(); + + Assert.AreEqual(expectedSectionResultsArray.Length, actualSectionResultsArray.Length); + + for (var i = 0; i < expectedSectionResultsArray.Length; i++) + { + MicrostabilityFailureMechanismSectionResult expectedSection = expectedSectionResultsArray[i]; + MicrostabilityFailureMechanismSectionResult actualSection = actualSectionResultsArray[i]; + + Assert.AreEqual(expectedSection.AssessmentLayerOne, actualSection.AssessmentLayerOne); + Assert.AreEqual(expectedSection.AssessmentLayerTwoA, actualSection.AssessmentLayerTwoA); + Assert.AreEqual(expectedSection.AssessmentLayerThree, actualSection.AssessmentLayerThree); + } + } + + private void AssertFailureMechanismSectionResults(IEnumerable expectedSectionResults, IEnumerable actualSectionResults) + { + var expectedSectionResultsArray = expectedSectionResults.ToArray(); + var actualSectionResultsArray = actualSectionResults.ToArray(); + + Assert.AreEqual(expectedSectionResultsArray.Length, actualSectionResultsArray.Length); + + for (var i = 0; i < expectedSectionResultsArray.Length; i++) + { + PipingStructureFailureMechanismSectionResult expectedSection = expectedSectionResultsArray[i]; + PipingStructureFailureMechanismSectionResult actualSection = actualSectionResultsArray[i]; + + Assert.AreEqual(expectedSection.AssessmentLayerOne, actualSection.AssessmentLayerOne); + Assert.AreEqual(expectedSection.AssessmentLayerTwoA, actualSection.AssessmentLayerTwoA); + Assert.AreEqual(expectedSection.AssessmentLayerThree, actualSection.AssessmentLayerThree); + } + } + private void AssertFailureMechanism(IFailureMechanism expectedFailureMechanism, IFailureMechanism actualFailureMechanism) { Assert.AreEqual(expectedFailureMechanism.Name, actualFailureMechanism.Name); Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/GrassCoverSlipOffInwardsSectionResultEntityReadExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/GrassCoverSlipOffInwardsSectionResultEntityReadExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/GrassCoverSlipOffInwardsSectionResultEntityReadExtensionsTest.cs (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -0,0 +1,124 @@ +// 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; +using Application.Ringtoets.Storage.TestUtil; +using NUnit.Framework; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Application.Ringtoets.Storage.Test.Read +{ + [TestFixture] + public class GrassCoverSlipOffInwardsSectionResultEntityReadExtensionsTest + { + [Test] + public void Read_CollectorIsNull_ThrowArgumentNullException() + { + // Setup + var entity = new GrassCoverSlipOffInwardsSectionResultEntity(); + + // Call + TestDelegate call = () => entity.Read(new GrassCoverSlipOffInwardsFailureMechanismSectionResult(new TestFailureMechanismSection()), null); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("collector", paramName); + } + + [Test] + public void Read_SectionResultIsNull_ThrowArgumentNullException() + { + // Setup + var entity = new GrassCoverSlipOffInwardsSectionResultEntity(); + + // Call + TestDelegate call = () => entity.Read(null, new ReadConversionCollector()); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("sectionResult", paramName); + } + + [Test] + [TestCase(true, AssessmentLayerTwoAResult.Failed)] + [TestCase(false, AssessmentLayerTwoAResult.Successful)] + [TestCase(false, AssessmentLayerTwoAResult.Failed)] + public void Read_WithDecimalParameterValues_ReturnGrassCoverSlipOffInwardsSoilLayerWithDoubleParameterValues(bool layerOne, AssessmentLayerTwoAResult layerTwoA) + { + // Setup + var random = new Random(21); + var entityId = random.Next(1, 502); + double layerThree = random.NextDouble(); + var collector = new ReadConversionCollector(); + + var failureMechanismSectionEntity = new FailureMechanismSectionEntity(); + collector.Read(failureMechanismSectionEntity, new TestFailureMechanismSection()); + var entity = new GrassCoverSlipOffInwardsSectionResultEntity + { + GrassCoverSlipOffInwardsSectionResultEntityId = entityId, + LayerThree = Convert.ToDecimal(layerThree), + LayerTwoA = Convert.ToByte(layerTwoA), + LayerOne = Convert.ToByte(layerOne), + FailureMechanismSectionEntity = failureMechanismSectionEntity + }; + var sectionResult = new GrassCoverSlipOffInwardsFailureMechanismSectionResult(new TestFailureMechanismSection()); + + // Call + entity.Read(sectionResult, collector); + + // Assert + Assert.IsNotNull(sectionResult); + Assert.AreEqual(entityId, sectionResult.StorageId); + Assert.AreEqual(layerOne, sectionResult.AssessmentLayerOne); + Assert.AreEqual((AssessmentLayerTwoAResult)layerTwoA, sectionResult.AssessmentLayerTwoA); + Assert.AreEqual(layerThree, sectionResult.AssessmentLayerThree, 1e-6); + } + + [Test] + [TestCase(true, AssessmentLayerTwoAResult.Failed)] + [TestCase(false, AssessmentLayerTwoAResult.Successful)] + [TestCase(false, AssessmentLayerTwoAResult.Failed)] + public void Read_WithNullLayerThree_ReturnGrassCoverSlipOffInwardsSoilLayerWithNullParameters(bool layerOne, AssessmentLayerTwoAResult layerTwoA) + { + // Setup + var collector = new ReadConversionCollector(); + var failureMechanismSectionEntity = new FailureMechanismSectionEntity(); + collector.Read(failureMechanismSectionEntity, new TestFailureMechanismSection()); + var entity = new GrassCoverSlipOffInwardsSectionResultEntity + { + LayerOne = Convert.ToByte(layerOne), + LayerTwoA = Convert.ToByte(layerTwoA), + LayerThree = null, + FailureMechanismSectionEntity = failureMechanismSectionEntity + }; + var sectionResult = new GrassCoverSlipOffInwardsFailureMechanismSectionResult(new TestFailureMechanismSection()); + + // Call + entity.Read(sectionResult, collector); + + // Assert + Assert.IsNaN(sectionResult.AssessmentLayerThree); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/GrassCoverSlipOffOutwardsSectionResultEntityReadExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/GrassCoverSlipOffOutwardsSectionResultEntityReadExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/GrassCoverSlipOffOutwardsSectionResultEntityReadExtensionsTest.cs (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -0,0 +1,124 @@ +// 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; +using Application.Ringtoets.Storage.TestUtil; +using NUnit.Framework; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Application.Ringtoets.Storage.Test.Read +{ + [TestFixture] + public class GrassCoverSlipOffOutwardsSectionResultEntityReadExtensionsTest + { + [Test] + public void Read_CollectorIsNull_ThrowArgumentNullException() + { + // Setup + var entity = new GrassCoverSlipOffOutwardsSectionResultEntity(); + + // Call + TestDelegate call = () => entity.Read(new GrassCoverSlipOffOutwardsFailureMechanismSectionResult(new TestFailureMechanismSection()), null); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("collector", paramName); + } + + [Test] + public void Read_SectionResultIsNull_ThrowArgumentNullException() + { + // Setup + var entity = new GrassCoverSlipOffOutwardsSectionResultEntity(); + + // Call + TestDelegate call = () => entity.Read(null, new ReadConversionCollector()); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("sectionResult", paramName); + } + + [Test] + [TestCase(true, AssessmentLayerTwoAResult.Failed)] + [TestCase(false, AssessmentLayerTwoAResult.Successful)] + [TestCase(false, AssessmentLayerTwoAResult.Failed)] + public void Read_WithDecimalParameterValues_ReturnGrassCoverSlipOffOutwardsSoilLayerWithDoubleParameterValues(bool layerOne, AssessmentLayerTwoAResult layerTwoA) + { + // Setup + var random = new Random(21); + var entityId = random.Next(1, 502); + double layerThree = random.NextDouble(); + var collector = new ReadConversionCollector(); + + var failureMechanismSectionEntity = new FailureMechanismSectionEntity(); + collector.Read(failureMechanismSectionEntity, new TestFailureMechanismSection()); + var entity = new GrassCoverSlipOffOutwardsSectionResultEntity + { + GrassCoverSlipOffOutwardsSectionResultEntityId = entityId, + LayerThree = Convert.ToDecimal(layerThree), + LayerTwoA = Convert.ToByte(layerTwoA), + LayerOne = Convert.ToByte(layerOne), + FailureMechanismSectionEntity = failureMechanismSectionEntity + }; + var sectionResult = new GrassCoverSlipOffOutwardsFailureMechanismSectionResult(new TestFailureMechanismSection()); + + // Call + entity.Read(sectionResult, collector); + + // Assert + Assert.IsNotNull(sectionResult); + Assert.AreEqual(entityId, sectionResult.StorageId); + Assert.AreEqual(layerOne, sectionResult.AssessmentLayerOne); + Assert.AreEqual((AssessmentLayerTwoAResult)layerTwoA, sectionResult.AssessmentLayerTwoA); + Assert.AreEqual(layerThree, sectionResult.AssessmentLayerThree, 1e-6); + } + + [Test] + [TestCase(true, AssessmentLayerTwoAResult.Failed)] + [TestCase(false, AssessmentLayerTwoAResult.Successful)] + [TestCase(false, AssessmentLayerTwoAResult.Failed)] + public void Read_WithNullLayerThree_ReturnGrassCoverSlipOffOutwardsSoilLayerWithNullParameters(bool layerOne, AssessmentLayerTwoAResult layerTwoA) + { + // Setup + var collector = new ReadConversionCollector(); + var failureMechanismSectionEntity = new FailureMechanismSectionEntity(); + collector.Read(failureMechanismSectionEntity, new TestFailureMechanismSection()); + var entity = new GrassCoverSlipOffOutwardsSectionResultEntity + { + LayerOne = Convert.ToByte(layerOne), + LayerTwoA = Convert.ToByte(layerTwoA), + LayerThree = null, + FailureMechanismSectionEntity = failureMechanismSectionEntity + }; + var sectionResult = new GrassCoverSlipOffOutwardsFailureMechanismSectionResult(new TestFailureMechanismSection()); + + // Call + entity.Read(sectionResult, collector); + + // Assert + Assert.IsNaN(sectionResult.AssessmentLayerThree); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/MicrostabilitySectionResultEntityReadExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/MicrostabilitySectionResultEntityReadExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/MicrostabilitySectionResultEntityReadExtensionsTest.cs (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -0,0 +1,124 @@ +// 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; +using Application.Ringtoets.Storage.TestUtil; +using NUnit.Framework; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Application.Ringtoets.Storage.Test.Read +{ + [TestFixture] + public class MicrostabilitySectionResultEntityReadExtensionsTest + { + [Test] + public void Read_CollectorIsNull_ThrowArgumentNullException() + { + // Setup + var entity = new MicrostabilitySectionResultEntity(); + + // Call + TestDelegate call = () => entity.Read(new MicrostabilityFailureMechanismSectionResult(new TestFailureMechanismSection()), null); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("collector", paramName); + } + + [Test] + public void Read_SectionResultIsNull_ThrowArgumentNullException() + { + // Setup + var entity = new MicrostabilitySectionResultEntity(); + + // Call + TestDelegate call = () => entity.Read(null, new ReadConversionCollector()); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("sectionResult", paramName); + } + + [Test] + [TestCase(true, AssessmentLayerTwoAResult.Failed)] + [TestCase(false, AssessmentLayerTwoAResult.Successful)] + [TestCase(false, AssessmentLayerTwoAResult.Failed)] + public void Read_WithDecimalParameterValues_ReturnMicrostabilitySoilLayerWithDoubleParameterValues(bool layerOne, AssessmentLayerTwoAResult layerTwoA) + { + // Setup + var random = new Random(21); + var entityId = random.Next(1, 502); + double layerThree = random.NextDouble(); + var collector = new ReadConversionCollector(); + + var failureMechanismSectionEntity = new FailureMechanismSectionEntity(); + collector.Read(failureMechanismSectionEntity, new TestFailureMechanismSection()); + var entity = new MicrostabilitySectionResultEntity + { + MicrostabilitySectionResultEntityId = entityId, + LayerThree = Convert.ToDecimal(layerThree), + LayerTwoA = Convert.ToByte(layerTwoA), + LayerOne = Convert.ToByte(layerOne), + FailureMechanismSectionEntity = failureMechanismSectionEntity + }; + var sectionResult = new MicrostabilityFailureMechanismSectionResult(new TestFailureMechanismSection()); + + // Call + entity.Read(sectionResult, collector); + + // Assert + Assert.IsNotNull(sectionResult); + Assert.AreEqual(entityId, sectionResult.StorageId); + Assert.AreEqual(layerOne, sectionResult.AssessmentLayerOne); + Assert.AreEqual((AssessmentLayerTwoAResult)layerTwoA, sectionResult.AssessmentLayerTwoA); + Assert.AreEqual(layerThree, sectionResult.AssessmentLayerThree, 1e-6); + } + + [Test] + [TestCase(true, AssessmentLayerTwoAResult.Failed)] + [TestCase(false, AssessmentLayerTwoAResult.Successful)] + [TestCase(false, AssessmentLayerTwoAResult.Failed)] + public void Read_WithNullLayerThree_ReturnMicrostabilitySoilLayerWithNullParameters(bool layerOne, AssessmentLayerTwoAResult layerTwoA) + { + // Setup + var collector = new ReadConversionCollector(); + var failureMechanismSectionEntity = new FailureMechanismSectionEntity(); + collector.Read(failureMechanismSectionEntity, new TestFailureMechanismSection()); + var entity = new MicrostabilitySectionResultEntity + { + LayerOne = Convert.ToByte(layerOne), + LayerTwoA = Convert.ToByte(layerTwoA), + LayerThree = null, + FailureMechanismSectionEntity = failureMechanismSectionEntity + }; + var sectionResult = new MicrostabilityFailureMechanismSectionResult(new TestFailureMechanismSection()); + + // Call + entity.Read(sectionResult, collector); + + // Assert + Assert.IsNaN(sectionResult.AssessmentLayerThree); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/PipingStructureSectionResultEntityReadExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/PipingStructureSectionResultEntityReadExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/PipingStructureSectionResultEntityReadExtensionsTest.cs (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -0,0 +1,124 @@ +// 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; +using Application.Ringtoets.Storage.TestUtil; +using NUnit.Framework; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Application.Ringtoets.Storage.Test.Read +{ + [TestFixture] + public class PipingStructureSectionResultEntityReadExtensionsTest + { + [Test] + public void Read_CollectorIsNull_ThrowArgumentNullException() + { + // Setup + var entity = new PipingStructureSectionResultEntity(); + + // Call + TestDelegate call = () => entity.Read(new PipingStructureFailureMechanismSectionResult(new TestFailureMechanismSection()), null); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("collector", paramName); + } + + [Test] + public void Read_SectionResultIsNull_ThrowArgumentNullException() + { + // Setup + var entity = new PipingStructureSectionResultEntity(); + + // Call + TestDelegate call = () => entity.Read(null, new ReadConversionCollector()); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("sectionResult", paramName); + } + + [Test] + [TestCase(true, AssessmentLayerTwoAResult.Failed)] + [TestCase(false, AssessmentLayerTwoAResult.Successful)] + [TestCase(false, AssessmentLayerTwoAResult.Failed)] + public void Read_WithDecimalParameterValues_ReturnPipingStructureSoilLayerWithDoubleParameterValues(bool layerOne, AssessmentLayerTwoAResult layerTwoA) + { + // Setup + var random = new Random(21); + var entityId = random.Next(1, 502); + double layerThree = random.NextDouble(); + var collector = new ReadConversionCollector(); + + var failureMechanismSectionEntity = new FailureMechanismSectionEntity(); + collector.Read(failureMechanismSectionEntity, new TestFailureMechanismSection()); + var entity = new PipingStructureSectionResultEntity + { + PipingStructureSectionResultEntityId = entityId, + LayerThree = Convert.ToDecimal(layerThree), + LayerTwoA = Convert.ToByte(layerTwoA), + LayerOne = Convert.ToByte(layerOne), + FailureMechanismSectionEntity = failureMechanismSectionEntity + }; + var sectionResult = new PipingStructureFailureMechanismSectionResult(new TestFailureMechanismSection()); + + // Call + entity.Read(sectionResult, collector); + + // Assert + Assert.IsNotNull(sectionResult); + Assert.AreEqual(entityId, sectionResult.StorageId); + Assert.AreEqual(layerOne, sectionResult.AssessmentLayerOne); + Assert.AreEqual((AssessmentLayerTwoAResult)layerTwoA, sectionResult.AssessmentLayerTwoA); + Assert.AreEqual(layerThree, sectionResult.AssessmentLayerThree, 1e-6); + } + + [Test] + [TestCase(true, AssessmentLayerTwoAResult.Failed)] + [TestCase(false, AssessmentLayerTwoAResult.Successful)] + [TestCase(false, AssessmentLayerTwoAResult.Failed)] + public void Read_WithNullLayerThree_ReturnPipingStructureSoilLayerWithNullParameters(bool layerOne, AssessmentLayerTwoAResult layerTwoA) + { + // Setup + var collector = new ReadConversionCollector(); + var failureMechanismSectionEntity = new FailureMechanismSectionEntity(); + collector.Read(failureMechanismSectionEntity, new TestFailureMechanismSection()); + var entity = new PipingStructureSectionResultEntity + { + LayerOne = Convert.ToByte(layerOne), + LayerTwoA = Convert.ToByte(layerTwoA), + LayerThree = null, + FailureMechanismSectionEntity = failureMechanismSectionEntity + }; + var sectionResult = new PipingStructureFailureMechanismSectionResult(new TestFailureMechanismSection()); + + // Call + entity.Read(sectionResult, collector); + + // Assert + Assert.IsNaN(sectionResult.AssessmentLayerThree); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/GrassCoverSlipOffInwardsFailureMechanismSectionResultUpdateExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/GrassCoverSlipOffInwardsFailureMechanismSectionResultUpdateExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/GrassCoverSlipOffInwardsFailureMechanismSectionResultUpdateExtensionsTest.cs (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -0,0 +1,163 @@ +// 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 Core.Common.Base.Data; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Application.Ringtoets.Storage.Test.Update +{ + [TestFixture] + public class GrassCoverSlipOffInwardsFailureMechanismSectionResultUpdateExtensionsTest + { + [Test] + public void Update_WithoutContext_ArgumentNullException() + { + // Setup + var sectionResult = new GrassCoverSlipOffInwardsFailureMechanismSectionResult(new TestFailureMechanismSection()); + + // Call + TestDelegate test = () => sectionResult.Update(new PersistenceRegistry(), null); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("context", paramName); + } + + [Test] + public void Update_WithoutPersistenceRegistry_ArgumentNullException() + { + // Setup + var sectionResult = new GrassCoverSlipOffInwardsFailureMechanismSectionResult(new TestFailureMechanismSection()); + + // Call + TestDelegate test = () => + { + using (var ringtoetsEntities = new RingtoetsEntities()) + { + sectionResult.Update(null, ringtoetsEntities); + } + }; + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("registry", paramName); + } + + [Test] + public void Update_ContextWithNoGrassCoverSlipOffInwardsSectionResult_EntityNotFoundException() + { + // Setup + var sectionResult = new GrassCoverSlipOffInwardsFailureMechanismSectionResult(new TestFailureMechanismSection()); + + // Call + TestDelegate test = () => + { + using (var ringtoetsEntities = new RingtoetsEntities()) + { + sectionResult.Update(new PersistenceRegistry(), ringtoetsEntities); + } + }; + + // Assert + var expectedMessage = String.Format("Het object 'GrassCoverSlipOffInwardsSectionResultEntity' met id '{0}' is niet gevonden.", 0); + EntityNotFoundException exception = Assert.Throws(test); + Assert.AreEqual(expectedMessage, exception.Message); + } + + [Test] + public void Update_ContextWithNoGrassCoverSlipOffInwardsSectionResultWithId_EntityNotFoundException() + { + // Setup + MockRepository mocks = new MockRepository(); + var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks); + + mocks.ReplayAll(); + + var storageId = 1; + var sectionResult = new GrassCoverSlipOffInwardsFailureMechanismSectionResult(new TestFailureMechanismSection()) + { + StorageId = storageId + }; + + ringtoetsEntities.GrassCoverSlipOffInwardsSectionResultEntities.Add(new GrassCoverSlipOffInwardsSectionResultEntity + { + GrassCoverSlipOffInwardsSectionResultEntityId = 2 + }); + + // Call + TestDelegate test = () => sectionResult.Update(new PersistenceRegistry(), ringtoetsEntities); + + // Assert + var expectedMessage = String.Format("Het object 'GrassCoverSlipOffInwardsSectionResultEntity' met id '{0}' is niet gevonden.", storageId); + EntityNotFoundException exception = Assert.Throws(test); + Assert.AreEqual(expectedMessage, exception.Message); + + mocks.VerifyAll(); + } + + [Test] + public void Update_WithGrassCoverSlipOffInwardsSectionResult_PropertiesUpdated() + { + // Setup + MockRepository mocks = new MockRepository(); + var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks); + + mocks.ReplayAll(); + + var sectionResult = new GrassCoverSlipOffInwardsFailureMechanismSectionResult(new TestFailureMechanismSection()) + { + StorageId = 1, + AssessmentLayerOne = true, + AssessmentLayerTwoA = AssessmentLayerTwoAResult.Failed, + AssessmentLayerThree = (RoundedDouble) 4.4 + }; + + var sectionResultEntity = new GrassCoverSlipOffInwardsSectionResultEntity + { + GrassCoverSlipOffInwardsSectionResultEntityId = sectionResult.StorageId, + LayerOne = Convert.ToByte(false), + LayerTwoA = Convert.ToByte(AssessmentLayerTwoAResult.Successful), + LayerThree = 1.1m, + }; + + ringtoetsEntities.GrassCoverSlipOffInwardsSectionResultEntities.Add(sectionResultEntity); + + // Call + sectionResult.Update(new PersistenceRegistry(), ringtoetsEntities); + + // Assert + Assert.AreEqual(Convert.ToByte(true), sectionResultEntity.LayerOne); + Assert.AreEqual(Convert.ToByte(sectionResult.AssessmentLayerTwoA), sectionResultEntity.LayerTwoA); + Assert.AreEqual(sectionResult.AssessmentLayerThree.Value.ToNullableDecimal(), sectionResultEntity.LayerThree); + + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/GrassCoverSlipOffInwardsFailureMechanismUpdateExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/GrassCoverSlipOffInwardsFailureMechanismUpdateExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/GrassCoverSlipOffInwardsFailureMechanismUpdateExtensionsTest.cs (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -0,0 +1,243 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Linq; + +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 Core.Common.Base.Geometry; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Integration.Data.StandAlone; + +namespace Application.Ringtoets.Storage.Test.Update +{ + [TestFixture] + public class GrassCoverSlipOffInwardsFailureMechanismUpdateExtensionsTest + { + [Test] + public void Update_WithoutContext_ThrowsArgumentNullException() + { + // Setup + var failureMechanism = new GrassCoverSlipOffInwardsFailureMechanism(); + + // Call + TestDelegate test = () => failureMechanism.Update(new PersistenceRegistry(), null); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("context", paramName); + } + + [Test] + public void Update_WithoutPersistenceRegistry_ThrowsArgumentNullException() + { + // Setup + var failureMechanism = new GrassCoverSlipOffInwardsFailureMechanism(); + + // Call + TestDelegate test = () => + { + using (var ringtoetsEntities = new RingtoetsEntities()) + { + failureMechanism.Update(null, ringtoetsEntities); + } + }; + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("registry", paramName); + } + + [Test] + public void Update_ContextWithNoGrassCoverSlipOffInwardsFailureMechanism_ThrowsEntityNotFoundException() + { + // Setup + var failureMechanism = new GrassCoverSlipOffInwardsFailureMechanism(); + + // Call + TestDelegate test = () => + { + using (var ringtoetsEntities = new RingtoetsEntities()) + { + failureMechanism.Update(new PersistenceRegistry(), ringtoetsEntities); + } + }; + + // Assert + var expectedMessage = String.Format("Het object 'FailureMechanismEntity' met id '{0}' is niet gevonden.", 0); + EntityNotFoundException exception = Assert.Throws(test); + Assert.AreEqual(expectedMessage, exception.Message); + } + + [Test] + public void Update_ContextWithNoGrassCoverSlipOffInwardsFailureMechanismWithId_ThrowsEntityNotFoundException() + { + // Setup + MockRepository mocks = new MockRepository(); + var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks); + + mocks.ReplayAll(); + + var storageId = 1; + var failureMechanism = new GrassCoverSlipOffInwardsFailureMechanism + { + StorageId = storageId + }; + + ringtoetsEntities.FailureMechanismEntities.Add(new FailureMechanismEntity + { + FailureMechanismEntityId = 2 + }); + + // Call + TestDelegate test = () => failureMechanism.Update(new PersistenceRegistry(), ringtoetsEntities); + + // Assert + var expectedMessage = String.Format("Het object 'FailureMechanismEntity' met id '{0}' is niet gevonden.", storageId); + EntityNotFoundException exception = Assert.Throws(test); + Assert.AreEqual(expectedMessage, exception.Message); + + mocks.VerifyAll(); + } + + [Test] + public void Update_ContextWithGrassCoverSlipOffInwardsFailureMechanism_PropertiesUpdated() + { + // Setup + MockRepository mocks = new MockRepository(); + var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks); + + mocks.ReplayAll(); + + var failureMechanism = new GrassCoverSlipOffInwardsFailureMechanism + { + StorageId = 1, + IsRelevant = true + }; + + var failureMechanismEntity = new FailureMechanismEntity + { + FailureMechanismEntityId = 1, + IsRelevant = Convert.ToByte(false) + }; + + ringtoetsEntities.FailureMechanismEntities.Add(failureMechanismEntity); + + // Call + failureMechanism.Update(new PersistenceRegistry(), ringtoetsEntities); + + // Assert + Assert.AreEqual(Convert.ToByte(true), failureMechanismEntity.IsRelevant); + + mocks.VerifyAll(); + } + + [Test] + public void Update_ContextWithNewFailureMechanismSections_FailureMechanismSectionsAdded() + { + // Setup + MockRepository mocks = new MockRepository(); + var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks); + + mocks.ReplayAll(); + + var failureMechanism = new GrassCoverSlipOffInwardsFailureMechanism + { + StorageId = 1 + }; + failureMechanism.AddSection(new FailureMechanismSection("", new[] + { + new Point2D(0, 0) + })); + + var failureMechanismEntity = new FailureMechanismEntity + { + FailureMechanismEntityId = 1, + }; + + ringtoetsEntities.FailureMechanismEntities.Add(failureMechanismEntity); + + // Call + failureMechanism.Update(new PersistenceRegistry(), ringtoetsEntities); + + // Assert + Assert.AreEqual(1, failureMechanismEntity.FailureMechanismSectionEntities.Count); + Assert.AreEqual(1, failureMechanismEntity.FailureMechanismSectionEntities.SelectMany(fms => fms.GrassCoverSlipOffInwardsSectionResultEntities).Count()); + + mocks.VerifyAll(); + } + + [Test] + public void Update_ContextWithUpdatedFailureMechanismSections_NoNewFailureMechanismSectionsAdded() + { + // Setup + MockRepository mocks = new MockRepository(); + var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks); + + mocks.ReplayAll(); + + var failureMechanism = new GrassCoverSlipOffInwardsFailureMechanism + { + StorageId = 1 + }; + var testName = "testName"; + failureMechanism.AddSection(new FailureMechanismSection(testName, new[] + { + new Point2D(0, 0) + }) + { + StorageId = 1 + }); + + var failureMechanismSectionEntity = new FailureMechanismSectionEntity + { + FailureMechanismSectionEntityId = 1, + }; + var failureMechanismEntity = new FailureMechanismEntity + { + FailureMechanismEntityId = 1, + FailureMechanismSectionEntities = + { + failureMechanismSectionEntity + } + }; + + ringtoetsEntities.FailureMechanismEntities.Add(failureMechanismEntity); + ringtoetsEntities.FailureMechanismSectionEntities.Add(failureMechanismSectionEntity); + + // Call + failureMechanism.Update(new PersistenceRegistry(), ringtoetsEntities); + + // Assert + Assert.AreEqual(1, failureMechanismEntity.FailureMechanismSectionEntities.Count); + Assert.AreEqual(1, failureMechanismEntity.FailureMechanismSectionEntities.SelectMany(fms => fms.GrassCoverSlipOffInwardsSectionResultEntities).Count()); + Assert.AreEqual(testName, failureMechanismEntity.FailureMechanismSectionEntities.ElementAt(0).Name); + + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/GrassCoverSlipOffOutwardsFailureMechanismSectionResultUpdateExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/GrassCoverSlipOffOutwardsFailureMechanismSectionResultUpdateExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/GrassCoverSlipOffOutwardsFailureMechanismSectionResultUpdateExtensionsTest.cs (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -0,0 +1,163 @@ +// 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 Core.Common.Base.Data; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Application.Ringtoets.Storage.Test.Update +{ + [TestFixture] + public class GrassCoverSlipOffOutwardsFailureMechanismSectionResultUpdateExtensionsTest + { + [Test] + public void Update_WithoutContext_ArgumentNullException() + { + // Setup + var sectionResult = new GrassCoverSlipOffOutwardsFailureMechanismSectionResult(new TestFailureMechanismSection()); + + // Call + TestDelegate test = () => sectionResult.Update(new PersistenceRegistry(), null); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("context", paramName); + } + + [Test] + public void Update_WithoutPersistenceRegistry_ArgumentNullException() + { + // Setup + var sectionResult = new GrassCoverSlipOffOutwardsFailureMechanismSectionResult(new TestFailureMechanismSection()); + + // Call + TestDelegate test = () => + { + using (var ringtoetsEntities = new RingtoetsEntities()) + { + sectionResult.Update(null, ringtoetsEntities); + } + }; + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("registry", paramName); + } + + [Test] + public void Update_ContextWithNoGrassCoverSlipOffOutwardsSectionResult_EntityNotFoundException() + { + // Setup + var sectionResult = new GrassCoverSlipOffOutwardsFailureMechanismSectionResult(new TestFailureMechanismSection()); + + // Call + TestDelegate test = () => + { + using (var ringtoetsEntities = new RingtoetsEntities()) + { + sectionResult.Update(new PersistenceRegistry(), ringtoetsEntities); + } + }; + + // Assert + var expectedMessage = String.Format("Het object 'GrassCoverSlipOffOutwardsSectionResultEntity' met id '{0}' is niet gevonden.", 0); + EntityNotFoundException exception = Assert.Throws(test); + Assert.AreEqual(expectedMessage, exception.Message); + } + + [Test] + public void Update_ContextWithNoGrassCoverSlipOffOutwardsSectionResultWithId_EntityNotFoundException() + { + // Setup + MockRepository mocks = new MockRepository(); + var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks); + + mocks.ReplayAll(); + + var storageId = 1; + var sectionResult = new GrassCoverSlipOffOutwardsFailureMechanismSectionResult(new TestFailureMechanismSection()) + { + StorageId = storageId + }; + + ringtoetsEntities.GrassCoverSlipOffOutwardsSectionResultEntities.Add(new GrassCoverSlipOffOutwardsSectionResultEntity + { + GrassCoverSlipOffOutwardsSectionResultEntityId = 2 + }); + + // Call + TestDelegate test = () => sectionResult.Update(new PersistenceRegistry(), ringtoetsEntities); + + // Assert + var expectedMessage = String.Format("Het object 'GrassCoverSlipOffOutwardsSectionResultEntity' met id '{0}' is niet gevonden.", storageId); + EntityNotFoundException exception = Assert.Throws(test); + Assert.AreEqual(expectedMessage, exception.Message); + + mocks.VerifyAll(); + } + + [Test] + public void Update_WithGrassCoverSlipOffOutwardsSectionResult_PropertiesUpdated() + { + // Setup + MockRepository mocks = new MockRepository(); + var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks); + + mocks.ReplayAll(); + + var sectionResult = new GrassCoverSlipOffOutwardsFailureMechanismSectionResult(new TestFailureMechanismSection()) + { + StorageId = 1, + AssessmentLayerOne = true, + AssessmentLayerTwoA = AssessmentLayerTwoAResult.Failed, + AssessmentLayerThree = (RoundedDouble) 4.4 + }; + + var sectionResultEntity = new GrassCoverSlipOffOutwardsSectionResultEntity + { + GrassCoverSlipOffOutwardsSectionResultEntityId = sectionResult.StorageId, + LayerOne = Convert.ToByte(false), + LayerTwoA = Convert.ToByte(AssessmentLayerTwoAResult.Successful), + LayerThree = 1.1m, + }; + + ringtoetsEntities.GrassCoverSlipOffOutwardsSectionResultEntities.Add(sectionResultEntity); + + // Call + sectionResult.Update(new PersistenceRegistry(), ringtoetsEntities); + + // Assert + Assert.AreEqual(Convert.ToByte(true), sectionResultEntity.LayerOne); + Assert.AreEqual(Convert.ToByte(sectionResult.AssessmentLayerTwoA), sectionResultEntity.LayerTwoA); + Assert.AreEqual(sectionResult.AssessmentLayerThree.Value.ToNullableDecimal(), sectionResultEntity.LayerThree); + + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/GrassCoverSlipOffOutwardsFailureMechanismUpdateExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/GrassCoverSlipOffOutwardsFailureMechanismUpdateExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/GrassCoverSlipOffOutwardsFailureMechanismUpdateExtensionsTest.cs (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -0,0 +1,243 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Linq; + +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 Core.Common.Base.Geometry; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Integration.Data.StandAlone; + +namespace Application.Ringtoets.Storage.Test.Update +{ + [TestFixture] + public class GrassCoverSlipOffOutwardsFailureMechanismUpdateExtensionsTest + { + [Test] + public void Update_WithoutContext_ThrowsArgumentNullException() + { + // Setup + var failureMechanism = new GrassCoverSlipOffOutwardsFailureMechanism(); + + // Call + TestDelegate test = () => failureMechanism.Update(new PersistenceRegistry(), null); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("context", paramName); + } + + [Test] + public void Update_WithoutPersistenceRegistry_ThrowsArgumentNullException() + { + // Setup + var failureMechanism = new GrassCoverSlipOffOutwardsFailureMechanism(); + + // Call + TestDelegate test = () => + { + using (var ringtoetsEntities = new RingtoetsEntities()) + { + failureMechanism.Update(null, ringtoetsEntities); + } + }; + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("registry", paramName); + } + + [Test] + public void Update_ContextWithNoGrassCoverSlipOffOutwardsFailureMechanism_ThrowsEntityNotFoundException() + { + // Setup + var failureMechanism = new GrassCoverSlipOffOutwardsFailureMechanism(); + + // Call + TestDelegate test = () => + { + using (var ringtoetsEntities = new RingtoetsEntities()) + { + failureMechanism.Update(new PersistenceRegistry(), ringtoetsEntities); + } + }; + + // Assert + var expectedMessage = String.Format("Het object 'FailureMechanismEntity' met id '{0}' is niet gevonden.", 0); + EntityNotFoundException exception = Assert.Throws(test); + Assert.AreEqual(expectedMessage, exception.Message); + } + + [Test] + public void Update_ContextWithNoGrassCoverSlipOffOutwardsFailureMechanismWithId_ThrowsEntityNotFoundException() + { + // Setup + MockRepository mocks = new MockRepository(); + var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks); + + mocks.ReplayAll(); + + var storageId = 1; + var failureMechanism = new GrassCoverSlipOffOutwardsFailureMechanism + { + StorageId = storageId + }; + + ringtoetsEntities.FailureMechanismEntities.Add(new FailureMechanismEntity + { + FailureMechanismEntityId = 2 + }); + + // Call + TestDelegate test = () => failureMechanism.Update(new PersistenceRegistry(), ringtoetsEntities); + + // Assert + var expectedMessage = String.Format("Het object 'FailureMechanismEntity' met id '{0}' is niet gevonden.", storageId); + EntityNotFoundException exception = Assert.Throws(test); + Assert.AreEqual(expectedMessage, exception.Message); + + mocks.VerifyAll(); + } + + [Test] + public void Update_ContextWithGrassCoverSlipOffOutwardsFailureMechanism_PropertiesUpdated() + { + // Setup + MockRepository mocks = new MockRepository(); + var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks); + + mocks.ReplayAll(); + + var failureMechanism = new GrassCoverSlipOffOutwardsFailureMechanism + { + StorageId = 1, + IsRelevant = true + }; + + var failureMechanismEntity = new FailureMechanismEntity + { + FailureMechanismEntityId = 1, + IsRelevant = Convert.ToByte(false) + }; + + ringtoetsEntities.FailureMechanismEntities.Add(failureMechanismEntity); + + // Call + failureMechanism.Update(new PersistenceRegistry(), ringtoetsEntities); + + // Assert + Assert.AreEqual(Convert.ToByte(true), failureMechanismEntity.IsRelevant); + + mocks.VerifyAll(); + } + + [Test] + public void Update_ContextWithNewFailureMechanismSections_FailureMechanismSectionsAdded() + { + // Setup + MockRepository mocks = new MockRepository(); + var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks); + + mocks.ReplayAll(); + + var failureMechanism = new GrassCoverSlipOffOutwardsFailureMechanism + { + StorageId = 1 + }; + failureMechanism.AddSection(new FailureMechanismSection("", new[] + { + new Point2D(0, 0) + })); + + var failureMechanismEntity = new FailureMechanismEntity + { + FailureMechanismEntityId = 1, + }; + + ringtoetsEntities.FailureMechanismEntities.Add(failureMechanismEntity); + + // Call + failureMechanism.Update(new PersistenceRegistry(), ringtoetsEntities); + + // Assert + Assert.AreEqual(1, failureMechanismEntity.FailureMechanismSectionEntities.Count); + Assert.AreEqual(1, failureMechanismEntity.FailureMechanismSectionEntities.SelectMany(fms => fms.GrassCoverSlipOffOutwardsSectionResultEntities).Count()); + + mocks.VerifyAll(); + } + + [Test] + public void Update_ContextWithUpdatedFailureMechanismSections_NoNewFailureMechanismSectionsAdded() + { + // Setup + MockRepository mocks = new MockRepository(); + var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks); + + mocks.ReplayAll(); + + var failureMechanism = new GrassCoverSlipOffOutwardsFailureMechanism + { + StorageId = 1 + }; + var testName = "testName"; + failureMechanism.AddSection(new FailureMechanismSection(testName, new[] + { + new Point2D(0, 0) + }) + { + StorageId = 1 + }); + + var failureMechanismSectionEntity = new FailureMechanismSectionEntity + { + FailureMechanismSectionEntityId = 1, + }; + var failureMechanismEntity = new FailureMechanismEntity + { + FailureMechanismEntityId = 1, + FailureMechanismSectionEntities = + { + failureMechanismSectionEntity + } + }; + + ringtoetsEntities.FailureMechanismEntities.Add(failureMechanismEntity); + ringtoetsEntities.FailureMechanismSectionEntities.Add(failureMechanismSectionEntity); + + // Call + failureMechanism.Update(new PersistenceRegistry(), ringtoetsEntities); + + // Assert + Assert.AreEqual(1, failureMechanismEntity.FailureMechanismSectionEntities.Count); + Assert.AreEqual(1, failureMechanismEntity.FailureMechanismSectionEntities.SelectMany(fms => fms.GrassCoverSlipOffOutwardsSectionResultEntities).Count()); + Assert.AreEqual(testName, failureMechanismEntity.FailureMechanismSectionEntities.ElementAt(0).Name); + + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/MicrostabilityFailureMechanismSectionResultUpdateExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/MicrostabilityFailureMechanismSectionResultUpdateExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/MicrostabilityFailureMechanismSectionResultUpdateExtensionsTest.cs (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -0,0 +1,163 @@ +// 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 Core.Common.Base.Data; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Application.Ringtoets.Storage.Test.Update +{ + [TestFixture] + public class MicrostabilityFailureMechanismSectionResultUpdateExtensionsTest + { + [Test] + public void Update_WithoutContext_ArgumentNullException() + { + // Setup + var sectionResult = new MicrostabilityFailureMechanismSectionResult(new TestFailureMechanismSection()); + + // Call + TestDelegate test = () => sectionResult.Update(new PersistenceRegistry(), null); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("context", paramName); + } + + [Test] + public void Update_WithoutPersistenceRegistry_ArgumentNullException() + { + // Setup + var sectionResult = new MicrostabilityFailureMechanismSectionResult(new TestFailureMechanismSection()); + + // Call + TestDelegate test = () => + { + using (var ringtoetsEntities = new RingtoetsEntities()) + { + sectionResult.Update(null, ringtoetsEntities); + } + }; + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("registry", paramName); + } + + [Test] + public void Update_ContextWithNoMicrostabilitySectionResult_EntityNotFoundException() + { + // Setup + var sectionResult = new MicrostabilityFailureMechanismSectionResult(new TestFailureMechanismSection()); + + // Call + TestDelegate test = () => + { + using (var ringtoetsEntities = new RingtoetsEntities()) + { + sectionResult.Update(new PersistenceRegistry(), ringtoetsEntities); + } + }; + + // Assert + var expectedMessage = String.Format("Het object 'MicrostabilitySectionResultEntity' met id '{0}' is niet gevonden.", 0); + EntityNotFoundException exception = Assert.Throws(test); + Assert.AreEqual(expectedMessage, exception.Message); + } + + [Test] + public void Update_ContextWithNoMicrostabilitySectionResultWithId_EntityNotFoundException() + { + // Setup + MockRepository mocks = new MockRepository(); + var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks); + + mocks.ReplayAll(); + + var storageId = 1; + var sectionResult = new MicrostabilityFailureMechanismSectionResult(new TestFailureMechanismSection()) + { + StorageId = storageId + }; + + ringtoetsEntities.MicrostabilitySectionResultEntities.Add(new MicrostabilitySectionResultEntity + { + MicrostabilitySectionResultEntityId = 2 + }); + + // Call + TestDelegate test = () => sectionResult.Update(new PersistenceRegistry(), ringtoetsEntities); + + // Assert + var expectedMessage = String.Format("Het object 'MicrostabilitySectionResultEntity' met id '{0}' is niet gevonden.", storageId); + EntityNotFoundException exception = Assert.Throws(test); + Assert.AreEqual(expectedMessage, exception.Message); + + mocks.VerifyAll(); + } + + [Test] + public void Update_WithMicrostabilitySectionResult_PropertiesUpdated() + { + // Setup + MockRepository mocks = new MockRepository(); + var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks); + + mocks.ReplayAll(); + + var sectionResult = new MicrostabilityFailureMechanismSectionResult(new TestFailureMechanismSection()) + { + StorageId = 1, + AssessmentLayerOne = true, + AssessmentLayerTwoA = AssessmentLayerTwoAResult.Failed, + AssessmentLayerThree = (RoundedDouble) 4.4 + }; + + var sectionResultEntity = new MicrostabilitySectionResultEntity + { + MicrostabilitySectionResultEntityId = sectionResult.StorageId, + LayerOne = Convert.ToByte(false), + LayerTwoA = Convert.ToByte(AssessmentLayerTwoAResult.Successful), + LayerThree = 1.1m, + }; + + ringtoetsEntities.MicrostabilitySectionResultEntities.Add(sectionResultEntity); + + // Call + sectionResult.Update(new PersistenceRegistry(), ringtoetsEntities); + + // Assert + Assert.AreEqual(Convert.ToByte(true), sectionResultEntity.LayerOne); + Assert.AreEqual(Convert.ToByte(sectionResult.AssessmentLayerTwoA), sectionResultEntity.LayerTwoA); + Assert.AreEqual(sectionResult.AssessmentLayerThree.Value.ToNullableDecimal(), sectionResultEntity.LayerThree); + + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/MicrostabilityFailureMechanismUpdateExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/MicrostabilityFailureMechanismUpdateExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/MicrostabilityFailureMechanismUpdateExtensionsTest.cs (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -0,0 +1,243 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Linq; + +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 Core.Common.Base.Geometry; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Integration.Data.StandAlone; + +namespace Application.Ringtoets.Storage.Test.Update +{ + [TestFixture] + public class MicrostabilityFailureMechanismUpdateExtensionsTest + { + [Test] + public void Update_WithoutContext_ThrowsArgumentNullException() + { + // Setup + var failureMechanism = new MicrostabilityFailureMechanism(); + + // Call + TestDelegate test = () => failureMechanism.Update(new PersistenceRegistry(), null); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("context", paramName); + } + + [Test] + public void Update_WithoutPersistenceRegistry_ThrowsArgumentNullException() + { + // Setup + var failureMechanism = new MicrostabilityFailureMechanism(); + + // Call + TestDelegate test = () => + { + using (var ringtoetsEntities = new RingtoetsEntities()) + { + failureMechanism.Update(null, ringtoetsEntities); + } + }; + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("registry", paramName); + } + + [Test] + public void Update_ContextWithNoMicrostabilityFailureMechanism_ThrowsEntityNotFoundException() + { + // Setup + var failureMechanism = new MicrostabilityFailureMechanism(); + + // Call + TestDelegate test = () => + { + using (var ringtoetsEntities = new RingtoetsEntities()) + { + failureMechanism.Update(new PersistenceRegistry(), ringtoetsEntities); + } + }; + + // Assert + var expectedMessage = String.Format("Het object 'FailureMechanismEntity' met id '{0}' is niet gevonden.", 0); + EntityNotFoundException exception = Assert.Throws(test); + Assert.AreEqual(expectedMessage, exception.Message); + } + + [Test] + public void Update_ContextWithNoMicrostabilityFailureMechanismWithId_ThrowsEntityNotFoundException() + { + // Setup + MockRepository mocks = new MockRepository(); + var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks); + + mocks.ReplayAll(); + + var storageId = 1; + var failureMechanism = new MicrostabilityFailureMechanism + { + StorageId = storageId + }; + + ringtoetsEntities.FailureMechanismEntities.Add(new FailureMechanismEntity + { + FailureMechanismEntityId = 2 + }); + + // Call + TestDelegate test = () => failureMechanism.Update(new PersistenceRegistry(), ringtoetsEntities); + + // Assert + var expectedMessage = String.Format("Het object 'FailureMechanismEntity' met id '{0}' is niet gevonden.", storageId); + EntityNotFoundException exception = Assert.Throws(test); + Assert.AreEqual(expectedMessage, exception.Message); + + mocks.VerifyAll(); + } + + [Test] + public void Update_ContextWithMicrostabilityFailureMechanism_PropertiesUpdated() + { + // Setup + MockRepository mocks = new MockRepository(); + var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks); + + mocks.ReplayAll(); + + var failureMechanism = new MicrostabilityFailureMechanism + { + StorageId = 1, + IsRelevant = true + }; + + var failureMechanismEntity = new FailureMechanismEntity + { + FailureMechanismEntityId = 1, + IsRelevant = Convert.ToByte(false) + }; + + ringtoetsEntities.FailureMechanismEntities.Add(failureMechanismEntity); + + // Call + failureMechanism.Update(new PersistenceRegistry(), ringtoetsEntities); + + // Assert + Assert.AreEqual(Convert.ToByte(true), failureMechanismEntity.IsRelevant); + + mocks.VerifyAll(); + } + + [Test] + public void Update_ContextWithNewFailureMechanismSections_FailureMechanismSectionsAdded() + { + // Setup + MockRepository mocks = new MockRepository(); + var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks); + + mocks.ReplayAll(); + + var failureMechanism = new MicrostabilityFailureMechanism + { + StorageId = 1 + }; + failureMechanism.AddSection(new FailureMechanismSection("", new[] + { + new Point2D(0, 0) + })); + + var failureMechanismEntity = new FailureMechanismEntity + { + FailureMechanismEntityId = 1, + }; + + ringtoetsEntities.FailureMechanismEntities.Add(failureMechanismEntity); + + // Call + failureMechanism.Update(new PersistenceRegistry(), ringtoetsEntities); + + // Assert + Assert.AreEqual(1, failureMechanismEntity.FailureMechanismSectionEntities.Count); + Assert.AreEqual(1, failureMechanismEntity.FailureMechanismSectionEntities.SelectMany(fms => fms.MicrostabilitySectionResultEntities).Count()); + + mocks.VerifyAll(); + } + + [Test] + public void Update_ContextWithUpdatedFailureMechanismSections_NoNewFailureMechanismSectionsAdded() + { + // Setup + MockRepository mocks = new MockRepository(); + var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks); + + mocks.ReplayAll(); + + var failureMechanism = new MicrostabilityFailureMechanism + { + StorageId = 1 + }; + var testName = "testName"; + failureMechanism.AddSection(new FailureMechanismSection(testName, new[] + { + new Point2D(0, 0) + }) + { + StorageId = 1 + }); + + var failureMechanismSectionEntity = new FailureMechanismSectionEntity + { + FailureMechanismSectionEntityId = 1, + }; + var failureMechanismEntity = new FailureMechanismEntity + { + FailureMechanismEntityId = 1, + FailureMechanismSectionEntities = + { + failureMechanismSectionEntity + } + }; + + ringtoetsEntities.FailureMechanismEntities.Add(failureMechanismEntity); + ringtoetsEntities.FailureMechanismSectionEntities.Add(failureMechanismSectionEntity); + + // Call + failureMechanism.Update(new PersistenceRegistry(), ringtoetsEntities); + + // Assert + Assert.AreEqual(1, failureMechanismEntity.FailureMechanismSectionEntities.Count); + Assert.AreEqual(1, failureMechanismEntity.FailureMechanismSectionEntities.SelectMany(fms => fms.MicrostabilitySectionResultEntities).Count()); + Assert.AreEqual(testName, failureMechanismEntity.FailureMechanismSectionEntities.ElementAt(0).Name); + + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/PipingStructureFailureMechanismSectionResultUpdateExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/PipingStructureFailureMechanismSectionResultUpdateExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/PipingStructureFailureMechanismSectionResultUpdateExtensionsTest.cs (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -0,0 +1,163 @@ +// 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 Core.Common.Base.Data; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Application.Ringtoets.Storage.Test.Update +{ + [TestFixture] + public class PipingStructureFailureMechanismSectionResultUpdateExtensionsTest + { + [Test] + public void Update_WithoutContext_ArgumentNullException() + { + // Setup + var sectionResult = new PipingStructureFailureMechanismSectionResult(new TestFailureMechanismSection()); + + // Call + TestDelegate test = () => sectionResult.Update(new PersistenceRegistry(), null); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("context", paramName); + } + + [Test] + public void Update_WithoutPersistenceRegistry_ArgumentNullException() + { + // Setup + var sectionResult = new PipingStructureFailureMechanismSectionResult(new TestFailureMechanismSection()); + + // Call + TestDelegate test = () => + { + using (var ringtoetsEntities = new RingtoetsEntities()) + { + sectionResult.Update(null, ringtoetsEntities); + } + }; + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("registry", paramName); + } + + [Test] + public void Update_ContextWithNoPipingStructureSectionResult_EntityNotFoundException() + { + // Setup + var sectionResult = new PipingStructureFailureMechanismSectionResult(new TestFailureMechanismSection()); + + // Call + TestDelegate test = () => + { + using (var ringtoetsEntities = new RingtoetsEntities()) + { + sectionResult.Update(new PersistenceRegistry(), ringtoetsEntities); + } + }; + + // Assert + var expectedMessage = String.Format("Het object 'PipingStructureSectionResultEntity' met id '{0}' is niet gevonden.", 0); + EntityNotFoundException exception = Assert.Throws(test); + Assert.AreEqual(expectedMessage, exception.Message); + } + + [Test] + public void Update_ContextWithNoPipingStructureSectionResultWithId_EntityNotFoundException() + { + // Setup + MockRepository mocks = new MockRepository(); + var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks); + + mocks.ReplayAll(); + + var storageId = 1; + var sectionResult = new PipingStructureFailureMechanismSectionResult(new TestFailureMechanismSection()) + { + StorageId = storageId + }; + + ringtoetsEntities.PipingStructureSectionResultEntities.Add(new PipingStructureSectionResultEntity + { + PipingStructureSectionResultEntityId = 2 + }); + + // Call + TestDelegate test = () => sectionResult.Update(new PersistenceRegistry(), ringtoetsEntities); + + // Assert + var expectedMessage = String.Format("Het object 'PipingStructureSectionResultEntity' met id '{0}' is niet gevonden.", storageId); + EntityNotFoundException exception = Assert.Throws(test); + Assert.AreEqual(expectedMessage, exception.Message); + + mocks.VerifyAll(); + } + + [Test] + public void Update_WithPipingStructureSectionResult_PropertiesUpdated() + { + // Setup + MockRepository mocks = new MockRepository(); + var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks); + + mocks.ReplayAll(); + + var sectionResult = new PipingStructureFailureMechanismSectionResult(new TestFailureMechanismSection()) + { + StorageId = 1, + AssessmentLayerOne = true, + AssessmentLayerTwoA = AssessmentLayerTwoAResult.Failed, + AssessmentLayerThree = (RoundedDouble) 4.4 + }; + + var sectionResultEntity = new PipingStructureSectionResultEntity + { + PipingStructureSectionResultEntityId = sectionResult.StorageId, + LayerOne = Convert.ToByte(false), + LayerTwoA = Convert.ToByte(AssessmentLayerTwoAResult.Successful), + LayerThree = 1.1m, + }; + + ringtoetsEntities.PipingStructureSectionResultEntities.Add(sectionResultEntity); + + // Call + sectionResult.Update(new PersistenceRegistry(), ringtoetsEntities); + + // Assert + Assert.AreEqual(Convert.ToByte(true), sectionResultEntity.LayerOne); + Assert.AreEqual(Convert.ToByte(sectionResult.AssessmentLayerTwoA), sectionResultEntity.LayerTwoA); + Assert.AreEqual(sectionResult.AssessmentLayerThree.Value.ToNullableDecimal(), sectionResultEntity.LayerThree); + + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/PipingStructureFailureMechanismUpdateExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/PipingStructureFailureMechanismUpdateExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/PipingStructureFailureMechanismUpdateExtensionsTest.cs (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -0,0 +1,243 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Linq; + +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 Core.Common.Base.Geometry; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Integration.Data.StandAlone; + +namespace Application.Ringtoets.Storage.Test.Update +{ + [TestFixture] + public class PipingStructureFailureMechanismUpdateExtensionsTest + { + [Test] + public void Update_WithoutContext_ThrowsArgumentNullException() + { + // Setup + var failureMechanism = new PipingStructureFailureMechanism(); + + // Call + TestDelegate test = () => failureMechanism.Update(new PersistenceRegistry(), null); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("context", paramName); + } + + [Test] + public void Update_WithoutPersistenceRegistry_ThrowsArgumentNullException() + { + // Setup + var failureMechanism = new PipingStructureFailureMechanism(); + + // Call + TestDelegate test = () => + { + using (var ringtoetsEntities = new RingtoetsEntities()) + { + failureMechanism.Update(null, ringtoetsEntities); + } + }; + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("registry", paramName); + } + + [Test] + public void Update_ContextWithNoPipingStructureFailureMechanism_ThrowsEntityNotFoundException() + { + // Setup + var failureMechanism = new PipingStructureFailureMechanism(); + + // Call + TestDelegate test = () => + { + using (var ringtoetsEntities = new RingtoetsEntities()) + { + failureMechanism.Update(new PersistenceRegistry(), ringtoetsEntities); + } + }; + + // Assert + var expectedMessage = String.Format("Het object 'FailureMechanismEntity' met id '{0}' is niet gevonden.", 0); + EntityNotFoundException exception = Assert.Throws(test); + Assert.AreEqual(expectedMessage, exception.Message); + } + + [Test] + public void Update_ContextWithNoPipingStructureFailureMechanismWithId_ThrowsEntityNotFoundException() + { + // Setup + MockRepository mocks = new MockRepository(); + var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks); + + mocks.ReplayAll(); + + var storageId = 1; + var failureMechanism = new PipingStructureFailureMechanism + { + StorageId = storageId + }; + + ringtoetsEntities.FailureMechanismEntities.Add(new FailureMechanismEntity + { + FailureMechanismEntityId = 2 + }); + + // Call + TestDelegate test = () => failureMechanism.Update(new PersistenceRegistry(), ringtoetsEntities); + + // Assert + var expectedMessage = String.Format("Het object 'FailureMechanismEntity' met id '{0}' is niet gevonden.", storageId); + EntityNotFoundException exception = Assert.Throws(test); + Assert.AreEqual(expectedMessage, exception.Message); + + mocks.VerifyAll(); + } + + [Test] + public void Update_ContextWithPipingStructureFailureMechanism_PropertiesUpdated() + { + // Setup + MockRepository mocks = new MockRepository(); + var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks); + + mocks.ReplayAll(); + + var failureMechanism = new PipingStructureFailureMechanism + { + StorageId = 1, + IsRelevant = true + }; + + var failureMechanismEntity = new FailureMechanismEntity + { + FailureMechanismEntityId = 1, + IsRelevant = Convert.ToByte(false) + }; + + ringtoetsEntities.FailureMechanismEntities.Add(failureMechanismEntity); + + // Call + failureMechanism.Update(new PersistenceRegistry(), ringtoetsEntities); + + // Assert + Assert.AreEqual(Convert.ToByte(true), failureMechanismEntity.IsRelevant); + + mocks.VerifyAll(); + } + + [Test] + public void Update_ContextWithNewFailureMechanismSections_FailureMechanismSectionsAdded() + { + // Setup + MockRepository mocks = new MockRepository(); + var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks); + + mocks.ReplayAll(); + + var failureMechanism = new PipingStructureFailureMechanism + { + StorageId = 1 + }; + failureMechanism.AddSection(new FailureMechanismSection("", new[] + { + new Point2D(0, 0) + })); + + var failureMechanismEntity = new FailureMechanismEntity + { + FailureMechanismEntityId = 1, + }; + + ringtoetsEntities.FailureMechanismEntities.Add(failureMechanismEntity); + + // Call + failureMechanism.Update(new PersistenceRegistry(), ringtoetsEntities); + + // Assert + Assert.AreEqual(1, failureMechanismEntity.FailureMechanismSectionEntities.Count); + Assert.AreEqual(1, failureMechanismEntity.FailureMechanismSectionEntities.SelectMany(fms => fms.PipingStructureSectionResultEntities).Count()); + + mocks.VerifyAll(); + } + + [Test] + public void Update_ContextWithUpdatedFailureMechanismSections_NoNewFailureMechanismSectionsAdded() + { + // Setup + MockRepository mocks = new MockRepository(); + var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks); + + mocks.ReplayAll(); + + var failureMechanism = new PipingStructureFailureMechanism + { + StorageId = 1 + }; + var testName = "testName"; + failureMechanism.AddSection(new FailureMechanismSection(testName, new[] + { + new Point2D(0, 0) + }) + { + StorageId = 1 + }); + + var failureMechanismSectionEntity = new FailureMechanismSectionEntity + { + FailureMechanismSectionEntityId = 1, + }; + var failureMechanismEntity = new FailureMechanismEntity + { + FailureMechanismEntityId = 1, + FailureMechanismSectionEntities = + { + failureMechanismSectionEntity + } + }; + + ringtoetsEntities.FailureMechanismEntities.Add(failureMechanismEntity); + ringtoetsEntities.FailureMechanismSectionEntities.Add(failureMechanismSectionEntity); + + // Call + failureMechanism.Update(new PersistenceRegistry(), ringtoetsEntities); + + // Assert + Assert.AreEqual(1, failureMechanismEntity.FailureMechanismSectionEntities.Count); + Assert.AreEqual(1, failureMechanismEntity.FailureMechanismSectionEntities.SelectMany(fms => fms.PipingStructureSectionResultEntities).Count()); + Assert.AreEqual(testName, failureMechanismEntity.FailureMechanismSectionEntities.ElementAt(0).Name); + + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsEntitiesHelper.cs =================================================================== diff -u -r4a12b47ea94488f0716d7c61c6cefba235d7db48 -r0e4717786f2f1a865e48da9fde2089a789bfe02c --- Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsEntitiesHelper.cs (.../RingtoetsEntitiesHelper.cs) (revision 4a12b47ea94488f0716d7c61c6cefba235d7db48) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsEntitiesHelper.cs (.../RingtoetsEntitiesHelper.cs) (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -52,6 +52,10 @@ DbSet macrostabilityOutwardsSectionResultsSet = CreateEmptyTestDbSet(); DbSet waveImpactAsphaltCoverSectionResultsSet = CreateEmptyTestDbSet(); DbSet grassCoverErosionOutwardsSectionResultsSet = CreateEmptyTestDbSet(); + DbSet grassCoverSlipOffInwardsSectionResultsSet = CreateEmptyTestDbSet(); + DbSet grassCoverSlipOffOutwardsSectionResultsSet = CreateEmptyTestDbSet(); + DbSet microstabilitySectionResultsSet = CreateEmptyTestDbSet(); + DbSet pipingStructureSectionResultsSet = CreateEmptyTestDbSet(); DbSet assessmentSectionsSet = CreateEmptyTestDbSet(); DbSet referenceLinesSet = CreateEmptyTestDbSet(); DbSet calculationGroupsSet = CreateEmptyTestDbSet(); @@ -85,6 +89,10 @@ ringtoetsEntities.Stub(r => r.MacrostabilityOutwardsSectionResultEntities).Return(macrostabilityOutwardsSectionResultsSet); ringtoetsEntities.Stub(r => r.WaveImpactAsphaltCoverSectionResultEntities).Return(waveImpactAsphaltCoverSectionResultsSet); ringtoetsEntities.Stub(r => r.GrassCoverErosionOutwardsSectionResultEntities).Return(grassCoverErosionOutwardsSectionResultsSet); + ringtoetsEntities.Stub(r => r.GrassCoverSlipOffInwardsSectionResultEntities).Return(grassCoverSlipOffInwardsSectionResultsSet); + ringtoetsEntities.Stub(r => r.GrassCoverSlipOffOutwardsSectionResultEntities).Return(grassCoverSlipOffOutwardsSectionResultsSet); + ringtoetsEntities.Stub(r => r.MicrostabilitySectionResultEntities).Return(microstabilitySectionResultsSet); + ringtoetsEntities.Stub(r => r.PipingStructureSectionResultEntities).Return(pipingStructureSectionResultsSet); ringtoetsEntities.Stub(r => r.AssessmentSectionEntities).Return(assessmentSectionsSet); ringtoetsEntities.Stub(r => r.ReferenceLinePointEntities).Return(referenceLinesSet); ringtoetsEntities.Stub(r => r.CalculationGroupEntities).Return(calculationGroupsSet); Index: Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsProjectHelper.cs =================================================================== diff -u -r4a12b47ea94488f0716d7c61c6cefba235d7db48 -r0e4717786f2f1a865e48da9fde2089a789bfe02c --- Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsProjectHelper.cs (.../RingtoetsProjectHelper.cs) (revision 4a12b47ea94488f0716d7c61c6cefba235d7db48) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsProjectHelper.cs (.../RingtoetsProjectHelper.cs) (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -221,15 +221,18 @@ AddSections(assessmentSection.MacrostabilityOutwards); SetSectionResults(assessmentSection.MacrostabilityOutwards.SectionResults); AddSections(assessmentSection.Microstability); + SetSectionResults(assessmentSection.Microstability.SectionResults); AddSections(assessmentSection.StabilityStoneCover); AddSections(assessmentSection.WaveImpactAsphaltCover); SetSectionResults(assessmentSection.WaveImpactAsphaltCover.SectionResults); AddSections(assessmentSection.WaterPressureAsphaltCover); SetSectionResults(assessmentSection.WaterPressureAsphaltCover.SectionResults); AddSections(assessmentSection.GrassCoverErosionOutwards); SetSectionResults(assessmentSection.GrassCoverErosionOutwards.SectionResults); - AddSections(assessmentSection.GrassCoverSlipOffOutwards); AddSections(assessmentSection.GrassCoverSlipOffInwards); + SetSectionResults(assessmentSection.GrassCoverSlipOffInwards.SectionResults); + AddSections(assessmentSection.GrassCoverSlipOffOutwards); + SetSectionResults(assessmentSection.GrassCoverSlipOffOutwards.SectionResults); AddSections(assessmentSection.HeightStructures); SetSectionResults(assessmentSection.HeightStructures.SectionResults); AddSections(assessmentSection.ClosingStructure); @@ -238,6 +241,7 @@ AddSections(assessmentSection.StrengthStabilityLengthwiseConstruction); SetSectionResults(assessmentSection.StrengthStabilityLengthwiseConstruction.SectionResults); AddSections(assessmentSection.PipingStructure); + SetSectionResults(assessmentSection.PipingStructure.SectionResults); AddSections(assessmentSection.DuneErosion); AddSections(assessmentSection.TechnicalInnovation); SetSectionResults(assessmentSection.TechnicalInnovation.SectionResults); @@ -362,6 +366,58 @@ } } + private static void SetSectionResults(IEnumerable sectionResults) + { + var random = new Random(21); + foreach (var sectionResult in sectionResults) + { + var randomLayer2AResult = (AssessmentLayerTwoAResult) random.Next(0, Enum.GetValues(typeof(AssessmentLayerTwoAResult)).Length); + + sectionResult.AssessmentLayerOne = Convert.ToBoolean(random.Next(0, 2)); + sectionResult.AssessmentLayerTwoA = randomLayer2AResult; + sectionResult.AssessmentLayerThree = (RoundedDouble)random.NextDouble(); + } + } + + private static void SetSectionResults(IEnumerable sectionResults) + { + var random = new Random(21); + foreach (var sectionResult in sectionResults) + { + var randomLayer2AResult = (AssessmentLayerTwoAResult) random.Next(0, Enum.GetValues(typeof(AssessmentLayerTwoAResult)).Length); + + sectionResult.AssessmentLayerOne = Convert.ToBoolean(random.Next(0, 2)); + sectionResult.AssessmentLayerTwoA = randomLayer2AResult; + sectionResult.AssessmentLayerThree = (RoundedDouble)random.NextDouble(); + } + } + + private static void SetSectionResults(IEnumerable sectionResults) + { + var random = new Random(21); + foreach (var sectionResult in sectionResults) + { + var randomLayer2AResult = (AssessmentLayerTwoAResult) random.Next(0, Enum.GetValues(typeof(AssessmentLayerTwoAResult)).Length); + + sectionResult.AssessmentLayerOne = Convert.ToBoolean(random.Next(0, 2)); + sectionResult.AssessmentLayerTwoA = randomLayer2AResult; + sectionResult.AssessmentLayerThree = (RoundedDouble)random.NextDouble(); + } + } + + private static void SetSectionResults(IEnumerable sectionResults) + { + var random = new Random(21); + foreach (var sectionResult in sectionResults) + { + var randomLayer2AResult = (AssessmentLayerTwoAResult) random.Next(0, Enum.GetValues(typeof(AssessmentLayerTwoAResult)).Length); + + sectionResult.AssessmentLayerOne = Convert.ToBoolean(random.Next(0, 2)); + sectionResult.AssessmentLayerTwoA = randomLayer2AResult; + sectionResult.AssessmentLayerThree = (RoundedDouble)random.NextDouble(); + } + } + private static void AddSections(IFailureMechanism failureMechanism) { failureMechanism.AddSection(new FailureMechanismSection("section 1", new[] Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/SectionResults/GrassCoverSlipOffInwardsFailureMechanismSectionResult.cs =================================================================== diff -u -r99aa5c56c58f8dddcb76b9d0e2f2f5ec4cd38e56 -r0e4717786f2f1a865e48da9fde2089a789bfe02c --- Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/SectionResults/GrassCoverSlipOffInwardsFailureMechanismSectionResult.cs (.../GrassCoverSlipOffInwardsFailureMechanismSectionResult.cs) (revision 99aa5c56c58f8dddcb76b9d0e2f2f5ec4cd38e56) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/SectionResults/GrassCoverSlipOffInwardsFailureMechanismSectionResult.cs (.../GrassCoverSlipOffInwardsFailureMechanismSectionResult.cs) (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -21,6 +21,7 @@ using System; using Core.Common.Base.Data; +using Core.Common.Base.Storage; using Ringtoets.Common.Data.FailureMechanism; namespace Ringtoets.Integration.Data.StandAlone.SectionResults @@ -29,7 +30,7 @@ /// This class holds information about the result of a calculation on section level for the /// Grass Cover Slip Off Inwards failure mechanism. /// - public class GrassCoverSlipOffInwardsFailureMechanismSectionResult : FailureMechanismSectionResult + public class GrassCoverSlipOffInwardsFailureMechanismSectionResult : FailureMechanismSectionResult, IStorable { /// /// Creates a new instance of . @@ -54,5 +55,7 @@ /// Gets or sets the value of the tailored assessment of safety. /// public RoundedDouble AssessmentLayerThree { get; set; } + + public long StorageId { get; set; } } } Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/SectionResults/GrassCoverSlipOffOutwardsFailureMechanismSectionResult.cs =================================================================== diff -u -r99aa5c56c58f8dddcb76b9d0e2f2f5ec4cd38e56 -r0e4717786f2f1a865e48da9fde2089a789bfe02c --- Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/SectionResults/GrassCoverSlipOffOutwardsFailureMechanismSectionResult.cs (.../GrassCoverSlipOffOutwardsFailureMechanismSectionResult.cs) (revision 99aa5c56c58f8dddcb76b9d0e2f2f5ec4cd38e56) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/SectionResults/GrassCoverSlipOffOutwardsFailureMechanismSectionResult.cs (.../GrassCoverSlipOffOutwardsFailureMechanismSectionResult.cs) (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -21,6 +21,7 @@ using System; using Core.Common.Base.Data; +using Core.Common.Base.Storage; using Ringtoets.Common.Data.FailureMechanism; namespace Ringtoets.Integration.Data.StandAlone.SectionResults @@ -29,7 +30,7 @@ /// This class holds information about the result of a calculation on section level for the /// Grass Cover Slip Off Outwards failure mechanism. /// - public class GrassCoverSlipOffOutwardsFailureMechanismSectionResult : FailureMechanismSectionResult + public class GrassCoverSlipOffOutwardsFailureMechanismSectionResult : FailureMechanismSectionResult, IStorable { /// /// Creates a new instance of . @@ -54,5 +55,7 @@ /// Gets or sets the value of the tailored assessment of safety. /// public RoundedDouble AssessmentLayerThree { get; set; } + + public long StorageId { get; set; } } } Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/SectionResults/MicrostabilityFailureMechanismSectionResult.cs =================================================================== diff -u -r99aa5c56c58f8dddcb76b9d0e2f2f5ec4cd38e56 -r0e4717786f2f1a865e48da9fde2089a789bfe02c --- Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/SectionResults/MicrostabilityFailureMechanismSectionResult.cs (.../MicrostabilityFailureMechanismSectionResult.cs) (revision 99aa5c56c58f8dddcb76b9d0e2f2f5ec4cd38e56) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/SectionResults/MicrostabilityFailureMechanismSectionResult.cs (.../MicrostabilityFailureMechanismSectionResult.cs) (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -21,6 +21,7 @@ using System; using Core.Common.Base.Data; +using Core.Common.Base.Storage; using Ringtoets.Common.Data.FailureMechanism; namespace Ringtoets.Integration.Data.StandAlone.SectionResults @@ -29,7 +30,7 @@ /// This class holds information about the result of a calculation on section level for the /// Microstability failure mechanism. /// - public class MicrostabilityFailureMechanismSectionResult : FailureMechanismSectionResult + public class MicrostabilityFailureMechanismSectionResult : FailureMechanismSectionResult, IStorable { /// /// Creates a new instance of . @@ -54,5 +55,7 @@ /// Gets or sets the value of the tailored assessment of safety. /// public RoundedDouble AssessmentLayerThree { get; set; } + + public long StorageId { get; set; } } } Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/SectionResults/PipingStructureFailureMechanismSectionResult.cs =================================================================== diff -u -r99aa5c56c58f8dddcb76b9d0e2f2f5ec4cd38e56 -r0e4717786f2f1a865e48da9fde2089a789bfe02c --- Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/SectionResults/PipingStructureFailureMechanismSectionResult.cs (.../PipingStructureFailureMechanismSectionResult.cs) (revision 99aa5c56c58f8dddcb76b9d0e2f2f5ec4cd38e56) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/SectionResults/PipingStructureFailureMechanismSectionResult.cs (.../PipingStructureFailureMechanismSectionResult.cs) (revision 0e4717786f2f1a865e48da9fde2089a789bfe02c) @@ -21,6 +21,7 @@ using System; using Core.Common.Base.Data; +using Core.Common.Base.Storage; using Ringtoets.Common.Data.FailureMechanism; namespace Ringtoets.Integration.Data.StandAlone.SectionResults @@ -29,7 +30,7 @@ /// This class holds information about the result of a calculation on section level for the /// Piping Structure failure mechanism. /// - public class PipingStructureFailureMechanismSectionResult : FailureMechanismSectionResult + public class PipingStructureFailureMechanismSectionResult : FailureMechanismSectionResult, IStorable { /// /// Creates a new instance of . @@ -54,5 +55,7 @@ /// Gets or sets the value of the tailored assessment of safety. /// public RoundedDouble AssessmentLayerThree { get; set; } + + public long StorageId { get; set; } } }