Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj =================================================================== diff -u -rb0f517aa5c87ef9036f146a5181a88508b135c23 -rb3af39ba024b8e12fe238d85130697255db28c59 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision b0f517aa5c87ef9036f146a5181a88508b135c23) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -75,7 +75,7 @@ RingtoetsEntities.tt - + RingtoetsEntities.tt @@ -226,8 +226,8 @@ - - + + @@ -285,7 +285,7 @@ - + Code Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/AssessmentSectionCreateExtensions.cs =================================================================== diff -u -r11f0867b39150ae5fac83dc178a89fee46d27611 -rb3af39ba024b8e12fe238d85130697255db28c59 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/AssessmentSectionCreateExtensions.cs (.../AssessmentSectionCreateExtensions.cs) (revision 11f0867b39150ae5fac83dc178a89fee46d27611) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/AssessmentSectionCreateExtensions.cs (.../AssessmentSectionCreateExtensions.cs) (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -20,7 +20,7 @@ // All rights reserved. using System; -using Application.Ringtoets.Storage.Create.ClosingStructure; +using Application.Ringtoets.Storage.Create.ClosingStructures; using Application.Ringtoets.Storage.Create.DuneErosion; using Application.Ringtoets.Storage.Create.GrassCoverErosionInwards; using Application.Ringtoets.Storage.Create.GrassCoverErosionOutwards; @@ -83,7 +83,7 @@ entity.FailureMechanismEntities.Add(section.StrengthStabilityLengthwiseConstruction.Create(registry)); entity.FailureMechanismEntities.Add(section.TechnicalInnovation.Create(registry)); entity.FailureMechanismEntities.Add(section.WaterPressureAsphaltCover.Create(registry)); - entity.FailureMechanismEntities.Add(section.ClosingStructure.Create(registry)); + entity.FailureMechanismEntities.Add(section.ClosingStructures.Create(registry)); entity.FailureMechanismEntities.Add(section.MacrostabilityInwards.Create(registry)); entity.FailureMechanismEntities.Add(section.MacrostabilityOutwards.Create(registry)); entity.FailureMechanismEntities.Add(section.WaveImpactAsphaltCover.Create(registry)); Fisheye: Tag b3af39ba024b8e12fe238d85130697255db28c59 refers to a dead (removed) revision in file `Application/Ringtoets/src/Application.Ringtoets.Storage/Create/ClosingStructure/ClosingStructureFailureMechanismCreateExtensions.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag b3af39ba024b8e12fe238d85130697255db28c59 refers to a dead (removed) revision in file `Application/Ringtoets/src/Application.Ringtoets.Storage/Create/ClosingStructure/ClosingStructureFailureMechanismSectionResultCreateExtensions.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/ClosingStructures/ClosingStructuresFailureMechanismCreateExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/ClosingStructures/ClosingStructuresFailureMechanismCreateExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/ClosingStructures/ClosingStructuresFailureMechanismCreateExtensions.cs (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -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 System.Collections.Generic; +using Application.Ringtoets.Storage.DbContext; +using Ringtoets.Integration.Data.StandAlone; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Application.Ringtoets.Storage.Create.ClosingStructures +{ + /// + /// Extension methods for related to creating a . + /// + internal static class ClosingStructuresFailureMechanismCreateExtensions + { + /// + /// 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 ClosingStructuresFailureMechanism mechanism, PersistenceRegistry registry) + { + var entity = mechanism.Create(FailureMechanismType.ReliabilityClosingOfStructure, registry); + AddEntitiesForSectionResults(mechanism.SectionResults, registry); + + 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.ClosingStructuresSectionResultEntities.Add(sectionResultEntity); + } + } + } +} \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/ClosingStructures/ClosingStructuresFailureMechanismSectionResultCreateExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/ClosingStructures/ClosingStructuresFailureMechanismSectionResultCreateExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/ClosingStructures/ClosingStructuresFailureMechanismSectionResultCreateExtensions.cs (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -0,0 +1,57 @@ +// 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.ClosingStructures +{ + /// + /// Extension methods for related to creating a + /// . + /// + internal static class ClosingStructuresFailureMechanismSectionResultCreateExtensions + { + /// + /// 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 ClosingStructuresSectionResultEntity Create(this ClosingStructuresFailureMechanismSectionResult result, PersistenceRegistry registry) + { + if (registry == null) + { + throw new ArgumentNullException("registry"); + } + var sectionResultEntity = new ClosingStructuresSectionResultEntity + { + LayerOne = Convert.ToByte(result.AssessmentLayerOne), + LayerTwoA = result.AssessmentLayerTwoA.ToNaNAsNull(), + LayerThree = result.AssessmentLayerThree.Value.ToNaNAsNull() + }; + + return sectionResultEntity; + } + } +} \ No newline at end of file Fisheye: Tag b3af39ba024b8e12fe238d85130697255db28c59 refers to a dead (removed) revision in file `Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/ClosingStructureSectionResultEntity.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/ClosingStructuresSectionResultEntity.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/ClosingStructuresSectionResultEntity.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/ClosingStructuresSectionResultEntity.cs (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -0,0 +1,46 @@ +// 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. + +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Application.Ringtoets.Storage.DbContext +{ + using System; + using System.Collections.Generic; + + public partial class ClosingStructuresSectionResultEntity + { + public long ClosingStructuresSectionResultEntityId { get; set; } + public long FailureMechanismSectionEntityId { get; set; } + public byte LayerOne { get; set; } + public Nullable LayerTwoA { get; set; } + public Nullable LayerThree { get; set; } + + public virtual FailureMechanismSectionEntity FailureMechanismSectionEntity { get; set; } + } +} Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/DatabaseStructure.sql =================================================================== diff -u -r22ca26b6be3835bc306c1657bbac0b9080fc3a3e -rb3af39ba024b8e12fe238d85130697255db28c59 --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/DatabaseStructure.sql (.../DatabaseStructure.sql) (revision 22ca26b6be3835bc306c1657bbac0b9080fc3a3e) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/DatabaseStructure.sql (.../DatabaseStructure.sql) (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -84,7 +84,7 @@ DROP TABLE IF EXISTS 'WaterPressureAsphaltCoverSectionResultEntity' ; -DROP TABLE IF EXISTS 'ClosingStructureSectionResultEntity' +DROP TABLE IF EXISTS 'ClosingStructuresSectionResultEntity' ; DROP TABLE IF EXISTS 'GrassCoverErosionOutwardsSectionResultEntity' @@ -492,14 +492,14 @@ ) ; -CREATE TABLE 'ClosingStructureSectionResultEntity' +CREATE TABLE 'ClosingStructuresSectionResultEntity' ( - 'ClosingStructureSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'ClosingStructuresSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, 'FailureMechanismSectionEntityId' INTEGER NOT NULL, 'LayerOne' TINYINT (1) NOT NULL, -- true or false 'LayerTwoA' REAL, 'LayerThree' REAL, - CONSTRAINT 'FK_ClosingStructureSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade + CONSTRAINT 'FK_ClosingStructuresSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade ) ; @@ -930,8 +930,8 @@ ON 'WaterPressureAsphaltCoverSectionResultEntity' ('FailureMechanismSectionEntityId' ASC) ; -CREATE INDEX 'IXFK_ClosingStructureSectionResultEntity_FailureMechanismSectionEntity' - ON 'ClosingStructureSectionResultEntity' ('FailureMechanismSectionEntityId' ASC) +CREATE INDEX 'IXFK_ClosingStructuresSectionResultEntity_FailureMechanismSectionEntity' + ON 'ClosingStructuresSectionResultEntity' ('FailureMechanismSectionEntityId' ASC) ; CREATE INDEX 'IXFK_GrassCoverErosionOutwardsSectionResultEntity_FailureMechanismSectionEntity' Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/FailureMechanismSectionEntity.cs =================================================================== diff -u -r741fcc00e47a7ff8fa01bbf15edbaedf8dec2e57 -rb3af39ba024b8e12fe238d85130697255db28c59 --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/FailureMechanismSectionEntity.cs (.../FailureMechanismSectionEntity.cs) (revision 741fcc00e47a7ff8fa01bbf15edbaedf8dec2e57) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/FailureMechanismSectionEntity.cs (.../FailureMechanismSectionEntity.cs) (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -38,7 +38,6 @@ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] public FailureMechanismSectionEntity() { - this.ClosingStructureSectionResultEntities = new HashSet(); this.DuneErosionSectionResultEntities = new HashSet(); this.GrassCoverErosionInwardsSectionResultEntities = new HashSet(); this.GrassCoverErosionOutwardsSectionResultEntities = new HashSet(); @@ -56,6 +55,7 @@ this.TechnicalInnovationSectionResultEntities = new HashSet(); this.WaterPressureAsphaltCoverSectionResultEntities = new HashSet(); this.WaveImpactAsphaltCoverSectionResultEntities = new HashSet(); + this.ClosingStructuresSectionResultEntities = new HashSet(); } public long FailureMechanismSectionEntityId { get; set; } @@ -64,8 +64,6 @@ public string FailureMechanismSectionPointXml { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] - public virtual ICollection ClosingStructureSectionResultEntities { get; set; } - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection DuneErosionSectionResultEntities { get; set; } public virtual FailureMechanismEntity FailureMechanismEntity { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] @@ -100,5 +98,7 @@ public virtual ICollection WaterPressureAsphaltCoverSectionResultEntities { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection WaveImpactAsphaltCoverSectionResultEntities { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection ClosingStructuresSectionResultEntities { get; set; } } } Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/IRingtoetsEntities.cs =================================================================== diff -u -rfa2d88ba58e524c1d132a21df4e0adf9fa6570c4 -rb3af39ba024b8e12fe238d85130697255db28c59 --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/IRingtoetsEntities.cs (.../IRingtoetsEntities.cs) (revision fa2d88ba58e524c1d132a21df4e0adf9fa6570c4) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/IRingtoetsEntities.cs (.../IRingtoetsEntities.cs) (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -115,10 +115,10 @@ DbSet WaterPressureAsphaltCoverSectionResultEntities { get; } /// - /// Gets a of containing + /// Gets a of containing /// every entity found in the database. /// - DbSet ClosingStructureSectionResultEntities { get; } + DbSet ClosingStructuresSectionResultEntities { get; } /// /// Gets a of containing Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.Context.cs =================================================================== diff -u -r553f0128e1d2b027e25e00909fd2f3d0b13404b2 -rb3af39ba024b8e12fe238d85130697255db28c59 --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.Context.cs (.../RingtoetsEntities.Context.cs) (revision 553f0128e1d2b027e25e00909fd2f3d0b13404b2) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.Context.cs (.../RingtoetsEntities.Context.cs) (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -55,7 +55,6 @@ public virtual DbSet AssessmentSectionEntities { get; set; } public virtual DbSet CalculationGroupEntities { get; set; } public virtual DbSet CharacteristicPointEntities { get; set; } - public virtual DbSet ClosingStructureSectionResultEntities { get; set; } public virtual DbSet DikeProfileEntities { get; set; } public virtual DbSet DuneErosionSectionResultEntities { get; set; } public virtual DbSet FailureMechanismEntities { get; set; } @@ -100,5 +99,6 @@ public virtual DbSet WaveImpactAsphaltCoverSectionResultEntities { get; set; } public virtual DbSet WaveImpactAsphaltCoverWaveConditionsCalculationEntities { get; set; } public virtual DbSet WaveImpactAsphaltCoverWaveConditionsOutputEntities { get; set; } + public virtual DbSet ClosingStructuresSectionResultEntities { get; set; } } } Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx =================================================================== diff -u -rb0f517aa5c87ef9036f146a5181a88508b135c23 -rb3af39ba024b8e12fe238d85130697255db28c59 --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx (.../RingtoetsEntities.edmx) (revision b0f517aa5c87ef9036f146a5181a88508b135c23) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx (.../RingtoetsEntities.edmx) (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -42,11 +42,11 @@ - + - + - + @@ -634,14 +634,14 @@ - + - + - + @@ -1310,7 +1310,7 @@ - + @@ -1367,9 +1367,9 @@ - + - + @@ -1600,7 +1600,6 @@ - @@ -1689,10 +1688,6 @@ - - - - @@ -1881,6 +1876,11 @@ + + + + + @@ -1931,17 +1931,6 @@ - - - - - - - - - - - @@ -2002,7 +1991,6 @@ - @@ -2021,6 +2009,7 @@ + @@ -2725,18 +2714,6 @@ - - - - - - - - - - - - @@ -3301,6 +3278,29 @@ + + + + + + + + + + + + + + + + + + + + + + + @@ -3347,17 +3347,6 @@ - - - - - - - - - - - @@ -3948,6 +3937,17 @@ + + + + + + + + + + + Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx.diagram =================================================================== diff -u -r553f0128e1d2b027e25e00909fd2f3d0b13404b2 -rb3af39ba024b8e12fe238d85130697255db28c59 --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx.diagram (.../RingtoetsEntities.edmx.diagram) (revision 553f0128e1d2b027e25e00909fd2f3d0b13404b2) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx.diagram (.../RingtoetsEntities.edmx.diagram) (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -4,11 +4,10 @@ - + - @@ -64,7 +63,6 @@ - @@ -112,6 +110,8 @@ + + Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/AssessmentSectionEntityReadExtensions.cs =================================================================== diff -u -r11f0867b39150ae5fac83dc178a89fee46d27611 -rb3af39ba024b8e12fe238d85130697255db28c59 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/AssessmentSectionEntityReadExtensions.cs (.../AssessmentSectionEntityReadExtensions.cs) (revision 11f0867b39150ae5fac83dc178a89fee46d27611) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/AssessmentSectionEntityReadExtensions.cs (.../AssessmentSectionEntityReadExtensions.cs) (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -70,7 +70,7 @@ entity.ReadStrengthStabilityLengthwiseConstructionFailureMechanism(assessmentSection, collector); entity.ReadTechnicalInnovationFailureMechanism(assessmentSection, collector); entity.ReadWaterPressureAsphaltCoverFailureMechanism(assessmentSection, collector); - entity.ReadClosingStructureFailureMechanism(assessmentSection, collector); + entity.ReadClosingStructuresFailureMechanism(assessmentSection, collector); entity.ReadMacrostabilityInwardsFailureMechanism(assessmentSection, collector); entity.ReadMacrostabilityOutwardsFailureMechanism(assessmentSection, collector); entity.ReadWaveImpactAsphaltCoverFailureMechanism(assessmentSection, collector); @@ -170,12 +170,12 @@ } } - private static void ReadClosingStructureFailureMechanism(this AssessmentSectionEntity entity, AssessmentSection assessmentSection, ReadConversionCollector collector) + private static void ReadClosingStructuresFailureMechanism(this AssessmentSectionEntity entity, AssessmentSection assessmentSection, ReadConversionCollector collector) { - var closingStructureFailureMechanismEntity = entity.FailureMechanismEntities.SingleOrDefault(fme => fme.FailureMechanismType == (int) FailureMechanismType.ReliabilityClosingOfStructure); - if (closingStructureFailureMechanismEntity != null) + var closingStructuresFailureMechanismEntity = entity.FailureMechanismEntities.SingleOrDefault(fme => fme.FailureMechanismType == (int) FailureMechanismType.ReliabilityClosingOfStructure); + if (closingStructuresFailureMechanismEntity != null) { - closingStructureFailureMechanismEntity.ReadAsClosingStructureFailureMechanism(assessmentSection.ClosingStructure, collector); + closingStructuresFailureMechanismEntity.ReadAsClosingStructuresFailureMechanism(assessmentSection.ClosingStructures, collector); } } Fisheye: Tag b3af39ba024b8e12fe238d85130697255db28c59 refers to a dead (removed) revision in file `Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ClosingStructureSectionResultEntityReadExtensions.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ClosingStructures/ClosingStructuresSectionResultEntityReadExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ClosingStructures/ClosingStructuresSectionResultEntityReadExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ClosingStructures/ClosingStructuresSectionResultEntityReadExtensions.cs (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -0,0 +1,55 @@ +// 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.Integration.Data.StandAlone.SectionResults; + +namespace Application.Ringtoets.Storage.Read.ClosingStructures +{ + /// + /// This class defines extension methods for read operations for a based on the + /// . + /// + internal static class ClosingStructuresSectionResultEntityReadExtensions + { + /// + /// Reads the and use the information to update a + /// . + /// + /// The to create for. + /// The target of the read operation. + /// A new . + /// Thrown when is null. + internal static void Read(this ClosingStructuresSectionResultEntity entity, ClosingStructuresFailureMechanismSectionResult sectionResult) + { + if (sectionResult == null) + { + throw new ArgumentNullException("sectionResult"); + } + + sectionResult.AssessmentLayerOne = Convert.ToBoolean(entity.LayerOne); + sectionResult.AssessmentLayerTwoA = (RoundedDouble) entity.LayerTwoA.ToNullAsNaN(); + sectionResult.AssessmentLayerThree = (RoundedDouble) entity.LayerThree.ToNullAsNaN(); + } + } +} \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/FailureMechanismEntityReadExtensions.cs =================================================================== diff -u -r5cc8a49cc445a67f425ced8216c772b9170ea517 -rb3af39ba024b8e12fe238d85130697255db28c59 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/FailureMechanismEntityReadExtensions.cs (.../FailureMechanismEntityReadExtensions.cs) (revision 5cc8a49cc445a67f425ced8216c772b9170ea517) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/FailureMechanismEntityReadExtensions.cs (.../FailureMechanismEntityReadExtensions.cs) (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -23,6 +23,7 @@ using System.Collections.Generic; using System.Linq; using Application.Ringtoets.Storage.DbContext; +using Application.Ringtoets.Storage.Read.ClosingStructures; using Application.Ringtoets.Storage.Read.GrassCoverErosionInwards; using Application.Ringtoets.Storage.Read.GrassCoverErosionOutwards; using Application.Ringtoets.Storage.Read.Piping; @@ -156,7 +157,7 @@ /// Read the and use the information to update a . /// /// The to read into a . - /// + /// The target of the read operation. /// The object keeping track of read operations. internal static void ReadAsGrassCoverErosionInwardsFailureMechanism(this FailureMechanismEntity entity, GrassCoverErosionInwardsFailureMechanism failureMechanism, ReadConversionCollector collector) { @@ -210,7 +211,7 @@ /// Read 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. internal static void ReadAsHeightStructuresFailureMechanism(this FailureMechanismEntity entity, HeightStructuresFailureMechanism failureMechanism, ReadConversionCollector collector) { @@ -237,7 +238,7 @@ /// Read 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. internal static void ReadAsStrengthStabilityLengthwiseConstructionFailureMechanism(this FailureMechanismEntity entity, StrengthStabilityLengthwiseConstructionFailureMechanism failureMechanism, ReadConversionCollector collector) { @@ -264,7 +265,7 @@ /// Read 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. internal static void ReadAsTechnicalInnovationFailureMechanism(this FailureMechanismEntity entity, TechnicalInnovationFailureMechanism failureMechanism, ReadConversionCollector collector) { @@ -291,7 +292,7 @@ /// Read 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. internal static void ReadAsWaterPressureAsphaltCoverFailureMechanism(this FailureMechanismEntity entity, WaterPressureAsphaltCoverFailureMechanism failureMechanism, ReadConversionCollector collector) { @@ -312,23 +313,23 @@ #endregion - #region Closing Structure + #region Closing Structures /// - /// Read the and use the information to update a . + /// Read the and use the information to update a . /// - /// The to create for. - /// + /// The to create for. + /// The target of the read operation. /// The object keeping track of read operations. - internal static void ReadAsClosingStructureFailureMechanism(this FailureMechanismEntity entity, ClosingStructureFailureMechanism failureMechanism, ReadConversionCollector collector) + internal static void ReadAsClosingStructuresFailureMechanism(this FailureMechanismEntity entity, ClosingStructuresFailureMechanism failureMechanism, ReadConversionCollector collector) { entity.ReadCommonFailureMechanismProperties(failureMechanism, collector); - entity.ReadClosingStructureMechanismSectionResults(failureMechanism, collector); + entity.ReadClosingStructuresMechanismSectionResults(failureMechanism, collector); } - - private static void ReadClosingStructureMechanismSectionResults(this FailureMechanismEntity entity, ClosingStructureFailureMechanism failureMechanism, ReadConversionCollector collector) + + private static void ReadClosingStructuresMechanismSectionResults(this FailureMechanismEntity entity, ClosingStructuresFailureMechanism failureMechanism, ReadConversionCollector collector) { - foreach (var sectionResultEntity in entity.FailureMechanismSectionEntities.SelectMany(fms => fms.ClosingStructureSectionResultEntities)) + foreach (var sectionResultEntity in entity.FailureMechanismSectionEntities.SelectMany(fms => fms.ClosingStructuresSectionResultEntities)) { var failureMechanismSection = collector.Get(sectionResultEntity.FailureMechanismSectionEntity); var result = failureMechanism.SectionResults.Single(sr => ReferenceEquals(sr.Section, failureMechanismSection)); @@ -345,7 +346,7 @@ /// Read 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. internal static void ReadAsMacrostabilityInwardsFailureMechanism(this FailureMechanismEntity entity, MacrostabilityInwardsFailureMechanism failureMechanism, ReadConversionCollector collector) { @@ -372,7 +373,7 @@ /// Read 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. internal static void ReadAsMacrostabilityOutwardsFailureMechanism(this FailureMechanismEntity entity, MacrostabilityOutwardsFailureMechanism failureMechanism, ReadConversionCollector collector) { @@ -399,7 +400,7 @@ /// Read 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. internal static void ReadAsWaveImpactAsphaltCoverFailureMechanism(this FailureMechanismEntity entity, WaveImpactAsphaltCoverFailureMechanism failureMechanism, ReadConversionCollector collector) { @@ -440,7 +441,7 @@ /// Read 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. internal static void ReadAsGrassCoverErosionOutwardsFailureMechanism(this FailureMechanismEntity entity, GrassCoverErosionOutwardsFailureMechanism failureMechanism, ReadConversionCollector collector) { @@ -492,7 +493,7 @@ /// Read 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. internal static void ReadAsGrassCoverSlipOffInwardsFailureMechanism(this FailureMechanismEntity entity, GrassCoverSlipOffInwardsFailureMechanism failureMechanism, ReadConversionCollector collector) { @@ -519,7 +520,7 @@ /// Read 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. internal static void ReadAsGrassCoverSlipOffOutwardsFailureMechanism(this FailureMechanismEntity entity, GrassCoverSlipOffOutwardsFailureMechanism failureMechanism, ReadConversionCollector collector) { @@ -546,7 +547,7 @@ /// Read 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. internal static void ReadAsMicrostabilityFailureMechanism(this FailureMechanismEntity entity, MicrostabilityFailureMechanism failureMechanism, ReadConversionCollector collector) { @@ -573,7 +574,7 @@ /// Read 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. internal static void ReadAsPipingStructureFailureMechanism(this FailureMechanismEntity entity, PipingStructureFailureMechanism failureMechanism, ReadConversionCollector collector) { @@ -600,7 +601,7 @@ /// Read 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. internal static void ReadAsDuneErosionFailureMechanism(this FailureMechanismEntity entity, DuneErosionFailureMechanism failureMechanism, ReadConversionCollector collector) { @@ -627,7 +628,7 @@ /// Read 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. internal static void ReadAsStabilityStoneCoverFailureMechanism(this FailureMechanismEntity entity, StabilityStoneCoverFailureMechanism failureMechanism, ReadConversionCollector collector) { @@ -675,7 +676,7 @@ /// Read 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. internal static void ReadAsStrengthStabilityPointConstructionFailureMechanism(this FailureMechanismEntity entity, StrengthStabilityPointConstructionFailureMechanism failureMechanism, ReadConversionCollector collector) { Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj =================================================================== diff -u -rb0f517aa5c87ef9036f146a5181a88508b135c23 -rb3af39ba024b8e12fe238d85130697255db28c59 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision b0f517aa5c87ef9036f146a5181a88508b135c23) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -95,8 +95,8 @@ - - + + @@ -158,7 +158,7 @@ - + Fisheye: Tag b3af39ba024b8e12fe238d85130697255db28c59 refers to a dead (removed) revision in file `Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/ClosingStructure/ClosingStructureFailureMechanismCreateExtensionsTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag b3af39ba024b8e12fe238d85130697255db28c59 refers to a dead (removed) revision in file `Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/ClosingStructure/ClosingStructureFailureMechanismSectionResultCreateExtensionsTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/ClosingStructures/ClosingStructuresFailureMechanismCreateExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/ClosingStructures/ClosingStructuresFailureMechanismCreateExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/ClosingStructures/ClosingStructuresFailureMechanismCreateExtensionsTest.cs (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -0,0 +1,121 @@ +// 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.Create.ClosingStructures; +using Application.Ringtoets.Storage.DbContext; +using Application.Ringtoets.Storage.TestUtil; +using NUnit.Framework; +using Ringtoets.Integration.Data.StandAlone; + +namespace Application.Ringtoets.Storage.Test.Create.ClosingStructures +{ + [TestFixture] + public class ClosingStructuresFailureMechanismCreateExtensionsTest + { + [Test] + public void Create_WithoutPersistenceRegistry_ThrowsArgumentNullException() + { + // Setup + var failureMechanism = new ClosingStructuresFailureMechanism(); + + // 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 ClosingStructuresFailureMechanism + { + IsRelevant = isRelevant, + Comments = "Some text" + }; + var registry = new PersistenceRegistry(); + + // Call + var entity = failureMechanism.Create(registry); + + // Assert + Assert.IsNotNull(entity); + Assert.AreEqual((short) FailureMechanismType.ReliabilityClosingOfStructure, entity.FailureMechanismType); + Assert.AreEqual(Convert.ToByte(isRelevant), entity.IsRelevant); + Assert.AreEqual(failureMechanism.Comments, entity.Comments); + } + + [Test] + public void Create_StringPropertiesDoNotShareReference() + { + // Setup + const string original = "Some text"; + var failureMechanism = new ClosingStructuresFailureMechanism + { + Comments = original + }; + var registry = new PersistenceRegistry(); + + // Call + var entity = failureMechanism.Create(registry); + + // Assert + Assert.AreNotSame(original, entity.Comments, + "To create stable binary representations/fingerprints, it's really important that strings are not shared."); + Assert.AreEqual(failureMechanism.Comments, entity.Comments); + } + + [Test] + public void Create_WithoutSections_EmptyFailureMechanismSectionEntities() + { + // Setup + var failureMechanism = new ClosingStructuresFailureMechanism(); + + // Call + var entity = failureMechanism.Create(new PersistenceRegistry()); + + // Assert + Assert.IsEmpty(entity.FailureMechanismSectionEntities); + } + + [Test] + public void Create_WithSections_FailureMechanismSectionEntitiesCreated() + { + // Setup + var failureMechanism = new ClosingStructuresFailureMechanism(); + 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.ClosingStructuresSectionResultEntities).Count()); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/ClosingStructures/ClosingStructuresFailureMechanismSectionResultCreateExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/ClosingStructures/ClosingStructuresFailureMechanismSectionResultCreateExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/ClosingStructures/ClosingStructuresFailureMechanismSectionResultCreateExtensionsTest.cs (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -0,0 +1,103 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using Application.Ringtoets.Storage.Create; +using Application.Ringtoets.Storage.Create.ClosingStructures; +using Application.Ringtoets.Storage.TestUtil; +using Core.Common.Base.Data; +using NUnit.Framework; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Application.Ringtoets.Storage.Test.Create.ClosingStructures +{ + [TestFixture] + public class ClosingStructuresFailureMechanismSectionResultCreateExtensionsTest + { + [Test] + public void Create_WithoutPersistenceRegistry_ThrowsArgumentNullException() + { + // Setup + var sectionResult = new ClosingStructuresFailureMechanismSectionResult(new TestFailureMechanismSection()); + + // Call + TestDelegate test = () => sectionResult.Create(null); + + // Assert + Assert.Throws(test); + } + + [Test] + public void Create_WithDifferentResults_ReturnsEntityWithExpectedResults( + [Values(true, false)] bool assessmentLayerOneResult, + [Values(0.2, 0.523)] double assessmentLayerTwoAResult, + [Values(3.2, 4.5)] double assessmentLayerThreeResult) + { + // Setup + var sectionResult = new ClosingStructuresFailureMechanismSectionResult(new TestFailureMechanismSection()) + { + AssessmentLayerOne = assessmentLayerOneResult, + AssessmentLayerTwoA = (RoundedDouble) assessmentLayerTwoAResult, + AssessmentLayerThree = (RoundedDouble) assessmentLayerThreeResult + }; + + // Call + var result = sectionResult.Create(new PersistenceRegistry()); + + // Assert + Assert.AreEqual(Convert.ToByte(assessmentLayerOneResult), result.LayerOne); + Assert.AreEqual(assessmentLayerTwoAResult, result.LayerTwoA); + Assert.AreEqual(assessmentLayerThreeResult, result.LayerThree); + } + + [Test] + public void Create_WithNaNLevel2aResult_ReturnsEntityWithExpectedResults() + { + // Setup + var sectionResult = new ClosingStructuresFailureMechanismSectionResult(new TestFailureMechanismSection()) + { + AssessmentLayerTwoA = (RoundedDouble) double.NaN + }; + + // Call + var result = sectionResult.Create(new PersistenceRegistry()); + + // Assert + Assert.IsNull(result.LayerTwoA); + } + + [Test] + public void Create_WithNaNLevel3Result_ReturnsEntityWithExpectedResults() + { + // Setup + var sectionResult = new ClosingStructuresFailureMechanismSectionResult(new TestFailureMechanismSection()) + { + 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 -ra97ce3590a70df41b28cac28f21b12168f5c50ee -rb3af39ba024b8e12fe238d85130697255db28c59 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/StorageSqLiteIntegrationTest.cs (.../StorageSqLiteIntegrationTest.cs) (revision a97ce3590a70df41b28cac28f21b12168f5c50ee) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/StorageSqLiteIntegrationTest.cs (.../StorageSqLiteIntegrationTest.cs) (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -302,8 +302,8 @@ expectedAssessmentSection.WaterPressureAsphaltCover.SectionResults, actualAssessmentSection.WaterPressureAsphaltCover.SectionResults); AssertFailureMechanismSectionResults( - expectedAssessmentSection.ClosingStructure.SectionResults, - actualAssessmentSection.ClosingStructure.SectionResults); + expectedAssessmentSection.ClosingStructures.SectionResults, + actualAssessmentSection.ClosingStructures.SectionResults); AssertFailureMechanismSectionResults( expectedAssessmentSection.MacrostabilityOutwards.SectionResults, actualAssessmentSection.MacrostabilityOutwards.SectionResults); @@ -408,7 +408,7 @@ } } - private static void AssertFailureMechanismSectionResults(IEnumerable expectedSectionResults, IEnumerable actualSectionResults) + private static void AssertFailureMechanismSectionResults(IEnumerable expectedSectionResults, IEnumerable actualSectionResults) { var expectedSectionResultsArray = expectedSectionResults.ToArray(); var actualSectionResultsArray = actualSectionResults.ToArray(); @@ -417,8 +417,8 @@ for (var i = 0; i < expectedSectionResultsArray.Length; i++) { - ClosingStructureFailureMechanismSectionResult expectedSection = expectedSectionResultsArray[i]; - ClosingStructureFailureMechanismSectionResult actualSection = actualSectionResultsArray[i]; + ClosingStructuresFailureMechanismSectionResult expectedSection = expectedSectionResultsArray[i]; + ClosingStructuresFailureMechanismSectionResult actualSection = actualSectionResultsArray[i]; Assert.AreEqual(expectedSection.AssessmentLayerOne, actualSection.AssessmentLayerOne); Assert.AreEqual(expectedSection.AssessmentLayerTwoA, actualSection.AssessmentLayerTwoA); Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/AssessmentSectionEntityReadExtensionsTest.cs =================================================================== diff -u -r52207b1b9ba8ad1c1743bbf31d58de7bb46192b8 -rb3af39ba024b8e12fe238d85130697255db28c59 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/AssessmentSectionEntityReadExtensionsTest.cs (.../AssessmentSectionEntityReadExtensionsTest.cs) (revision 52207b1b9ba8ad1c1743bbf31d58de7bb46192b8) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/AssessmentSectionEntityReadExtensionsTest.cs (.../AssessmentSectionEntityReadExtensionsTest.cs) (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -823,7 +823,7 @@ AssertFailureMechanismEqual(isRelevant, macrostabilityOutwardsEntityComment, 2, section.MacrostabilityOutwards); AssertFailureMechanismEqual(isRelevant, microstabilityEntityComment, 2, section.Microstability); AssertFailureMechanismEqual(isRelevant, structureHeightEntityComment, 2, section.HeightStructures); - AssertFailureMechanismEqual(isRelevant, closingEntityComment, 2, section.ClosingStructure); + AssertFailureMechanismEqual(isRelevant, closingEntityComment, 2, section.ClosingStructures); AssertFailureMechanismEqual(isRelevant, failingOfConstructionPointEntityComment, 2, section.StrengthStabilityPointConstruction); AssertFailureMechanismEqual(isRelevant, failingOfConstructionLengthwiseEntityComment, 2, section.StrengthStabilityLengthwiseConstruction); AssertFailureMechanismEqual(isRelevant, waterPressureEntityComment, 2, section.WaterPressureAsphaltCover); Fisheye: Tag b3af39ba024b8e12fe238d85130697255db28c59 refers to a dead (removed) revision in file `Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/ClosingStructureSectionResultEntityReadExtensionsTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/ClosingStructures/ClosingStructuresSectionResultEntityReadExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/ClosingStructures/ClosingStructuresSectionResultEntityReadExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/ClosingStructures/ClosingStructuresSectionResultEntityReadExtensionsTest.cs (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -0,0 +1,131 @@ +// 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.Read.ClosingStructures; +using Application.Ringtoets.Storage.TestUtil; +using NUnit.Framework; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Application.Ringtoets.Storage.Test.Read.ClosingStructures +{ + [TestFixture] + public class ClosingStructuresSectionResultEntityReadExtensionsTest + { + [Test] + public void Read_SectionResultIsNull_ThrowArgumentNullException() + { + // Setup + var entity = new ClosingStructuresSectionResultEntity(); + + // Call + TestDelegate call = () => entity.Read(null); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("sectionResult", paramName); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void Read_WithDecimalParameterValues_ReturnClosingStructuresSectionResultWithDoubleParameterValues(bool layerOne) + { + // Setup + var random = new Random(21); + double layerThree = random.NextDouble(); + double layerTwoA = random.NextDouble(); + var collector = new ReadConversionCollector(); + + var failureMechanismSectionEntity = new FailureMechanismSectionEntity(); + collector.Read(failureMechanismSectionEntity, new TestFailureMechanismSection()); + var entity = new ClosingStructuresSectionResultEntity + { + LayerThree = layerThree, + LayerTwoA = layerTwoA, + LayerOne = Convert.ToByte(layerOne), + FailureMechanismSectionEntity = failureMechanismSectionEntity + }; + var sectionResult = new ClosingStructuresFailureMechanismSectionResult(new TestFailureMechanismSection()); + + // Call + entity.Read(sectionResult); + + // Assert + Assert.IsNotNull(sectionResult); + Assert.AreEqual(layerOne, sectionResult.AssessmentLayerOne); + Assert.AreEqual(layerTwoA, sectionResult.AssessmentLayerTwoA, 1e-6); + Assert.AreEqual(layerThree, sectionResult.AssessmentLayerThree, 1e-6); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void Read_WithNullLayerTwoA_ReturnClosingStructuresSectionResultWithNullParameters(bool layerOne) + { + // Setup + var collector = new ReadConversionCollector(); + var failureMechanismSectionEntity = new FailureMechanismSectionEntity(); + collector.Read(failureMechanismSectionEntity, new TestFailureMechanismSection()); + var entity = new ClosingStructuresSectionResultEntity + { + LayerOne = Convert.ToByte(layerOne), + LayerTwoA = null, + LayerThree = new Random(21).NextDouble(), + FailureMechanismSectionEntity = failureMechanismSectionEntity + }; + var sectionResult = new ClosingStructuresFailureMechanismSectionResult(new TestFailureMechanismSection()); + + // Call + entity.Read(sectionResult); + + // Assert + Assert.IsNaN(sectionResult.AssessmentLayerTwoA); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void Read_WithNullLayerThree_ReturnClosingStructuresSectionResultWithNullParameters(bool layerOne) + { + // Setup + var collector = new ReadConversionCollector(); + var failureMechanismSectionEntity = new FailureMechanismSectionEntity(); + collector.Read(failureMechanismSectionEntity, new TestFailureMechanismSection()); + var entity = new ClosingStructuresSectionResultEntity + { + LayerOne = Convert.ToByte(layerOne), + LayerTwoA = new Random(21).NextDouble(), + LayerThree = null, + FailureMechanismSectionEntity = failureMechanismSectionEntity + }; + var sectionResult = new ClosingStructuresFailureMechanismSectionResult(new TestFailureMechanismSection()); + + // Call + entity.Read(sectionResult); + + // Assert + Assert.IsNaN(sectionResult.AssessmentLayerThree); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/HeightStructuresSectionResultEntityReadExtensionsTest.cs =================================================================== diff -u -r97018b4e8e9cd81438e8fd0d111d889e20946617 -rb3af39ba024b8e12fe238d85130697255db28c59 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/HeightStructuresSectionResultEntityReadExtensionsTest.cs (.../HeightStructuresSectionResultEntityReadExtensionsTest.cs) (revision 97018b4e8e9cd81438e8fd0d111d889e20946617) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/HeightStructuresSectionResultEntityReadExtensionsTest.cs (.../HeightStructuresSectionResultEntityReadExtensionsTest.cs) (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -35,7 +35,7 @@ public void Read_SectionResultIsNull_ThrowArgumentNullException() { // Setup - var entity = new ClosingStructureSectionResultEntity(); + var entity = new HeightStructuresSectionResultEntity(); // Call TestDelegate call = () => entity.Read(null); Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/Piping/PipingSectionResultEntityReadExtensionsTest.cs =================================================================== diff -u -r97018b4e8e9cd81438e8fd0d111d889e20946617 -rb3af39ba024b8e12fe238d85130697255db28c59 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/Piping/PipingSectionResultEntityReadExtensionsTest.cs (.../PipingSectionResultEntityReadExtensionsTest.cs) (revision 97018b4e8e9cd81438e8fd0d111d889e20946617) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/Piping/PipingSectionResultEntityReadExtensionsTest.cs (.../PipingSectionResultEntityReadExtensionsTest.cs) (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -36,7 +36,7 @@ public void Read_SectionResultIsNull_ThrowArgumentNullException() { // Setup - var entity = new ClosingStructureSectionResultEntity(); + var entity = new PipingSectionResultEntity(); // Call TestDelegate call = () => entity.Read(null); Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/StrengthStabilityLengthwiseConstructionSectionResultEntityReadExtensionsTest.cs =================================================================== diff -u -r97018b4e8e9cd81438e8fd0d111d889e20946617 -rb3af39ba024b8e12fe238d85130697255db28c59 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/StrengthStabilityLengthwiseConstructionSectionResultEntityReadExtensionsTest.cs (.../StrengthStabilityLengthwiseConstructionSectionResultEntityReadExtensionsTest.cs) (revision 97018b4e8e9cd81438e8fd0d111d889e20946617) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/StrengthStabilityLengthwiseConstructionSectionResultEntityReadExtensionsTest.cs (.../StrengthStabilityLengthwiseConstructionSectionResultEntityReadExtensionsTest.cs) (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -35,7 +35,7 @@ public void Read_SectionResultIsNull_ThrowArgumentNullException() { // Setup - var entity = new ClosingStructureSectionResultEntity(); + var entity = new StrengthStabilityLengthwiseConstructionSectionResultEntity(); // Call TestDelegate call = () => entity.Read(null); Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/TechnicalInnovationSectionResultEntityReadExtensionsTest.cs =================================================================== diff -u -r97018b4e8e9cd81438e8fd0d111d889e20946617 -rb3af39ba024b8e12fe238d85130697255db28c59 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/TechnicalInnovationSectionResultEntityReadExtensionsTest.cs (.../TechnicalInnovationSectionResultEntityReadExtensionsTest.cs) (revision 97018b4e8e9cd81438e8fd0d111d889e20946617) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/TechnicalInnovationSectionResultEntityReadExtensionsTest.cs (.../TechnicalInnovationSectionResultEntityReadExtensionsTest.cs) (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -35,7 +35,7 @@ public void Read_SectionResultIsNull_ThrowArgumentNullException() { // Setup - var entity = new ClosingStructureSectionResultEntity(); + var entity = new TechnicalInnovationSectionResultEntity(); // Call TestDelegate call = () => entity.Read(null); Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/WaterPressureAsphaltCoverSectionResultEntityReadExtensionsTest.cs =================================================================== diff -u -r97018b4e8e9cd81438e8fd0d111d889e20946617 -rb3af39ba024b8e12fe238d85130697255db28c59 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/WaterPressureAsphaltCoverSectionResultEntityReadExtensionsTest.cs (.../WaterPressureAsphaltCoverSectionResultEntityReadExtensionsTest.cs) (revision 97018b4e8e9cd81438e8fd0d111d889e20946617) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/WaterPressureAsphaltCoverSectionResultEntityReadExtensionsTest.cs (.../WaterPressureAsphaltCoverSectionResultEntityReadExtensionsTest.cs) (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -35,7 +35,7 @@ public void Read_SectionResultIsNull_ThrowArgumentNullException() { // Setup - var entity = new ClosingStructureSectionResultEntity(); + var entity = new WaterPressureAsphaltCoverSectionResultEntity(); // Call TestDelegate call = () => entity.Read(null); Index: Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsProjectTestHelper.cs =================================================================== diff -u -rcc8cd8bb3747e3578ffadc0851675302aeaca01a -rb3af39ba024b8e12fe238d85130697255db28c59 --- Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsProjectTestHelper.cs (.../RingtoetsProjectTestHelper.cs) (revision cc8cd8bb3747e3578ffadc0851675302aeaca01a) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsProjectTestHelper.cs (.../RingtoetsProjectTestHelper.cs) (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -106,8 +106,8 @@ SetSectionResults(assessmentSection.GrassCoverSlipOffOutwards.SectionResults); AddSections(assessmentSection.HeightStructures); SetSectionResults(assessmentSection.HeightStructures.SectionResults); - AddSections(assessmentSection.ClosingStructure); - SetSectionResults(assessmentSection.ClosingStructure.SectionResults); + AddSections(assessmentSection.ClosingStructures); + SetSectionResults(assessmentSection.ClosingStructures.SectionResults); AddSections(assessmentSection.StrengthStabilityPointConstruction); SetSectionResults(assessmentSection.StrengthStabilityPointConstruction.SectionResults); AddSections(assessmentSection.StrengthStabilityLengthwiseConstruction); @@ -171,7 +171,7 @@ } } - private static void SetSectionResults(IEnumerable sectionResults) + private static void SetSectionResults(IEnumerable sectionResults) { var random = new Random(21); foreach (var sectionResult in sectionResults) Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/AssessmentSection.cs =================================================================== diff -u -r11f0867b39150ae5fac83dc178a89fee46d27611 -rb3af39ba024b8e12fe238d85130697255db28c59 --- Ringtoets/Integration/src/Ringtoets.Integration.Data/AssessmentSection.cs (.../AssessmentSection.cs) (revision 11f0867b39150ae5fac83dc178a89fee46d27611) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/AssessmentSection.cs (.../AssessmentSection.cs) (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -67,7 +67,7 @@ GrassCoverSlipOffOutwards = new GrassCoverSlipOffOutwardsFailureMechanism(); GrassCoverSlipOffInwards = new GrassCoverSlipOffInwardsFailureMechanism(); HeightStructures = new HeightStructuresFailureMechanism(); - ClosingStructure = new ClosingStructureFailureMechanism(); + ClosingStructures = new ClosingStructuresFailureMechanism(); StrengthStabilityPointConstruction = new StrengthStabilityPointConstructionFailureMechanism(); StrengthStabilityLengthwiseConstruction = new StrengthStabilityLengthwiseConstructionFailureMechanism(); PipingStructure = new PipingStructureFailureMechanism(); @@ -141,7 +141,7 @@ /// /// Gets the "Kunstwerken - Betrouwbaarheid sluiting kunstwerk" failure mechanism. /// - public ClosingStructureFailureMechanism ClosingStructure { get; private set; } + public ClosingStructuresFailureMechanism ClosingStructures { get; private set; } /// /// Gets the "Kunstwerken - Piping bij kunstwerk" failure mechanism. @@ -207,7 +207,7 @@ yield return GrassCoverSlipOffOutwards; yield return GrassCoverSlipOffInwards; yield return HeightStructures; - yield return ClosingStructure; + yield return ClosingStructures; yield return PipingStructure; yield return StrengthStabilityPointConstruction; yield return StrengthStabilityLengthwiseConstruction; @@ -228,7 +228,7 @@ GrassCoverErosionOutwards.Contribution = 5; GrassCoverSlipOffOutwards.Contribution = 1; HeightStructures.Contribution = 24; - ClosingStructure.Contribution = 4; + ClosingStructures.Contribution = 4; PipingStructure.Contribution = 2; StrengthStabilityPointConstruction.Contribution = 2; DuneErosion.Contribution = 0; @@ -243,7 +243,7 @@ GrassCoverErosionOutwards.Contribution = 0; GrassCoverSlipOffOutwards.Contribution = 0; HeightStructures.Contribution = 0; - ClosingStructure.Contribution = 0; + ClosingStructures.Contribution = 0; PipingStructure.Contribution = 0; StrengthStabilityPointConstruction.Contribution = 0; DuneErosion.Contribution = 70; @@ -258,7 +258,7 @@ GrassCoverErosionOutwards.Contribution = 5; GrassCoverSlipOffOutwards.Contribution = 1; HeightStructures.Contribution = 24; - ClosingStructure.Contribution = 4; + ClosingStructures.Contribution = 4; PipingStructure.Contribution = 2; StrengthStabilityPointConstruction.Contribution = 2; DuneErosion.Contribution = 10; @@ -280,7 +280,7 @@ yield return GrassCoverErosionOutwards; yield return GrassCoverSlipOffOutwards; yield return HeightStructures; - yield return ClosingStructure; + yield return ClosingStructures; yield return PipingStructure; yield return StrengthStabilityPointConstruction; yield return DuneErosion; Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/Properties/Resources.Designer.cs =================================================================== diff -u -re05b8947a4f5a41c2cb8b3f5460daf20ab77b2c8 -rb3af39ba024b8e12fe238d85130697255db28c59 --- Ringtoets/Integration/src/Ringtoets.Integration.Data/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision e05b8947a4f5a41c2cb8b3f5460daf20ab77b2c8) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -22,7 +22,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.18444 +// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -102,18 +102,18 @@ /// /// Looks up a localized string similar to BSKW. /// - public static string ClosingStructureFailureMechanism_Code { + public static string ClosingStructuresFailureMechanism_Code { get { - return ResourceManager.GetString("ClosingStructureFailureMechanism_Code", resourceCulture); + return ResourceManager.GetString("ClosingStructuresFailureMechanism_Code", resourceCulture); } } /// /// Looks up a localized string similar to Kunstwerken - Betrouwbaarheid sluiting kunstwerk. /// - public static string ClosingStructureFailureMechanism_DisplayName { + public static string ClosingStructuresFailureMechanism_DisplayName { get { - return ResourceManager.GetString("ClosingStructureFailureMechanism_DisplayName", resourceCulture); + return ResourceManager.GetString("ClosingStructuresFailureMechanism_DisplayName", resourceCulture); } } Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/Properties/Resources.resx =================================================================== diff -u -re05b8947a4f5a41c2cb8b3f5460daf20ab77b2c8 -rb3af39ba024b8e12fe238d85130697255db28c59 --- Ringtoets/Integration/src/Ringtoets.Integration.Data/Properties/Resources.resx (.../Resources.resx) (revision e05b8947a4f5a41c2cb8b3f5460daf20ab77b2c8) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/Properties/Resources.resx (.../Resources.resx) (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -135,7 +135,7 @@ Kunstwerken - Sterkte en stabiliteit puntconstructies - + Kunstwerken - Betrouwbaarheid sluiting kunstwerk @@ -150,7 +150,7 @@ GABU - + BSKW Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/Ringtoets.Integration.Data.csproj =================================================================== diff -u -r944d2501b3f780d208e00015a1b850afad4c3aa8 -rb3af39ba024b8e12fe238d85130697255db28c59 --- Ringtoets/Integration/src/Ringtoets.Integration.Data/Ringtoets.Integration.Data.csproj (.../Ringtoets.Integration.Data.csproj) (revision 944d2501b3f780d208e00015a1b850afad4c3aa8) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/Ringtoets.Integration.Data.csproj (.../Ringtoets.Integration.Data.csproj) (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -44,7 +44,7 @@ - + @@ -63,7 +63,7 @@ - + Fisheye: Tag b3af39ba024b8e12fe238d85130697255db28c59 refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/ClosingStructureFailureMechanism.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/ClosingStructuresFailureMechanism.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/ClosingStructuresFailureMechanism.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/ClosingStructuresFailureMechanism.cs (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -0,0 +1,77 @@ +// 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.Collections.Generic; +using Ringtoets.Common.Data.Calculation; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Integration.Data.Properties; +using Ringtoets.Integration.Data.StandAlone.SectionResults; +using RingtoetsCommonDataResources = Ringtoets.Common.Data.Properties.Resources; + +namespace Ringtoets.Integration.Data.StandAlone +{ + /// + /// Model containing input and output needed to perform different levels of the + /// Closing Structures failure mechanism. + /// + public class ClosingStructuresFailureMechanism : FailureMechanismBase, IHasSectionResults + { + private readonly List sectionResults; + + /// + /// Initializes a new instance of the class. + /// + public ClosingStructuresFailureMechanism() + : base(Resources.ClosingStructuresFailureMechanism_DisplayName, Resources.ClosingStructuresFailureMechanism_Code) + { + sectionResults = new List(); + } + + public override IEnumerable Calculations + { + get + { + yield break; + } + } + + public IEnumerable SectionResults + { + get + { + return sectionResults; + } + } + + public override void AddSection(FailureMechanismSection section) + { + base.AddSection(section); + + sectionResults.Add(new ClosingStructuresFailureMechanismSectionResult(section)); + } + + public override void ClearAllSections() + { + base.ClearAllSections(); + sectionResults.Clear(); + } + } +} \ No newline at end of file Fisheye: Tag b3af39ba024b8e12fe238d85130697255db28c59 refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/SectionResults/ClosingStructureFailureMechanismSectionResult.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/SectionResults/ClosingStructuresFailureMechanismSectionResult.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/SectionResults/ClosingStructuresFailureMechanismSectionResult.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/SectionResults/ClosingStructuresFailureMechanismSectionResult.cs (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -0,0 +1,80 @@ +// 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 Core.Common.Base.Data; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.Properties; + +namespace Ringtoets.Integration.Data.StandAlone.SectionResults +{ + /// + /// This class holds information about the result of a calculation on section level for the + /// Closing Structures failure mechanism. + /// + public class ClosingStructuresFailureMechanismSectionResult : FailureMechanismSectionResult + { + private double assessmentLayerTwoA; + + /// + /// Creates a new instance of . + /// + /// The for which the + /// will hold the result. + /// Thrown when is null. + public ClosingStructuresFailureMechanismSectionResult(FailureMechanismSection section) + : base(section) + { + AssessmentLayerTwoA = double.NaN; + AssessmentLayerThree = (RoundedDouble) double.NaN; + } + + /// + /// Gets or sets the value representing whether the simple assessment of safety passed. + /// + public bool AssessmentLayerOne { get; set; } + + /// + /// Gets or sets the value for the detailed assessment of safety per failure mechanism section as a probability. + /// + /// Thrown when is not in range [0,1]. + public double AssessmentLayerTwoA + { + get + { + return assessmentLayerTwoA; + } + set + { + if (!double.IsNaN(value) && (value < 0 || value > 1)) + { + throw new ArgumentException(Resources.ArbitraryProbabilityFailureMechanismSectionResult_AssessmentLayerTwoA_Value_needs_to_be_between_0_and_1); + } + assessmentLayerTwoA = value; + } + } + + /// + /// Gets or sets the value of the tailored assessment of safety. + /// + public RoundedDouble AssessmentLayerThree { get; set; } + } +} \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj =================================================================== diff -u -r51d8e744ffb2168ca56ca4b6260ad9c2590c0170 -rb3af39ba024b8e12fe238d85130697255db28c59 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision 51d8e744ffb2168ca56ca4b6260ad9c2590c0170) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -98,7 +98,7 @@ DesignWaterLevelLocationsView.cs - + @@ -110,7 +110,7 @@ - + UserControl Fisheye: Tag b3af39ba024b8e12fe238d85130697255db28c59 refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/ClosingStructureSectionResultRow.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/ClosingStructuresSectionResultRow.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/ClosingStructuresSectionResultRow.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/ClosingStructuresSectionResultRow.cs (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -0,0 +1,93 @@ +// 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.ComponentModel; +using Core.Common.Base.Data; +using Ringtoets.Common.Forms.TypeConverters; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Ringtoets.Integration.Forms.Views.SectionResultRows +{ + /// + /// Class for displaying as a row in a grid view. + /// + public class ClosingStructuresSectionResultRow : FailureMechanismSectionResultRow + { + /// + /// Creates a new instance of . + /// + /// The to wrap + /// so that it can be displayed as a row. + /// Thrown when is null. + public ClosingStructuresSectionResultRow(ClosingStructuresFailureMechanismSectionResult sectionResult) : base(sectionResult) { } + + /// + /// Gets or sets the value representing the result of the . + /// + public bool AssessmentLayerOne + { + get + { + return SectionResult.AssessmentLayerOne; + } + set + { + SectionResult.AssessmentLayerOne = value; + SectionResult.NotifyObservers(); + } + } + + /// + /// Gets or sets the value representing the result of the . + /// + /// Thrown when is + /// not in the range [0,1]. + [TypeConverter(typeof(FailureMechanismSectionResultNoProbabilityValueDoubleConverter))] + public double AssessmentLayerTwoA + { + get + { + return SectionResult.AssessmentLayerTwoA; + } + set + { + SectionResult.AssessmentLayerTwoA = value; + } + } + + /// + /// Gets or sets the value representing the result of the . + /// + [TypeConverter(typeof(NoValueRoundedDoubleConverter))] + public RoundedDouble AssessmentLayerThree + { + get + { + return SectionResult.AssessmentLayerThree; + } + set + { + SectionResult.AssessmentLayerThree = value; + } + } + } +} \ No newline at end of file Fisheye: Tag b3af39ba024b8e12fe238d85130697255db28c59 refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/ClosingStructureResultView.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/ClosingStructuresResultView.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/ClosingStructuresResultView.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/ClosingStructuresResultView.cs (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -0,0 +1,92 @@ +// 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.Windows.Forms; +using Core.Common.Utils.Reflection; +using Ringtoets.Common.Forms.Views; +using Ringtoets.Integration.Data.StandAlone.SectionResults; +using Ringtoets.Integration.Forms.Views.SectionResultRows; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.Integration.Forms.Views.SectionResultViews +{ + /// + /// The view for a collection of . + /// + public class ClosingStructuresResultView : FailureMechanismResultView + { + private const int assessmentLayerOneColumnIndex = 1; + + /// + /// Creates a new instance of . + /// + public ClosingStructuresResultView() + { + DataGridViewControl.AddCellFormattingHandler(OnCellFormatting); + + AddDataGridColumns(); + } + + protected override object CreateFailureMechanismSectionResultRow(ClosingStructuresFailureMechanismSectionResult sectionResult) + { + return new ClosingStructuresSectionResultRow(sectionResult); + } + + protected override void Dispose(bool disposing) + { + DataGridViewControl.RemoveCellFormattingHandler(OnCellFormatting); + + base.Dispose(disposing); + } + + private void AddDataGridColumns() + { + DataGridViewControl.AddTextBoxColumn( + TypeUtils.GetMemberName(sr => sr.Name), + RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Section_name, + true); + DataGridViewControl.AddCheckBoxColumn( + TypeUtils.GetMemberName(sr => sr.AssessmentLayerOne), + RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_one); + DataGridViewControl.AddTextBoxColumn( + TypeUtils.GetMemberName(sr => sr.AssessmentLayerTwoA), + RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_two_a); + DataGridViewControl.AddTextBoxColumn( + TypeUtils.GetMemberName(sr => sr.AssessmentLayerThree), + RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_three); + } + + private void OnCellFormatting(object sender, DataGridViewCellFormattingEventArgs eventArgs) + { + if (eventArgs.ColumnIndex > assessmentLayerOneColumnIndex) + { + if (HasPassedLevelOne(eventArgs.RowIndex)) + { + DataGridViewControl.DisableCell(eventArgs.RowIndex, eventArgs.ColumnIndex); + } + else + { + DataGridViewControl.RestoreCell(eventArgs.RowIndex, eventArgs.ColumnIndex); + } + } + } + } +} \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs =================================================================== diff -u -r88b44f34ed4dd17abbc44d54932215754cfd0601 -rb3af39ba024b8e12fe238d85130697255db28c59 --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 88b44f34ed4dd17abbc44d54932215754cfd0601) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -187,7 +187,7 @@ assessmentSection) ), new FailureMechanismContextAssociation( - typeof(ClosingStructureFailureMechanism), + typeof(ClosingStructuresFailureMechanism), (mechanism, assessmentSection) => new FailureMechanismContext( mechanism, assessmentSection) @@ -381,8 +381,8 @@ StrengthStabilityPointConstructionFailureMechanismSectionResult, StrengthStabilityPointConstructionResultView>(); yield return CreateFailureMechanismResultViewInfo< - ClosingStructureFailureMechanismSectionResult, - ClosingStructureResultView>(); + ClosingStructuresFailureMechanismSectionResult, + ClosingStructuresResultView>(); yield return new ViewInfo, ICommentable, CommentView> { @@ -622,7 +622,7 @@ yield return CreateFailureMechanismSectionResultTreeNodeInfo(); yield return CreateFailureMechanismSectionResultTreeNodeInfo(); yield return CreateFailureMechanismSectionResultTreeNodeInfo(); - yield return CreateFailureMechanismSectionResultTreeNodeInfo(); + yield return CreateFailureMechanismSectionResultTreeNodeInfo(); yield return CreateFailureMechanismSectionResultTreeNodeInfo(); yield return CreateFailureMechanismSectionResultTreeNodeInfo(); yield return CreateFailureMechanismSectionResultTreeNodeInfo(); @@ -979,7 +979,7 @@ var strengthStabilityLengthwiseConstruction = nodeData as IHasSectionResults; var waterPressureAsphaltCover = nodeData as IHasSectionResults; var waveImpactAsphaltCover = nodeData as IHasSectionResults; - var closingStructure = nodeData as IHasSectionResults; + var closingStructures = nodeData as IHasSectionResults; var macrostabilityInwards = nodeData as IHasSectionResults; var macrostabilityOutwards = nodeData as IHasSectionResults; var strengthStabilityPointConstruction = nodeData as IHasSectionResults; @@ -1035,10 +1035,10 @@ failureMechanismSectionResultContexts[0] = new FailureMechanismSectionResultContext(waveImpactAsphaltCover.SectionResults, nodeData); } - if (closingStructure != null) + if (closingStructures != null) { failureMechanismSectionResultContexts[0] = - new FailureMechanismSectionResultContext(closingStructure.SectionResults, nodeData); + new FailureMechanismSectionResultContext(closingStructures.SectionResults, nodeData); } if (macrostabilityInwards != null) { Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/AssessmentSectionTest.cs =================================================================== diff -u -rf2be29fe8c407a4f32cb1bfcbaf4816c1f99c83f -rb3af39ba024b8e12fe238d85130697255db28c59 --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/AssessmentSectionTest.cs (.../AssessmentSectionTest.cs) (revision f2be29fe8c407a4f32cb1bfcbaf4816c1f99c83f) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/AssessmentSectionTest.cs (.../AssessmentSectionTest.cs) (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -45,33 +45,33 @@ // Call var section = new AssessmentSection(composition); - var pipingName = "Dijken en dammen - Piping"; - var grassErosionInsideName = "Dijken en dammen - Grasbekleding erosie kruin en binnentalud"; - var macrostabilityInwardName = "Dijken en dammen - Macrostabiliteit binnenwaarts"; - var stoneRevetmentName = "Dijken en dammen - Stabiliteit steenzetting"; - var waveImpactAsphaltName = "Dijken en dammen - Golfklappen op asfaltbekleding"; - var grassCoverErosionOutwardsName = "Dijken en dammen - Grasbekleding erosie buitentalud"; - var grassCoverSlipOffOutsideName = "Dijken en dammen - Grasbekleding afschuiven buitentalud"; - var heightStructureName = "Kunstwerken - Hoogte kunstwerk"; - var closingStructureName = "Kunstwerken - Betrouwbaarheid sluiting kunstwerk"; - var pipingStructureName = "Kunstwerken - Piping bij kunstwerk"; - var strengthStabilityPointConstructionName = "Kunstwerken - Sterkte en stabiliteit puntconstructies"; - var duneErosionName = "Duinwaterkering - Duinafslag"; - var otherName = "Overig"; + const string pipingName = "Dijken en dammen - Piping"; + const string grassErosionInsideName = "Dijken en dammen - Grasbekleding erosie kruin en binnentalud"; + const string macrostabilityInwardName = "Dijken en dammen - Macrostabiliteit binnenwaarts"; + const string stoneRevetmentName = "Dijken en dammen - Stabiliteit steenzetting"; + const string waveImpactAsphaltName = "Dijken en dammen - Golfklappen op asfaltbekleding"; + const string grassCoverErosionOutwardsName = "Dijken en dammen - Grasbekleding erosie buitentalud"; + const string grassCoverSlipOffOutsideName = "Dijken en dammen - Grasbekleding afschuiven buitentalud"; + const string heightStructuresName = "Kunstwerken - Hoogte kunstwerk"; + const string closingStructuresName = "Kunstwerken - Betrouwbaarheid sluiting kunstwerk"; + const string pipingStructuresName = "Kunstwerken - Piping bij kunstwerk"; + const string strengthStabilityPointConstructionName = "Kunstwerken - Sterkte en stabiliteit puntconstructies"; + const string duneErosionName = "Duinwaterkering - Duinafslag"; + const string otherName = "Overig"; - var pipingCode = "STPH"; - var grassErosionInsideCode = "GEKB"; - var macrostabilityInwardCode = "STBI"; - var stoneRevetmentCode = "ZST"; - var waveImpactAsphaltCode = "AGK"; - var grassCoverErosionOutwardsCode = "GEBU"; - var grassCoverSlipOffOutsideCode = "GABU"; - var heightStructureCode = "HTKW"; - var closingStructureCode = "BSKW"; - var pipingStructureCode = "PKW"; - var strengthStabilityPointConstructionCode = "STKWp"; - var duneErosionCode = "DA"; - var otherCode = "-"; + const string pipingCode = "STPH"; + const string grassErosionInsideCode = "GEKB"; + const string macrostabilityInwardCode = "STBI"; + const string stoneRevetmentCode = "ZST"; + const string waveImpactAsphaltCode = "AGK"; + const string grassCoverErosionOutwardsCode = "GEBU"; + const string grassCoverSlipOffOutsideCode = "GABU"; + const string heightStructuresCode = "HTKW"; + const string closingStructuresCode = "BSKW"; + const string pipingStructuresCode = "PKW"; + const string strengthStabilityPointConstructionCode = "STKWp"; + const string duneErosionCode = "DA"; + const string otherCode = "-"; var names = new[] { @@ -82,9 +82,9 @@ waveImpactAsphaltName, grassCoverErosionOutwardsName, grassCoverSlipOffOutsideName, - heightStructureName, - closingStructureName, - pipingStructureName, + heightStructuresName, + closingStructuresName, + pipingStructuresName, strengthStabilityPointConstructionName, duneErosionName, otherName @@ -99,9 +99,9 @@ waveImpactAsphaltCode, grassCoverErosionOutwardsCode, grassCoverSlipOffOutsideCode, - heightStructureCode, - closingStructureCode, - pipingStructureCode, + heightStructuresCode, + closingStructuresCode, + pipingStructuresCode, strengthStabilityPointConstructionCode, duneErosionCode, otherCode @@ -133,7 +133,7 @@ Assert.NotNull(section.GrassCoverSlipOffOutwards); Assert.NotNull(section.GrassCoverSlipOffInwards); Assert.NotNull(section.HeightStructures); - Assert.NotNull(section.ClosingStructure); + Assert.NotNull(section.ClosingStructures); Assert.NotNull(section.PipingStructure); Assert.NotNull(section.StrengthStabilityPointConstruction); Assert.NotNull(section.StrengthStabilityLengthwiseConstruction); @@ -207,7 +207,7 @@ assessmentSection.GrassCoverSlipOffOutwards, assessmentSection.GrassCoverSlipOffInwards, assessmentSection.HeightStructures, - assessmentSection.ClosingStructure, + assessmentSection.ClosingStructures, assessmentSection.PipingStructure, assessmentSection.StrengthStabilityPointConstruction, assessmentSection.StrengthStabilityLengthwiseConstruction, @@ -352,7 +352,7 @@ section.GrassCoverErosionOutwards, section.GrassCoverSlipOffOutwards, section.HeightStructures, - section.ClosingStructure, + section.ClosingStructures, section.PipingStructure, section.StrengthStabilityPointConstruction, section.DuneErosion, @@ -371,7 +371,7 @@ Assert.AreEqual(contributions[5], assessmentSection.GrassCoverErosionOutwards.Contribution); Assert.AreEqual(contributions[6], assessmentSection.GrassCoverSlipOffOutwards.Contribution); Assert.AreEqual(contributions[7], assessmentSection.HeightStructures.Contribution); - Assert.AreEqual(contributions[8], assessmentSection.ClosingStructure.Contribution); + Assert.AreEqual(contributions[8], assessmentSection.ClosingStructures.Contribution); Assert.AreEqual(contributions[9], assessmentSection.PipingStructure.Contribution); Assert.AreEqual(contributions[10], assessmentSection.StrengthStabilityPointConstruction.Contribution); Assert.AreEqual(contributions[11], assessmentSection.DuneErosion.Contribution); Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/Ringtoets.Integration.Data.Test.csproj =================================================================== diff -u -r944d2501b3f780d208e00015a1b850afad4c3aa8 -rb3af39ba024b8e12fe238d85130697255db28c59 --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/Ringtoets.Integration.Data.Test.csproj (.../Ringtoets.Integration.Data.Test.csproj) (revision 944d2501b3f780d208e00015a1b850afad4c3aa8) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/Ringtoets.Integration.Data.Test.csproj (.../Ringtoets.Integration.Data.Test.csproj) (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -56,10 +56,10 @@ - + - + Fisheye: Tag b3af39ba024b8e12fe238d85130697255db28c59 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/ClosingStructureFailureMechanismTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/ClosingStructuresFailureMechanismTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/ClosingStructuresFailureMechanismTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/ClosingStructuresFailureMechanismTest.cs (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -0,0 +1,66 @@ +// 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.Linq; +using Core.Common.Base.Geometry; +using NUnit.Framework; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Integration.Data.StandAlone; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Ringtoets.Integration.Data.Test.StandAlone +{ + [TestFixture] + public class ClosingStructuresFailureMechanismTest + { + [Test] + public void DefaultConstructor_Always_PropertiesSet() + { + // Call + var failureMechanism = new ClosingStructuresFailureMechanism(); + + // Assert + Assert.IsInstanceOf(failureMechanism); + Assert.IsInstanceOf>(failureMechanism); + Assert.AreEqual("Kunstwerken - Betrouwbaarheid sluiting kunstwerk", failureMechanism.Name); + Assert.AreEqual("BSKW", failureMechanism.Code); + CollectionAssert.IsEmpty(failureMechanism.Sections); + CollectionAssert.IsEmpty(failureMechanism.Calculations); + } + + [Test] + public void AddSection_WithSection_AddedClosingStructuresFailureMechanismSectionResult() + { + // Setup + var failureMechanism = new ClosingStructuresFailureMechanism(); + + // Call + failureMechanism.AddSection(new FailureMechanismSection("", new[] + { + new Point2D(2, 1) + })); + + // Assert + Assert.AreEqual(1, failureMechanism.SectionResults.Count()); + Assert.IsInstanceOf(failureMechanism.SectionResults.ElementAt(0)); + } + } +} \ No newline at end of file Fisheye: Tag b3af39ba024b8e12fe238d85130697255db28c59 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/SectionResults/ClosingStructureFailureMechanismSectionResultTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/SectionResults/ClosingStructuresFailureMechanismSectionResultTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/SectionResults/ClosingStructuresFailureMechanismSectionResultTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/SectionResults/ClosingStructuresFailureMechanismSectionResultTest.cs (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -0,0 +1,111 @@ +// 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 Core.Common.Base.Geometry; +using NUnit.Framework; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.Properties; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Ringtoets.Integration.Data.Test.StandAlone.SectionResults +{ + [TestFixture] + public class ClosingStructuresFailureMechanismSectionResultTest + { + [Test] + public void Constructor_WithoutSection_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new ClosingStructuresFailureMechanismSectionResult(null); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("section", paramName); + } + + [Test] + public void Constructor_WithSection_ResultCreatedForSection() + { + // Setup + var section = new FailureMechanismSection("Section", new[] + { + new Point2D(0, 0) + }); + + // Call + var result = new ClosingStructuresFailureMechanismSectionResult(section); + + // Assert + Assert.IsInstanceOf(result); + Assert.AreSame(section, result.Section); + Assert.IsFalse(result.AssessmentLayerOne); + Assert.IsNaN(result.AssessmentLayerTwoA); + Assert.IsNaN(result.AssessmentLayerThree); + } + + [Test] + [TestCase(-20)] + [TestCase(-1e-6)] + [TestCase(1 + 1e-6)] + [TestCase(12)] + public void AssessmentLayerTwoA_ForInvalidValues_ThrowsException(double a) + { + // Setup + var section = new FailureMechanismSection("Section", new[] + { + new Point2D(0, 0) + }); + var result = new ClosingStructuresFailureMechanismSectionResult(section); + + // Call + TestDelegate test = () => result.AssessmentLayerTwoA = a; + + // Assert + var message = Assert.Throws(test).Message; + Assert.AreEqual( + Resources.ArbitraryProbabilityFailureMechanismSectionResult_AssessmentLayerTwoA_Value_needs_to_be_between_0_and_1, + message); + } + + [Test] + [TestCase(0)] + [TestCase(1e-6)] + [TestCase(0.5)] + [TestCase(1 - 1e-6)] + [TestCase(1)] + public void AssessmentLayerTwoA_ForValidValues_NewValueSet(double a) + { + // Setup + var section = new FailureMechanismSection("Section", new[] + { + new Point2D(0, 0) + }); + var result = new ClosingStructuresFailureMechanismSectionResult(section); + + // Call + result.AssessmentLayerTwoA = a; + + // Assert + Assert.AreEqual(a, result.AssessmentLayerTwoA); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj =================================================================== diff -u -r1e9a35d13ae40069200f8b1e6c1aa91bb54ce086 -rb3af39ba024b8e12fe238d85130697255db28c59 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision 1e9a35d13ae40069200f8b1e6c1aa91bb54ce086) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -95,7 +95,7 @@ - + @@ -127,7 +127,7 @@ - + @@ -145,7 +145,7 @@ - + Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/AssessmentSectionTreeNodeInfoTest.cs =================================================================== diff -u -r944d2501b3f780d208e00015a1b850afad4c3aa8 -rb3af39ba024b8e12fe238d85130697255db28c59 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/AssessmentSectionTreeNodeInfoTest.cs (.../AssessmentSectionTreeNodeInfoTest.cs) (revision 944d2501b3f780d208e00015a1b850afad4c3aa8) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/AssessmentSectionTreeNodeInfoTest.cs (.../AssessmentSectionTreeNodeInfoTest.cs) (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -209,9 +209,9 @@ Assert.AreSame(assessmentSection.HeightStructures, heightStructuresFailureMechanismContext.WrappedData); Assert.AreSame(assessmentSection, heightStructuresFailureMechanismContext.Parent); - var closingStructureFailureMechnaismContext = (FailureMechanismContext)objects[16]; - Assert.AreSame(assessmentSection.ClosingStructure, closingStructureFailureMechnaismContext.WrappedData); - Assert.AreSame(assessmentSection, closingStructureFailureMechnaismContext.Parent); + var closingStructuresFailureMechanismContext = (FailureMechanismContext)objects[16]; + Assert.AreSame(assessmentSection.ClosingStructures, closingStructuresFailureMechanismContext.WrappedData); + Assert.AreSame(assessmentSection, closingStructuresFailureMechanismContext.Parent); var pipingStructureFailureMechanismContext = (FailureMechanismContext)objects[17]; Assert.AreSame(assessmentSection.PipingStructure, pipingStructureFailureMechanismContext.WrappedData); Assert.AreSame(assessmentSection, pipingStructureFailureMechanismContext.Parent); Fisheye: Tag b3af39ba024b8e12fe238d85130697255db28c59 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/ClosingStructureFailureMechanismSectionResultContextTreeNodeInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/ClosingStructuresFailureMechanismSectionResultContextTreeNodeInfoTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/ClosingStructuresFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/ClosingStructuresFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -0,0 +1,140 @@ +// 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.Linq; +using Core.Common.Controls.TreeView; +using Core.Common.Gui; +using Core.Common.Gui.ContextMenu; +using Core.Common.TestUtil; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Forms.PresentationObjects; +using Ringtoets.Common.Forms.Properties; +using Ringtoets.Integration.Data.StandAlone; +using Ringtoets.Integration.Data.StandAlone.SectionResults; +using Ringtoets.Integration.Plugin; + +namespace Ringtoets.Integration.Forms.Test.TreeNodeInfos +{ + [TestFixture] + public class ClosingStructuresFailureMechanismSectionResultContextTreeNodeInfoTest + { + private MockRepository mocks; + private RingtoetsPlugin plugin; + private TreeNodeInfo info; + + [SetUp] + public void SetUp() + { + mocks = new MockRepository(); + plugin = new RingtoetsPlugin(); + info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(FailureMechanismSectionResultContext)); + } + + [TearDown] + public void TearDown() + { + plugin.Dispose(); + mocks.VerifyAll(); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Setup + mocks.ReplayAll(); + + // Assert + Assert.AreEqual(typeof(FailureMechanismSectionResultContext), info.TagType); + + Assert.IsNull(info.ChildNodeObjects); + Assert.IsNull(info.ForeColor); + Assert.IsNull(info.EnsureVisibleOnCreate); + Assert.IsNull(info.CanRename); + Assert.IsNull(info.OnNodeRenamed); + Assert.IsNull(info.CanRemove); + Assert.IsNull(info.OnNodeRemoved); + Assert.IsNull(info.CanCheck); + Assert.IsNull(info.IsChecked); + Assert.IsNull(info.OnNodeChecked); + Assert.IsNull(info.CanDrag); + Assert.IsNull(info.CanDrop); + Assert.IsNull(info.CanInsert); + Assert.IsNull(info.OnDrop); + } + + [Test] + public void Text_Always_ReturnsName() + { + // Setup + mocks.ReplayAll(); + + var mechanism = new ClosingStructuresFailureMechanism(); + var context = new FailureMechanismSectionResultContext(mechanism.SectionResults, mechanism); + + // Call + var text = info.Text(context); + + // Assert + Assert.AreEqual("Resultaat", text); + } + + [Test] + public void Image_Always_ReturnsGenericInputOutputIcon() + { + // Setup + mocks.ReplayAll(); + + // Call + var image = info.Image(null); + + // Assert + TestHelper.AssertImagesAreEqual(Resources.FailureMechanismSectionResultIcon, image); + } + + [Test] + public void ContextMenuStrip_Always_CallsBuilder() + { + // Setup + var gui = mocks.Stub(); + var menuBuilderMock = mocks.StrictMock(); + + using (var treeViewControl = new TreeViewControl()) + { + gui.Expect(g => g.Get(null, treeViewControl)).Return(menuBuilderMock); + gui.Expect(g => g.ProjectOpened += null).IgnoreArguments(); + gui.Expect(g => g.ProjectOpened -= null).IgnoreArguments(); + + menuBuilderMock.Expect(mb => mb.AddOpenItem()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.Build()).Return(null); + + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + info.ContextMenuStrip(null, null, treeViewControl); + } + // Assert + // Assert expectancies are called in TearDown() + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -rff8a088931e6af2e46f6f4f09b633bcdd0b84ecd -rb3af39ba024b8e12fe238d85130697255db28c59 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismContextTreeNodeInfoTest.cs (.../FailureMechanismContextTreeNodeInfoTest.cs) (revision ff8a088931e6af2e46f6f4f09b633bcdd0b84ecd) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismContextTreeNodeInfoTest.cs (.../FailureMechanismContextTreeNodeInfoTest.cs) (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -212,8 +212,8 @@ TestName = "ChildNodeObjects_FailureMechanismIsRelevant_OutputNodeAddedForResult(StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult)")] [TestCase(typeof(WaterPressureAsphaltCoverFailureMechanismSectionResult), TestName = "ChildNodeObjects_FailureMechanismIsRelevant_OutputNodeAddedForResult(WaterPressureAsphaltCoverFailureMechanismSectionResult)")] - [TestCase(typeof(ClosingStructureFailureMechanismSectionResult), - TestName = "ChildNodeObjects_FailureMechanismIsRelevant_OutputNodeAddedForResult(ClosingStructureFailureMechanismSectionResult)")] + [TestCase(typeof(ClosingStructuresFailureMechanismSectionResult), + TestName = "ChildNodeObjects_FailureMechanismIsRelevant_OutputNodeAddedForResult(ClosingStructuresFailureMechanismSectionResult)")] [TestCase(typeof(MacrostabilityInwardsFailureMechanismSectionResult), TestName = "ChildNodeObjects_FailureMechanismIsRelevant_OutputNodeAddedForResult(MacrostabilityInwardsFailureMechanismSectionResult)")] [TestCase(typeof(MacrostabilityOutwardsFailureMechanismSectionResult), Fisheye: Tag b3af39ba024b8e12fe238d85130697255db28c59 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRows/ClosingStructureSectionResultRowTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRows/ClosingStructuresSectionResultRowTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRows/ClosingStructuresSectionResultRowTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRows/ClosingStructuresSectionResultRowTest.cs (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -0,0 +1,168 @@ +// 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 Core.Common.Base; +using Core.Common.Base.Data; +using Core.Common.Base.Geometry; +using Core.Common.Utils.Reflection; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Forms.TypeConverters; +using Ringtoets.Integration.Data.StandAlone.SectionResults; +using Ringtoets.Integration.Forms.Views.SectionResultRows; +using CoreCommonBaseResources = Core.Common.Base.Properties.Resources; +using RingtoetsCommonDataResources = Ringtoets.Common.Data.Properties.Resources; + +namespace Ringtoets.Integration.Forms.Test.Views.SectionResultRows +{ + [TestFixture] + public class ClosingStructuresSectionResultRowTest + { + [Test] + public void Constructor_WithoutSectionResult_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new ClosingStructuresSectionResultRow(null); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("sectionResult", paramName); + } + + [Test] + public void Constructor_WithSectionResult_PropertiesFromSectionAndResult() + { + // Setup + var section = CreateSection(); + var result = new ClosingStructuresFailureMechanismSectionResult(section); + + // Call + var row = new ClosingStructuresSectionResultRow(result); + + // Assert + Assert.AreEqual(section.Name, row.Name); + Assert.AreEqual(result.AssessmentLayerOne, row.AssessmentLayerOne); + Assert.AreEqual(result.AssessmentLayerTwoA, row.AssessmentLayerTwoA); + Assert.AreEqual(result.AssessmentLayerThree, row.AssessmentLayerThree); + + Assert.IsTrue(TypeUtils.HasTypeConverter( + r => r.AssessmentLayerTwoA)); + Assert.IsTrue(TypeUtils.HasTypeConverter( + r => r.AssessmentLayerThree)); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void AssessmentLayerOne_AlwaysOnChange_NotifyObserversOfResultAndResultPropertyChanged(bool newValue) + { + // Setup + var mocks = new MockRepository(); + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); + mocks.ReplayAll(); + + var section = CreateSection(); + var result = new ClosingStructuresFailureMechanismSectionResult(section); + result.Attach(observer); + + var row = new ClosingStructuresSectionResultRow(result); + + // Call + row.AssessmentLayerOne = newValue; + + // Assert + Assert.AreEqual(newValue, result.AssessmentLayerOne); + + mocks.VerifyAll(); + } + + [Test] + [TestCase(0)] + [TestCase(1)] + [TestCase(0.5)] + [TestCase(1e-6)] + public void AssessmentLayerTwoA_ForValidValues_ResultPropertyChanged(double value) + { + // Setup + var section = CreateSection(); + var result = new ClosingStructuresFailureMechanismSectionResult(section); + var row = new ClosingStructuresSectionResultRow(result); + + // Call + row.AssessmentLayerTwoA = value; + + // Assert + Assert.AreEqual(value, row.AssessmentLayerTwoA); + } + + [Test] + [TestCase(-20)] + [TestCase(-1e-6)] + [TestCase(1 + 1e-6)] + [TestCase(12)] + public void AssessmentLayerTwoA_ForInvalidValues_ThrowsArgumentException(double value) + { + // Setup + var section = CreateSection(); + var result = new ClosingStructuresFailureMechanismSectionResult(section); + var row = new ClosingStructuresSectionResultRow(result); + + // Call + TestDelegate test = () => row.AssessmentLayerTwoA = value; + + // Assert + var message = Assert.Throws(test).Message; + Assert.AreEqual(RingtoetsCommonDataResources.ArbitraryProbabilityFailureMechanismSectionResult_AssessmentLayerTwoA_Value_needs_to_be_between_0_and_1, + message); + } + + [Test] + public void AssessmentLayerThree_AlwaysOnChange_ResultPropertyChanged() + { + // Setup + var random = new Random(21); + var newValue = random.NextDouble(); + var section = CreateSection(); + var result = new ClosingStructuresFailureMechanismSectionResult(section); + var row = new ClosingStructuresSectionResultRow(result); + + // Call + row.AssessmentLayerThree = (RoundedDouble) newValue; + + // Assert + Assert.AreEqual(newValue, result.AssessmentLayerThree, row.AssessmentLayerThree.GetAccuracy()); + } + + private static FailureMechanismSection CreateSection() + { + return new FailureMechanismSection("name", new[] + { + new Point2D(0, 0) + }); + } + } +} \ No newline at end of file Fisheye: Tag b3af39ba024b8e12fe238d85130697255db28c59 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultViews/ClosingStructureResultViewTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultViews/ClosingStructuresResultViewTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultViews/ClosingStructuresResultViewTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultViews/ClosingStructuresResultViewTest.cs (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -0,0 +1,242 @@ +// 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.Drawing; +using System.Windows.Forms; +using Core.Common.Base.Data; +using Core.Common.Base.Geometry; +using NUnit.Extensions.Forms; +using NUnit.Framework; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Forms.Helpers; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; +using Ringtoets.Integration.Data.StandAlone.SectionResults; +using Ringtoets.Integration.Forms.Views.SectionResultViews; +using CoreCommonBaseResources = Core.Common.Base.Properties.Resources; + +namespace Ringtoets.Integration.Forms.Test.Views.SectionResultViews +{ + [TestFixture] + public class ClosingStructuresResultViewTest + { + private const int nameColumnIndex = 0; + private const int assessmentLayerOneIndex = 1; + private const int assessmentLayerTwoAIndex = 2; + private const int assessmentLayerThreeIndex = 3; + + [Test] + public void GivenFormWithClosingStructuresFailureMechanismResultView_ThenExpectedColumnsAreVisible() + { + // Given + using (var form = new Form()) + using (var view = new ClosingStructuresResultView()) + { + form.Controls.Add(view); + form.Show(); + + // Then + var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + + Assert.AreEqual(4, dataGridView.ColumnCount); + + Assert.IsInstanceOf(dataGridView.Columns[assessmentLayerOneIndex]); + Assert.IsInstanceOf(dataGridView.Columns[assessmentLayerTwoAIndex]); + Assert.IsInstanceOf(dataGridView.Columns[assessmentLayerThreeIndex]); + + Assert.AreEqual( + RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_one, + dataGridView.Columns[assessmentLayerOneIndex].HeaderText); + Assert.AreEqual( + RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_two_a, + dataGridView.Columns[assessmentLayerTwoAIndex].HeaderText); + Assert.AreEqual( + RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_three, + dataGridView.Columns[assessmentLayerThreeIndex].HeaderText); + + Assert.AreEqual(DataGridViewAutoSizeColumnsMode.AllCells, dataGridView.AutoSizeColumnsMode); + Assert.AreEqual(DataGridViewContentAlignment.MiddleCenter, dataGridView.ColumnHeadersDefaultCellStyle.Alignment); + } + } + + [Test] + public void GivenFormWithClosingStructuresFailureMechanismResultView_WhenDataSourceWithClosingStructureFailureMechanismSectionResultAssigned_ThenSectionsAddedAsRows() + { + // Given + var section1 = new FailureMechanismSection("Section 1", new[] + { + new Point2D(0, 0) + }); + var section2 = new FailureMechanismSection("Section 2", new[] + { + new Point2D(0, 0) + }); + Random random = new Random(21); + var result1 = new ClosingStructuresFailureMechanismSectionResult(section1) + { + AssessmentLayerOne = true, + AssessmentLayerTwoA = (RoundedDouble) random.NextDouble(), + AssessmentLayerThree = (RoundedDouble) random.NextDouble() + }; + var result2 = new ClosingStructuresFailureMechanismSectionResult(section2) + { + AssessmentLayerOne = false, + AssessmentLayerTwoA = (RoundedDouble) random.NextDouble(), + AssessmentLayerThree = (RoundedDouble) random.NextDouble() + }; + + using (var form = new Form()) + using (var view = new ClosingStructuresResultView()) + { + form.Controls.Add(view); + form.Show(); + + // When + view.Data = new[] + { + result1, + result2 + }; + + // Then + var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + var rows = dataGridView.Rows; + Assert.AreEqual(2, rows.Count); + + var cells = rows[0].Cells; + Assert.AreEqual(4, cells.Count); + Assert.AreEqual("Section 1", cells[nameColumnIndex].FormattedValue); + Assert.AreEqual(result1.AssessmentLayerOne, cells[assessmentLayerOneIndex].Value); + var expectedAssessmentLayer2AString1 = ProbabilityFormattingHelper.Format(result1.AssessmentLayerTwoA); + + Assert.AreEqual(expectedAssessmentLayer2AString1, cells[assessmentLayerTwoAIndex].FormattedValue); + Assert.AreEqual(result1.AssessmentLayerThree.ToString(), cells[assessmentLayerThreeIndex].FormattedValue); + + AssertCellIsDisabled(cells[assessmentLayerTwoAIndex]); + AssertCellIsDisabled(cells[assessmentLayerThreeIndex]); + + cells = rows[1].Cells; + Assert.AreEqual(4, cells.Count); + Assert.AreEqual("Section 2", cells[nameColumnIndex].FormattedValue); + Assert.AreEqual(result2.AssessmentLayerOne, cells[assessmentLayerOneIndex].Value); + var expectedAssessmentLayer2AString2 = ProbabilityFormattingHelper.Format(result2.AssessmentLayerTwoA); + Assert.AreEqual(expectedAssessmentLayer2AString2, cells[assessmentLayerTwoAIndex].FormattedValue); + Assert.AreEqual(result2.AssessmentLayerThree.ToString(), cells[assessmentLayerThreeIndex].FormattedValue); + + AssertCellIsEnabled(cells[assessmentLayerTwoAIndex]); + AssertCellIsEnabled(cells[assessmentLayerThreeIndex]); + } + } + + [Test] + public void GivenFormWithClosingStructuresFailureMechanismResultView_WhenSectionPassesLevel0AndListenersNotified_ThenRowsForSectionBecomesDisabled() + { + // Given + var section = new FailureMechanismSection("Section 1", new[] + { + new Point2D(0, 0) + }); + Random random = new Random(21); + var result = new ClosingStructuresFailureMechanismSectionResult(section) + { + AssessmentLayerOne = false, + AssessmentLayerTwoA = (RoundedDouble) random.NextDouble(), + AssessmentLayerThree = (RoundedDouble) random.NextDouble() + }; + using (var form = new Form()) + using (var view = new ClosingStructuresResultView()) + { + form.Controls.Add(view); + form.Show(); + + view.Data = new[] + { + result + }; + + // When + result.AssessmentLayerOne = true; + result.NotifyObservers(); + + // Then + var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + var rows = dataGridView.Rows; + Assert.AreEqual(1, rows.Count); + + var cells = rows[0].Cells; + Assert.AreEqual(4, cells.Count); + + AssertCellIsDisabled(cells[assessmentLayerTwoAIndex]); + AssertCellIsDisabled(cells[assessmentLayerThreeIndex]); + } + } + + [Test] + public void GivenFormWithClosingStructuresFailureMechanismResultView_WhenDataSourceWithOtherFailureMechanismSectionResultAssigned_ThenSectionsNotAdded() + { + // Given + var section1 = new FailureMechanismSection("Section 1", new[] + { + new Point2D(0, 0) + }); + var section2 = new FailureMechanismSection("Section 2", new[] + { + new Point2D(0, 0) + }); + var result1 = new TestFailureMechanismSectionResult(section1); + var result2 = new TestFailureMechanismSectionResult(section2); + + using (var form = new Form()) + using (var view = new ClosingStructuresResultView()) + { + form.Controls.Add(view); + form.Show(); + + // When + view.Data = new[] + { + result1, + result2 + }; + + // Then + var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + var rows = dataGridView.Rows; + Assert.AreEqual(0, rows.Count); + } + } + + private static void AssertCellIsDisabled(DataGridViewCell dataGridViewCell) + { + Assert.AreEqual(true, dataGridViewCell.ReadOnly); + Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), dataGridViewCell.Style.ForeColor); + Assert.AreEqual(Color.FromKnownColor(KnownColor.DarkGray), dataGridViewCell.Style.BackColor); + } + + private static void AssertCellIsEnabled(DataGridViewCell dataGridViewCell) + { + Assert.AreEqual(false, dataGridViewCell.ReadOnly); + Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), dataGridViewCell.Style.ForeColor); + Assert.AreEqual(Color.FromKnownColor(KnownColor.White), dataGridViewCell.Style.BackColor); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj =================================================================== diff -u -ra8163cf0aa69df29f6c37a8cccd2981cf97b4b35 -rb3af39ba024b8e12fe238d85130697255db28c59 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision a8163cf0aa69df29f6c37a8cccd2981cf97b4b35) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -82,7 +82,7 @@ - + Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs =================================================================== diff -u -r51d8e744ffb2168ca56ca4b6260ad9c2590c0170 -rb3af39ba024b8e12fe238d85130697255db28c59 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs (.../RingtoetsPluginTest.cs) (revision 51d8e744ffb2168ca56ca4b6260ad9c2590c0170) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs (.../RingtoetsPluginTest.cs) (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -361,10 +361,10 @@ Assert.AreEqual(typeof(WaterPressureAsphaltCoverResultView), waterPressureAsphaltCoverResultViewInfo.ViewType); TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.FailureMechanismSectionResultIcon, waterPressureAsphaltCoverResultViewInfo.Image); - var closingStructureResultViewInfo = viewInfos.Single(vi => vi.DataType == typeof(FailureMechanismSectionResultContext)); - Assert.AreEqual(typeof(IEnumerable), closingStructureResultViewInfo.ViewDataType); - Assert.AreEqual(typeof(ClosingStructureResultView), closingStructureResultViewInfo.ViewType); - TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.FailureMechanismSectionResultIcon, closingStructureResultViewInfo.Image); + var closingStructuresResultViewInfo = viewInfos.Single(vi => vi.DataType == typeof(FailureMechanismSectionResultContext)); + Assert.AreEqual(typeof(IEnumerable), closingStructuresResultViewInfo.ViewDataType); + Assert.AreEqual(typeof(ClosingStructuresResultView), closingStructuresResultViewInfo.ViewType); + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.FailureMechanismSectionResultIcon, closingStructuresResultViewInfo.Image); var macrostabilityOutwardsResultViewInfo = viewInfos.Single(vi => vi.DataType == typeof(FailureMechanismSectionResultContext)); Assert.AreEqual(typeof(IEnumerable), macrostabilityOutwardsResultViewInfo.ViewDataType); @@ -448,7 +448,7 @@ Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismSectionResultContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismSectionResultContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismSectionResultContext))); - Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismSectionResultContext))); + Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismSectionResultContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismSectionResultContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismSectionResultContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismSectionResultContext))); Fisheye: Tag b3af39ba024b8e12fe238d85130697255db28c59 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/ClosingStructureResultViewInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/ClosingStructuresResultViewInfoTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/ClosingStructuresResultViewInfoTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/ClosingStructuresResultViewInfoTest.cs (revision b3af39ba024b8e12fe238d85130697255db28c59) @@ -0,0 +1,316 @@ +// 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.Collections.Generic; +using System.Linq; +using Core.Common.Gui.Plugin; +using Core.Common.TestUtil; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Forms.PresentationObjects; +using Ringtoets.Integration.Data.StandAlone; +using Ringtoets.Integration.Data.StandAlone.SectionResults; +using Ringtoets.Integration.Forms.Views.SectionResultViews; +using Ringtoets.Piping.Data; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.Integration.Plugin.Test.ViewInfos +{ + [TestFixture] + public class ClosingStructuresResultViewInfoTest + { + private MockRepository mocks; + private RingtoetsPlugin plugin; + private ViewInfo info; + + [SetUp] + public void SetUp() + { + mocks = new MockRepository(); + plugin = new RingtoetsPlugin(); + info = plugin.GetViewInfos().First(tni => tni.ViewType == typeof(ClosingStructuresResultView)); + } + + [TearDown] + public void TearDown() + { + plugin.Dispose(); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Assert + Assert.AreEqual(typeof(FailureMechanismSectionResultContext), info.DataType); + Assert.AreEqual(typeof(IEnumerable), info.ViewDataType); + } + + [Test] + public void GetViewData_Always_ReturnsWrappedFailureMechanismResult() + { + // Setup + var failureMechanism = new ClosingStructuresFailureMechanism(); + var context = new FailureMechanismSectionResultContext(failureMechanism.SectionResults, failureMechanism); + + // Call + var viewData = info.GetViewData(context); + + // Assert + Assert.AreSame(failureMechanism.SectionResults, viewData); + } + + [Test] + public void GetViewName_Always_ReturnsViewName() + { + // Setup + var failureMechanism = new ClosingStructuresFailureMechanism(); + var viewMock = mocks.StrictMock(); + + mocks.ReplayAll(); + + // Call + var viewName = info.GetViewName(viewMock, failureMechanism.SectionResults); + + // Assert + Assert.AreEqual("Resultaat", viewName); + mocks.VerifyAll(); + } + + [Test] + public void ViewType_Always_ReturnsViewType() + { + // Call + var viewType = info.ViewType; + + // Assert + Assert.AreEqual(typeof(ClosingStructuresResultView), viewType); + } + + [Test] + public void DataType_Always_ReturnsDataType() + { + // Call + var dataType = info.DataType; + + // Assert + Assert.AreEqual(typeof(FailureMechanismSectionResultContext), dataType); + } + + [Test] + public void ViewDataType_Always_ReturnsViewDataType() + { + // Call + var viewDataType = info.ViewDataType; + + // Assert + Assert.AreEqual(typeof(IEnumerable), viewDataType); + } + + [Test] + public void Image_Always_ReturnsGenericInputOutputIcon() + { + // Call + var image = info.Image; + + // Assert + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.FailureMechanismSectionResultIcon, image); + } + + [Test] + public void CloseForData_AssessmentSectionRemovedWithoutFailureMechanism_ReturnsFalse() + { + // Setup + var assessmentSectionMock = mocks.StrictMock(); + assessmentSectionMock.Expect(asm => asm.GetFailureMechanisms()).Return(new IFailureMechanism[0]); + mocks.ReplayAll(); + + using (var view = new ClosingStructuresResultView()) + { + var failureMechanism = new ClosingStructuresFailureMechanism(); + view.Data = failureMechanism.SectionResults; + + // Call + var closeForData = info.CloseForData(view, assessmentSectionMock); + + // Assert + Assert.IsFalse(closeForData); + } + mocks.VerifyAll(); + } + + [Test] + public void CloseForData_ViewNotCorrespondingToRemovedAssessmentSection_ReturnsFalse() + { + // Setup + var assessmentSectionMock = mocks.StrictMock(); + var failureMechanismMock = mocks.Stub("N", "C"); + var failureMechanism = new ClosingStructuresFailureMechanism(); + + assessmentSectionMock.Expect(asm => asm.GetFailureMechanisms()).Return(new[] + { + failureMechanismMock + }); + + mocks.ReplayAll(); + + using (var view = new ClosingStructuresResultView()) + { + view.Data = failureMechanism.SectionResults; + + // Call + var closeForData = info.CloseForData(view, assessmentSectionMock); + + // Assert + Assert.IsFalse(closeForData); + } + mocks.VerifyAll(); + } + + [Test] + public void CloseForData_ViewCorrespondingToRemovedAssessmentSection_ReturnsTrue() + { + // Setup + var assessmentSectionMock = mocks.StrictMock(); + var failureMechanism = new ClosingStructuresFailureMechanism(); + + assessmentSectionMock.Expect(asm => asm.GetFailureMechanisms()).Return(new IFailureMechanism[] + { + new PipingFailureMechanism(), + failureMechanism + }); + + mocks.ReplayAll(); + + using (var view = new ClosingStructuresResultView()) + { + view.Data = failureMechanism.SectionResults; + + // Call + var closeForData = info.CloseForData(view, assessmentSectionMock); + + // Assert + Assert.IsTrue(closeForData); + } + mocks.VerifyAll(); + } + + [Test] + public void CloseForData_ViewCorrespondingToRemovedFailureMechanism_ReturnsTrue() + { + // Setup + using (var view = new ClosingStructuresResultView()) + { + var failureMechanism = new ClosingStructuresFailureMechanism(); + view.Data = failureMechanism.SectionResults; + + // Call + var closeForData = info.CloseForData(view, failureMechanism); + + // Assert + Assert.IsTrue(closeForData); + } + } + + [Test] + public void CloseForData_ViewNotCorrespondingToRemovedFailureMechanismContext_ReturnsFalse() + { + // Setup + using (var view = new ClosingStructuresResultView()) + { + var failureMechanism = new ClosingStructuresFailureMechanism(); + view.Data = failureMechanism.SectionResults; + + // Call + var closeForData = info.CloseForData(view, new ClosingStructuresFailureMechanism()); + + // Assert + Assert.IsFalse(closeForData); + } + } + + [Test] + public void CloseForData_ViewCorrespondingToRemovedFailureMechanismContext_ReturnsTrue() + { + // Setup + var failureMechanismContext = mocks.StrictMock>(); + var failureMechanism = new ClosingStructuresFailureMechanism(); + failureMechanismContext.Expect(fm => fm.WrappedData).Return(failureMechanism); + + mocks.ReplayAll(); + + using (var view = new ClosingStructuresResultView()) + { + view.Data = failureMechanism.SectionResults; + + // Call + var closeForData = info.CloseForData(view, failureMechanismContext); + + // Assert + Assert.IsTrue(closeForData); + } + mocks.VerifyAll(); + } + + [Test] + public void CloseForData_ViewNotCorrespondingToRemovedFailureMechanism_ReturnsFalse() + { + // Setup + var failureMechanismContext = mocks.StrictMock>(); + failureMechanismContext.Expect(fm => fm.WrappedData).Return(new ClosingStructuresFailureMechanism()); + + mocks.ReplayAll(); + + using (var view = new ClosingStructuresResultView()) + { + var failureMechanism = new ClosingStructuresFailureMechanism(); + view.Data = failureMechanism.SectionResults; + + // Call + var closeForData = info.CloseForData(view, failureMechanismContext); + + // Assert + Assert.IsFalse(closeForData); + } + mocks.VerifyAll(); + } + + [Test] + public void AfterCreate_Always_SetsSpecificPropertiesToView() + { + // Setup + var failureMechanism = new ClosingStructuresFailureMechanism(); + var view = mocks.StrictMock(); + var context = new FailureMechanismSectionResultContext(failureMechanism.SectionResults, failureMechanism); + + view.Expect(v => v.FailureMechanism = failureMechanism); + + mocks.ReplayAll(); + + // Call + info.AfterCreate(view, context); + + // Assert + mocks.VerifyAll(); + } + } +} \ No newline at end of file