Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj =================================================================== diff -u -r4ad65cef966ec4b0e6f36b7a612aef4bdd088837 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 4ad65cef966ec4b0e6f36b7a612aef4bdd088837) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -426,8 +426,8 @@ - - + + Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PersistenceRegistry.cs =================================================================== diff -u -rd6fe8399e8398224cf1bda9259052232d85b85a4 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PersistenceRegistry.cs (.../PersistenceRegistry.cs) (revision d6fe8399e8398224cf1bda9259052232d85b85a4) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PersistenceRegistry.cs (.../PersistenceRegistry.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -32,7 +32,7 @@ using Ringtoets.DuneErosion.Data; using Ringtoets.GrassCoverErosionInwards.Data; using Ringtoets.HeightStructures.Data; -using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Primitives; using Ringtoets.StabilityPointStructures.Data; @@ -58,13 +58,13 @@ private readonly Dictionary grassCoverErosionInwardsCalculations = CreateDictionary(); - private readonly Dictionary stochasticSoilModels = - CreateDictionary(); + private readonly Dictionary pipingStochasticSoilModels = + CreateDictionary(); - private readonly Dictionary stochasticSoilProfiles = - CreateDictionary(); + private readonly Dictionary pipingStochasticSoilProfiles = + CreateDictionary(); - private readonly Dictionary soilProfiles = + private readonly Dictionary pipingSoilProfiles = CreateDictionary(); private readonly Dictionary surfaceLines = @@ -254,31 +254,31 @@ /// that was constructed with the information. /// /// The to be registered. - /// The to be registered. + /// The to be registered. /// Thrown when either: /// /// is null /// is null /// - internal void Register(StochasticSoilModelEntity entity, StochasticSoilModel model) + internal void Register(StochasticSoilModelEntity entity, PipingStochasticSoilModel model) { - Register(stochasticSoilModels, entity, model); + Register(pipingStochasticSoilModels, entity, model); } /// /// Registers a create operation for and the /// that was constructed with the information. /// /// The to be registered. - /// The to be registered. + /// The to be registered. /// Thrown when either: /// /// is null /// is null /// - internal void Register(StochasticSoilProfileEntity entity, StochasticSoilProfile model) + internal void Register(StochasticSoilProfileEntity entity, PipingStochasticSoilProfile model) { - Register(stochasticSoilProfiles, entity, model); + Register(pipingStochasticSoilProfiles, entity, model); } /// @@ -294,7 +294,7 @@ /// internal void Register(SoilProfileEntity entity, PipingSoilProfile model) { - Register(soilProfiles, entity, model); + Register(pipingSoilProfiles, entity, model); } /// @@ -410,23 +410,23 @@ /// /// Checks whether a create operations has been registered for the given . /// - /// The to check for. + /// The to check for. /// true if the was registered before, false otherwise. /// Thrown when is null. - internal bool Contains(StochasticSoilModel model) + internal bool Contains(PipingStochasticSoilModel model) { - return ContainsValue(stochasticSoilModels, model); + return ContainsValue(pipingStochasticSoilModels, model); } /// /// Checks whether a create operations has been registered for the given . /// - /// The to check for. + /// The to check for. /// true if the was registered before, false otherwise. /// Thrown when is null. - internal bool Contains(StochasticSoilProfile model) + internal bool Contains(PipingStochasticSoilProfile model) { - return ContainsValue(stochasticSoilProfiles, model); + return ContainsValue(pipingStochasticSoilProfiles, model); } /// @@ -437,7 +437,7 @@ /// Thrown when is null. internal bool Contains(PipingSoilProfile model) { - return ContainsValue(soilProfiles, model); + return ContainsValue(pipingSoilProfiles, model); } /// @@ -608,34 +608,34 @@ /// Obtains the which was registered for /// the given . /// - /// The for which a create + /// The for which a create /// operation has been registered. /// The created . /// Thrown when is null. /// Thrown when no create operation /// has been registered for . - /// Use to find out whether + /// Use to find out whether /// a create operation has been registered for . - internal StochasticSoilModelEntity Get(StochasticSoilModel model) + internal StochasticSoilModelEntity Get(PipingStochasticSoilModel model) { - return Get(stochasticSoilModels, model); + return Get(pipingStochasticSoilModels, model); } /// /// Obtains the which was registered for /// the given . /// - /// The for which a create + /// The for which a create /// operation has been registered. /// The created . /// Thrown when is null. /// Thrown when no create operation /// has been registered for . - /// Use to find out whether + /// Use to find out whether /// a create/create operation has been registered for . - internal StochasticSoilProfileEntity Get(StochasticSoilProfile model) + internal StochasticSoilProfileEntity Get(PipingStochasticSoilProfile model) { - return Get(stochasticSoilProfiles, model); + return Get(pipingStochasticSoilProfiles, model); } /// @@ -652,7 +652,7 @@ /// create operation has been registered for . internal SoilProfileEntity Get(PipingSoilProfile model) { - return Get(soilProfiles, model); + return Get(pipingSoilProfiles, model); } /// Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/Piping/PipingFailureMechanismCreateExtensions.cs =================================================================== diff -u -rd6fe8399e8398224cf1bda9259052232d85b85a4 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/Piping/PipingFailureMechanismCreateExtensions.cs (.../PipingFailureMechanismCreateExtensions.cs) (revision d6fe8399e8398224cf1bda9259052232d85b85a4) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/Piping/PipingFailureMechanismCreateExtensions.cs (.../PipingFailureMechanismCreateExtensions.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -24,6 +24,7 @@ using Application.Ringtoets.Storage.DbContext; using Core.Common.Utils.Extensions; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Primitives; namespace Application.Ringtoets.Storage.Create.Piping @@ -82,7 +83,7 @@ private static void AddEntitiesForStochasticSoilModels(PipingFailureMechanism mechanism, PersistenceRegistry registry, FailureMechanismEntity entity) { var index = 0; - foreach (StochasticSoilModel stochasticSoilModel in mechanism.StochasticSoilModels) + foreach (PipingStochasticSoilModel stochasticSoilModel in mechanism.StochasticSoilModels) { entity.StochasticSoilModelEntities.Add(stochasticSoilModel.Create(registry, index++)); } Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/Piping/PipingStochasticSoilModelCreateExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/Piping/PipingStochasticSoilModelCreateExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/Piping/PipingStochasticSoilModelCreateExtensions.cs (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -0,0 +1,81 @@ +// Copyright (C) Stichting Deltares 2017. 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.Serializers; +using Core.Common.Utils.Extensions; +using Ringtoets.Piping.Data.SoilProfile; + +namespace Application.Ringtoets.Storage.Create.Piping +{ + /// + /// Extension methods for related to creating + /// a . + /// + internal static class PipingStochasticSoilModelCreateExtensions + { + /// + /// Creates a based on the information of the . + /// + /// The model to create a database entity for. + /// The object keeping track of create operations. + /// Index at which this instance resides inside its parent container. + /// A new . + /// Thrown when is null. + internal static StochasticSoilModelEntity Create(this PipingStochasticSoilModel model, + PersistenceRegistry registry, + int order) + { + if (registry == null) + { + throw new ArgumentNullException(nameof(registry)); + } + if (registry.Contains(model)) + { + return registry.Get(model); + } + + var entity = new StochasticSoilModelEntity + { + Name = model.Name.DeepClone(), + StochasticSoilModelSegmentPointXml = new Point2DXmlSerializer().ToXml(model.Geometry), + Order = order + }; + + AddEntitiesForStochasticSoilProfiles(model, registry, entity); + + registry.Register(entity, model); + return entity; + } + + private static void AddEntitiesForStochasticSoilProfiles(PipingStochasticSoilModel model, + PersistenceRegistry registry, + StochasticSoilModelEntity entity) + { + for (var i = 0; i < model.StochasticSoilProfiles.Count; i++) + { + PipingStochasticSoilProfile stochasticSoilProfile = model.StochasticSoilProfiles[i]; + entity.StochasticSoilProfileEntities.Add(stochasticSoilProfile.Create(registry, i)); + } + } + } +} \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/Piping/PipingStochasticSoilProfileCreateExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/Piping/PipingStochasticSoilProfileCreateExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/Piping/PipingStochasticSoilProfileCreateExtensions.cs (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -0,0 +1,62 @@ +// Copyright (C) Stichting Deltares 2017. 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.Piping.Data.SoilProfile; + +namespace Application.Ringtoets.Storage.Create.Piping +{ + /// + /// Extension methods for related to creating + /// a . + /// + internal static class PipingStochasticSoilProfileCreateExtensions + { + /// + /// Creates a based on the information of the + /// . + /// + /// The profile to create a database entity for. + /// The object keeping track of create operations. + /// Index at which this instance resides inside its parent container. + /// A new . + /// Thrown when is null. + internal static StochasticSoilProfileEntity Create(this PipingStochasticSoilProfile profile, + PersistenceRegistry registry, + int order) + { + var entity = new StochasticSoilProfileEntity + { + Probability = profile.Probability, + SoilProfileEntity = profile.SoilProfile.Create(registry), + Order = order + }; + if (registry.Contains(profile)) + { + return registry.Get(profile); + } + + registry.Register(entity, profile); + return entity; + } + } +} \ No newline at end of file Fisheye: Tag 26f527fb809a2325c8f883ece9da01a8f8040eb3 refers to a dead (removed) revision in file `Application/Ringtoets/src/Application.Ringtoets.Storage/Create/Piping/StochasticSoilModelCreateExtensions.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 26f527fb809a2325c8f883ece9da01a8f8040eb3 refers to a dead (removed) revision in file `Application/Ringtoets/src/Application.Ringtoets.Storage/Create/Piping/StochasticSoilProfileCreateExtensions.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/Piping/PipingCalculationEntityReadExtensions.cs =================================================================== diff -u -r3fb0df0ed6e64657154700ee7706e035d5bf99f5 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/Piping/PipingCalculationEntityReadExtensions.cs (.../PipingCalculationEntityReadExtensions.cs) (revision 3fb0df0ed6e64657154700ee7706e035d5bf99f5) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/Piping/PipingCalculationEntityReadExtensions.cs (.../PipingCalculationEntityReadExtensions.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -27,6 +27,10 @@ namespace Application.Ringtoets.Storage.Read.Piping { + /// + /// This class defines extension methods for read operations for a + /// based on the . + /// internal static class PipingCalculationEntityReadExtensions { /// Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/Piping/StochasticSoilModelEntityReadExtensions.cs =================================================================== diff -u -r16df8541528639fd1e8d9f2584fae28808b63fad -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/Piping/StochasticSoilModelEntityReadExtensions.cs (.../StochasticSoilModelEntityReadExtensions.cs) (revision 16df8541528639fd1e8d9f2584fae28808b63fad) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/Piping/StochasticSoilModelEntityReadExtensions.cs (.../StochasticSoilModelEntityReadExtensions.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -23,26 +23,28 @@ using System.Linq; using Application.Ringtoets.Storage.DbContext; using Application.Ringtoets.Storage.Serializers; -using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; namespace Application.Ringtoets.Storage.Read.Piping { /// - /// This class defines extension methods for read operations for a based on the - /// . + /// This class defines extension methods for read operations for a + /// based on the . /// internal static class StochasticSoilModelEntityReadExtensions { /// - /// Reads the and use the information to construct a . + /// Reads the and use the information to construct + /// a . /// - /// The to create for. + /// The to create for. /// The object keeping track of read operations. - /// A new . + /// A new . /// Thrown when is null. /// Thrown when /// of is null or empty. - internal static StochasticSoilModel Read(this StochasticSoilModelEntity entity, ReadConversionCollector collector) + internal static PipingStochasticSoilModel Read(this StochasticSoilModelEntity entity, + ReadConversionCollector collector) { if (collector == null) { @@ -53,7 +55,7 @@ return collector.Get(entity); } - var model = new StochasticSoilModel(entity.Name); + var model = new PipingStochasticSoilModel(entity.Name); entity.ReadStochasticSoilProfiles(model, collector); entity.ReadSegmentPoints(model); @@ -62,15 +64,18 @@ return model; } - private static void ReadStochasticSoilProfiles(this StochasticSoilModelEntity entity, StochasticSoilModel model, ReadConversionCollector collector) + private static void ReadStochasticSoilProfiles(this StochasticSoilModelEntity entity, + PipingStochasticSoilModel model, + ReadConversionCollector collector) { foreach (StochasticSoilProfileEntity stochasticSoilProfileEntity in entity.StochasticSoilProfileEntities.OrderBy(ssp => ssp.Order)) { model.StochasticSoilProfiles.Add(stochasticSoilProfileEntity.Read(collector)); } } - private static void ReadSegmentPoints(this StochasticSoilModelEntity entity, StochasticSoilModel model) + private static void ReadSegmentPoints(this StochasticSoilModelEntity entity, + PipingStochasticSoilModel model) { model.Geometry.AddRange(new Point2DXmlSerializer().FromXml(entity.StochasticSoilModelSegmentPointXml)); } Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/Piping/StochasticSoilProfileEntityReadExtensions.cs =================================================================== diff -u -r3fb0df0ed6e64657154700ee7706e035d5bf99f5 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/Piping/StochasticSoilProfileEntityReadExtensions.cs (.../StochasticSoilProfileEntityReadExtensions.cs) (revision 3fb0df0ed6e64657154700ee7706e035d5bf99f5) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/Piping/StochasticSoilProfileEntityReadExtensions.cs (.../StochasticSoilProfileEntityReadExtensions.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -21,25 +21,27 @@ using System; using Application.Ringtoets.Storage.DbContext; -using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Primitives; namespace Application.Ringtoets.Storage.Read.Piping { /// - /// This class defines extension methods for read operations for a based on the - /// . + /// This class defines extension methods for read operations for a + /// based on the . /// internal static class StochasticSoilProfileEntityReadExtensions { /// - /// Reads the and use the information to construct a . + /// Reads the and use the information to construct + /// a . /// - /// The to create for. + /// The to create for. /// The object keeping track of read operations. - /// A new . + /// A new . /// Thrown when is null. - internal static StochasticSoilProfile Read(this StochasticSoilProfileEntity entity, ReadConversionCollector collector) + internal static PipingStochasticSoilProfile Read(this StochasticSoilProfileEntity entity, + ReadConversionCollector collector) { if (collector == null) { @@ -50,17 +52,18 @@ return collector.Get(entity); } - var profile = new StochasticSoilProfile(entity.Probability, (SoilProfileType) entity.Type, -1); - entity.ReadSoilProfile(profile, collector); + PipingSoilProfile soilProfile = entity.ReadSoilProfile(collector); + var stochasticSoilProfile = new PipingStochasticSoilProfile(entity.Probability, soilProfile); - collector.Read(entity, profile); + collector.Read(entity, stochasticSoilProfile); - return profile; + return stochasticSoilProfile; } - private static void ReadSoilProfile(this StochasticSoilProfileEntity entity, StochasticSoilProfile profile, ReadConversionCollector collector) + private static PipingSoilProfile ReadSoilProfile(this StochasticSoilProfileEntity entity, + ReadConversionCollector collector) { - profile.SoilProfile = entity.SoilProfileEntity.Read(collector); + return entity.SoilProfileEntity.Read(collector); } } } \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ReadConversionCollector.cs =================================================================== diff -u -rd6fe8399e8398224cf1bda9259052232d85b85a4 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ReadConversionCollector.cs (.../ReadConversionCollector.cs) (revision d6fe8399e8398224cf1bda9259052232d85b85a4) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ReadConversionCollector.cs (.../ReadConversionCollector.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -31,7 +31,7 @@ using Ringtoets.DuneErosion.Data; using Ringtoets.GrassCoverErosionInwards.Data; using Ringtoets.HeightStructures.Data; -using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Primitives; using Ringtoets.StabilityPointStructures.Data; @@ -43,13 +43,13 @@ /// internal class ReadConversionCollector { - private readonly Dictionary stochasticSoilModels = - CreateDictionary(); + private readonly Dictionary pipingStochasticSoilModels = + CreateDictionary(); - private readonly Dictionary stochasticSoilProfiles = - CreateDictionary(); + private readonly Dictionary pipingStochasticSoilProfiles = + CreateDictionary(); - private readonly Dictionary soilProfiles = + private readonly Dictionary pipingSoilProfiles = CreateDictionary(); private readonly Dictionary surfaceLines = @@ -103,16 +103,16 @@ /// /// Registers a read operation for and the - /// that was constructed with the information. + /// that was constructed with the information. /// /// The that was read. - /// The that was constructed. + /// The that was constructed. /// Thrown when either: /// /// is null /// is null /// - internal void Read(StochasticSoilModelEntity entity, StochasticSoilModel model) + internal void Read(StochasticSoilModelEntity entity, PipingStochasticSoilModel model) { if (entity == null) { @@ -123,7 +123,7 @@ throw new ArgumentNullException(nameof(model)); } - stochasticSoilModels[entity] = model; + pipingStochasticSoilModels[entity] = model; } /// @@ -138,29 +138,29 @@ { throw new ArgumentNullException(nameof(entity)); } - return stochasticSoilModels.ContainsKey(entity); + return pipingStochasticSoilModels.ContainsKey(entity); } /// - /// Obtains the which was read for the given . + /// Obtains the which was read for the given . /// /// The for which a /// read operation has been registered. - /// The constructed . + /// The constructed . /// Thrown when is null. /// Thrown when no read operation has been registered for /// . /// Use to find out /// whether a read operation has been registered for . - internal StochasticSoilModel Get(StochasticSoilModelEntity entity) + internal PipingStochasticSoilModel Get(StochasticSoilModelEntity entity) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } try { - return stochasticSoilModels[entity]; + return pipingStochasticSoilModels[entity]; } catch (KeyNotFoundException e) { @@ -174,16 +174,16 @@ /// /// Registers a read operation for and - /// the that was constructed with the information. + /// the that was constructed with the information. /// /// The that was read. - /// The that was constructed. + /// The that was constructed. /// Thrown when either: /// /// is null /// is null /// - internal void Read(StochasticSoilProfileEntity entity, StochasticSoilProfile model) + internal void Read(StochasticSoilProfileEntity entity, PipingStochasticSoilProfile model) { if (entity == null) { @@ -194,7 +194,7 @@ throw new ArgumentNullException(nameof(model)); } - stochasticSoilProfiles[entity] = model; + pipingStochasticSoilProfiles[entity] = model; } /// @@ -209,30 +209,30 @@ { throw new ArgumentNullException(nameof(entity)); } - return stochasticSoilProfiles.ContainsKey(entity); + return pipingStochasticSoilProfiles.ContainsKey(entity); } /// - /// Obtains the which was read for the given + /// Obtains the which was read for the given /// . /// /// The for which /// a read operation has been registered. - /// The constructed . + /// The constructed . /// Thrown when is null. /// Thrown when no read operation has been registered for /// . /// Use to find out whether a read operation has been registered for /// . - internal StochasticSoilProfile Get(StochasticSoilProfileEntity entity) + internal PipingStochasticSoilProfile Get(StochasticSoilProfileEntity entity) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } try { - return stochasticSoilProfiles[entity]; + return pipingStochasticSoilProfiles[entity]; } catch (KeyNotFoundException e) { @@ -266,7 +266,7 @@ throw new ArgumentNullException(nameof(model)); } - soilProfiles[entity] = model; + pipingSoilProfiles[entity] = model; } /// @@ -281,7 +281,7 @@ { throw new ArgumentNullException(nameof(entity)); } - return soilProfiles.ContainsKey(entity); + return pipingSoilProfiles.ContainsKey(entity); } /// @@ -302,7 +302,7 @@ } try { - return soilProfiles[entity]; + return pipingSoilProfiles[entity]; } catch (KeyNotFoundException e) { Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj =================================================================== diff -u -r4ad65cef966ec4b0e6f36b7a612aef4bdd088837 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 4ad65cef966ec4b0e6f36b7a612aef4bdd088837) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -189,8 +189,8 @@ - - + + Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PersistenceRegistryTest.cs =================================================================== diff -u -raa49537188229065df91b1a931f088c32115702a -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PersistenceRegistryTest.cs (.../PersistenceRegistryTest.cs) (revision aa49537188229065df91b1a931f088c32115702a) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PersistenceRegistryTest.cs (.../PersistenceRegistryTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -37,8 +37,7 @@ using Ringtoets.GrassCoverErosionInwards.Data; using Ringtoets.HeightStructures.Data; using Ringtoets.HeightStructures.Data.TestUtil; -using Ringtoets.Piping.Data; -using Ringtoets.Piping.Data.TestUtil; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.KernelWrapper.TestUtil; using Ringtoets.Piping.Primitives; using Ringtoets.StabilityPointStructures.Data; @@ -303,25 +302,25 @@ } [Test] - public void Contains_WithoutStochasticSoilModel_ThrowsArgumentNullException() + public void Contains_WithoutPipingStochasticSoilModel_ThrowsArgumentNullException() { // Setup var registry = new PersistenceRegistry(); // Call - TestDelegate test = () => registry.Contains((StochasticSoilModel) null); + TestDelegate test = () => registry.Contains((PipingStochasticSoilModel) null); // Assert string paramName = Assert.Throws(test).ParamName; Assert.AreEqual("model", paramName); } [Test] - public void Contains_StochasticSoilModelAdded_ReturnsTrue() + public void Contains_PipingStochasticSoilModelAdded_ReturnsTrue() { // Setup var registry = new PersistenceRegistry(); - var soilModel = new StochasticSoilModel("A"); + var soilModel = new PipingStochasticSoilModel("A"); registry.Register(new StochasticSoilModelEntity(), soilModel); // Call @@ -332,11 +331,11 @@ } [Test] - public void Contains_NoStochasticSoilModelAdded_ReturnsFalse() + public void Contains_NoPipingStochasticSoilModelAdded_ReturnsFalse() { // Setup var registry = new PersistenceRegistry(); - var soilModel = new StochasticSoilModel("A"); + var soilModel = new PipingStochasticSoilModel("A"); // Call bool result = registry.Contains(soilModel); @@ -346,12 +345,12 @@ } [Test] - public void Contains_OtherStochasticSoilModelAdded_ReturnsFalse() + public void Contains_OtherPipingPipingStochasticSoilModelAdded_ReturnsFalse() { // Setup var registry = new PersistenceRegistry(); - var soilModel = new StochasticSoilModel("A"); - registry.Register(new StochasticSoilModelEntity(), new StochasticSoilModel("B")); + var soilModel = new PipingStochasticSoilModel("A"); + registry.Register(new StochasticSoilModelEntity(), new PipingStochasticSoilModel("B")); // Call bool result = registry.Contains(soilModel); @@ -361,13 +360,13 @@ } [Test] - public void Contains_WithoutStochasticSoilProfile_ThrowsArgumentNullException() + public void Contains_WithoutPipingStochasticSoilProfile_ThrowsArgumentNullException() { // Setup var registry = new PersistenceRegistry(); // Call - TestDelegate test = () => registry.Contains((StochasticSoilProfile) null); + TestDelegate test = () => registry.Contains((PipingStochasticSoilProfile) null); // Assert string paramName = Assert.Throws(test).ParamName; @@ -379,7 +378,7 @@ { // Setup var registry = new PersistenceRegistry(); - var stochasticSoilProfile = new StochasticSoilProfile(0.4, SoilProfileType.SoilProfile1D, 1); + var stochasticSoilProfile = new PipingStochasticSoilProfile(0.4, new TestPipingSoilProfile()); registry.Register(new StochasticSoilProfileEntity(), stochasticSoilProfile); // Call @@ -390,11 +389,11 @@ } [Test] - public void Contains_NoStochasticSoilProfileAdded_ReturnsFalse() + public void Contains_NoPipingStochasticSoilProfileAdded_ReturnsFalse() { // Setup var registry = new PersistenceRegistry(); - var stochasticSoilProfile = new StochasticSoilProfile(0.4, SoilProfileType.SoilProfile1D, 1); + var stochasticSoilProfile = new PipingStochasticSoilProfile(0.4, new TestPipingSoilProfile()); // Call bool result = registry.Contains(stochasticSoilProfile); @@ -404,12 +403,12 @@ } [Test] - public void Contains_OtherStochasticSoilProfileAdded_ReturnsFalse() + public void Contains_OtherPipingStochasticSoilProfileAdded_ReturnsFalse() { // Setup var registry = new PersistenceRegistry(); - var stochasticSoilProfile = new StochasticSoilProfile(0.4, SoilProfileType.SoilProfile1D, 1); - registry.Register(new StochasticSoilProfileEntity(), new StochasticSoilProfile(0.7, SoilProfileType.SoilProfile1D, 3)); + var stochasticSoilProfile = new PipingStochasticSoilProfile(0.4, new TestPipingSoilProfile()); + registry.Register(new StochasticSoilProfileEntity(), new PipingStochasticSoilProfile(0.7, new TestPipingSoilProfile())); // Call bool result = registry.Contains(stochasticSoilProfile); @@ -1250,25 +1249,25 @@ } [Test] - public void Get_WithoutStochasticSoilModel_ThrowsArgumentNullException() + public void Get_WithoutPipingStochasticSoilModel_ThrowsArgumentNullException() { // Setup var registry = new PersistenceRegistry(); // Call - TestDelegate test = () => registry.Get((StochasticSoilModel) null); + TestDelegate test = () => registry.Get((PipingStochasticSoilModel) null); // Assert string paramName = Assert.Throws(test).ParamName; Assert.AreEqual("model", paramName); } [Test] - public void Get_StochasticSoilModelAdded_ReturnsEntity() + public void Get_PipingStochasticSoilModelAdded_ReturnsEntity() { // Setup var registry = new PersistenceRegistry(); - var soilModel = new StochasticSoilModel("6"); + var soilModel = new PipingStochasticSoilModel("6"); var entity = new StochasticSoilModelEntity(); registry.Register(entity, soilModel); @@ -1280,11 +1279,11 @@ } [Test] - public void Get_NoStochasticSoilModelAdded_ThrowsInvalidOperationException() + public void Get_NoPipingStochasticSoilModelAdded_ThrowsInvalidOperationException() { // Setup var registry = new PersistenceRegistry(); - var soilModel = new StochasticSoilModel("6"); + var soilModel = new PipingStochasticSoilModel("6"); // Call TestDelegate test = () => registry.Get(soilModel); @@ -1294,12 +1293,12 @@ } [Test] - public void Get_OtherStochasticSoilModelAdded_ThrowsInvalidOperationException() + public void Get_OtherPipingStochasticSoilModelAdded_ThrowsInvalidOperationException() { // Setup var registry = new PersistenceRegistry(); - var soilModel = new StochasticSoilModel("6"); - registry.Register(new StochasticSoilModelEntity(), new StochasticSoilModel("2")); + var soilModel = new PipingStochasticSoilModel("6"); + registry.Register(new StochasticSoilModelEntity(), new PipingStochasticSoilModel("2")); // Call TestDelegate test = () => registry.Get(soilModel); @@ -1309,25 +1308,25 @@ } [Test] - public void Get_WithoutStochasticSoilProfileEntity_ThrowsArgumentNullException() + public void Get_WithoutPipingStochasticSoilProfileEntity_ThrowsArgumentNullException() { // Setup var registry = new PersistenceRegistry(); // Call - TestDelegate test = () => registry.Get((StochasticSoilProfile) null); + TestDelegate test = () => registry.Get((PipingStochasticSoilProfile) null); // Assert string paramName = Assert.Throws(test).ParamName; Assert.AreEqual("model", paramName); } [Test] - public void Get_StochasticSoilProfileAdded_ReturnsEntity() + public void Get_PipingStochasticSoilProfileAdded_ReturnsEntity() { // Setup var registry = new PersistenceRegistry(); - var stochasticSoilProfile = new StochasticSoilProfile(0.2, SoilProfileType.SoilProfile1D, 1); + var stochasticSoilProfile = new PipingStochasticSoilProfile(0.2, new TestPipingSoilProfile()); var entity = new StochasticSoilProfileEntity(); registry.Register(entity, stochasticSoilProfile); @@ -1339,11 +1338,11 @@ } [Test] - public void Get_NoStochasticSoilProfileAdded_ThrowsInvalidOperationException() + public void Get_NoPipingStochasticSoilProfileAdded_ThrowsInvalidOperationException() { // Setup var registry = new PersistenceRegistry(); - var stochasticSoilProfile = new StochasticSoilProfile(0.2, SoilProfileType.SoilProfile1D, 1); + var stochasticSoilProfile = new PipingStochasticSoilProfile(0.2, new TestPipingSoilProfile()); // Call TestDelegate test = () => registry.Get(stochasticSoilProfile); @@ -1353,12 +1352,12 @@ } [Test] - public void Get_OtherStochasticSoilProfileAdded_ThrowsInvalidOperationException() + public void Get_OtherPipingStochasticSoilProfileAdded_ThrowsInvalidOperationException() { // Setup var registry = new PersistenceRegistry(); - var stochasticSoilProfile = new StochasticSoilProfile(0.2, SoilProfileType.SoilProfile1D, 1); - registry.Register(new StochasticSoilProfileEntity(), new StochasticSoilProfile(0.4, SoilProfileType.SoilProfile1D, 2)); + var stochasticSoilProfile = new PipingStochasticSoilProfile(0.2, new TestPipingSoilProfile()); + registry.Register(new StochasticSoilProfileEntity(), new PipingStochasticSoilProfile(0.4, new TestPipingSoilProfile())); // Call TestDelegate test = () => registry.Get(stochasticSoilProfile); @@ -2103,21 +2102,21 @@ } [Test] - public void Register_WithNullStochasticSoilModelEntity_ThrowsArgumentNullException() + public void Register_WithNullPipingStochasticSoilModelEntity_ThrowsArgumentNullException() { // Setup var registry = new PersistenceRegistry(); // Call - TestDelegate test = () => registry.Register(null, new TestStochasticSoilModel()); + TestDelegate test = () => registry.Register(null, new PipingStochasticSoilModel("some name")); // Assert string paramName = Assert.Throws(test).ParamName; Assert.AreEqual("entity", paramName); } [Test] - public void Register_WithNullStochasticSoilModel_ThrowsArgumentNullException() + public void Register_WithNullPipingStochasticSoilModel_ThrowsArgumentNullException() { // Setup var registry = new PersistenceRegistry(); @@ -2131,21 +2130,21 @@ } [Test] - public void Register_WithNullStochasticSoilProfileEntity_ThrowsArgumentNullException() + public void Register_WithNullPipingStochasticSoilProfileEntity_ThrowsArgumentNullException() { // Setup var registry = new PersistenceRegistry(); // Call - TestDelegate test = () => registry.Register(null, new StochasticSoilProfile(1, SoilProfileType.SoilProfile1D, -1)); + TestDelegate test = () => registry.Register(null, new PipingStochasticSoilProfile(1, new TestPipingSoilProfile())); // Assert string paramName = Assert.Throws(test).ParamName; Assert.AreEqual("entity", paramName); } [Test] - public void Register_WithNullStochasticSoilProfile_ThrowsArgumentNullException() + public void Register_WithNullPipingStochasticSoilProfile_ThrowsArgumentNullException() { // Setup var registry = new PersistenceRegistry(); Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/Piping/PipingCalculationScenarioCreateExtensionsTest.cs =================================================================== diff -u -rd6fe8399e8398224cf1bda9259052232d85b85a4 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/Piping/PipingCalculationScenarioCreateExtensionsTest.cs (.../PipingCalculationScenarioCreateExtensionsTest.cs) (revision d6fe8399e8398224cf1bda9259052232d85b85a4) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/Piping/PipingCalculationScenarioCreateExtensionsTest.cs (.../PipingCalculationScenarioCreateExtensionsTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -30,6 +30,7 @@ using NUnit.Framework; using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.KernelWrapper.TestUtil; using Ringtoets.Piping.Primitives; @@ -240,12 +241,9 @@ { // Setup var soilProfile = new TestPipingSoilProfile(); - var stochasticSoilProfile = new StochasticSoilProfile(0.6, SoilProfileType.SoilProfile1D, 1) - { - SoilProfile = soilProfile - }; + var stochasticSoilProfile = new PipingStochasticSoilProfile(0.6, soilProfile); - var soilModel = new StochasticSoilModel("A"); + var soilModel = new PipingStochasticSoilModel("A"); soilModel.StochasticSoilProfiles.Add(stochasticSoilProfile); var registry = new PersistenceRegistry(); Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/Piping/PipingFailureMechanismCreateExtensionsTest.cs =================================================================== diff -u -rd6fe8399e8398224cf1bda9259052232d85b85a4 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/Piping/PipingFailureMechanismCreateExtensionsTest.cs (.../PipingFailureMechanismCreateExtensionsTest.cs) (revision d6fe8399e8398224cf1bda9259052232d85b85a4) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/Piping/PipingFailureMechanismCreateExtensionsTest.cs (.../PipingFailureMechanismCreateExtensionsTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -30,6 +30,7 @@ using NUnit.Framework; using Ringtoets.Common.Data.Calculation; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Primitives; namespace Application.Ringtoets.Storage.Test.Create.Piping @@ -149,8 +150,8 @@ const string somePath = "some/path/to/file"; failureMechanism.StochasticSoilModels.AddRange(new[] { - new StochasticSoilModel("name"), - new StochasticSoilModel("name2") + new PipingStochasticSoilModel("name"), + new PipingStochasticSoilModel("name2") }, somePath); var registry = new PersistenceRegistry(); Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/Piping/PipingStochasticSoilModelCreateExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/Piping/PipingStochasticSoilModelCreateExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/Piping/PipingStochasticSoilModelCreateExtensionsTest.cs (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -0,0 +1,147 @@ +// Copyright (C) Stichting Deltares 2017. 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.Piping; +using Application.Ringtoets.Storage.DbContext; +using Application.Ringtoets.Storage.Serializers; +using Core.Common.Base.Geometry; +using NUnit.Framework; +using Ringtoets.Piping.Data.SoilProfile; +using Ringtoets.Piping.Data.TestUtil; +using Ringtoets.Piping.KernelWrapper.TestUtil; + +namespace Application.Ringtoets.Storage.Test.Create.Piping +{ + [TestFixture] + public class PipingStochasticSoilModelCreateExtensionsTest + { + [Test] + public void Create_WithoutPersistenceRegistry_ThrowsArgumentNullException() + { + // Setup + PipingStochasticSoilModel stochasticSoilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(); + + // Call + TestDelegate test = () => stochasticSoilModel.Create(null, 0); + + // Assert + string parameterName = Assert.Throws(test).ParamName; + Assert.AreEqual("registry", parameterName); + } + + [Test] + public void Create_WithCollector_ReturnsStochasticSoilModelEntityWithPropertiesSet() + { + // Setup + int order = new Random(1).Next(); + const string testName = "testName"; + var stochasticSoilModel = new PipingStochasticSoilModel(testName); + var registry = new PersistenceRegistry(); + + // Call + StochasticSoilModelEntity entity = stochasticSoilModel.Create(registry, order); + + // Assert + Assert.IsNotNull(entity); + Assert.AreEqual(testName, entity.Name); + Assert.AreEqual(order, entity.Order); + CollectionAssert.IsEmpty(entity.StochasticSoilProfileEntities); + } + + [Test] + public void Create_StringPropertiesDoNotShareReference() + { + // Setup + const string testName = "testName"; + PipingStochasticSoilModel stochasticSoilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(testName); + var registry = new PersistenceRegistry(); + + // Call + StochasticSoilModelEntity entity = stochasticSoilModel.Create(registry, 0); + + // Assert + Assert.AreNotSame(testName, entity.Name, + "To create stable binary representations/fingerprints, it's really important that strings are not shared."); + Assert.AreEqual(testName, entity.Name); + } + + [Test] + public void Create_WithStochasticSoilProfiles_ReturnsStochasticSoilModelEntityWithPropertiesAndStochasticSoilProfileEntitiesSet() + { + // Setup + var stochasticSoilModel = new PipingStochasticSoilModel("testName") + { + StochasticSoilProfiles = + { + new PipingStochasticSoilProfile(0.5, new TestPipingSoilProfile()), + new PipingStochasticSoilProfile(0.5, new TestPipingSoilProfile()) + } + }; + var registry = new PersistenceRegistry(); + + // Call + StochasticSoilModelEntity entity = stochasticSoilModel.Create(registry, 0); + + // Assert + Assert.IsNotNull(entity); + Assert.AreEqual(2, entity.StochasticSoilProfileEntities.Count); + } + + [Test] + public void Create_WithGeometryPoints_ReturnsStochasticSoilModelEntityWithPropertiesAndStochasticSoilModelSegmentPointEntitiesSet() + { + // Setup + PipingStochasticSoilModel stochasticSoilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("testName"); + stochasticSoilModel.Geometry.AddRange(new[] + { + new Point2D(-12.34, 56.78), + new Point2D(91.23, -34.56) + }); + var registry = new PersistenceRegistry(); + + // Call + StochasticSoilModelEntity entity = stochasticSoilModel.Create(registry, 0); + + // Assert + Assert.IsNotNull(entity); + string expectedXml = new Point2DXmlSerializer().ToXml(stochasticSoilModel.Geometry); + Assert.AreEqual(expectedXml, entity.StochasticSoilModelSegmentPointXml); + } + + [Test] + public void Create_SameModelCreatedMultipleTimes_ReturnSameEntity() + { + // Setup + PipingStochasticSoilModel soilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("A"); + + var registry = new PersistenceRegistry(); + + // Call + StochasticSoilModelEntity entity1 = soilModel.Create(registry, 0); + StochasticSoilModelEntity entity2 = soilModel.Create(registry, 0); + + // Assert + Assert.AreSame(entity1, entity2); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/Piping/PipingStochasticSoilProfileCreateExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/Piping/PipingStochasticSoilProfileCreateExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/Piping/PipingStochasticSoilProfileCreateExtensionsTest.cs (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -0,0 +1,101 @@ +// Copyright (C) Stichting Deltares 2017. 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.Piping; +using Application.Ringtoets.Storage.DbContext; +using NUnit.Framework; +using Ringtoets.Piping.Data.SoilProfile; +using Ringtoets.Piping.KernelWrapper.TestUtil; + +namespace Application.Ringtoets.Storage.Test.Create.Piping +{ + [TestFixture] + public class PipingStochasticSoilProfileCreateExtensionsTest + { + [Test] + public void Create_WithoutPersistenceRegistry_ThrowsArgumentNullException() + { + // Setup + var stochasticSoilProfile = new PipingStochasticSoilProfile(0.4, new TestPipingSoilProfile()); + + // Call + TestDelegate test = () => stochasticSoilProfile.Create(null, 0); + + // Assert + string parameterName = Assert.Throws(test).ParamName; + Assert.AreEqual("registry", parameterName); + } + + [Test] + public void Create_WithCollector_ReturnsStochasticSoilProfileEntityWithPropertiesSet() + { + // Setup + var random = new Random(21); + double probability = random.NextDouble(); + int order = random.Next(); + var stochasticSoilProfile = new PipingStochasticSoilProfile(probability, new TestPipingSoilProfile()); + var registry = new PersistenceRegistry(); + + // Call + StochasticSoilProfileEntity entity = stochasticSoilProfile.Create(registry, order); + + // Assert + Assert.IsNotNull(entity); + Assert.AreEqual(probability, entity.Probability); + Assert.AreEqual(order, entity.Order); + } + + [Test] + public void Create_DifferentStochasticSoilProfilesWithSamePipingSoilProfile_ReturnsStochasticSoilProfileEntityWithSameSoilProfileEntitySet() + { + // Setup + var testPipingSoilProfile = new TestPipingSoilProfile(); + var firstStochasticSoilProfile = new PipingStochasticSoilProfile(new Random(21).NextDouble(), testPipingSoilProfile); + var secondStochasticSoilProfile = new PipingStochasticSoilProfile(new Random(21).NextDouble(), testPipingSoilProfile); + var registry = new PersistenceRegistry(); + + // Call + StochasticSoilProfileEntity firstEntity = firstStochasticSoilProfile.Create(registry, 0); + StochasticSoilProfileEntity secondEntity = secondStochasticSoilProfile.Create(registry, 0); + + // Assert + Assert.AreSame(firstEntity.SoilProfileEntity, secondEntity.SoilProfileEntity); + } + + [Test] + public void Create_SameStochasticSoilProfileMultipleTimes_ReturnSameEntity() + { + // Setup + var soilProfile = new TestPipingSoilProfile(); + var stochasticSoilProfile = new PipingStochasticSoilProfile(0.4, soilProfile); + var registry = new PersistenceRegistry(); + + // Call + StochasticSoilProfileEntity entity1 = stochasticSoilProfile.Create(registry, 0); + StochasticSoilProfileEntity entity2 = stochasticSoilProfile.Create(registry, 0); + + // Assert + Assert.AreSame(entity1, entity2); + } + } +} \ No newline at end of file Fisheye: Tag 26f527fb809a2325c8f883ece9da01a8f8040eb3 refers to a dead (removed) revision in file `Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/Piping/StochasticSoilModelCreateExtensionsTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 26f527fb809a2325c8f883ece9da01a8f8040eb3 refers to a dead (removed) revision in file `Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/Piping/StochasticSoilProfileCreateExtensionsTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/StorageSqLiteIntegrationTest.cs =================================================================== diff -u -rafa720a0da947ce7179500fefc71203d773de21e -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/StorageSqLiteIntegrationTest.cs (.../StorageSqLiteIntegrationTest.cs) (revision afa720a0da947ce7179500fefc71203d773de21e) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/StorageSqLiteIntegrationTest.cs (.../StorageSqLiteIntegrationTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -54,13 +54,12 @@ using Ringtoets.Integration.Data.StandAlone.SectionResults; using Ringtoets.MacroStabilityInwards.Data; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Primitives; using Ringtoets.Revetment.Data; using Ringtoets.StabilityPointStructures.Data; using Ringtoets.StabilityStoneCover.Data; using Ringtoets.WaveImpactAsphaltCover.Data; -using StochasticSoilModelCollection = Ringtoets.Piping.Data.StochasticSoilModelCollection; -using StochasticSoilProfile = Ringtoets.Piping.Data.StochasticSoilProfile; namespace Application.Ringtoets.Storage.Test.IntegrationTests { @@ -500,8 +499,8 @@ CollectionAssert.AreEqual(expectedReferenceLine.Points, actualReferenceLine.Points); } - private static void AssertStochasticSoilModels(StochasticSoilModelCollection expectedModels, - StochasticSoilModelCollection actualModels) + private static void AssertStochasticSoilModels(PipingStochasticSoilModelCollection expectedModels, + PipingStochasticSoilModelCollection actualModels) { Assert.Less(0, actualModels.Count); @@ -522,8 +521,8 @@ CollectionAssert.AreEqual(expectedSoilModelSegmentPoints, actualSoilModelSegmentPoints); } - private static void AssertStochasticSoilProfiles(IEnumerable expectedStochasticSoilProfiles, - IEnumerable actualStochasticSoilProfiles) + private static void AssertStochasticSoilProfiles(IEnumerable expectedStochasticSoilProfiles, + IEnumerable actualStochasticSoilProfiles) { Assert.Less(0, actualStochasticSoilProfiles.Count()); @@ -532,7 +531,7 @@ AssertPipingSoilProfile); } - private static void AssertPipingSoilProfile(StochasticSoilProfile expectedProfile, StochasticSoilProfile actualProfile) + private static void AssertPipingSoilProfile(PipingStochasticSoilProfile expectedProfile, PipingStochasticSoilProfile actualProfile) { Assert.AreEqual(expectedProfile.Probability, actualProfile.Probability); Assert.AreEqual(expectedProfile.SoilProfile.Bottom, actualProfile.SoilProfile.Bottom); Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/FailureMechanismEntityReadExtensionsTest.cs =================================================================== diff -u -rfe90a6d174a01975381e6cda55ed1f7f4e831a51 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/FailureMechanismEntityReadExtensionsTest.cs (.../FailureMechanismEntityReadExtensionsTest.cs) (revision fe90a6d174a01975381e6cda55ed1f7f4e831a51) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/FailureMechanismEntityReadExtensionsTest.cs (.../FailureMechanismEntityReadExtensionsTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -39,6 +39,7 @@ using Ringtoets.GrassCoverErosionOutwards.Data; using Ringtoets.HeightStructures.Data; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.StabilityPointStructures.Data; using Ringtoets.StabilityStoneCover.Data; using Ringtoets.WaveImpactAsphaltCover.Data; @@ -321,7 +322,7 @@ entity.ReadAsPipingFailureMechanism(failureMechanism, collector); // Assert - StochasticSoilModelCollection stochasticSoilModels = failureMechanism.StochasticSoilModels; + PipingStochasticSoilModelCollection stochasticSoilModels = failureMechanism.StochasticSoilModels; Assert.AreEqual(sourcePath, stochasticSoilModels.SourcePath); CollectionAssert.IsEmpty(stochasticSoilModels); } Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/Piping/PipingCalculationEntityReadExtensionsTest.cs =================================================================== diff -u -rd6fe8399e8398224cf1bda9259052232d85b85a4 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/Piping/PipingCalculationEntityReadExtensionsTest.cs (.../PipingCalculationEntityReadExtensionsTest.cs) (revision d6fe8399e8398224cf1bda9259052232d85b85a4) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/Piping/PipingCalculationEntityReadExtensionsTest.cs (.../PipingCalculationEntityReadExtensionsTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -30,6 +30,8 @@ using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Data.TestUtil; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; +using Ringtoets.Piping.KernelWrapper.TestUtil; using Ringtoets.Piping.Primitives; namespace Application.Ringtoets.Storage.Test.Read.Piping @@ -245,10 +247,10 @@ public void Read_EntityWithStochasticSoilModelEntityInCollector_CalculationHasAlreadyReadStochasticSoilModel() { // Setup - var stochasticSoilModel = new StochasticSoilModel("A"); + var stochasticSoilModel = new PipingStochasticSoilModel("A"); var stochasticSoilModelEntity = new StochasticSoilModelEntity(); - var stochasticSoilProfile = new StochasticSoilProfile(1, SoilProfileType.SoilProfile1D, 1); + var stochasticSoilProfile = new PipingStochasticSoilProfile(1, new TestPipingSoilProfile()); var stochasticSoilProfileEntity = new StochasticSoilProfileEntity { StochasticSoilModelEntity = stochasticSoilModelEntity Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/Piping/StochasticSoilModelEntityReadExtensionsTest.cs =================================================================== diff -u -r8a0dd3cd494c23f4801327565ddf5d774949e077 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/Piping/StochasticSoilModelEntityReadExtensionsTest.cs (.../StochasticSoilModelEntityReadExtensionsTest.cs) (revision 8a0dd3cd494c23f4801327565ddf5d774949e077) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/Piping/StochasticSoilModelEntityReadExtensionsTest.cs (.../StochasticSoilModelEntityReadExtensionsTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -27,7 +27,7 @@ using Application.Ringtoets.Storage.Serializers; using Core.Common.Base.Geometry; using NUnit.Framework; -using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; namespace Application.Ringtoets.Storage.Test.Read.Piping { @@ -81,7 +81,7 @@ var collector = new ReadConversionCollector(); // Call - StochasticSoilModel model = entity.Read(collector); + PipingStochasticSoilModel model = entity.Read(collector); // Assert Assert.IsNotNull(model); @@ -127,7 +127,7 @@ var collector = new ReadConversionCollector(); // Call - StochasticSoilModel model = entity.Read(collector); + PipingStochasticSoilModel model = entity.Read(collector); // Assert Assert.AreEqual(2, model.StochasticSoilProfiles.Count); @@ -155,7 +155,7 @@ var collector = new ReadConversionCollector(); // Call - StochasticSoilModel model = entity.Read(collector); + PipingStochasticSoilModel model = entity.Read(collector); // Assert CollectionAssert.AreEqual(segmentPoints, model.Geometry); @@ -173,8 +173,8 @@ var collector = new ReadConversionCollector(); // Call - StochasticSoilModel soilModel1 = entity.Read(collector); - StochasticSoilModel soilModel2 = entity.Read(collector); + PipingStochasticSoilModel soilModel1 = entity.Read(collector); + PipingStochasticSoilModel soilModel2 = entity.Read(collector); // Assert Assert.AreSame(soilModel1, soilModel2); Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/Piping/StochasticSoilProfileEntityReadExtensionsTest.cs =================================================================== diff -u -r3fb0df0ed6e64657154700ee7706e035d5bf99f5 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/Piping/StochasticSoilProfileEntityReadExtensionsTest.cs (.../StochasticSoilProfileEntityReadExtensionsTest.cs) (revision 3fb0df0ed6e64657154700ee7706e035d5bf99f5) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/Piping/StochasticSoilProfileEntityReadExtensionsTest.cs (.../StochasticSoilProfileEntityReadExtensionsTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -24,8 +24,7 @@ using Application.Ringtoets.Storage.Read; using Application.Ringtoets.Storage.Read.Piping; using NUnit.Framework; -using Ringtoets.Piping.Data; -using Ringtoets.Piping.Primitives; +using Ringtoets.Piping.Data.SoilProfile; namespace Application.Ringtoets.Storage.Test.Read.Piping { @@ -69,12 +68,11 @@ var collector = new ReadConversionCollector(); // Call - StochasticSoilProfile profile = entity.Read(collector); + PipingStochasticSoilProfile profile = entity.Read(collector); // Assert Assert.IsNotNull(profile); Assert.AreEqual(probability, profile.Probability, 1e-6); - Assert.AreEqual((SoilProfileType) soilProfileType, profile.SoilProfileType); Assert.IsTrue(collector.Contains(entity)); } @@ -102,10 +100,10 @@ }; var collector = new ReadConversionCollector(); - StochasticSoilProfile firstProfile = firstEntity.Read(collector); + PipingStochasticSoilProfile firstProfile = firstEntity.Read(collector); // Call - StochasticSoilProfile secondProfile = secondEntity.Read(collector); + PipingStochasticSoilProfile secondProfile = secondEntity.Read(collector); // Assert Assert.AreNotSame(firstProfile, secondProfile); @@ -130,8 +128,8 @@ var collector = new ReadConversionCollector(); // Call - StochasticSoilProfile profile1 = entity.Read(collector); - StochasticSoilProfile profile2 = entity.Read(collector); + PipingStochasticSoilProfile profile1 = entity.Read(collector); + PipingStochasticSoilProfile profile2 = entity.Read(collector); // Assert Assert.AreSame(profile1, profile2); Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/ReadConversionCollectorTest.cs =================================================================== diff -u -raa49537188229065df91b1a931f088c32115702a -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/ReadConversionCollectorTest.cs (.../ReadConversionCollectorTest.cs) (revision aa49537188229065df91b1a931f088c32115702a) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/ReadConversionCollectorTest.cs (.../ReadConversionCollectorTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -36,7 +36,7 @@ using Ringtoets.GrassCoverErosionInwards.Data; using Ringtoets.HeightStructures.Data; using Ringtoets.HeightStructures.Data.TestUtil; -using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.KernelWrapper.TestUtil; using Ringtoets.Piping.Primitives; using Ringtoets.StabilityPointStructures.Data; @@ -69,7 +69,7 @@ // Setup var collector = new ReadConversionCollector(); var entity = new StochasticSoilProfileEntity(); - collector.Read(entity, new StochasticSoilProfile(1, SoilProfileType.SoilProfile1D, 1)); + collector.Read(entity, new PipingStochasticSoilProfile(1, new TestPipingSoilProfile())); // Call bool result = collector.Contains(entity); @@ -98,7 +98,7 @@ // Setup var collector = new ReadConversionCollector(); var entity = new StochasticSoilProfileEntity(); - collector.Read(new StochasticSoilProfileEntity(), new StochasticSoilProfile(0.4, SoilProfileType.SoilProfile2D, 2)); + collector.Read(new StochasticSoilProfileEntity(), new PipingStochasticSoilProfile(0.4, new TestPipingSoilProfile())); // Call bool result = collector.Contains(entity); @@ -126,12 +126,12 @@ { // Setup var collector = new ReadConversionCollector(); - var profile = new StochasticSoilProfile(0.5, SoilProfileType.SoilProfile2D, 2); + var profile = new PipingStochasticSoilProfile(0.5, new TestPipingSoilProfile()); var entity = new StochasticSoilProfileEntity(); collector.Read(entity, profile); // Call - StochasticSoilProfile result = collector.Get(entity); + PipingStochasticSoilProfile result = collector.Get(entity); // Assert Assert.AreSame(profile, result); @@ -157,7 +157,7 @@ // Setup var collector = new ReadConversionCollector(); var entity = new StochasticSoilProfileEntity(); - collector.Read(new StochasticSoilProfileEntity(), new StochasticSoilProfile(0.7, SoilProfileType.SoilProfile1D, 6)); + collector.Read(new StochasticSoilProfileEntity(), new PipingStochasticSoilProfile(0.7, new TestPipingSoilProfile())); // Call TestDelegate test = () => collector.Get(entity); @@ -173,7 +173,7 @@ var collector = new ReadConversionCollector(); // Call - TestDelegate test = () => collector.Read(null, new StochasticSoilProfile(0.7, SoilProfileType.SoilProfile1D, 6)); + TestDelegate test = () => collector.Read(null, new PipingStochasticSoilProfile(0.7, new TestPipingSoilProfile())); // Assert string paramName = Assert.Throws(test).ParamName; Index: Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil.Test/RingtoetsProjectTestHelperTest.cs =================================================================== diff -u -rafa720a0da947ce7179500fefc71203d773de21e -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil.Test/RingtoetsProjectTestHelperTest.cs (.../RingtoetsProjectTestHelperTest.cs) (revision afa720a0da947ce7179500fefc71203d773de21e) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil.Test/RingtoetsProjectTestHelperTest.cs (.../RingtoetsProjectTestHelperTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -35,6 +35,7 @@ using Ringtoets.HeightStructures.Data; using Ringtoets.Integration.Data; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Primitives; using Ringtoets.StabilityPointStructures.Data; using Ringtoets.StabilityStoneCover.Data; @@ -90,17 +91,13 @@ PipingFailureMechanism failureMechanism = assessmentSection.PipingFailureMechanism; Assert.AreEqual("some/path/to/stochasticSoilModelFile", failureMechanism.StochasticSoilModels.SourcePath); Assert.AreEqual(1, failureMechanism.StochasticSoilModels.Count); - StochasticSoilModel soilModel = failureMechanism.StochasticSoilModels[0]; + PipingStochasticSoilModel soilModel = failureMechanism.StochasticSoilModels[0]; Assert.AreEqual("modelName", soilModel.Name); Assert.AreEqual(2, soilModel.StochasticSoilProfiles.Count); - StochasticSoilProfile stochasticSoilProfile1 = soilModel.StochasticSoilProfiles[0]; + PipingStochasticSoilProfile stochasticSoilProfile1 = soilModel.StochasticSoilProfiles[0]; Assert.AreEqual(0.2, stochasticSoilProfile1.Probability); - Assert.AreEqual(SoilProfileType.SoilProfile1D, stochasticSoilProfile1.SoilProfileType); - Assert.AreEqual(-1, stochasticSoilProfile1.SoilProfileId); - StochasticSoilProfile stochasticSoilProfile2 = soilModel.StochasticSoilProfiles[1]; + PipingStochasticSoilProfile stochasticSoilProfile2 = soilModel.StochasticSoilProfiles[1]; Assert.AreEqual(0.8, stochasticSoilProfile2.Probability); - Assert.AreEqual(SoilProfileType.SoilProfile2D, stochasticSoilProfile2.SoilProfileType); - Assert.AreEqual(-1, stochasticSoilProfile2.SoilProfileId); Assert.AreEqual("some/path/to/surfaceLineFile", failureMechanism.SurfaceLines.SourcePath); Assert.AreEqual(1, failureMechanism.SurfaceLines.Count); Index: Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsProjectTestHelper.cs =================================================================== diff -u -rafa720a0da947ce7179500fefc71203d773de21e -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsProjectTestHelper.cs (.../RingtoetsProjectTestHelper.cs) (revision afa720a0da947ce7179500fefc71203d773de21e) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsProjectTestHelper.cs (.../RingtoetsProjectTestHelper.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -46,15 +46,14 @@ using Ringtoets.Integration.Data.StandAlone.SectionResults; using Ringtoets.MacroStabilityInwards.Data; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.KernelWrapper.TestUtil; using Ringtoets.Piping.Primitives; using Ringtoets.Revetment.Data; using Ringtoets.StabilityPointStructures.Data; using Ringtoets.StabilityPointStructures.Data.TestUtil; using Ringtoets.StabilityStoneCover.Data; using Ringtoets.WaveImpactAsphaltCover.Data; -using StochasticSoilModel = Ringtoets.Piping.Data.StochasticSoilModel; -using StochasticSoilProfile = Ringtoets.Piping.Data.StochasticSoilProfile; namespace Application.Ringtoets.Storage.TestUtil { @@ -874,7 +873,7 @@ pipingFailureMechanism.StochasticSoilModels.AddRange(new[] { - new StochasticSoilModel("modelName") + new PipingStochasticSoilModel("modelName") { Geometry = { @@ -884,14 +883,8 @@ }, StochasticSoilProfiles = { - new StochasticSoilProfile(0.2, SoilProfileType.SoilProfile1D, -1) - { - SoilProfile = pipingSoilProfile - }, - new StochasticSoilProfile(0.8, SoilProfileType.SoilProfile2D, -1) - { - SoilProfile = new TestPipingSoilProfile() - } + new PipingStochasticSoilProfile(0.2, pipingSoilProfile), + new PipingStochasticSoilProfile(0.8, new TestPipingSoilProfile()) } } }, "some/path/to/stochasticSoilModelFile"); Index: Demo/Ringtoets/src/Demo.Ringtoets/Commands/AddNewDemoAssessmentSectionCommand.cs =================================================================== diff -u -re6671f07e31bef1e5617d8998ce01be60cc648d2 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Demo/Ringtoets/src/Demo.Ringtoets/Commands/AddNewDemoAssessmentSectionCommand.cs (.../AddNewDemoAssessmentSectionCommand.cs) (revision e6671f07e31bef1e5617d8998ce01be60cc648d2) +++ Demo/Ringtoets/src/Demo.Ringtoets/Commands/AddNewDemoAssessmentSectionCommand.cs (.../AddNewDemoAssessmentSectionCommand.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -39,14 +39,15 @@ using Ringtoets.Common.IO.FileImporters; using Ringtoets.Common.IO.FileImporters.MessageProviders; using Ringtoets.Common.IO.ReferenceLines; +using Ringtoets.Common.IO.SoilProfile; using Ringtoets.Common.IO.SurfaceLines; using Ringtoets.GrassCoverErosionInwards.Data; using Ringtoets.GrassCoverErosionOutwards.Data; using Ringtoets.HeightStructures.Data; using Ringtoets.Integration.Data; using Ringtoets.Integration.Plugin.Handlers; using Ringtoets.Piping.Data; -using Ringtoets.Piping.IO.Importers; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Plugin.FileImporter; using Ringtoets.Piping.Primitives; using Ringtoets.StabilityPointStructures.Data; @@ -590,11 +591,12 @@ using (var embeddedResourceFileWriter = new EmbeddedResourceFileWriter(GetType().Assembly, true, "DR6.soil")) { - var soilProfilesImporter = new StochasticSoilModelImporter(pipingFailureMechanism.StochasticSoilModels, - Path.Combine(embeddedResourceFileWriter.TargetFolderPath, - "DR6.soil"), - new ImportMessageProvider(), - new StochasticSoilModelReplaceDataStrategy(pipingFailureMechanism)); + var soilProfilesImporter = + new StochasticSoilModelImporter( + pipingFailureMechanism.StochasticSoilModels, + Path.Combine(embeddedResourceFileWriter.TargetFolderPath, "DR6.soil"), + new ImportMessageProvider(), + StochasticSoilModelImporterConfigurationFactory.CreateReplaceStrategyConfiguration(pipingFailureMechanism)); soilProfilesImporter.Import(); } @@ -608,7 +610,7 @@ }; calculation.InputParameters.SurfaceLine = pipingFailureMechanism.SurfaceLines.First(sl => sl.Name == "PK001_0001"); - StochasticSoilModel stochasticSoilModel = pipingFailureMechanism.StochasticSoilModels.First(sm => sm.Name == "PK001_0001_Piping"); + PipingStochasticSoilModel stochasticSoilModel = pipingFailureMechanism.StochasticSoilModels.First(sm => sm.Name == "PK001_0001_Piping"); calculation.InputParameters.StochasticSoilModel = stochasticSoilModel; calculation.InputParameters.StochasticSoilProfile = stochasticSoilModel.StochasticSoilProfiles.First(sp => sp.SoilProfile.Name == "W1-6_0_1D1"); calculation.InputParameters.HydraulicBoundaryLocation = demoAssessmentSection.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001); Index: Demo/Ringtoets/test/Demo.Ringtoets.Test/Commands/AddNewDemoAssessmentSectionCommandTest.cs =================================================================== diff -u -r3178e116f5e59e03078d465efeb303c5e232c7bf -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Demo/Ringtoets/test/Demo.Ringtoets.Test/Commands/AddNewDemoAssessmentSectionCommandTest.cs (.../AddNewDemoAssessmentSectionCommandTest.cs) (revision 3178e116f5e59e03078d465efeb303c5e232c7bf) +++ Demo/Ringtoets/test/Demo.Ringtoets.Test/Commands/AddNewDemoAssessmentSectionCommandTest.cs (.../AddNewDemoAssessmentSectionCommandTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -43,6 +43,7 @@ using Ringtoets.HeightStructures.Data; using Ringtoets.Integration.Data; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Primitives; using Ringtoets.Piping.Service; using Ringtoets.Revetment.Data; @@ -374,7 +375,7 @@ private static void AssertPipingFailureMechanism(AssessmentSection demoAssessmentSection) { - StochasticSoilModel[] soilModels = demoAssessmentSection.PipingFailureMechanism.StochasticSoilModels.ToArray(); + PipingStochasticSoilModel[] soilModels = demoAssessmentSection.PipingFailureMechanism.StochasticSoilModels.ToArray(); Assert.AreEqual(4, soilModels.Length); PipingSurfaceLine[] surfaceLines = demoAssessmentSection.PipingFailureMechanism.SurfaceLines.ToArray(); Assert.AreEqual(4, surfaceLines.Length); Index: Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/StochasticSoilModelImporter.cs =================================================================== diff -u -r4fc96d31a69029557095247c8ff890d06239b65a -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/StochasticSoilModelImporter.cs (.../StochasticSoilModelImporter.cs) (revision 4fc96d31a69029557095247c8ff890d06239b65a) +++ Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/StochasticSoilModelImporter.cs (.../StochasticSoilModelImporter.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -241,10 +241,7 @@ return new ReadResult(false); } - if (!ValidateStochasticSoilModel(stochasticSoilModel)) - { - return new ReadResult(true); - } + ValidateStochasticSoilModel(stochasticSoilModel); transformedStochasticSoilModels.Add(transformer.Transform(stochasticSoilModel)); } @@ -255,21 +252,13 @@ }; } - /// - /// Validate the definition of a . - /// - /// The to validate. - /// false when the sum of the stochastic soil profiles in the stochastic - /// soil model does add up to 100%, true otherwise. - private bool ValidateStochasticSoilModel(StochasticSoilModel stochasticSoilModel) + private void ValidateStochasticSoilModel(StochasticSoilModel stochasticSoilModel) { if (!IsSumOfAllProbabilitiesEqualToOne(stochasticSoilModel)) { - Log.ErrorFormat(Resources.StochasticSoilModelImporter_ValidateStochasticSoilModel_Sum_of_probabilities_of_stochastic_soil_model_0_is_not_correct, - stochasticSoilModel.Name); - return false; + Log.WarnFormat(Resources.StochasticSoilModelImporter_ValidateStochasticSoilModel_Sum_of_probabilities_of_stochastic_soil_model_0_is_not_correct, + stochasticSoilModel.Name); } - return true; } private static bool IsSumOfAllProbabilitiesEqualToOne(StochasticSoilModel stochasticSoilModel) Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/StochasticSoilModelImporterTest.cs =================================================================== diff -u -r4fc96d31a69029557095247c8ff890d06239b65a -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/StochasticSoilModelImporterTest.cs (.../StochasticSoilModelImporterTest.cs) (revision 4fc96d31a69029557095247c8ff890d06239b65a) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/StochasticSoilModelImporterTest.cs (.../StochasticSoilModelImporterTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -719,8 +719,17 @@ public void Import_IncorrectProbability_LogAndImportSoilModelToCollection() { // Setup + string validFilePath = Path.Combine(testDataPath, "incorrectProbability.soil"); + const string expectedAddDataProgressText = "Adding data..."; + + var stochasticSoilModelCollection = new TestStochasticSoilModelCollection(); + var messageProvider = mocks.StrictMock(); + messageProvider.Expect(mp => mp.GetAddDataToModelProgressText()) + .Return(expectedAddDataProgressText); var updateStrategy = mocks.StrictMock>(); + updateStrategy.Expect(u => u.UpdateModelWithImportedData(Arg.List.ContainsAll(stochasticSoilModelCollection), + Arg.Is.Equal(validFilePath))); var filter = mocks.StrictMock(); filter.Expect(f => f.IsValidForFailureMechanism(null)) .IgnoreArguments() @@ -729,10 +738,8 @@ .AtLeastOnce(); mocks.ReplayAll(); - string validFilePath = Path.Combine(testDataPath, "incorrectProbability.soil"); - var importer = new StochasticSoilModelImporter( - new TestStochasticSoilModelCollection(), + stochasticSoilModelCollection, validFilePath, messageProvider, new StochasticSoilModelImporterConfiguration( @@ -747,9 +754,9 @@ // Assert const string expectedLogMessage = "De som van de kansen van voorkomen in het stochastich ondergrondmodel 'Name' is niet gelijk aan 100%."; - Tuple expectedLogMessageAndLevel = Tuple.Create(expectedLogMessage, LogLevelConstant.Error); + Tuple expectedLogMessageAndLevel = Tuple.Create(expectedLogMessage, LogLevelConstant.Warn); TestHelper.AssertLogMessageWithLevelIsGenerated(call, expectedLogMessageAndLevel, 1); - Assert.IsFalse(importResult); + Assert.IsTrue(importResult); } [Test] Index: Ringtoets/Integration/test/Ringtoets.Integration.Service.Test/RingtoetsDataSynchronizationServiceTest.cs =================================================================== diff -u -r902fc625ae4a0c3344e9e50d5e1560c060728e12 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Integration/test/Ringtoets.Integration.Service.Test/RingtoetsDataSynchronizationServiceTest.cs (.../RingtoetsDataSynchronizationServiceTest.cs) (revision 902fc625ae4a0c3344e9e50d5e1560c060728e12) +++ Ringtoets/Integration/test/Ringtoets.Integration.Service.Test/RingtoetsDataSynchronizationServiceTest.cs (.../RingtoetsDataSynchronizationServiceTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -45,11 +45,11 @@ using Ringtoets.MacroStabilityInwards.Data; using Ringtoets.MacroStabilityInwards.Primitives; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Primitives; using Ringtoets.StabilityPointStructures.Data; using Ringtoets.StabilityStoneCover.Data; using Ringtoets.WaveImpactAsphaltCover.Data; -using PipingStochasticSoilModel = Ringtoets.Piping.Data.StochasticSoilModel; using MacroStabilityInwardsStochasticSoilModel = Ringtoets.MacroStabilityInwards.Data.StochasticSoilModel; namespace Ringtoets.Integration.Service.Test Index: Ringtoets/Integration/test/Ringtoets.Integration.TestUtils/DataImportHelper.cs =================================================================== diff -u -rcd90ebf744fb74f0d4b0dd6ee06f9c39b5faf213 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Integration/test/Ringtoets.Integration.TestUtils/DataImportHelper.cs (.../DataImportHelper.cs) (revision cd90ebf744fb74f0d4b0dd6ee06f9c39b5faf213) +++ Ringtoets/Integration/test/Ringtoets.Integration.TestUtils/DataImportHelper.cs (.../DataImportHelper.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -33,13 +33,16 @@ using Ringtoets.Common.IO.FileImporters; using Ringtoets.Common.IO.FileImporters.MessageProviders; using Ringtoets.Common.IO.ReferenceLines; +using Ringtoets.Common.IO.SoilProfile; using Ringtoets.Common.IO.SurfaceLines; using Ringtoets.Integration.Data; using Ringtoets.Integration.Plugin.Handlers; using Ringtoets.MacroStabilityInwards.Data; +using Ringtoets.MacroStabilityInwards.IO.Importers; +using Ringtoets.MacroStabilityInwards.Plugin.FileImporter; using Ringtoets.MacroStabilityInwards.Primitives; using Ringtoets.Piping.Data; -using Ringtoets.Piping.IO.Importers; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Plugin.FileImporter; using Ringtoets.Piping.Primitives; using PipingSurfaceLinesCsvImporterConfigurationFactory = Ringtoets.Piping.Plugin.FileImporter.SurfaceLinesCsvImporterConfigurationFactory; @@ -204,7 +207,7 @@ } /// - /// Imports the data for the + /// Imports the data for the /// of the given . /// /// The to import on. @@ -216,12 +219,13 @@ "DR6.soil")) { string filePath = Path.Combine(embeddedResourceFileWriter.TargetFolderPath, "DR6.soil"); - var activity = new FileImportActivity(new StochasticSoilModelImporter( - assessmentSection.PipingFailureMechanism.StochasticSoilModels, - filePath, - new ImportMessageProvider(), - new StochasticSoilModelReplaceDataStrategy(assessmentSection.PipingFailureMechanism)), - "StochasticSoilModelImporter"); + var activity = new FileImportActivity( + new StochasticSoilModelImporter( + assessmentSection.PipingFailureMechanism.StochasticSoilModels, + filePath, + new ImportMessageProvider(), + StochasticSoilModelImporterConfigurationFactory.CreateReplaceStrategyConfiguration(assessmentSection.PipingFailureMechanism)), + "StochasticSoilModelImporter"); activity.Run(); activity.Finish(); } @@ -269,11 +273,11 @@ "DR6.soil")) { string filePath = Path.Combine(embeddedResourceFileWriter.TargetFolderPath, "DR6.soil"); - var activity = new FileImportActivity(new MacroStabilityInwards.IO.Importers.StochasticSoilModelImporter( + var activity = new FileImportActivity(new StochasticSoilModelImporter( assessmentSection.MacroStabilityInwards.StochasticSoilModels, filePath, new ImportMessageProvider(), - new MacroStabilityInwards.Plugin.FileImporter.StochasticSoilModelReplaceDataStrategy(assessmentSection.MacroStabilityInwards)), + new StochasticSoilModelReplaceDataStrategy(assessmentSection.MacroStabilityInwards)), "StochasticSoilModelImporter"); activity.Run(); activity.Finish(); Index: Ringtoets/Integration/test/Ringtoets.Integration.TestUtils/DataUpdateHelper.cs =================================================================== diff -u -r650fc7b43cb6729baee51d079f0377df8d7a3de9 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Integration/test/Ringtoets.Integration.TestUtils/DataUpdateHelper.cs (.../DataUpdateHelper.cs) (revision 650fc7b43cb6729baee51d079f0377df8d7a3de9) +++ Ringtoets/Integration/test/Ringtoets.Integration.TestUtils/DataUpdateHelper.cs (.../DataUpdateHelper.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -24,9 +24,12 @@ using Core.Common.Utils.IO; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.IO.FileImporters.MessageProviders; +using Ringtoets.Common.IO.SoilProfile; using Ringtoets.Integration.Data; +using Ringtoets.MacroStabilityInwards.IO.Importers; +using Ringtoets.MacroStabilityInwards.Plugin.FileImporter; using Ringtoets.Piping.Data; -using Ringtoets.Piping.IO.Importers; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Plugin.FileImporter; namespace Ringtoets.Integration.TestUtils @@ -37,7 +40,7 @@ public static class DataUpdateHelper { /// - /// Imports the data for the + /// Imports the data for the /// of the given and updates existing data based upon the imported /// data. /// @@ -52,12 +55,13 @@ "DR6_updated.soil")) { string filePath = Path.Combine(embeddedResourceFileWriter.TargetFolderPath, "DR6_updated.soil"); - var activity = new FileImportActivity(new StochasticSoilModelImporter( - assessmentSection.PipingFailureMechanism.StochasticSoilModels, - filePath, - new UpdateMessageProvider(), - new StochasticSoilModelUpdateDataStrategy(assessmentSection.PipingFailureMechanism)), - "StochasticSoilModelUpdater"); + var activity = new FileImportActivity( + new StochasticSoilModelImporter( + assessmentSection.PipingFailureMechanism.StochasticSoilModels, + filePath, + new UpdateMessageProvider(), + StochasticSoilModelImporterConfigurationFactory.CreateUpdateStrategyConfiguration(assessmentSection.PipingFailureMechanism)), + "StochasticSoilModelUpdater"); activity.Run(); activity.Finish(); } @@ -79,11 +83,11 @@ "DR6_updated.soil")) { string filePath = Path.Combine(embeddedResourceFileWriter.TargetFolderPath, "DR6_updated.soil"); - var activity = new FileImportActivity(new MacroStabilityInwards.IO.Importers.StochasticSoilModelImporter( + var activity = new FileImportActivity(new StochasticSoilModelImporter( assessmentSection.MacroStabilityInwards.StochasticSoilModels, filePath, new UpdateMessageProvider(), - new MacroStabilityInwards.Plugin.FileImporter.StochasticSoilModelUpdateDataStrategy(assessmentSection.MacroStabilityInwards)), + new StochasticSoilModelUpdateDataStrategy(assessmentSection.MacroStabilityInwards)), "StochasticSoilModelUpdater"); activity.Run(); activity.Finish(); Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/DerivedPipingInput.cs =================================================================== diff -u -rfc7fef209ce94b913bf4bfb974abd71242b4769d -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/src/Ringtoets.Piping.Data/DerivedPipingInput.cs (.../DerivedPipingInput.cs) (revision fc7fef209ce94b913bf4bfb974abd71242b4769d) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/DerivedPipingInput.cs (.../DerivedPipingInput.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -25,6 +25,7 @@ using Core.Common.Base.Data; using Ringtoets.Common.Data.Exceptions; using Ringtoets.Common.Data.Probabilistics; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.InputParameterCalculation; using Ringtoets.Piping.Primitives; @@ -204,7 +205,7 @@ private void UpdateThicknessAquiferLayerMean(LogNormalDistribution thicknessAquiferLayer) { - StochasticSoilProfile stochasticSoilProfile = input.StochasticSoilProfile; + PipingStochasticSoilProfile stochasticSoilProfile = input.StochasticSoilProfile; PipingSurfaceLine surfaceLine = input.SurfaceLine; RoundedDouble exitPointL = input.ExitPointL; @@ -222,7 +223,7 @@ private void UpdateThicknessCoverageLayerMean(LogNormalDistribution thicknessCoverageLayerDistribution) { - StochasticSoilProfile stochasticSoilProfile = input.StochasticSoilProfile; + PipingStochasticSoilProfile stochasticSoilProfile = input.StochasticSoilProfile; PipingSurfaceLine surfaceLine = input.SurfaceLine; RoundedDouble exitPointL = input.ExitPointL; Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingFailureMechanism.cs =================================================================== diff -u -raa49537188229065df91b1a931f088c32115702a -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingFailureMechanism.cs (.../PipingFailureMechanism.cs) (revision aa49537188229065df91b1a931f088c32115702a) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingFailureMechanism.cs (.../PipingFailureMechanism.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -22,6 +22,7 @@ using System.Collections.Generic; using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Piping.Data.SoilProfile; using RingtoetsCommonDataResources = Ringtoets.Common.Data.Properties.Resources; using PipingDataResources = Ringtoets.Piping.Data.Properties.Resources; @@ -43,7 +44,7 @@ PipingProbabilityAssessmentInput = new PipingProbabilityAssessmentInput(); GeneralInput = new GeneralPipingInput(); SurfaceLines = new PipingSurfaceLineCollection(); - StochasticSoilModels = new StochasticSoilModelCollection(); + StochasticSoilModels = new PipingStochasticSoilModelCollection(); CalculationsGroup = new CalculationGroup(RingtoetsCommonDataResources.FailureMechanism_Calculations_DisplayName, false); sectionResults = new List(); @@ -65,7 +66,7 @@ /// /// Gets the available stochastic soil models within the scope of the piping failure mechanism. /// - public StochasticSoilModelCollection StochasticSoilModels { get; } + public PipingStochasticSoilModelCollection StochasticSoilModels { get; } /// /// Gets the general piping calculation input parameters that apply to each piping calculation. Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingInput.cs =================================================================== diff -u -rd6fe8399e8398224cf1bda9259052232d85b85a4 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingInput.cs (.../PipingInput.cs) (revision d6fe8399e8398224cf1bda9259052232d85b85a4) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingInput.cs (.../PipingInput.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -29,6 +29,7 @@ using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Data.Probabilistics; using Ringtoets.Piping.Data.Properties; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Primitives; namespace Ringtoets.Piping.Data @@ -176,14 +177,14 @@ } /// - /// Gets or sets the stochastic soil model which is linked to the . + /// Gets or sets the stochastic soil model which is linked to the . /// - public StochasticSoilModel StochasticSoilModel { get; set; } + public PipingStochasticSoilModel StochasticSoilModel { get; set; } /// /// Gets or sets the profile which contains a 1 dimensional definition of soil layers with properties. /// - public StochasticSoilProfile StochasticSoilProfile { get; set; } + public PipingStochasticSoilProfile StochasticSoilProfile { get; set; } /// /// Gets or sets the hydraulic boundary location from which to use the assessment level. Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/Ringtoets.Piping.Data.csproj =================================================================== diff -u -r94ce658a9488c346f114446f0e37dabab7acaa38 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/src/Ringtoets.Piping.Data/Ringtoets.Piping.Data.csproj (.../Ringtoets.Piping.Data.csproj) (revision 94ce658a9488c346f114446f0e37dabab7acaa38) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/Ringtoets.Piping.Data.csproj (.../Ringtoets.Piping.Data.csproj) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -61,12 +61,10 @@ + + + - - - - - Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/SoilProfile/PipingStochasticSoilModel.cs =================================================================== diff -u -rb78437864e9677d66dc309d766b0e706c8af0c1f -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/src/Ringtoets.Piping.Data/SoilProfile/PipingStochasticSoilModel.cs (.../PipingStochasticSoilModel.cs) (revision b78437864e9677d66dc309d766b0e706c8af0c1f) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/SoilProfile/PipingStochasticSoilModel.cs (.../PipingStochasticSoilModel.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -19,10 +19,13 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.Collections.Generic; +using System.Linq; using Core.Common.Base; using Core.Common.Base.Geometry; using Ringtoets.Common.Data; +using Ringtoets.Piping.Primitives; namespace Ringtoets.Piping.Data.SoilProfile { @@ -47,7 +50,7 @@ /// /// Gets the name of the soil model. /// - public string Name { get; } + public string Name { get; private set; } /// /// Gets the list of geometry points. @@ -59,9 +62,81 @@ /// public List StochasticSoilProfiles { get; } + /// + /// Updates the with the properties from . + /// + /// The to + /// obtain the property values from. + /// The differences summed up in an instance of . + /// Thrown when + /// is null. + /// Thrown when + /// contains multiple profiles with the same name, and also contains a + /// profile with the same name. + /// + public PipingStochasticSoilModelProfileDifference Update(PipingStochasticSoilModel fromModel) + { + if (fromModel == null) + { + throw new ArgumentNullException(nameof(fromModel)); + } + + Name = fromModel.Name; + Geometry.Clear(); + foreach (Point2D point in fromModel.Geometry) + { + Geometry.Add(point); + } + + var newSoilProfiles = new List(); + var updatedProfiles = new List(); + var addedProfiles = new List(); + var removedProfiles = new List(); + + foreach (PipingStochasticSoilProfile fromProfile in fromModel.StochasticSoilProfiles) + { + PipingStochasticSoilProfile sameProfile = StochasticSoilProfiles.SingleOrDefault( + sp => IsSame(sp, fromProfile) + ); + if (sameProfile != null) + { + if (sameProfile.Update(fromProfile)) + { + updatedProfiles.Add(sameProfile); + } + } + else + { + StochasticSoilProfiles.Add(fromProfile); + addedProfiles.Add(fromProfile); + } + newSoilProfiles.Add(fromProfile.SoilProfile); + } + + foreach (PipingStochasticSoilProfile profileToRemove in StochasticSoilProfiles.Where( + sp => !newSoilProfiles.Any(newSp => IsSame(newSp, sp.SoilProfile))).ToArray()) + { + StochasticSoilProfiles.Remove(profileToRemove); + removedProfiles.Add(profileToRemove); + } + + return new PipingStochasticSoilModelProfileDifference(addedProfiles, updatedProfiles, removedProfiles); + } + public override string ToString() { return Name; } + + private static bool IsSame(PipingSoilProfile pipingSoilProfile, PipingSoilProfile otherPipingSoilProfile) + { + return pipingSoilProfile.Name.Equals(otherPipingSoilProfile.Name) + && pipingSoilProfile.SoilProfileType.Equals(otherPipingSoilProfile.SoilProfileType); + } + + private static bool IsSame(PipingStochasticSoilProfile stochasticSoilProfile, PipingStochasticSoilProfile otherStochasticSoilProfile) + { + return IsSame(stochasticSoilProfile.SoilProfile, otherStochasticSoilProfile.SoilProfile); + } } } \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/SoilProfile/PipingStochasticSoilModelCollection.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.Data/SoilProfile/PipingStochasticSoilModelCollection.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/SoilProfile/PipingStochasticSoilModelCollection.cs (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -0,0 +1,39 @@ +// Copyright (C) Stichting Deltares 2017. 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 Core.Common.Base; +using Ringtoets.Piping.Data.Properties; +using RingtoetsCommonDataResources = Ringtoets.Common.Data.Properties.Resources; + +namespace Ringtoets.Piping.Data.SoilProfile +{ + /// + /// A collection of . The names of the elements are + /// unique within the collection. + /// + public class PipingStochasticSoilModelCollection : ObservableUniqueItemCollectionWithSourcePath + { + public PipingStochasticSoilModelCollection() : base(model => model.Name, + RingtoetsCommonDataResources.StochasticSoilModelCollection_TypeDescriptor, + Resources.UniqueFeature_Name_FeatureDescription) + { } + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/SoilProfile/PipingStochasticSoilModelExtensions.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.Data/SoilProfile/PipingStochasticSoilModelExtensions.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/SoilProfile/PipingStochasticSoilModelExtensions.cs (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -0,0 +1,78 @@ +// Copyright (C) Stichting Deltares 2017. 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 System.Linq; +using Core.Common.Base.Geometry; +using Ringtoets.Common.Data; +using Ringtoets.Piping.Primitives; + +namespace Ringtoets.Piping.Data.SoilProfile +{ + /// + /// Extension methods dealing with instances. + /// + public static class PipingStochasticSoilModelExtensions + { + /// + /// Indicates whether a stochastic soil model intersects with a surface line. + /// + /// The stochastic soil model used to match a surface line. + /// The surface line used to match a stochastic soil model. + /// true when the intersects with the ; + /// false otherwise. + /// Thrown when any input parameter is null. + public static bool IntersectsWithSurfaceLineGeometry(this PipingStochasticSoilModel stochasticSoilModel, + PipingSurfaceLine surfaceLine) + { + if (stochasticSoilModel == null) + { + throw new ArgumentNullException(nameof(stochasticSoilModel)); + } + if (surfaceLine == null) + { + throw new ArgumentNullException(nameof(surfaceLine)); + } + + Segment2D[] surfaceLineSegments = Math2D.ConvertLinePointsToLineSegments(GetSurfaceLine2DGeometry(surfaceLine)).ToArray(); + return DoesSoilModelGeometryIntersectWithSurfaceLineGeometry(stochasticSoilModel, surfaceLineSegments); + } + + private static IEnumerable GetSurfaceLine2DGeometry(MechanismSurfaceLineBase surfaceLine) + { + return surfaceLine.Points.Select(p => new Point2D(p.X, p.Y)); + } + + private static bool DoesSoilModelGeometryIntersectWithSurfaceLineGeometry(PipingStochasticSoilModel stochasticSoilModel, + Segment2D[] surfaceLineSegments) + { + IEnumerable soilProfileGeometrySegments = Math2D.ConvertLinePointsToLineSegments(stochasticSoilModel.Geometry); + return soilProfileGeometrySegments.Any(s => DoesSegmentIntersectWithSegmentArray(s, surfaceLineSegments)); + } + + private static bool DoesSegmentIntersectWithSegmentArray(Segment2D segment, Segment2D[] segmentArray) + { + // Consider intersections and overlaps similarly + return segmentArray.Any(sls => Math2D.GetIntersectionBetweenSegments(segment, sls).IntersectionType != Intersection2DType.DoesNotIntersect); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/SoilProfile/PipingStochasticSoilModelProfileDifference.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.Data/SoilProfile/PipingStochasticSoilModelProfileDifference.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/SoilProfile/PipingStochasticSoilModelProfileDifference.cs (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -0,0 +1,63 @@ +// Copyright (C) Stichting Deltares 2017. 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; + +namespace Ringtoets.Piping.Data.SoilProfile +{ + /// + /// Container for the differences of the collection of contained + /// by a . + /// + public class PipingStochasticSoilModelProfileDifference + { + /// + /// Creates a new instance of . + /// + /// Profiles that were added to the model. + /// Profiles that were updated. + /// Profiles that were removed from the model. + public PipingStochasticSoilModelProfileDifference( + IEnumerable addedProfiles, + IEnumerable updatedProfiles, + IEnumerable removedProfiles) + { + AddedProfiles = addedProfiles; + UpdatedProfiles = updatedProfiles; + RemovedProfiles = removedProfiles; + } + + /// + /// Gets the profiles that were updated. + /// + public IEnumerable UpdatedProfiles { get; } + + /// + /// Gets the profiles that were removed from the model. + /// + public IEnumerable RemovedProfiles { get; } + + /// + /// Gets the profiles that were added to the model. + /// + public IEnumerable AddedProfiles { get; } + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/SoilProfile/PipingStochasticSoilProfile.cs =================================================================== diff -u -r94ce658a9488c346f114446f0e37dabab7acaa38 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/src/Ringtoets.Piping.Data/SoilProfile/PipingStochasticSoilProfile.cs (.../PipingStochasticSoilProfile.cs) (revision 94ce658a9488c346f114446f0e37dabab7acaa38) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/SoilProfile/PipingStochasticSoilProfile.cs (.../PipingStochasticSoilProfile.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -34,6 +34,7 @@ public class PipingStochasticSoilProfile : Observable { private static readonly Range probabilityValidityRange = new Range(0, 1); + private double probability; /// /// Creates a new instance of . @@ -49,23 +50,66 @@ { throw new ArgumentNullException(nameof(soilProfile)); } - - ValidateProbability(probability); - + Probability = probability; SoilProfile = soilProfile; } /// /// Gets the probability of the stochastic soil profile. /// - public double Probability { get; } + /// Thrown when the is outside the range + /// [0, 1]. + public double Probability + { + get + { + return probability; + } + private set + { + if (!probabilityValidityRange.InRange(value)) + { + throw new ArgumentOutOfRangeException( + nameof(value), + string.Format( + Resources.StochasticSoilProfile_Probability_Should_be_in_range_0_, + probabilityValidityRange.ToString(FormattableConstants.ShowAtLeastOneDecimal, CultureInfo.CurrentCulture))); + } + probability = value; + } + } /// /// Gets the . /// - public PipingSoilProfile SoilProfile { get; } + public PipingSoilProfile SoilProfile { get; private set; } + /// + /// Updates the with the properties + /// from . + /// + /// The to + /// obtain the property values from. + /// Thrown when + /// is null. + /// true if the profile has been updated; false otherwise. + public bool Update(PipingStochasticSoilProfile fromProfile) + { + if (fromProfile == null) + { + throw new ArgumentNullException(nameof(fromProfile)); + } + if (Equals(fromProfile)) + { + return false; + } + + SoilProfile = fromProfile.SoilProfile; + Probability = fromProfile.Probability; + return true; + } + public override string ToString() { return SoilProfile.ToString(); @@ -95,24 +139,6 @@ } } - /// - /// Checks that is valid. - /// - /// Probability of the stochastic soil profile. - /// Thrown when the - /// is outside the range [0, 1]. - private static void ValidateProbability(double probability) - { - if (!probabilityValidityRange.InRange(probability)) - { - throw new ArgumentOutOfRangeException( - nameof(probability), - string.Format( - Resources.StochasticSoilProfile_Probability_Should_be_in_range_0_, - probabilityValidityRange.ToString(FormattableConstants.ShowAtLeastOneDecimal, CultureInfo.CurrentCulture))); - } - } - private bool Equals(PipingStochasticSoilProfile other) { return Probability.Equals(other.Probability) Fisheye: Tag 26f527fb809a2325c8f883ece9da01a8f8040eb3 refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.Data/StochasticSoilModel.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 26f527fb809a2325c8f883ece9da01a8f8040eb3 refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.Data/StochasticSoilModelCollection.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 26f527fb809a2325c8f883ece9da01a8f8040eb3 refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.Data/StochasticSoilModelExtensions.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 26f527fb809a2325c8f883ece9da01a8f8040eb3 refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.Data/StochasticSoilModelProfileDifference.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 26f527fb809a2325c8f883ece9da01a8f8040eb3 refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.Data/StochasticSoilProfile.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Factories/PipingMapDataFactory.cs =================================================================== diff -u -r513400f1ec7b01dd0e4d3ce2681af3c1e8bf2e0e -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Factories/PipingMapDataFactory.cs (.../PipingMapDataFactory.cs) (revision 513400f1ec7b01dd0e4d3ce2681af3c1e8bf2e0e) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Factories/PipingMapDataFactory.cs (.../PipingMapDataFactory.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -22,7 +22,7 @@ using System.Drawing; using Core.Components.Gis.Data; using Core.Components.Gis.Style; -using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Primitives; using RingtoetsCommonDataResources = Ringtoets.Common.Data.Properties.Resources; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; @@ -53,7 +53,7 @@ } /// - /// Create with default styling for collections of . + /// Create with default styling for collections of . /// /// The created . public static MapLineData CreateStochasticSoilModelsMapData() Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Factories/PipingMapDataFeaturesFactory.cs =================================================================== diff -u -rd6fe8399e8398224cf1bda9259052232d85b85a4 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Factories/PipingMapDataFeaturesFactory.cs (.../PipingMapDataFeaturesFactory.cs) (revision d6fe8399e8398224cf1bda9259052232d85b85a4) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Factories/PipingMapDataFeaturesFactory.cs (.../PipingMapDataFeaturesFactory.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -27,6 +27,7 @@ using Ringtoets.Common.Forms.Factories; using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Primitives; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; @@ -68,17 +69,17 @@ /// /// Create stochastic soil model features based on the provided . /// - /// The collection of to create the stochastic soil model features for. + /// The collection of to create the stochastic soil model features for. /// An array of features or an empty array when is null or empty. - public static MapFeature[] CreateStochasticSoilModelFeatures(StochasticSoilModel[] stochasticSoilModels) + public static MapFeature[] CreateStochasticSoilModelFeatures(PipingStochasticSoilModel[] stochasticSoilModels) { if (stochasticSoilModels != null && stochasticSoilModels.Any()) { var features = new MapFeature[stochasticSoilModels.Length]; for (var i = 0; i < stochasticSoilModels.Length; i++) { - StochasticSoilModel stochasticSoilModel = stochasticSoilModels[i]; + PipingStochasticSoilModel stochasticSoilModel = stochasticSoilModels[i]; MapFeature feature = RingtoetsMapDataFeaturesFactory.CreateSingleLineMapFeature(GetWorldPoints(stochasticSoilModel)); feature.MetaData[RingtoetsCommonFormsResources.MetaData_Name] = stochasticSoilModel.Name; @@ -125,7 +126,7 @@ return surfaceLine.Points.Select(p => new Point2D(p.X, p.Y)); } - private static IEnumerable GetWorldPoints(StochasticSoilModel stochasticSoilModel) + private static IEnumerable GetWorldPoints(PipingStochasticSoilModel stochasticSoilModel) { return stochasticSoilModel.Geometry.Select(p => new Point2D(p)); } Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PipingCalculationConfigurationHelper.cs =================================================================== diff -u -raa49537188229065df91b1a931f088c32115702a -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PipingCalculationConfigurationHelper.cs (.../PipingCalculationConfigurationHelper.cs) (revision aa49537188229065df91b1a931f088c32115702a) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PipingCalculationConfigurationHelper.cs (.../PipingCalculationConfigurationHelper.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -27,6 +27,7 @@ using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Forms.Helpers; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Forms.Properties; using Ringtoets.Piping.Primitives; @@ -55,7 +56,9 @@ /// is null /// is null /// - public static IEnumerable GenerateCalculationItemsStructure(IEnumerable surfaceLines, IEnumerable soilModels, GeneralPipingInput generalInput) + public static IEnumerable GenerateCalculationItemsStructure(IEnumerable surfaceLines, + IEnumerable soilModels, + GeneralPipingInput generalInput) { if (surfaceLines == null) { @@ -91,30 +94,33 @@ /// /// Gets the stochastic soil models matching the input of a calculation. /// - /// The surface line used to match a . + /// The surface line used to match a . /// The available stochastic soil models. /// The (sub)set of stochastic soil models from - /// or empty if no matching instances can be found + /// or empty if no matching instances can be found /// or when there is not enough information to associate soil profiles to the calculation. - public static IEnumerable GetStochasticSoilModelsForSurfaceLine(PipingSurfaceLine surfaceLine, IEnumerable availableSoilModels) + public static IEnumerable GetStochasticSoilModelsForSurfaceLine(PipingSurfaceLine surfaceLine, + IEnumerable availableSoilModels) { if (surfaceLine == null) { - return Enumerable.Empty(); + return Enumerable.Empty(); } return availableSoilModels.Where(stochasticSoilModel => stochasticSoilModel.StochasticSoilProfiles.Any() && stochasticSoilModel.IntersectsWithSurfaceLineGeometry(surfaceLine)) .ToList(); } - private static CalculationGroup CreateCalculationGroup(PipingSurfaceLine surfaceLine, IEnumerable soilModels, GeneralPipingInput generalInput) + private static CalculationGroup CreateCalculationGroup(PipingSurfaceLine surfaceLine, + IEnumerable soilModels, + GeneralPipingInput generalInput) { var calculationGroup = new CalculationGroup(surfaceLine.Name, true); - IEnumerable stochasticSoilModels = GetStochasticSoilModelsForSurfaceLine(surfaceLine, soilModels); - foreach (StochasticSoilModel stochasticSoilModel in stochasticSoilModels) + IEnumerable stochasticSoilModels = GetStochasticSoilModelsForSurfaceLine(surfaceLine, soilModels); + foreach (PipingStochasticSoilModel stochasticSoilModel in stochasticSoilModels) { - foreach (StochasticSoilProfile soilProfile in stochasticSoilModel.StochasticSoilProfiles) + foreach (PipingStochasticSoilProfile soilProfile in stochasticSoilModel.StochasticSoilProfiles) { calculationGroup.Children.Add(CreatePipingCalculation(surfaceLine, stochasticSoilModel, soilProfile, calculationGroup.Children, generalInput)); } @@ -123,7 +129,11 @@ return calculationGroup; } - private static ICalculationBase CreatePipingCalculation(PipingSurfaceLine surfaceLine, StochasticSoilModel stochasticSoilModel, StochasticSoilProfile stochasticSoilProfile, IEnumerable calculations, GeneralPipingInput generalInput) + private static ICalculationBase CreatePipingCalculation(PipingSurfaceLine surfaceLine, + PipingStochasticSoilModel stochasticSoilModel, + PipingStochasticSoilProfile stochasticSoilProfile, + IEnumerable calculations, + GeneralPipingInput generalInput) { string nameBase = $"{surfaceLine.Name} {stochasticSoilProfile}"; string name = NamingHelper.GetUniqueName(calculations, nameBase, c => c.Name); Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/PipingCalculationGroupContext.cs =================================================================== diff -u -r8b60c9e846480f3ffeeb263bfea5d3367bf6bee3 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/PipingCalculationGroupContext.cs (.../PipingCalculationGroupContext.cs) (revision 8b60c9e846480f3ffeeb263bfea5d3367bf6bee3) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/PipingCalculationGroupContext.cs (.../PipingCalculationGroupContext.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -25,6 +25,7 @@ using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Primitives; namespace Ringtoets.Piping.Forms.PresentationObjects @@ -49,7 +50,7 @@ public PipingCalculationGroupContext(CalculationGroup calculationGroup, CalculationGroup parent, IEnumerable surfaceLines, - IEnumerable stochasticSoilModels, + IEnumerable stochasticSoilModels, PipingFailureMechanism pipingFailureMechanism, IAssessmentSection assessmentSection) : base(calculationGroup, surfaceLines, stochasticSoilModels, pipingFailureMechanism, assessmentSection) Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/PipingCalculationScenarioContext.cs =================================================================== diff -u -r8b60c9e846480f3ffeeb263bfea5d3367bf6bee3 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/PipingCalculationScenarioContext.cs (.../PipingCalculationScenarioContext.cs) (revision 8b60c9e846480f3ffeeb263bfea5d3367bf6bee3) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/PipingCalculationScenarioContext.cs (.../PipingCalculationScenarioContext.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -25,6 +25,7 @@ using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Primitives; namespace Ringtoets.Piping.Forms.PresentationObjects @@ -49,7 +50,7 @@ public PipingCalculationScenarioContext(PipingCalculationScenario calculation, CalculationGroup parent, IEnumerable surfaceLines, - IEnumerable stochasticSoilModels, + IEnumerable stochasticSoilModels, PipingFailureMechanism pipingFailureMechanism, IAssessmentSection assessmentSection) : base(calculation, surfaceLines, stochasticSoilModels, pipingFailureMechanism, assessmentSection) Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/PipingContext.cs =================================================================== diff -u -rd6fe8399e8398224cf1bda9259052232d85b85a4 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/PipingContext.cs (.../PipingContext.cs) (revision d6fe8399e8398224cf1bda9259052232d85b85a4) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/PipingContext.cs (.../PipingContext.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -27,6 +27,7 @@ using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Primitives; namespace Ringtoets.Piping.Forms.PresentationObjects @@ -49,7 +50,7 @@ protected PipingContext( T wrappedData, IEnumerable surfaceLines, - IEnumerable stochasticSoilModels, + IEnumerable stochasticSoilModels, PipingFailureMechanism pipingFailureMechanism, IAssessmentSection assessmentSection) : base(wrappedData) { @@ -68,10 +69,10 @@ public IEnumerable AvailablePipingSurfaceLines { get; private set; } /// - /// Gets the available stochastic soil models in order for the user to select a and + /// Gets the available stochastic soil models in order for the user to select a and /// to set and . /// - public IEnumerable AvailableStochasticSoilModels { get; private set; } + public IEnumerable AvailableStochasticSoilModels { get; private set; } /// /// Gets the available hydraulic boundary locations in order for the user to select one to @@ -108,7 +109,7 @@ /// The assessment section. /// Thrown when any input parameter is null. private static void AssertInputsAreNotNull(IEnumerable surfaceLines, - IEnumerable stochasticSoilModels, + IEnumerable stochasticSoilModels, PipingFailureMechanism pipingFailureMechanism, IAssessmentSection assessmentSection) { Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/PipingInputContext.cs =================================================================== diff -u -rd6fe8399e8398224cf1bda9259052232d85b85a4 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/PipingInputContext.cs (.../PipingInputContext.cs) (revision d6fe8399e8398224cf1bda9259052232d85b85a4) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/PipingInputContext.cs (.../PipingInputContext.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -23,6 +23,7 @@ using System.Collections.Generic; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Primitives; namespace Ringtoets.Piping.Forms.PresentationObjects @@ -47,7 +48,7 @@ public PipingInputContext(PipingInput pipingInput, PipingCalculationScenario calculation, IEnumerable surfaceLines, - IEnumerable stochasticSoilModels, + IEnumerable stochasticSoilModels, PipingFailureMechanism pipingFailureMechanism, IAssessmentSection assessmentSection) : base(pipingInput, surfaceLines, stochasticSoilModels, pipingFailureMechanism, assessmentSection) Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/StochasticSoilModelCollectionContext.cs =================================================================== diff -u -r81fa8a9bf3bd503cbd280e88b8f6037a840cff12 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/StochasticSoilModelCollectionContext.cs (.../StochasticSoilModelCollectionContext.cs) (revision 81fa8a9bf3bd503cbd280e88b8f6037a840cff12) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/StochasticSoilModelCollectionContext.cs (.../StochasticSoilModelCollectionContext.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -23,13 +23,14 @@ using Core.Common.Controls.PresentationObjects; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; namespace Ringtoets.Piping.Forms.PresentationObjects { /// /// The presentation object for . /// - public class StochasticSoilModelCollectionContext : ObservableWrappedObjectContextBase + public class StochasticSoilModelCollectionContext : ObservableWrappedObjectContextBase { /// /// Creates a new instance of . @@ -38,7 +39,7 @@ /// The failure mechanism. /// The assessment section. /// Thrown when any input argument is null. - public StochasticSoilModelCollectionContext(StochasticSoilModelCollection wrappedStochasticSoilModels, + public StochasticSoilModelCollectionContext(PipingStochasticSoilModelCollection wrappedStochasticSoilModels, PipingFailureMechanism failureMechanism, IAssessmentSection assessmentSection) : base(wrappedStochasticSoilModels) Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingInputContextProperties.cs =================================================================== diff -u -rd6fe8399e8398224cf1bda9259052232d85b85a4 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingInputContextProperties.cs (.../PipingInputContextProperties.cs) (revision d6fe8399e8398224cf1bda9259052232d85b85a4) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingInputContextProperties.cs (.../PipingInputContextProperties.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -34,6 +34,7 @@ using Ringtoets.Common.Forms.PropertyClasses; using Ringtoets.Common.Forms.UITypeEditors; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Forms.PresentationObjects; using Ringtoets.Piping.Forms.Properties; using Ringtoets.Piping.Forms.UITypeEditors; @@ -103,21 +104,24 @@ /// /// Gets the available stochastic soil models on . /// - public IEnumerable GetAvailableStochasticSoilModels() + public IEnumerable GetAvailableStochasticSoilModels() { if (data.WrappedData.SurfaceLine == null) { return data.AvailableStochasticSoilModels; } - return PipingCalculationConfigurationHelper.GetStochasticSoilModelsForSurfaceLine(data.WrappedData.SurfaceLine, data.AvailableStochasticSoilModels); + return PipingCalculationConfigurationHelper.GetStochasticSoilModelsForSurfaceLine(data.WrappedData.SurfaceLine, + data.AvailableStochasticSoilModels); } /// /// Gets the available stochastic soil profiles on . /// - public IEnumerable GetAvailableStochasticSoilProfiles() + public IEnumerable GetAvailableStochasticSoilProfiles() { - return data.WrappedData.StochasticSoilModel != null ? data.WrappedData.StochasticSoilModel.StochasticSoilProfiles : new List(); + return data.WrappedData.StochasticSoilModel != null + ? data.WrappedData.StochasticSoilModel.StochasticSoilProfiles + : new List(); } [DynamicReadOnlyValidationMethod] @@ -289,7 +293,7 @@ [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_Schematization))] [ResourcesDisplayName(typeof(Resources), nameof(Resources.PipingInput_StochasticSoilModel_DisplayName))] [ResourcesDescription(typeof(Resources), nameof(Resources.PipingInput_StochasticSoilModel_Description))] - public StochasticSoilModel StochasticSoilModel + public PipingStochasticSoilModel StochasticSoilModel { get { @@ -313,7 +317,7 @@ [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_Schematization))] [ResourcesDisplayName(typeof(Resources), nameof(Resources.PipingInput_StochasticSoilProfile_DisplayName))] [ResourcesDescription(typeof(Resources), nameof(Resources.PipingInput_StochasticSoilProfile_Description))] - public StochasticSoilProfile StochasticSoilProfile + public PipingStochasticSoilProfile StochasticSoilProfile { get { Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingStochasticSoilModelCollectionProperties.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingStochasticSoilModelCollectionProperties.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingStochasticSoilModelCollectionProperties.cs (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -0,0 +1,62 @@ +// Copyright (C) Stichting Deltares 2017. 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.Gui.PropertyBag; +using Core.Common.Utils.Attributes; +using Ringtoets.Piping.Data.SoilProfile; +using Ringtoets.Piping.Forms.Properties; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.Piping.Forms.PropertyClasses +{ + /// + /// ViewModel of for properties panel. + /// + public class PipingStochasticSoilModelCollectionProperties : ObjectProperties + { + /// + /// Creates a new instance of . + /// + /// The collection for which the properties are shown. + /// Thrown when + /// is null. + public PipingStochasticSoilModelCollectionProperties(PipingStochasticSoilModelCollection collection) + { + if (collection == null) + { + throw new ArgumentNullException(nameof(collection)); + } + data = collection; + } + + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_General))] + [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.ObservableCollectionWithSourcePath_SourcePath_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.StochasticSoilModelCollection_SourcePath_Description))] + public string SourcePath + { + get + { + return data.SourcePath; + } + } + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingStochasticSoilModelProperties.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingStochasticSoilModelProperties.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingStochasticSoilModelProperties.cs (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -0,0 +1,96 @@ +// Copyright (C) Stichting Deltares 2017. 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 System.Linq; +using Core.Common.Base.Geometry; +using Core.Common.Gui.Attributes; +using Core.Common.Gui.Converters; +using Core.Common.Gui.PropertyBag; +using Core.Common.Utils.Attributes; +using Ringtoets.Piping.Data.SoilProfile; +using Ringtoets.Piping.Forms.Properties; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.Piping.Forms.PropertyClasses +{ + /// + /// ViewModel of for properties panel. + /// + public class PipingStochasticSoilModelProperties : ObjectProperties + { + /// + /// Creates a new instance of . + /// + /// The stochastic soil model for which the properties are shown. + /// Thrown when + /// is null. + public PipingStochasticSoilModelProperties(PipingStochasticSoilModel stochasticSoilModel) + { + if (stochasticSoilModel == null) + { + throw new ArgumentNullException(nameof(stochasticSoilModel)); + } + data = stochasticSoilModel; + } + + [PropertyOrder(1)] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_General))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.StochasticSoilModel_Name_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.StochasticSoilModel_Name_Description))] + public string Name + { + get + { + return data.Name; + } + } + + [PropertyOrder(2)] + [TypeConverter(typeof(ExpandableArrayConverter))] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_General))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.StochasticSoilModel_Geometry_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.StochasticSoilModel_Geometry_Description))] + public Point2D[] Geometry + { + get + { + return data.Geometry.ToArray(); + } + } + + [PropertyOrder(3)] + [TypeConverter(typeof(ExpandableArrayConverter))] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_General))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.StochasticSoilModel_StochasticSoilProfiles_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.StochasticSoilModel_StochasticSoilProfiles_Description))] + public PipingStochasticSoilProfileProperties[] StochasticSoilProfiles + { + get + { + return data.StochasticSoilProfiles.Count > 0 + ? data.StochasticSoilProfiles.Select(ssp => new PipingStochasticSoilProfileProperties(ssp)).ToArray() + : new PipingStochasticSoilProfileProperties[0]; + } + } + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingStochasticSoilProfileProperties.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingStochasticSoilProfileProperties.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingStochasticSoilProfileProperties.cs (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -0,0 +1,127 @@ +// Copyright (C) Stichting Deltares 2017. 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 System.Globalization; +using System.Linq; +using Core.Common.Base.Data; +using Core.Common.Gui.Attributes; +using Core.Common.Gui.Converters; +using Core.Common.Gui.PropertyBag; +using Core.Common.Utils.Attributes; +using Ringtoets.Piping.Data.SoilProfile; +using Ringtoets.Piping.Forms.Properties; +using Ringtoets.Piping.Primitives; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.Piping.Forms.PropertyClasses +{ + /// + /// ViewModel of for properties panel. + /// + [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.StochasticSoilProfileProperties_DisplayName))] + [TypeConverter(typeof(ExpandableObjectConverter))] + public class PipingStochasticSoilProfileProperties : ObjectProperties + { + /// + /// Creates a new instance of . + /// + /// The stochastic soil profile for which the properties are shown. + /// Thrown when + /// is null. + public PipingStochasticSoilProfileProperties(PipingStochasticSoilProfile stochasticSoilProfile) + { + if (stochasticSoilProfile == null) + { + throw new ArgumentNullException(nameof(stochasticSoilProfile)); + } + + Data = stochasticSoilProfile; + } + + [PropertyOrder(1)] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_General))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.StochasticSoilProfile_Name_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.StochasticSoilProfile_Name_Description))] + public string Name + { + get + { + return data.SoilProfile.Name; + } + } + + [PropertyOrder(2)] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_General))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.StochasticSoilProfile_Probability_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.StochasticSoilProfile_Probability_Description))] + public string Probability + { + get + { + return new RoundedDouble(3, data.Probability * 100).Value.ToString(CultureInfo.CurrentCulture); + } + } + + [PropertyOrder(3)] + [TypeConverter(typeof(ExpandableReadOnlyArrayConverter))] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_General))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.StochasticSoilProfile_Tops_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.StochasticSoilProfile_Tops_Description))] + public double[] TopLevels + { + get + { + return data.SoilProfile.Layers.Select(l => l.Top).ToArray(); + } + } + + [PropertyOrder(4)] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_General))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.StochasticSoilProfile_Bottom_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.StochasticSoilProfile_Bottom_Description))] + public double Bottom + { + get + { + return data.SoilProfile.Bottom; + } + } + + [PropertyOrder(5)] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_General))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.StochasticSoilProfile_Type_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.StochasticSoilProfile_Type_Description))] + public string Type + { + get + { + return data.SoilProfile.SoilProfileType == SoilProfileType.SoilProfile1D ? "1D profiel" : "2D profiel"; + } + } + + public override string ToString() + { + return Name; + } + } +} \ No newline at end of file Fisheye: Tag 26f527fb809a2325c8f883ece9da01a8f8040eb3 refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/StochasticSoilModelCollectionProperties.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 26f527fb809a2325c8f883ece9da01a8f8040eb3 refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/StochasticSoilModelProperties.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 26f527fb809a2325c8f883ece9da01a8f8040eb3 refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/StochasticSoilProfileProperties.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Ringtoets.Piping.Forms.csproj =================================================================== diff -u -raa49537188229065df91b1a931f088c32115702a -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Ringtoets.Piping.Forms.csproj (.../Ringtoets.Piping.Forms.csproj) (revision aa49537188229065df91b1a931f088c32115702a) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Ringtoets.Piping.Forms.csproj (.../Ringtoets.Piping.Forms.csproj) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -75,10 +75,10 @@ - - + + - + Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/UITypeEditors/PipingInputContextStochasticSoilModelSelectionEditor.cs =================================================================== diff -u -r81fa8a9bf3bd503cbd280e88b8f6037a840cff12 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/UITypeEditors/PipingInputContextStochasticSoilModelSelectionEditor.cs (.../PipingInputContextStochasticSoilModelSelectionEditor.cs) (revision 81fa8a9bf3bd503cbd280e88b8f6037a840cff12) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/UITypeEditors/PipingInputContextStochasticSoilModelSelectionEditor.cs (.../PipingInputContextStochasticSoilModelSelectionEditor.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -22,31 +22,31 @@ using System.Collections.Generic; using System.ComponentModel; using Core.Common.Gui.UITypeEditors; -using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Forms.PropertyClasses; namespace Ringtoets.Piping.Forms.UITypeEditors { /// /// This class defines a drop down list edit-control from which the user can select a - /// from a collection. + /// from a collection. /// - public class PipingInputContextStochasticSoilModelSelectionEditor : SelectionEditor + public class PipingInputContextStochasticSoilModelSelectionEditor : SelectionEditor { /// /// Creates a new instance of . /// public PipingInputContextStochasticSoilModelSelectionEditor() { - DisplayMember = nameof(StochasticSoilModel.Name); + DisplayMember = nameof(PipingStochasticSoilModel.Name); } - protected override IEnumerable GetAvailableOptions(ITypeDescriptorContext context) + protected override IEnumerable GetAvailableOptions(ITypeDescriptorContext context) { return GetPropertiesObject(context).GetAvailableStochasticSoilModels(); } - protected override StochasticSoilModel GetCurrentOption(ITypeDescriptorContext context) + protected override PipingStochasticSoilModel GetCurrentOption(ITypeDescriptorContext context) { return GetPropertiesObject(context).StochasticSoilModel; } Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/UITypeEditors/PipingInputContextStochasticSoilProfileSelectionEditor.cs =================================================================== diff -u -r81fa8a9bf3bd503cbd280e88b8f6037a840cff12 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/UITypeEditors/PipingInputContextStochasticSoilProfileSelectionEditor.cs (.../PipingInputContextStochasticSoilProfileSelectionEditor.cs) (revision 81fa8a9bf3bd503cbd280e88b8f6037a840cff12) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/UITypeEditors/PipingInputContextStochasticSoilProfileSelectionEditor.cs (.../PipingInputContextStochasticSoilProfileSelectionEditor.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -22,17 +22,17 @@ using System.Collections.Generic; using System.ComponentModel; using Core.Common.Gui.UITypeEditors; -using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Forms.PropertyClasses; using Ringtoets.Piping.Primitives; namespace Ringtoets.Piping.Forms.UITypeEditors { /// /// This class defines a drop down list edit-control from which the user can select a - /// from a collection. + /// from a collection. /// - public class PipingInputContextStochasticSoilProfileSelectionEditor : SelectionEditor + public class PipingInputContextStochasticSoilProfileSelectionEditor : SelectionEditor { /// /// Creates a new instance of . @@ -42,12 +42,12 @@ DisplayMember = nameof(PipingSoilProfile.Name); } - protected override IEnumerable GetAvailableOptions(ITypeDescriptorContext context) + protected override IEnumerable GetAvailableOptions(ITypeDescriptorContext context) { return GetPropertiesObject(context).GetAvailableStochasticSoilProfiles(); } - protected override StochasticSoilProfile GetCurrentOption(ITypeDescriptorContext context) + protected override PipingStochasticSoilProfile GetCurrentOption(ITypeDescriptorContext context) { return GetPropertiesObject(context).StochasticSoilProfile; } Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingCalculationRow.cs =================================================================== diff -u -r81fa8a9bf3bd503cbd280e88b8f6037a840cff12 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingCalculationRow.cs (.../PipingCalculationRow.cs) (revision 81fa8a9bf3bd503cbd280e88b8f6037a840cff12) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingCalculationRow.cs (.../PipingCalculationRow.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -28,6 +28,7 @@ using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.Forms.PropertyClasses; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; namespace Ringtoets.Piping.Forms.Views { @@ -85,15 +86,15 @@ /// /// Gets or sets the stochastic soil model of the . /// - public DataGridViewComboBoxItemWrapper StochasticSoilModel + public DataGridViewComboBoxItemWrapper StochasticSoilModel { get { - return new DataGridViewComboBoxItemWrapper(PipingCalculation.InputParameters.StochasticSoilModel); + return new DataGridViewComboBoxItemWrapper(PipingCalculation.InputParameters.StochasticSoilModel); } set { - StochasticSoilModel valueToSet = value?.WrappedObject; + PipingStochasticSoilModel valueToSet = value?.WrappedObject; if (!ReferenceEquals(PipingCalculation.InputParameters.StochasticSoilModel, valueToSet)) { PropertyChangeHelper.ChangePropertyAndNotify(() => PipingCalculation.InputParameters.StochasticSoilModel = valueToSet, propertyChangeHandler); @@ -104,15 +105,15 @@ /// /// Gets or sets the stochastic soil profile of the . /// - public DataGridViewComboBoxItemWrapper StochasticSoilProfile + public DataGridViewComboBoxItemWrapper StochasticSoilProfile { get { - return new DataGridViewComboBoxItemWrapper(PipingCalculation.InputParameters.StochasticSoilProfile); + return new DataGridViewComboBoxItemWrapper(PipingCalculation.InputParameters.StochasticSoilProfile); } set { - StochasticSoilProfile valueToSet = value?.WrappedObject; + PipingStochasticSoilProfile valueToSet = value?.WrappedObject; if (!ReferenceEquals(PipingCalculation.InputParameters.StochasticSoilProfile, valueToSet)) { PropertyChangeHelper.ChangePropertyAndNotify(() => PipingCalculation.InputParameters.StochasticSoilProfile = valueToSet, propertyChangeHandler); Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingCalculationsView.cs =================================================================== diff -u -r721c0d4f72803e74398f903d86fa9c1cb0d9ced8 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingCalculationsView.cs (.../PipingCalculationsView.cs) (revision 721c0d4f72803e74398f903d86fa9c1cb0d9ced8) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingCalculationsView.cs (.../PipingCalculationsView.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -35,6 +35,7 @@ using Ringtoets.Common.Forms.Helpers; using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Forms.PresentationObjects; using Ringtoets.Piping.Forms.Properties; using Ringtoets.Piping.Primitives; @@ -58,7 +59,7 @@ private readonly Observer pipingFailureMechanismObserver; private readonly RecursiveObserver pipingSurfaceLineObserver; private readonly Observer pipingStochasticSoilModelsObserver; - private readonly RecursiveObserver stochasticSoilProfileObserver; + private readonly RecursiveObserver stochasticSoilProfileObserver; private IAssessmentSection assessmentSection; private CalculationGroup calculationGroup; private PipingFailureMechanism pipingFailureMechanism; @@ -84,7 +85,7 @@ pipingSurfaceLineObserver = new RecursiveObserver(UpdateDataGridViewDataSource, rpslc => rpslc); pipingStochasticSoilModelsObserver = new Observer(OnStochasticSoilModelsUpdate); - stochasticSoilProfileObserver = new RecursiveObserver(dataGridViewControl.RefreshDataGridView, ssmc => ssmc.SelectMany(ssm => ssm.StochasticSoilProfiles)); + stochasticSoilProfileObserver = new RecursiveObserver(dataGridViewControl.RefreshDataGridView, ssmc => ssmc.SelectMany(ssm => ssm.StochasticSoilProfiles)); } /// @@ -204,19 +205,19 @@ nameof(PipingCalculationRow.Name), Resources.PipingCalculation_Name_DisplayName); - dataGridViewControl.AddComboBoxColumn>( + dataGridViewControl.AddComboBoxColumn>( nameof(PipingCalculationRow.StochasticSoilModel), Resources.PipingInput_StochasticSoilModel_DisplayName, null, - nameof(DataGridViewComboBoxItemWrapper.This), - nameof(DataGridViewComboBoxItemWrapper.DisplayName)); + nameof(DataGridViewComboBoxItemWrapper.This), + nameof(DataGridViewComboBoxItemWrapper.DisplayName)); - dataGridViewControl.AddComboBoxColumn>( + dataGridViewControl.AddComboBoxColumn>( nameof(PipingCalculationRow.StochasticSoilProfile), Resources.PipingInput_StochasticSoilProfile_DisplayName, null, - nameof(DataGridViewComboBoxItemWrapper.This), - nameof(DataGridViewComboBoxItemWrapper.DisplayName)); + nameof(DataGridViewComboBoxItemWrapper.This), + nameof(DataGridViewComboBoxItemWrapper.DisplayName)); dataGridViewControl.AddTextBoxColumn( nameof(PipingCalculationRow.StochasticSoilProfileProbability), @@ -340,53 +341,58 @@ UpdateSelectableHydraulicBoundaryLocationsColumn(); } - private static IEnumerable> GetPrefillStochasticSoilModelsDataSource(IEnumerable stochasticSoilModels) + private static IEnumerable> GetPrefillStochasticSoilModelsDataSource( + IEnumerable stochasticSoilModels) { - yield return new DataGridViewComboBoxItemWrapper(null); + yield return new DataGridViewComboBoxItemWrapper(null); - foreach (StochasticSoilModel stochasticSoilModel in stochasticSoilModels) + foreach (PipingStochasticSoilModel stochasticSoilModel in stochasticSoilModels) { - yield return new DataGridViewComboBoxItemWrapper(stochasticSoilModel); + yield return new DataGridViewComboBoxItemWrapper(stochasticSoilModel); } } - private static IEnumerable> GetStochasticSoilModelsDataSource(IEnumerable stochasticSoilModels) + private static IEnumerable> GetStochasticSoilModelsDataSource( + IEnumerable stochasticSoilModels) { - StochasticSoilModel[] stochasticSoilModelsArray = stochasticSoilModels.ToArray(); + PipingStochasticSoilModel[] stochasticSoilModelsArray = stochasticSoilModels.ToArray(); if (stochasticSoilModelsArray.Length != 1) { - yield return new DataGridViewComboBoxItemWrapper(null); + yield return new DataGridViewComboBoxItemWrapper(null); } - foreach (StochasticSoilModel stochasticSoilModel in stochasticSoilModelsArray) + foreach (PipingStochasticSoilModel stochasticSoilModel in stochasticSoilModelsArray) { - yield return new DataGridViewComboBoxItemWrapper(stochasticSoilModel); + yield return new DataGridViewComboBoxItemWrapper(stochasticSoilModel); } } - private static IEnumerable> GetPrefillSoilProfilesDataSource(IEnumerable stochasticSoilProfiles) + private static IEnumerable> GetPrefillSoilProfilesDataSource( + IEnumerable stochasticSoilProfiles) { - yield return new DataGridViewComboBoxItemWrapper(null); + yield return new DataGridViewComboBoxItemWrapper(null); - foreach (StochasticSoilProfile stochasticSoilProfile in stochasticSoilProfiles) + foreach (PipingStochasticSoilProfile stochasticSoilProfile in stochasticSoilProfiles) { - yield return new DataGridViewComboBoxItemWrapper(stochasticSoilProfile); + yield return new DataGridViewComboBoxItemWrapper(stochasticSoilProfile); } } - private static IEnumerable> GetSoilProfilesDataSource(IEnumerable stochasticSoilProfiles) + private static IEnumerable> GetSoilProfilesDataSource( + IEnumerable stochasticSoilProfiles) { - StochasticSoilProfile[] stochasticSoilProfilesArray = stochasticSoilProfiles.ToArray(); + PipingStochasticSoilProfile[] stochasticSoilProfilesArray = stochasticSoilProfiles.ToArray(); if (stochasticSoilProfilesArray.Length != 1) { - yield return new DataGridViewComboBoxItemWrapper(null); + yield return new DataGridViewComboBoxItemWrapper(null); } - foreach (StochasticSoilProfile stochasticSoilProfile in stochasticSoilProfilesArray) + foreach (PipingStochasticSoilProfile stochasticSoilProfile in stochasticSoilProfilesArray) { - yield return new DataGridViewComboBoxItemWrapper(stochasticSoilProfile); + yield return new DataGridViewComboBoxItemWrapper(stochasticSoilProfile); } } - private static List> GetSelectableHydraulicBoundaryLocationsDataSource(IEnumerable selectableHydraulicBoundaryLocations = null) + private static List> GetSelectableHydraulicBoundaryLocationsDataSource( + IEnumerable selectableHydraulicBoundaryLocations = null) { var dataGridViewComboBoxItemWrappers = new List> { @@ -459,17 +465,17 @@ private void FillAvailableSoilModelsList(DataGridViewRow dataGridViewRow) { var rowData = (PipingCalculationRow) dataGridViewRow.DataBoundItem; - IEnumerable stochasticSoilModels = GetSoilModelsForCalculation(rowData.PipingCalculation); + IEnumerable stochasticSoilModels = GetSoilModelsForCalculation(rowData.PipingCalculation); var cell = (DataGridViewComboBoxCell) dataGridViewRow.Cells[stochasticSoilModelColumnIndex]; SetItemsOnObjectCollection(cell.Items, GetStochasticSoilModelsDataSource(stochasticSoilModels).ToArray()); } - private IEnumerable GetSoilModelsForCalculation(PipingCalculation pipingCalculation) + private IEnumerable GetSoilModelsForCalculation(PipingCalculation pipingCalculation) { if (pipingFailureMechanism == null) { - return Enumerable.Empty(); + return Enumerable.Empty(); } return PipingCalculationConfigurationHelper.GetStochasticSoilModelsForSurfaceLine( pipingCalculation.InputParameters.SurfaceLine, @@ -491,22 +497,22 @@ } } - private void FillAvailableSoilProfilesList(DataGridViewRow dataGridViewRow) + private static void FillAvailableSoilProfilesList(DataGridViewRow dataGridViewRow) { var rowData = (PipingCalculationRow) dataGridViewRow.DataBoundItem; PipingInputService.SyncStochasticSoilProfileWithStochasticSoilModel(rowData.PipingCalculation.InputParameters); - IEnumerable stochasticSoilProfiles = GetSoilProfilesForCalculation(rowData.PipingCalculation); + IEnumerable stochasticSoilProfiles = GetSoilProfilesForCalculation(rowData.PipingCalculation); var cell = (DataGridViewComboBoxCell) dataGridViewRow.Cells[stochasticSoilProfileColumnIndex]; SetItemsOnObjectCollection(cell.Items, GetSoilProfilesDataSource(stochasticSoilProfiles).ToArray()); } - private IEnumerable GetSoilProfilesForCalculation(PipingCalculation pipingCalculation) + private static IEnumerable GetSoilProfilesForCalculation(PipingCalculation pipingCalculation) { if (pipingCalculation.InputParameters.StochasticSoilModel == null) { - return Enumerable.Empty(); + return Enumerable.Empty(); } return pipingCalculation.InputParameters.StochasticSoilModel.StochasticSoilProfiles; } @@ -528,12 +534,12 @@ // items. using (new SuspendDataGridViewColumnResizes(stochasticSoilModelColumn)) { - StochasticSoilModelCollection stochasticSoilModels = pipingFailureMechanism.StochasticSoilModels; + PipingStochasticSoilModelCollection stochasticSoilModels = pipingFailureMechanism.StochasticSoilModels; SetItemsOnObjectCollection(stochasticSoilModelColumn.Items, GetPrefillStochasticSoilModelsDataSource(stochasticSoilModels).ToArray()); } using (new SuspendDataGridViewColumnResizes(stochasticSoilProfileColumn)) { - StochasticSoilProfile[] pipingSoilProfiles = GetPipingStochasticSoilProfilesFromStochasticSoilModels(); + PipingStochasticSoilProfile[] pipingSoilProfiles = GetPipingStochasticSoilProfilesFromStochasticSoilModels(); SetItemsOnObjectCollection(stochasticSoilProfileColumn.Items, GetPrefillSoilProfilesDataSource(pipingSoilProfiles).ToArray()); } using (new SuspendDataGridViewColumnResizes(selectableHydraulicBoundaryLocationColumn)) @@ -565,7 +571,7 @@ return selectableHydraulicBoundaryLocations; } - private StochasticSoilProfile[] GetPipingStochasticSoilProfilesFromStochasticSoilModels() + private PipingStochasticSoilProfile[] GetPipingStochasticSoilProfilesFromStochasticSoilModels() { return pipingFailureMechanism?.StochasticSoilModels .SelectMany(ssm => ssm.StochasticSoilProfiles) Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingFailureMechanismView.cs =================================================================== diff -u -ra1e976b5692d931d9bf7bc79ad667a2587125978 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingFailureMechanismView.cs (.../PipingFailureMechanismView.cs) (revision a1e976b5692d931d9bf7bc79ad667a2587125978) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingFailureMechanismView.cs (.../PipingFailureMechanismView.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -31,6 +31,7 @@ using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Forms.Factories; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Forms.Factories; using Ringtoets.Piping.Forms.PresentationObjects; using Ringtoets.Piping.Primitives; @@ -301,7 +302,7 @@ private void SetStochasticSoilModelsMapData() { - StochasticSoilModelCollection stochasticSoilModels = data.WrappedData.StochasticSoilModels; + PipingStochasticSoilModelCollection stochasticSoilModels = data.WrappedData.StochasticSoilModels; stochasticSoilModelsMapData.Features = PipingMapDataFeaturesFactory.CreateStochasticSoilModelFeatures(stochasticSoilModels.ToArray()); } Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Configurations/PipingCalculationConfigurationImporter.cs =================================================================== diff -u -ra1e976b5692d931d9bf7bc79ad667a2587125978 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/src/Ringtoets.Piping.IO/Configurations/PipingCalculationConfigurationImporter.cs (.../PipingCalculationConfigurationImporter.cs) (revision a1e976b5692d931d9bf7bc79ad667a2587125978) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Configurations/PipingCalculationConfigurationImporter.cs (.../PipingCalculationConfigurationImporter.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -28,6 +28,7 @@ using Ringtoets.Common.IO.Configurations.Helpers; using Ringtoets.Common.IO.Configurations.Import; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.IO.Properties; using Ringtoets.Piping.Primitives; @@ -226,9 +227,9 @@ /// The calculation to configure. /// false when /// - /// the has a set + /// the has a set /// which is not available in the failure mechanism. - /// The does not intersect with the + /// The does not intersect with the /// when this is set. /// /// true otherwise. @@ -237,8 +238,8 @@ { if (calculationConfiguration.StochasticSoilModelName != null) { - StochasticSoilModel soilModel = failureMechanism.StochasticSoilModels - .FirstOrDefault(ssm => ssm.Name == calculationConfiguration.StochasticSoilModelName); + PipingStochasticSoilModel soilModel = failureMechanism.StochasticSoilModels + .FirstOrDefault(ssm => ssm.Name == calculationConfiguration.StochasticSoilModelName); if (soilModel == null) { @@ -272,8 +273,8 @@ /// The calculation to configure. /// false when the has: /// - /// a set but no is specified; - /// a set which is not available in the . + /// a set but no is specified; + /// a set which is not available in the . /// /// true otherwise. private bool TrySetStochasticSoilProfile(PipingCalculationConfiguration calculationConfiguration, @@ -290,7 +291,7 @@ return false; } - StochasticSoilProfile soilProfile = pipingCalculation + PipingStochasticSoilProfile soilProfile = pipingCalculation .InputParameters .StochasticSoilModel .StochasticSoilProfiles Fisheye: Tag 26f527fb809a2325c8f883ece9da01a8f8040eb3 refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/IStochasticSoilModelUpdateModelStrategy.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 26f527fb809a2325c8f883ece9da01a8f8040eb3 refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/StochasticSoilModelImporter.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj =================================================================== diff -u -ra5f97617cc03e3535d369676ae09179c82947b17 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj (.../Ringtoets.Piping.IO.csproj) (revision a5f97617cc03e3535d369676ae09179c82947b17) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj (.../Ringtoets.Piping.IO.csproj) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -48,7 +48,6 @@ - @@ -57,7 +56,6 @@ - True True @@ -76,10 +74,8 @@ - - Fisheye: Tag 26f527fb809a2325c8f883ece9da01a8f8040eb3 refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/StochasticSoilModelReader.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 26f527fb809a2325c8f883ece9da01a8f8040eb3 refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/StochasticSoilProfileReader.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingStochasticSoilModelReplaceDataStrategy.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingStochasticSoilModelReplaceDataStrategy.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingStochasticSoilModelReplaceDataStrategy.cs (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -0,0 +1,58 @@ +// Copyright (C) Stichting Deltares 2017. 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 Core.Common.Base; +using Ringtoets.Common.Data.UpdateDataStrategies; +using Ringtoets.Common.IO.SoilProfile; +using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; +using Ringtoets.Piping.Service; + +namespace Ringtoets.Piping.Plugin.FileImporter +{ + /// + /// A to replace the stochastic + /// soil models with the imported stochastic soil models. + /// + public class PipingStochasticSoilModelReplaceDataStrategy : ReplaceDataStrategyBase, + IStochasticSoilModelUpdateModelStrategy + { + /// + /// Creates a new instance of . + /// + /// The failure mechanism in which the models are updated. + /// Thrown when is null. + public PipingStochasticSoilModelReplaceDataStrategy(PipingFailureMechanism failureMechanism) + : base(failureMechanism, failureMechanism?.StochasticSoilModels) {} + + public IEnumerable UpdateModelWithImportedData(IEnumerable stochasticSoilModels, string sourceFilePath) + { + return ReplaceTargetCollectionWithImportedData(stochasticSoilModels, sourceFilePath); + } + + protected override IEnumerable ClearData() + { + return PipingDataSynchronizationService.RemoveAllStochasticSoilModels(FailureMechanism); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingStochasticSoilModelUpdateDataStrategy.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingStochasticSoilModelUpdateDataStrategy.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingStochasticSoilModelUpdateDataStrategy.cs (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -0,0 +1,114 @@ +// Copyright (C) Stichting Deltares 2017. 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 System.Linq; +using Core.Common.Base; +using Core.Common.Utils; +using Ringtoets.Common.Data.UpdateDataStrategies; +using Ringtoets.Common.IO.SoilProfile; +using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; +using Ringtoets.Piping.Primitives; +using Ringtoets.Piping.Service; + +namespace Ringtoets.Piping.Plugin.FileImporter +{ + /// + /// An for updating stochastic soil models based on imported data. + /// + public class PipingStochasticSoilModelUpdateDataStrategy : UpdateDataStrategyBase, + IStochasticSoilModelUpdateModelStrategy + { + /// + /// Creates a new instance of . + /// + /// The failure mechanism in which the models are updated. + /// Thrown when is null. + public PipingStochasticSoilModelUpdateDataStrategy(PipingFailureMechanism failureMechanism) + : base(failureMechanism, failureMechanism?.StochasticSoilModels, new SoilModelNameEqualityComparer()) {} + + public IEnumerable UpdateModelWithImportedData(IEnumerable stochasticSoilModels, string sourceFilePath) + { + return UpdateTargetCollectionData(stochasticSoilModels, sourceFilePath); + } + + #region Remove Data Functions + + protected override IEnumerable RemoveObjectAndDependentData(PipingStochasticSoilModel removedModel) + { + return PipingDataSynchronizationService.RemoveStochasticSoilModel(FailureMechanism, removedModel); + } + + #endregion + + /// + /// Class for comparing by just the name. + /// + private class SoilModelNameEqualityComparer : IEqualityComparer + { + public bool Equals(PipingStochasticSoilModel x, PipingStochasticSoilModel y) + { + return x.Name == y.Name; + } + + public int GetHashCode(PipingStochasticSoilModel obj) + { + return obj.Name.GetHashCode(); + } + } + + #region Update Data Functions + + protected override IEnumerable UpdateObjectAndDependentData(PipingStochasticSoilModel soilModelToUpdate, + PipingStochasticSoilModel soilModelToUpdateFrom) + { + return UpdateStochasticSoilModel(soilModelToUpdate, soilModelToUpdateFrom); + } + + private IEnumerable UpdateStochasticSoilModel(PipingStochasticSoilModel modelToUpdate, PipingStochasticSoilModel modelToUpdateFrom) + { + Dictionary oldProfiles = modelToUpdate + .StochasticSoilProfiles + .ToDictionary(ssp => ssp, ssp => ssp.SoilProfile, new ReferenceEqualityComparer()); + + PipingStochasticSoilModelProfileDifference difference = modelToUpdate.Update(modelToUpdateFrom); + + var affectedObjects = new List(); + foreach (PipingStochasticSoilProfile removedProfile in difference.RemovedProfiles) + { + affectedObjects.AddRange(PipingDataSynchronizationService.RemoveStochasticSoilProfileFromInput(FailureMechanism, removedProfile)); + } + foreach (PipingStochasticSoilProfile updatedProfile in difference.UpdatedProfiles) + { + if (!oldProfiles[updatedProfile].Equals(updatedProfile.SoilProfile)) + { + affectedObjects.AddRange(PipingDataSynchronizationService.ClearStochasticSoilProfileDependentData(FailureMechanism, updatedProfile)); + } + affectedObjects.Add(updatedProfile); + } + return affectedObjects; + } + + #endregion + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSurfaceLineUpdateDataStrategy.cs =================================================================== diff -u -raa49537188229065df91b1a931f088c32115702a -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSurfaceLineUpdateDataStrategy.cs (.../PipingSurfaceLineUpdateDataStrategy.cs) (revision aa49537188229065df91b1a931f088c32115702a) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSurfaceLineUpdateDataStrategy.cs (.../PipingSurfaceLineUpdateDataStrategy.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -28,6 +28,7 @@ using Ringtoets.Common.IO.SurfaceLines; using Ringtoets.Common.Service; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Forms; using Ringtoets.Piping.Primitives; using Ringtoets.Piping.Service; @@ -110,7 +111,7 @@ var affectedObjects = new List(); foreach (PipingCalculation calculation in calculationsToUpdate) { - IEnumerable matchingSoilModels = GetAvailableStochasticSoilModels(updatedSurfaceLine); + IEnumerable matchingSoilModels = GetAvailableStochasticSoilModels(updatedSurfaceLine); PipingInput calculationInput = calculation.InputParameters; PipingInputService.SetMatchingStochasticSoilModel(calculationInput, matchingSoilModels); @@ -129,7 +130,7 @@ return affectedCalculations; } - private IEnumerable GetAvailableStochasticSoilModels(PipingSurfaceLine surfaceLine) + private IEnumerable GetAvailableStochasticSoilModels(PipingSurfaceLine surfaceLine) { return PipingCalculationConfigurationHelper.GetStochasticSoilModelsForSurfaceLine(surfaceLine, FailureMechanism.StochasticSoilModels); Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/StochasticSoilModelImporterConfigurationFactory.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/StochasticSoilModelImporterConfigurationFactory.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/StochasticSoilModelImporterConfigurationFactory.cs (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -0,0 +1,64 @@ +// Copyright (C) Stichting Deltares 2017. 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 Ringtoets.Common.IO.SoilProfile; +using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; +using Ringtoets.Piping.IO.Importers; + +namespace Ringtoets.Piping.Plugin.FileImporter +{ + /// + /// Factory for creating valid configurations for the . + /// + public static class StochasticSoilModelImporterConfigurationFactory + { + /// + /// Creates a configuration to replace the current stochastic soil models on + /// with imported stochastic soil models. + /// + /// The failure mechanism to replace the stochastic soil models for. + /// The configuration for the replace operation. + public static StochasticSoilModelImporterConfiguration CreateReplaceStrategyConfiguration( + PipingFailureMechanism failureMechanism) + { + return new StochasticSoilModelImporterConfiguration( + new PipingStochasticSoilModelTransformer(), + new PipingStochasticSoilModelFilter(), + new PipingStochasticSoilModelReplaceDataStrategy(failureMechanism)); + } + + /// + /// Creates a configuration to update the current stochastic soil models on + /// with imported stochastic soil models. + /// + /// The failure mechanism to update the stochastic soil models for. + /// The configuration for the update operation. + public static StochasticSoilModelImporterConfiguration CreateUpdateStrategyConfiguration( + PipingFailureMechanism failureMechanism) + { + return new StochasticSoilModelImporterConfiguration( + new PipingStochasticSoilModelTransformer(), + new PipingStochasticSoilModelFilter(), + new PipingStochasticSoilModelUpdateDataStrategy(failureMechanism)); + } + } +} \ No newline at end of file Fisheye: Tag 26f527fb809a2325c8f883ece9da01a8f8040eb3 refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/StochasticSoilModelReplaceDataStrategy.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 26f527fb809a2325c8f883ece9da01a8f8040eb3 refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/StochasticSoilModelUpdateDataStrategy.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs =================================================================== diff -u -r8b60c9e846480f3ffeeb263bfea5d3367bf6bee3 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision 8b60c9e846480f3ffeeb263bfea5d3367bf6bee3) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -41,15 +41,16 @@ using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.Forms.TreeNodeInfos; using Ringtoets.Common.IO.FileImporters.MessageProviders; +using Ringtoets.Common.IO.SoilProfile; using Ringtoets.Common.IO.SurfaceLines; using Ringtoets.Common.Service; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Forms; using Ringtoets.Piping.Forms.PresentationObjects; using Ringtoets.Piping.Forms.PropertyClasses; using Ringtoets.Piping.Forms.Views; using Ringtoets.Piping.IO.Configurations; -using Ringtoets.Piping.IO.Importers; using Ringtoets.Piping.Plugin.FileImporter; using Ringtoets.Piping.Plugin.Properties; using Ringtoets.Piping.Primitives; @@ -81,12 +82,18 @@ CreateInstance = context => new PipingSurfaceLineCollectionProperties(context.WrappedData) }; yield return new PropertyInfo(); - yield return new PropertyInfo + yield return new PropertyInfo { - CreateInstance = context => new StochasticSoilModelCollectionProperties(context.WrappedData) + CreateInstance = context => new PipingStochasticSoilModelCollectionProperties(context.WrappedData) }; - yield return new PropertyInfo(); - yield return new PropertyInfo(); + yield return new PropertyInfo + { + CreateInstance = stochasticSoilModel => new PipingStochasticSoilModelProperties(stochasticSoilModel) + }; + yield return new PropertyInfo + { + CreateInstance = stochasticSoilProfile => new PipingStochasticSoilProfileProperties(stochasticSoilProfile) + }; } public override IEnumerable GetImportInfos() @@ -113,7 +120,12 @@ Image = PipingFormsResources.PipingSoilProfileIcon, FileFilterGenerator = StochasticSoilModelFileFilter, IsEnabled = context => context.AssessmentSection.ReferenceLine != null, - CreateFileImporter = (context, filePath) => StochasticSoilModelImporter(context, filePath, new ImportMessageProvider(), new StochasticSoilModelReplaceDataStrategy(context.FailureMechanism)), + CreateFileImporter = (context, filePath) => new StochasticSoilModelImporter( + context.WrappedData, + filePath, + new ImportMessageProvider(), + StochasticSoilModelImporterConfigurationFactory.CreateReplaceStrategyConfiguration(context.FailureMechanism) + ), VerifyUpdates = context => VerifyStochasticSoilModelUpdates(context, Resources.PipingPlugin_VerifyStochasticSoilModelImport_When_importing_StochasticSoilModels_calculation_output_will_be_cleared_confirm) }; @@ -165,7 +177,12 @@ FileFilterGenerator = StochasticSoilModelFileFilter, IsEnabled = context => context.WrappedData.SourcePath != null, CurrentPath = context => context.WrappedData.SourcePath, - CreateFileImporter = (context, filePath) => StochasticSoilModelImporter(context, filePath, new UpdateMessageProvider(), new StochasticSoilModelUpdateDataStrategy(context.FailureMechanism)), + CreateFileImporter = (context, filePath) => new StochasticSoilModelImporter( + context.WrappedData, + filePath, + new UpdateMessageProvider(), + StochasticSoilModelImporterConfigurationFactory.CreateUpdateStrategyConfiguration(context.FailureMechanism) + ), VerifyUpdates = context => VerifyStochasticSoilModelUpdates(context, Resources.PipingPlugin_VerifyStochasticSoilModelUpdates_When_updating_StochasticSoilModel_definitions_assigned_to_calculation_output_will_be_cleared_confirm) }; } @@ -267,7 +284,9 @@ { Text = pipingSurfaceLine => RingtoetsCommonDataResources.SurfaceLineCollection_TypeDescriptor, Image = pipingSurfaceLine => RingtoetsCommonFormsResources.GeneralFolderIcon, - ForeColor = pipingSurfaceLine => pipingSurfaceLine.WrappedData.Any() ? Color.FromKnownColor(KnownColor.ControlText) : Color.FromKnownColor(KnownColor.GrayText), + ForeColor = pipingSurfaceLine => pipingSurfaceLine.WrappedData.Any() + ? Color.FromKnownColor(KnownColor.ControlText) + : Color.FromKnownColor(KnownColor.GrayText), ChildNodeObjects = pipingSurfaceLine => pipingSurfaceLine.WrappedData.Cast().ToArray(), ContextMenuStrip = PipingSurfaceLinesContextContextMenuStrip }; @@ -293,7 +312,7 @@ ContextMenuStrip = StochasticSoilModelCollectionContextContextMenuStrip }; - yield return new TreeNodeInfo + yield return new TreeNodeInfo { Text = stochasticSoilModel => stochasticSoilModel.Name, Image = stochasticSoilModel => PipingFormsResources.StochasticSoilModelIcon, @@ -306,9 +325,9 @@ .Build() }; - yield return new TreeNodeInfo + yield return new TreeNodeInfo { - Text = pipingSoilProfile => pipingSoilProfile.SoilProfile != null ? pipingSoilProfile.SoilProfile.Name : "Profile", + Text = pipingSoilProfile => pipingSoilProfile.SoilProfile.Name, Image = pipingSoilProfile => PipingFormsResources.PipingSoilProfileIcon, ContextMenuStrip = (nodeData, parentData, treeViewControl) => Gui.Get(nodeData, treeViewControl) .AddPropertiesItem() @@ -352,15 +371,6 @@ } } - private static StochasticSoilModelImporter StochasticSoilModelImporter(StochasticSoilModelCollectionContext context, string filePath, - IImporterMessageProvider messageProvider, IStochasticSoilModelUpdateModelStrategy updateStrategy) - { - return new StochasticSoilModelImporter(context.WrappedData, - filePath, - messageProvider, - updateStrategy); - } - private bool VerifyStochasticSoilModelUpdates(StochasticSoilModelCollectionContext context, string query) { var changeHandler = new FailureMechanismCalculationChangeHandler(context.FailureMechanism, @@ -1003,7 +1013,10 @@ nodeData.NotifyObservers(); } - private static void GeneratePipingCalculations(CalculationGroup target, IEnumerable surfaceLines, IEnumerable soilModels, GeneralPipingInput generalInput) + private static void GeneratePipingCalculations(CalculationGroup target, + IEnumerable surfaceLines, + IEnumerable soilModels, + GeneralPipingInput generalInput) { foreach (ICalculationBase group in PipingCalculationConfigurationHelper.GenerateCalculationItemsStructure(surfaceLines, soilModels, generalInput)) { Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Ringtoets.Piping.Plugin.csproj =================================================================== diff -u -ra940166534b3dd6e778de2e7c8e7e5241f3d3381 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Ringtoets.Piping.Plugin.csproj (.../Ringtoets.Piping.Plugin.csproj) (revision a940166534b3dd6e778de2e7c8e7e5241f3d3381) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Ringtoets.Piping.Plugin.csproj (.../Ringtoets.Piping.Plugin.csproj) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -51,8 +51,9 @@ - - + + + @@ -83,11 +84,6 @@ Core.Common.Gui False - - {E344867E-9AC9-44C8-88A5-8185681679A9} - Core.Common.IO - False - {F49BD8B2-332A-4C91-A196-8CCE0A2C7D98} Core.Common.Utils Index: Ringtoets/Piping/src/Ringtoets.Piping.Service/PipingDataSynchronizationService.cs =================================================================== diff -u -rd6fe8399e8398224cf1bda9259052232d85b85a4 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/src/Ringtoets.Piping.Service/PipingDataSynchronizationService.cs (.../PipingDataSynchronizationService.cs) (revision d6fe8399e8398224cf1bda9259052232d85b85a4) +++ Ringtoets/Piping/src/Ringtoets.Piping.Service/PipingDataSynchronizationService.cs (.../PipingDataSynchronizationService.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -25,8 +25,10 @@ using System.Linq; using Core.Common.Base; using Ringtoets.Common.Data.Calculation; +using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Service; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Primitives; namespace Ringtoets.Piping.Service @@ -201,7 +203,7 @@ } /// - /// Removes a given from the + /// Removes a given from the /// and clears all data that depends on it, either directly or indirectly. /// /// The failure mechanism containing . @@ -210,7 +212,8 @@ /// All observable objects affected by this method. /// Thrown when /// or is null. - public static IEnumerable RemoveStochasticSoilModel(PipingFailureMechanism failureMechanism, StochasticSoilModel soilModel) + public static IEnumerable RemoveStochasticSoilModel(PipingFailureMechanism failureMechanism, + PipingStochasticSoilModel soilModel) { if (failureMechanism == null) { @@ -273,7 +276,7 @@ } /// - /// Removes a given from calculations in the + /// Removes a given from calculations in the /// and clears all data that depends on it, either directly or indirectly. /// /// The failure mechanism containing . @@ -282,7 +285,8 @@ /// All observable objects affected by this method. /// Thrown when /// or is null. - public static IEnumerable RemoveStochasticSoilProfileFromInput(PipingFailureMechanism failureMechanism, StochasticSoilProfile soilProfile) + public static IEnumerable RemoveStochasticSoilProfileFromInput(PipingFailureMechanism failureMechanism, + PipingStochasticSoilProfile soilProfile) { if (failureMechanism == null) { @@ -305,7 +309,7 @@ } /// - /// Clears data dependent on a given , either directly or indirectly, + /// Clears data dependent on a given , either directly or indirectly, /// from calculations in the . /// /// The failure mechanism containing . @@ -314,7 +318,8 @@ /// All observable objects affected by this method. /// Thrown when /// or is null. - public static IEnumerable ClearStochasticSoilProfileDependentData(PipingFailureMechanism failureMechanism, StochasticSoilProfile soilProfile) + public static IEnumerable ClearStochasticSoilProfileDependentData(PipingFailureMechanism failureMechanism, + PipingStochasticSoilProfile soilProfile) { if (failureMechanism == null) { @@ -347,7 +352,8 @@ return changedObservables; } - private static IEnumerable GetCalculationsWithSoilProfileAssigned(PipingFailureMechanism failureMechanism, StochasticSoilProfile soilProfile) + private static IEnumerable GetCalculationsWithSoilProfileAssigned(PipingFailureMechanism failureMechanism, + PipingStochasticSoilProfile soilProfile) { IEnumerable pipingCalculationScenarios = failureMechanism.Calculations Index: Ringtoets/Piping/src/Ringtoets.Piping.Service/PipingInputService.cs =================================================================== diff -u -r81fa8a9bf3bd503cbd280e88b8f6037a840cff12 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/src/Ringtoets.Piping.Service/PipingInputService.cs (.../PipingInputService.cs) (revision 81fa8a9bf3bd503cbd280e88b8f6037a840cff12) +++ Ringtoets/Piping/src/Ringtoets.Piping.Service/PipingInputService.cs (.../PipingInputService.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -22,6 +22,7 @@ using System.Collections.Generic; using System.Linq; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; namespace Ringtoets.Piping.Service { @@ -32,13 +33,13 @@ { /// /// Sets and that match the input of a calculation if there is one matching - /// or respectively. + /// or respectively. /// - /// The input parameters to set the . + /// The input parameters to set the . /// The available stochastic soil models. - public static void SetMatchingStochasticSoilModel(PipingInput pipingInput, IEnumerable availableStochasticSoilModels) + public static void SetMatchingStochasticSoilModel(PipingInput pipingInput, IEnumerable availableStochasticSoilModels) { - List available = availableStochasticSoilModels.ToList(); + List available = availableStochasticSoilModels.ToList(); if (available.Count == 1) { pipingInput.StochasticSoilModel = available.First(); @@ -57,7 +58,7 @@ /// The first element of when it is the only element. /// /// - /// The input parameters to set the . + /// The input parameters to set the . public static void SyncStochasticSoilProfileWithStochasticSoilModel(PipingInput pipingInput) { if (pipingInput.StochasticSoilModel != null) Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/DerivedPipingInputTest.cs =================================================================== diff -u -r81fa8a9bf3bd503cbd280e88b8f6037a840cff12 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/DerivedPipingInputTest.cs (.../DerivedPipingInputTest.cs) (revision 81fa8a9bf3bd503cbd280e88b8f6037a840cff12) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/DerivedPipingInputTest.cs (.../DerivedPipingInputTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -25,6 +25,7 @@ using NUnit.Framework; using Ringtoets.Common.Data.Probabilistics; using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Data.TestUtil; using Ringtoets.Piping.KernelWrapper.SubCalculator; using Ringtoets.Piping.KernelWrapper.TestUtil.SubCalculator; @@ -172,16 +173,15 @@ // Setup PipingInput input = PipingInputFactory.CreateInputWithAquiferAndCoverageLayer(); var derivedInput = new DerivedPipingInput(input); - input.StochasticSoilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) - { - SoilProfile = new PipingSoilProfile(string.Empty, 0, new[] + input.StochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile(string.Empty, 0, new[] { new PipingSoilLayer(2.0) { IsAquifer = false } }, SoilProfileType.SoilProfile1D, 0) - }; + ); // Call LogNormalDistribution effectiveThicknessCoverageLayer = derivedInput.EffectiveThicknessCoverageLayer; @@ -196,9 +196,8 @@ // Setup PipingInput input = PipingInputFactory.CreateInputWithAquiferAndCoverageLayer(); var derivedInput = new DerivedPipingInput(input); - input.StochasticSoilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) - { - SoilProfile = new PipingSoilProfile(string.Empty, 0, new[] + input.StochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile(string.Empty, 0, new[] { new PipingSoilLayer(2.0) { @@ -209,7 +208,7 @@ IsAquifer = true } }, SoilProfileType.SoilProfile1D, 0) - }; + ); // Call LogNormalDistribution effectiveThicknessCoverageLayer = derivedInput.EffectiveThicknessCoverageLayer; @@ -305,16 +304,15 @@ // Setup PipingInput input = PipingInputFactory.CreateInputWithAquiferAndCoverageLayer(); var derivedInput = new DerivedPipingInput(input); - input.StochasticSoilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) - { - SoilProfile = new PipingSoilProfile(string.Empty, 0, new[] + input.StochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile(string.Empty, 0, new[] { new PipingSoilLayer(2.0) { IsAquifer = false } }, SoilProfileType.SoilProfile1D, 0) - }; + ); // Call LogNormalDistribution thicknessCoverageLayer = derivedInput.ThicknessCoverageLayer; @@ -329,9 +327,8 @@ // Setup PipingInput input = PipingInputFactory.CreateInputWithAquiferAndCoverageLayer(); var derivedInput = new DerivedPipingInput(input); - input.StochasticSoilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) - { - SoilProfile = new PipingSoilProfile(string.Empty, 0, new[] + input.StochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile(string.Empty, 0, new[] { new PipingSoilLayer(2.0) { @@ -342,7 +339,7 @@ IsAquifer = true } }, SoilProfileType.SoilProfile1D, 0) - }; + ); // Call LogNormalDistribution thicknessCoverageLayer = derivedInput.ThicknessCoverageLayer; @@ -466,16 +463,15 @@ // Setup PipingInput input = PipingInputFactory.CreateInputWithAquiferAndCoverageLayer(); var derivedInput = new DerivedPipingInput(input); - input.StochasticSoilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) - { - SoilProfile = new PipingSoilProfile(string.Empty, 0, new[] + input.StochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile(string.Empty, 0, new[] { new PipingSoilLayer(2.0) { IsAquifer = false } }, SoilProfileType.SoilProfile1D, 0) - }; + ); // Call LogNormalDistribution thicknessAquiferLayer = derivedInput.ThicknessAquiferLayer; @@ -520,9 +516,8 @@ // Setup PipingInput input = PipingInputFactory.CreateInputWithAquiferAndCoverageLayer(); var derivedInput = new DerivedPipingInput(input); - input.StochasticSoilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) - { - SoilProfile = new PipingSoilProfile(string.Empty, 0, new[] + input.StochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile(string.Empty, 0, new[] { new PipingSoilLayer(2.0) { @@ -533,7 +528,7 @@ IsAquifer = true } }, SoilProfileType.SoilProfile1D, 0) - }; + ); // Call LogNormalDistribution thicknessAquiferLayer = derivedInput.ThicknessAquiferLayer; @@ -548,9 +543,8 @@ // Setup PipingInput input = PipingInputFactory.CreateInputWithAquiferAndCoverageLayer(); var derivedInput = new DerivedPipingInput(input); - input.StochasticSoilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) - { - SoilProfile = new PipingSoilProfile(string.Empty, 0, new[] + input.StochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile(string.Empty, 0, new[] { new PipingSoilLayer(2.5) { @@ -561,7 +555,7 @@ IsAquifer = true } }, SoilProfileType.SoilProfile1D, 0) - }; + ); // Call LogNormalDistribution thicknessAquiferLayer = derivedInput.ThicknessAquiferLayer; @@ -618,23 +612,6 @@ } [Test] - public void SaturatedVolumicWeightOfCoverageLayer_NoSoilProfile_ReturnsNaNForParameters() - { - // Setup - PipingInput input = PipingInputFactory.CreateInputWithAquiferAndCoverageLayer(); - var derivedInput = new DerivedPipingInput(input); - input.StochasticSoilProfile.SoilProfile = null; - - // Call - LogNormalDistribution result = derivedInput.SaturatedVolumicWeightOfCoverageLayer; - - // Assert - Assert.IsNaN(result.Mean); - Assert.IsNaN(result.Shift); - Assert.IsNaN(result.StandardDeviation); - } - - [Test] public void SaturatedVolumicWeightOfCoverageLayer_NoStochasticSoilProfile_ReturnsNaNForParameters() { // Setup @@ -691,13 +668,14 @@ // Setup PipingInput input = PipingInputFactory.CreateInputWithAquiferAndCoverageLayer(); var derivedInput = new DerivedPipingInput(input); - input.StochasticSoilProfile.SoilProfile = new PipingSoilProfile("", -2.0, new[] - { - new PipingSoilLayer(1.0) + input.StochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile("", -2.0, new[] { - IsAquifer = true - } - }, SoilProfileType.SoilProfile1D, 0); + new PipingSoilLayer(1.0) + { + IsAquifer = true + } + }, SoilProfileType.SoilProfile1D, 0)); // Call LogNormalDistribution result = derivedInput.SaturatedVolumicWeightOfCoverageLayer; @@ -714,13 +692,14 @@ // Setup PipingInput input = PipingInputFactory.CreateInputWithAquiferAndCoverageLayer(); var derivedInput = new DerivedPipingInput(input); - input.StochasticSoilProfile.SoilProfile = new PipingSoilProfile("", -2.0, new[] - { - new PipingSoilLayer(1.0) + input.StochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile("", -2.0, new[] { - IsAquifer = false - } - }, SoilProfileType.SoilProfile1D, 0); + new PipingSoilLayer(1.0) + { + IsAquifer = false + } + }, SoilProfileType.SoilProfile1D, 0)); // Call LogNormalDistribution result = derivedInput.SaturatedVolumicWeightOfCoverageLayer; @@ -737,17 +716,18 @@ // Setup PipingInput input = PipingInputFactory.CreateInputWithAquiferAndCoverageLayer(); var derivedInput = new DerivedPipingInput(input); - input.StochasticSoilProfile.SoilProfile = new PipingSoilProfile("", -2.0, new[] - { - new PipingSoilLayer(2.0) + input.StochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile("", -2.0, new[] { - IsAquifer = false - }, - new PipingSoilLayer(1.0) - { - IsAquifer = true - } - }, SoilProfileType.SoilProfile1D, 0); + new PipingSoilLayer(2.0) + { + IsAquifer = false + }, + new PipingSoilLayer(1.0) + { + IsAquifer = true + } + }, SoilProfileType.SoilProfile1D, 0)); // Call LogNormalDistribution result = derivedInput.SaturatedVolumicWeightOfCoverageLayer; @@ -768,19 +748,20 @@ double belowPhreaticLevelMean = 0.1 + random.NextDouble(); double deviation = random.NextDouble(); double shift = random.NextDouble(); - input.StochasticSoilProfile.SoilProfile = new PipingSoilProfile("", 0.0, new[] - { - new PipingSoilLayer(2.5) + input.StochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile("", 0.0, new[] { - BelowPhreaticLevelDeviation = deviation, - BelowPhreaticLevelShift = shift, - BelowPhreaticLevelMean = belowPhreaticLevelMean - }, - new PipingSoilLayer(0.5) - { - IsAquifer = true - } - }, SoilProfileType.SoilProfile1D, 0); + new PipingSoilLayer(2.5) + { + BelowPhreaticLevelDeviation = deviation, + BelowPhreaticLevelShift = shift, + BelowPhreaticLevelMean = belowPhreaticLevelMean + }, + new PipingSoilLayer(0.5) + { + IsAquifer = true + } + }, SoilProfileType.SoilProfile1D, 0)); // Call LogNormalDistribution result = derivedInput.SaturatedVolumicWeightOfCoverageLayer; @@ -802,25 +783,26 @@ double belowPhreaticLevelMeanB = 0.1 + random.NextDouble(); double deviation = random.NextDouble(); double shift = random.NextDouble(); - input.StochasticSoilProfile.SoilProfile = new PipingSoilProfile("", -2.0, new[] - { - new PipingSoilLayer(2.5) + input.StochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile("", -2.0, new[] { - BelowPhreaticLevelDeviation = deviation, - BelowPhreaticLevelShift = shift, - BelowPhreaticLevelMean = belowPhreaticLevelMeanA - }, - new PipingSoilLayer(-0.5) - { - BelowPhreaticLevelDeviation = deviation, - BelowPhreaticLevelShift = shift, - BelowPhreaticLevelMean = belowPhreaticLevelMeanB - }, - new PipingSoilLayer(-1.5) - { - IsAquifer = true - } - }, SoilProfileType.SoilProfile1D, 0); + new PipingSoilLayer(2.5) + { + BelowPhreaticLevelDeviation = deviation, + BelowPhreaticLevelShift = shift, + BelowPhreaticLevelMean = belowPhreaticLevelMeanA + }, + new PipingSoilLayer(-0.5) + { + BelowPhreaticLevelDeviation = deviation, + BelowPhreaticLevelShift = shift, + BelowPhreaticLevelMean = belowPhreaticLevelMeanB + }, + new PipingSoilLayer(-1.5) + { + IsAquifer = true + } + }, SoilProfileType.SoilProfile1D, 0)); // Call LogNormalDistribution result = derivedInput.SaturatedVolumicWeightOfCoverageLayer; @@ -850,25 +832,26 @@ double belowPhreaticLevelMeanB = 0.1 + random.NextDouble(); double deviation = random.NextDouble(); double shift = random.NextDouble(); - input.StochasticSoilProfile.SoilProfile = new PipingSoilProfile("", -2.0, new[] - { - new PipingSoilLayer(2.5) + input.StochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile("", -2.0, new[] { - BelowPhreaticLevelDeviation = deviation, - BelowPhreaticLevelShift = shift, - BelowPhreaticLevelMean = belowPhreaticLevelMeanA - }, - new PipingSoilLayer(-0.5) - { - BelowPhreaticLevelDeviation = deviation + deviationDelta, - BelowPhreaticLevelShift = shift + shiftDelta, - BelowPhreaticLevelMean = belowPhreaticLevelMeanB - }, - new PipingSoilLayer(-1.5) - { - IsAquifer = true - } - }, SoilProfileType.SoilProfile1D, 0); + new PipingSoilLayer(2.5) + { + BelowPhreaticLevelDeviation = deviation, + BelowPhreaticLevelShift = shift, + BelowPhreaticLevelMean = belowPhreaticLevelMeanA + }, + new PipingSoilLayer(-0.5) + { + BelowPhreaticLevelDeviation = deviation + deviationDelta, + BelowPhreaticLevelShift = shift + shiftDelta, + BelowPhreaticLevelMean = belowPhreaticLevelMeanB + }, + new PipingSoilLayer(-1.5) + { + IsAquifer = true + } + }, SoilProfileType.SoilProfile1D, 0)); // Call LogNormalDistribution result = derivedInput.SaturatedVolumicWeightOfCoverageLayer; @@ -887,25 +870,26 @@ var derivedInput = new DerivedPipingInput(input); const double belowPhreaticLevelMeanA = 2.5; const double belowPhreaticLevelMeanB = 3.4; - input.StochasticSoilProfile.SoilProfile = new PipingSoilProfile("", -2.0, new[] - { - new PipingSoilLayer(2.5) + input.StochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile("", -2.0, new[] { - BelowPhreaticLevelDeviation = 1.014, - BelowPhreaticLevelShift = 1.014, - BelowPhreaticLevelMean = belowPhreaticLevelMeanA - }, - new PipingSoilLayer(-0.5) - { - BelowPhreaticLevelDeviation = 1.006, - BelowPhreaticLevelShift = 1.006, - BelowPhreaticLevelMean = belowPhreaticLevelMeanB - }, - new PipingSoilLayer(-1.5) - { - IsAquifer = true - } - }, SoilProfileType.SoilProfile1D, 0); + new PipingSoilLayer(2.5) + { + BelowPhreaticLevelDeviation = 1.014, + BelowPhreaticLevelShift = 1.014, + BelowPhreaticLevelMean = belowPhreaticLevelMeanA + }, + new PipingSoilLayer(-0.5) + { + BelowPhreaticLevelDeviation = 1.006, + BelowPhreaticLevelShift = 1.006, + BelowPhreaticLevelMean = belowPhreaticLevelMeanB + }, + new PipingSoilLayer(-1.5) + { + IsAquifer = true + } + }, SoilProfileType.SoilProfile1D, 0)); // Call LogNormalDistribution result = derivedInput.SaturatedVolumicWeightOfCoverageLayer; @@ -922,19 +906,20 @@ // Setup PipingInput input = PipingInputFactory.CreateInputWithAquiferAndCoverageLayer(); var derivedInput = new DerivedPipingInput(input); - input.StochasticSoilProfile.SoilProfile = new PipingSoilProfile("", -2.0, new[] - { - new PipingSoilLayer(2.5) + input.StochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile("", -2.0, new[] { - BelowPhreaticLevelDeviation = 2.5, - BelowPhreaticLevelShift = 1.01, - BelowPhreaticLevelMean = 1.00 - }, - new PipingSoilLayer(-1.5) - { - IsAquifer = true - } - }, SoilProfileType.SoilProfile1D, 0); + new PipingSoilLayer(2.5) + { + BelowPhreaticLevelDeviation = 2.5, + BelowPhreaticLevelShift = 1.01, + BelowPhreaticLevelMean = 1.00 + }, + new PipingSoilLayer(-1.5) + { + IsAquifer = true + } + }, SoilProfileType.SoilProfile1D, 0)); // Call LogNormalDistribution result = derivedInput.SaturatedVolumicWeightOfCoverageLayer; @@ -951,25 +936,26 @@ // Setup PipingInput input = PipingInputFactory.CreateInputWithAquiferAndCoverageLayer(); var derivedInput = new DerivedPipingInput(input); - input.StochasticSoilProfile.SoilProfile = new PipingSoilProfile("", -2.0, new[] - { - new PipingSoilLayer(2.5) + input.StochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile("", -2.0, new[] { - BelowPhreaticLevelDeviation = 3.5, - BelowPhreaticLevelShift = 0.5, - BelowPhreaticLevelMean = 1.00 - }, - new PipingSoilLayer(-0.5) - { - BelowPhreaticLevelDeviation = 2.5, - BelowPhreaticLevelShift = 1.01, - BelowPhreaticLevelMean = 1.00 - }, - new PipingSoilLayer(-1.5) - { - IsAquifer = true - } - }, SoilProfileType.SoilProfile1D, 0); + new PipingSoilLayer(2.5) + { + BelowPhreaticLevelDeviation = 3.5, + BelowPhreaticLevelShift = 0.5, + BelowPhreaticLevelMean = 1.00 + }, + new PipingSoilLayer(-0.5) + { + BelowPhreaticLevelDeviation = 2.5, + BelowPhreaticLevelShift = 1.01, + BelowPhreaticLevelMean = 1.00 + }, + new PipingSoilLayer(-1.5) + { + IsAquifer = true + } + }, SoilProfileType.SoilProfile1D, 0)); // Call LogNormalDistribution result = derivedInput.SaturatedVolumicWeightOfCoverageLayer; @@ -981,22 +967,6 @@ } [Test] - public void DarcyPermeability_NoSoilProfile_ReturnsNaNForParameters() - { - // Setup - PipingInput input = PipingInputFactory.CreateInputWithAquiferAndCoverageLayer(); - var derivedInput = new DerivedPipingInput(input); - input.StochasticSoilProfile.SoilProfile = null; - - // Call - VariationCoefficientLogNormalDistribution result = derivedInput.DarcyPermeability; - - // Assert - Assert.IsNaN(result.Mean); - Assert.IsNaN(result.CoefficientOfVariation); - } - - [Test] public void DarcyPermeability_NoStochasticSoilProfile_ReturnsNaNForParameters() { // Setup @@ -1050,10 +1020,11 @@ // Setup PipingInput input = PipingInputFactory.CreateInputWithAquiferAndCoverageLayer(); var derivedInput = new DerivedPipingInput(input); - input.StochasticSoilProfile.SoilProfile = new PipingSoilProfile("", -2.0, new[] - { - new PipingSoilLayer(1.0) - }, SoilProfileType.SoilProfile1D, 0); + input.StochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile("", -2.0, new[] + { + new PipingSoilLayer(1.0) + }, SoilProfileType.SoilProfile1D, 0)); // Call VariationCoefficientLogNormalDistribution result = derivedInput.DarcyPermeability; @@ -1069,15 +1040,16 @@ // Setup PipingInput input = PipingInputFactory.CreateInputWithAquiferAndCoverageLayer(); var derivedInput = new DerivedPipingInput(input); - input.StochasticSoilProfile.SoilProfile = new PipingSoilProfile("", 0.0, new[] - { - new PipingSoilLayer(0.5) + input.StochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile("", 0.0, new[] { - IsAquifer = true, - PermeabilityCoefficientOfVariation = 0.3, - PermeabilityMean = 0 - } - }, SoilProfileType.SoilProfile1D, 0); + new PipingSoilLayer(0.5) + { + IsAquifer = true, + PermeabilityCoefficientOfVariation = 0.3, + PermeabilityMean = 0 + } + }, SoilProfileType.SoilProfile1D, 0)); // Call VariationCoefficientLogNormalDistribution result = derivedInput.DarcyPermeability; @@ -1093,21 +1065,22 @@ // Setup PipingInput input = PipingInputFactory.CreateInputWithAquiferAndCoverageLayer(); var derivedInput = new DerivedPipingInput(input); - input.StochasticSoilProfile.SoilProfile = new PipingSoilProfile("", 0.0, new[] - { - new PipingSoilLayer(0.5) + input.StochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile("", 0.0, new[] { - IsAquifer = true, - PermeabilityCoefficientOfVariation = 0.3, - PermeabilityMean = 0 - }, - new PipingSoilLayer(1.5) - { - IsAquifer = true, - PermeabilityCoefficientOfVariation = 0.3, - PermeabilityMean = 2.4 - } - }, SoilProfileType.SoilProfile1D, 0); + new PipingSoilLayer(0.5) + { + IsAquifer = true, + PermeabilityCoefficientOfVariation = 0.3, + PermeabilityMean = 0 + }, + new PipingSoilLayer(1.5) + { + IsAquifer = true, + PermeabilityCoefficientOfVariation = 0.3, + PermeabilityMean = 2.4 + } + }, SoilProfileType.SoilProfile1D, 0)); // Call VariationCoefficientLogNormalDistribution result = derivedInput.DarcyPermeability; @@ -1129,21 +1102,22 @@ double mean2 = 0.1 + random.NextDouble(); const double coefficientOfVariation = 0.5; - input.StochasticSoilProfile.SoilProfile = new PipingSoilProfile("", 0.0, new[] - { - new PipingSoilLayer(0.5) + input.StochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile("", 0.0, new[] { - IsAquifer = true, - PermeabilityCoefficientOfVariation = coefficientOfVariation, - PermeabilityMean = mean - }, - new PipingSoilLayer(1.5) - { - IsAquifer = true, - PermeabilityCoefficientOfVariation = coefficientOfVariation, - PermeabilityMean = mean2 - } - }, SoilProfileType.SoilProfile1D, 0); + new PipingSoilLayer(0.5) + { + IsAquifer = true, + PermeabilityCoefficientOfVariation = coefficientOfVariation, + PermeabilityMean = mean + }, + new PipingSoilLayer(1.5) + { + IsAquifer = true, + PermeabilityCoefficientOfVariation = coefficientOfVariation, + PermeabilityMean = mean2 + } + }, SoilProfileType.SoilProfile1D, 0)); // Call VariationCoefficientLogNormalDistribution result = derivedInput.DarcyPermeability; @@ -1163,15 +1137,16 @@ var random = new Random(21); double permeabilityMean = 0.1 + random.NextDouble(); double permeabilityCoefficientOfVariation = random.NextDouble(); - input.StochasticSoilProfile.SoilProfile = new PipingSoilProfile("", -2.0, new[] - { - new PipingSoilLayer(1.0) + input.StochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile("", -2.0, new[] { - IsAquifer = true, - PermeabilityMean = permeabilityMean, - PermeabilityCoefficientOfVariation = permeabilityCoefficientOfVariation - } - }, SoilProfileType.SoilProfile1D, 0); + new PipingSoilLayer(1.0) + { + IsAquifer = true, + PermeabilityMean = permeabilityMean, + PermeabilityCoefficientOfVariation = permeabilityCoefficientOfVariation + } + }, SoilProfileType.SoilProfile1D, 0)); // Call VariationCoefficientLogNormalDistribution result = derivedInput.DarcyPermeability; @@ -1189,21 +1164,22 @@ // Setup PipingInput input = PipingInputFactory.CreateInputWithAquiferAndCoverageLayer(); var derivedInput = new DerivedPipingInput(input); - input.StochasticSoilProfile.SoilProfile = new PipingSoilProfile("", -2.0, new[] - { - new PipingSoilLayer(1.0) + input.StochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile("", -2.0, new[] { - IsAquifer = true, - PermeabilityMean = 0.5, - PermeabilityCoefficientOfVariation = 0.2 - }, - new PipingSoilLayer(0.0) - { - IsAquifer = true, - PermeabilityMean = 12.5, - PermeabilityCoefficientOfVariation = 2.3 - } - }, SoilProfileType.SoilProfile1D, 0); + new PipingSoilLayer(1.0) + { + IsAquifer = true, + PermeabilityMean = 0.5, + PermeabilityCoefficientOfVariation = 0.2 + }, + new PipingSoilLayer(0.0) + { + IsAquifer = true, + PermeabilityMean = 12.5, + PermeabilityCoefficientOfVariation = 2.3 + } + }, SoilProfileType.SoilProfile1D, 0)); // Call VariationCoefficientLogNormalDistribution result = derivedInput.DarcyPermeability; @@ -1214,22 +1190,6 @@ } [Test] - public void DiameterD70_NoSoilProfile_ReturnsNaNForParameters() - { - // Setup - PipingInput input = PipingInputFactory.CreateInputWithAquiferAndCoverageLayer(); - var derivedInput = new DerivedPipingInput(input); - input.StochasticSoilProfile.SoilProfile = null; - - // Call - VariationCoefficientLogNormalDistribution result = derivedInput.DiameterD70; - - // Assert - Assert.IsNaN(result.Mean); - Assert.IsNaN(result.CoefficientOfVariation); - } - - [Test] public void DiameterD70_NoStochasticSoilProfile_ReturnsNaNForParameters() { // Setup @@ -1283,10 +1243,11 @@ // Setup PipingInput input = PipingInputFactory.CreateInputWithAquiferAndCoverageLayer(); var derivedInput = new DerivedPipingInput(input); - input.StochasticSoilProfile.SoilProfile = new PipingSoilProfile("", -2.0, new[] - { - new PipingSoilLayer(1.0) - }, SoilProfileType.SoilProfile1D, 0); + input.StochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile("", -2.0, new[] + { + new PipingSoilLayer(1.0) + }, SoilProfileType.SoilProfile1D, 0)); // Call VariationCoefficientLogNormalDistribution result = derivedInput.DiameterD70; @@ -1305,15 +1266,16 @@ var random = new Random(21); double diameterD70Mean = 0.1 + random.NextDouble(); double diameterD70CoefficientOfVariation = random.NextDouble(); - input.StochasticSoilProfile.SoilProfile = new PipingSoilProfile("", -2.0, new[] - { - new PipingSoilLayer(1.0) + input.StochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile("", -2.0, new[] { - IsAquifer = true, - DiameterD70Mean = diameterD70Mean, - DiameterD70CoefficientOfVariation = diameterD70CoefficientOfVariation - } - }, SoilProfileType.SoilProfile1D, 0); + new PipingSoilLayer(1.0) + { + IsAquifer = true, + DiameterD70Mean = diameterD70Mean, + DiameterD70CoefficientOfVariation = diameterD70CoefficientOfVariation + } + }, SoilProfileType.SoilProfile1D, 0)); // Call VariationCoefficientLogNormalDistribution result = derivedInput.DiameterD70; @@ -1331,21 +1293,22 @@ var derivedInput = new DerivedPipingInput(input); const double diameterD70Mean = 0.5; const double diameterD70CoefficientOfVariation = 0.2; - input.StochasticSoilProfile.SoilProfile = new PipingSoilProfile("", -2.0, new[] - { - new PipingSoilLayer(1.0) + input.StochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile("", -2.0, new[] { - IsAquifer = true, - DiameterD70Mean = diameterD70Mean, - DiameterD70CoefficientOfVariation = diameterD70CoefficientOfVariation - }, - new PipingSoilLayer(0.0) - { - IsAquifer = true, - DiameterD70Mean = 12.5, - DiameterD70CoefficientOfVariation = 2.3 - } - }, SoilProfileType.SoilProfile1D, 0); + new PipingSoilLayer(1.0) + { + IsAquifer = true, + DiameterD70Mean = diameterD70Mean, + DiameterD70CoefficientOfVariation = diameterD70CoefficientOfVariation + }, + new PipingSoilLayer(0.0) + { + IsAquifer = true, + DiameterD70Mean = 12.5, + DiameterD70CoefficientOfVariation = 2.3 + } + }, SoilProfileType.SoilProfile1D, 0)); // Call VariationCoefficientLogNormalDistribution result = derivedInput.DiameterD70; Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingInputTest.cs =================================================================== diff -u -rd6fe8399e8398224cf1bda9259052232d85b85a4 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingInputTest.cs (.../PipingInputTest.cs) (revision d6fe8399e8398224cf1bda9259052232d85b85a4) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingInputTest.cs (.../PipingInputTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -30,6 +30,7 @@ using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Data.Probabilistics; using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Data.TestUtil; using Ringtoets.Piping.KernelWrapper.SubCalculator; using Ringtoets.Piping.KernelWrapper.TestUtil.SubCalculator; @@ -40,6 +41,17 @@ [TestFixture] public class PipingInputTest { + private static IEnumerable DifferentSurfaceLineProperties + { + get + { + yield return new TestCaseData(new Point3D(3, 0, 0), new Point3D(3, 0, 0)) + .SetName("DifferentDikeToeAtRiver"); + yield return new TestCaseData(new Point3D(2, 0, 3), new Point3D(4, 0, 2)) + .SetName("DifferentDikeToeAtPolder"); + } + } + [Test] public void Constructor_ExpectedValues() { @@ -555,17 +567,6 @@ Assert.IsFalse(synchronized); } - private static IEnumerable DifferentSurfaceLineProperties - { - get - { - yield return new TestCaseData(new Point3D(3, 0, 0), new Point3D(3, 0, 0)) - .SetName("DifferentDikeToeAtRiver"); - yield return new TestCaseData(new Point3D(2, 0, 3), new Point3D(4, 0, 2)) - .SetName("DifferentDikeToeAtPolder"); - } - } - [Test] public void GivenSurfaceLineSet_WhenSurfaceLineNull_ThenEntryAndExitPointsNaN() { @@ -896,16 +897,15 @@ { // Setup PipingInput input = PipingInputFactory.CreateInputWithAquiferAndCoverageLayer(); - input.StochasticSoilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) - { - SoilProfile = new PipingSoilProfile(string.Empty, 0, new[] + input.StochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile(string.Empty, 0, new[] { new PipingSoilLayer(2.0) { IsAquifer = false } }, SoilProfileType.SoilProfile1D, 0) - }; + ); // Call LogNormalDistribution thicknessAquiferLayer = input.ThicknessAquiferLayer; @@ -961,9 +961,8 @@ { // Setup PipingInput input = PipingInputFactory.CreateInputWithAquiferAndCoverageLayer(); - input.StochasticSoilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) - { - SoilProfile = new PipingSoilProfile(string.Empty, 0, new[] + input.StochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile(string.Empty, 0, new[] { new PipingSoilLayer(2.0) { @@ -974,7 +973,7 @@ IsAquifer = true } }, SoilProfileType.SoilProfile1D, 0) - }; + ); // Call LogNormalDistribution thicknessAquiferLayer = input.ThicknessAquiferLayer; @@ -988,9 +987,8 @@ { // Setup PipingInput input = PipingInputFactory.CreateInputWithAquiferAndCoverageLayer(); - input.StochasticSoilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) - { - SoilProfile = new PipingSoilProfile(string.Empty, 0, new[] + input.StochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile(string.Empty, 0, new[] { new PipingSoilLayer(2.5) { @@ -1001,7 +999,7 @@ IsAquifer = true } }, SoilProfileType.SoilProfile1D, 0) - }; + ); // Call LogNormalDistribution thicknessAquiferLayer = input.ThicknessAquiferLayer; @@ -1074,16 +1072,15 @@ { // Setup PipingInput input = PipingInputFactory.CreateInputWithAquiferAndCoverageLayer(); - input.StochasticSoilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) - { - SoilProfile = new PipingSoilProfile(string.Empty, 0, new[] + input.StochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile(string.Empty, 0, new[] { new PipingSoilLayer(2.0) { IsAquifer = false } }, SoilProfileType.SoilProfile1D, 0) - }; + ); // Call LogNormalDistribution thicknessCoverageLayer = input.ThicknessCoverageLayer; @@ -1097,9 +1094,8 @@ { // Setup PipingInput input = PipingInputFactory.CreateInputWithAquiferAndCoverageLayer(); - input.StochasticSoilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) - { - SoilProfile = new PipingSoilProfile(string.Empty, 0, new[] + input.StochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile(string.Empty, 0, new[] { new PipingSoilLayer(2.0) { @@ -1110,7 +1106,7 @@ IsAquifer = true } }, SoilProfileType.SoilProfile1D, 0) - }; + ); // Call LogNormalDistribution thicknessCoverageLayer = input.ThicknessCoverageLayer; @@ -1183,16 +1179,15 @@ { // Setup PipingInput input = PipingInputFactory.CreateInputWithAquiferAndCoverageLayer(); - input.StochasticSoilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) - { - SoilProfile = new PipingSoilProfile(string.Empty, 0, new[] + input.StochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile(string.Empty, 0, new[] { new PipingSoilLayer(2.0) { IsAquifer = false } }, SoilProfileType.SoilProfile1D, 0) - }; + ); // Call LogNormalDistribution effectiveThicknessCoverageLayer = input.EffectiveThicknessCoverageLayer; @@ -1206,9 +1201,8 @@ { // Setup PipingInput input = PipingInputFactory.CreateInputWithAquiferAndCoverageLayer(); - input.StochasticSoilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) - { - SoilProfile = new PipingSoilProfile(string.Empty, 0, new[] + input.StochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile(string.Empty, 0, new[] { new PipingSoilLayer(2.0) { @@ -1219,7 +1213,7 @@ IsAquifer = true } }, SoilProfileType.SoilProfile1D, 0) - }; + ); // Call LogNormalDistribution effectiveThicknessCoverageLayer = input.EffectiveThicknessCoverageLayer; Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Ringtoets.Piping.Data.Test.csproj =================================================================== diff -u -r94ce658a9488c346f114446f0e37dabab7acaa38 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Ringtoets.Piping.Data.Test.csproj (.../Ringtoets.Piping.Data.Test.csproj) (revision 94ce658a9488c346f114446f0e37dabab7acaa38) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Ringtoets.Piping.Data.Test.csproj (.../Ringtoets.Piping.Data.Test.csproj) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -72,12 +72,11 @@ + + - - - - + Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/SoilProfile/PipingStochasticSoilModelCollectionTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/SoilProfile/PipingStochasticSoilModelCollectionTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/SoilProfile/PipingStochasticSoilModelCollectionTest.cs (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -0,0 +1,81 @@ +// Copyright (C) Stichting Deltares 2017. 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 System.Linq; +using Core.Common.Base; +using NUnit.Framework; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Piping.Data.SoilProfile; + +namespace Ringtoets.Piping.Data.Test.SoilProfile +{ + [TestFixture] + public class PipingStochasticSoilModelCollectionTest : + CustomObservableUniqueItemCollectionWithSourcePathTestFixtureBase< + ObservableUniqueItemCollectionWithSourcePath, PipingStochasticSoilModel> + { + protected override ObservableUniqueItemCollectionWithSourcePath CreateCollection() + { + return new PipingStochasticSoilModelCollection(); + } + + protected override IEnumerable UniqueElements() + { + yield return new PipingStochasticSoilModel("Model A"); + yield return new PipingStochasticSoilModel("Model B"); + } + + protected override IEnumerable SingleNonUniqueElements() + { + const string someName = "Soil model"; + yield return new PipingStochasticSoilModel(someName); + yield return new PipingStochasticSoilModel(someName); + } + + protected override IEnumerable MultipleNonUniqueElements() + { + const string someName = "Soil model"; + const string someOtherName = "Other soil model"; + yield return new PipingStochasticSoilModel(someName); + yield return new PipingStochasticSoilModel(someName); + yield return new PipingStochasticSoilModel(someOtherName); + yield return new PipingStochasticSoilModel(someOtherName); + yield return new PipingStochasticSoilModel(someOtherName); + } + + protected override void AssertSingleNonUniqueElements(ArgumentException exception, IEnumerable itemsToAdd) + { + string someName = itemsToAdd.First().Name; + Assert.AreEqual("Stochastische ondergrondmodellen moeten een unieke naam hebben. " + + $"Gevonden dubbele elementen: {someName}.", exception.Message); + } + + protected override void AssertMultipleNonUniqueElements(ArgumentException exception, IEnumerable itemsToAdd) + { + string someName = itemsToAdd.First().Name; + string someOtherName = itemsToAdd.First(i => i.Name != someName).Name; + Assert.AreEqual("Stochastische ondergrondmodellen moeten een unieke naam hebben. " + + $"Gevonden dubbele elementen: {someName}, {someOtherName}.", exception.Message); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/SoilProfile/PipingStochasticSoilModelProfileDifferenceTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/SoilProfile/PipingStochasticSoilModelProfileDifferenceTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/SoilProfile/PipingStochasticSoilModelProfileDifferenceTest.cs (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -0,0 +1,50 @@ +// Copyright (C) Stichting Deltares 2017. 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 NUnit.Framework; +using Ringtoets.Piping.Data.SoilProfile; + +namespace Ringtoets.Piping.Data.Test.SoilProfile +{ + [TestFixture] + public class PipingStochasticSoilModelProfileDifferenceTest + { + [Test] + public void Constructor_ValidArguments_ExpectedProperties() + { + // Setup + var addedProfiles = new List(); + var updatedProfiles = new List(); + var removedProfiles = new List(); + + // Call + var difference = new PipingStochasticSoilModelProfileDifference(addedProfiles, + updatedProfiles, + removedProfiles); + + // Assert + Assert.AreSame(addedProfiles, difference.AddedProfiles); + Assert.AreSame(updatedProfiles, difference.UpdatedProfiles); + Assert.AreSame(removedProfiles, difference.RemovedProfiles); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/SoilProfile/PipingStochasticSoilModelTest.cs =================================================================== diff -u -rb78437864e9677d66dc309d766b0e706c8af0c1f -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/SoilProfile/PipingStochasticSoilModelTest.cs (.../PipingStochasticSoilModelTest.cs) (revision b78437864e9677d66dc309d766b0e706c8af0c1f) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/SoilProfile/PipingStochasticSoilModelTest.cs (.../PipingStochasticSoilModelTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -19,10 +19,15 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; +using System.Collections.Generic; using Core.Common.Base; +using Core.Common.Base.Geometry; using NUnit.Framework; using Ringtoets.Common.Data; using Ringtoets.Piping.Data.SoilProfile; +using Ringtoets.Piping.KernelWrapper.TestUtil; +using Ringtoets.Piping.Primitives; namespace Ringtoets.Piping.Data.Test.SoilProfile { @@ -47,5 +52,280 @@ CollectionAssert.IsEmpty(model.StochasticSoilProfiles); Assert.AreEqual(name, model.ToString()); } + + [Test] + public void Update_WithNullModel_ThrowsArgumentNullException() + { + // Setup + var model = new PipingStochasticSoilModel("name"); + + // Call + TestDelegate test = () => model.Update(null); + + // Assert + string paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("fromModel", paramName); + } + + [Test] + public void Update_ModelWithUpdatedProperties_PropertiesUpdated() + { + // Setup + var model = new PipingStochasticSoilModel("name"); + model.Geometry.AddRange(new[] + { + new Point2D(1, 2), + new Point2D(4, 5) + }); + + const string expectedName = "otherName"; + var expectedGeometry = new[] + { + new Point2D(4, 2) + }; + + var otherModel = new PipingStochasticSoilModel(expectedName); + otherModel.Geometry.AddRange(expectedGeometry); + + // Call + PipingStochasticSoilModelProfileDifference difference = model.Update(otherModel); + + // Assert + Assert.AreEqual(expectedName, model.Name); + CollectionAssert.AreEqual(expectedGeometry, model.Geometry); + + CollectionAssert.IsEmpty(difference.AddedProfiles); + CollectionAssert.IsEmpty(difference.UpdatedProfiles); + CollectionAssert.IsEmpty(difference.RemovedProfiles); + } + + [Test] + public void Update_ModelWithAddedProfile_ProfileAdded() + { + // Setup + PipingStochasticSoilModel model = CreateEmptyModel(); + PipingStochasticSoilModel otherModel = CreateEmptyModel(); + var expectedAddedProfile = new PipingStochasticSoilProfile(0.2, new TestPipingSoilProfile()); + otherModel.StochasticSoilProfiles.Add(expectedAddedProfile); + + // Call + PipingStochasticSoilModelProfileDifference difference = model.Update(otherModel); + + // Assert + Assert.AreEqual(1, otherModel.StochasticSoilProfiles.Count); + Assert.AreEqual(expectedAddedProfile, otherModel.StochasticSoilProfiles[0]); + + CollectionAssert.AreEqual(new[] + { + expectedAddedProfile + }, difference.AddedProfiles); + CollectionAssert.IsEmpty(difference.UpdatedProfiles); + CollectionAssert.IsEmpty(difference.RemovedProfiles); + } + + [Test] + public void Update_ModelWithUpdatedProfile_ProfileUpdated() + { + // Setup + const string profileName = "A"; + var expectedUpdatedProfile = new PipingStochasticSoilProfile(0.2, + new PipingSoilProfile(profileName, -2, CreateLayers(), SoilProfileType.SoilProfile1D, -5)); + PipingStochasticSoilModel model = CreateEmptyModel(); + model.StochasticSoilProfiles.Add(expectedUpdatedProfile); + PipingStochasticSoilModel otherModel = CreateEmptyModel(); + otherModel.StochasticSoilProfiles.Add(new PipingStochasticSoilProfile(0.2, + new PipingSoilProfile(profileName, -1, CreateLayers(), SoilProfileType.SoilProfile1D, -5))); + + // Call + PipingStochasticSoilModelProfileDifference difference = model.Update(otherModel); + + // Assert + Assert.AreEqual(1, otherModel.StochasticSoilProfiles.Count); + Assert.AreEqual(expectedUpdatedProfile, otherModel.StochasticSoilProfiles[0]); + + CollectionAssert.IsEmpty(difference.AddedProfiles); + CollectionAssert.AreEqual(new[] + { + expectedUpdatedProfile + }, difference.UpdatedProfiles); + CollectionAssert.IsEmpty(difference.RemovedProfiles); + } + + [Test] + public void Update_ModelWithUpdatedStochasticSoilProfile_ProfileUpdated() + { + // Setup + const string profileName = "A"; + var soilProfile = new PipingSoilProfile(profileName, -2, CreateLayers(), SoilProfileType.SoilProfile1D, -5); + var expectedUpdatedProfile = new PipingStochasticSoilProfile(0.2, soilProfile); + PipingStochasticSoilModel model = CreateEmptyModel(); + model.StochasticSoilProfiles.Add(expectedUpdatedProfile); + + PipingStochasticSoilModel otherModel = CreateEmptyModel(); + otherModel.StochasticSoilProfiles.Add(new PipingStochasticSoilProfile(0.5, soilProfile)); + + // Call + PipingStochasticSoilModelProfileDifference difference = model.Update(otherModel); + + // Assert + CollectionAssert.IsEmpty(difference.AddedProfiles); + CollectionAssert.AreEqual(new[] + { + expectedUpdatedProfile + }, difference.UpdatedProfiles); + CollectionAssert.IsEmpty(difference.RemovedProfiles); + } + + [Test] + public void Update_ModelWithRemovedProfile_ProfileRemoved() + { + // Setup + const string profileName = "A"; + var soilProfile = new PipingSoilProfile(profileName, -2, CreateLayers(), SoilProfileType.SoilProfile1D, -5); + var expectedRemovedProfile = new PipingStochasticSoilProfile(0.2, soilProfile); + PipingStochasticSoilModel model = CreateEmptyModel(); + model.StochasticSoilProfiles.Add(expectedRemovedProfile); + + PipingStochasticSoilModel otherModel = CreateEmptyModel(); + + // Call + PipingStochasticSoilModelProfileDifference difference = model.Update(otherModel); + + // Assert + CollectionAssert.IsEmpty(difference.AddedProfiles); + CollectionAssert.IsEmpty(difference.UpdatedProfiles); + CollectionAssert.AreEqual(new[] + { + expectedRemovedProfile + }, difference.RemovedProfiles); + } + + [Test] + public void Update_ModelWithRemovedProfileSameNameOtherType_ProfileRemoved() + { + // Setup + const string profileName = "A"; + var soilProfile = new PipingSoilProfile(profileName, -2, CreateLayers(), SoilProfileType.SoilProfile1D, -5); + var expectedRemovedProfile = new PipingStochasticSoilProfile(0.2, soilProfile); + var newProfile = new PipingStochasticSoilProfile(0.2, + new PipingSoilProfile(profileName, -2, CreateLayers(), SoilProfileType.SoilProfile2D, -5)); + PipingStochasticSoilModel model = CreateEmptyModel(); + model.StochasticSoilProfiles.Add(expectedRemovedProfile); + + PipingStochasticSoilModel otherModel = CreateEmptyModel(); + otherModel.StochasticSoilProfiles.Add(newProfile); + + // Call + PipingStochasticSoilModelProfileDifference difference = model.Update(otherModel); + + // Assert + CollectionAssert.AreEqual(new[] + { + newProfile + }, difference.AddedProfiles); + CollectionAssert.IsEmpty(difference.UpdatedProfiles); + CollectionAssert.AreEqual(new[] + { + expectedRemovedProfile + }, difference.RemovedProfiles); + } + + [Test] + public void Update_WithOtherModel_PropertiesUpdated() + { + // Setup + const string equalProfileName = "nameA"; + PipingStochasticSoilModel model = CreateEmptyModel(); + + var stochasticProfileA = new PipingStochasticSoilProfile(0.5, new TestPipingSoilProfile(equalProfileName)); + var stochasticProfileB = new PipingStochasticSoilProfile(0.5, new TestPipingSoilProfile("nameB")); + model.StochasticSoilProfiles.Add(stochasticProfileA); + model.StochasticSoilProfiles.Add(stochasticProfileB); + + const string otherName = "other name"; + var otherModel = new PipingStochasticSoilModel(otherName); + + var otherPointA = new Point2D(2, 0); + var otherPointB = new Point2D(3, 0); + otherModel.Geometry.Add(otherPointA); + otherModel.Geometry.Add(otherPointB); + + var otherStochasticProfileA = new PipingStochasticSoilProfile(0.7, new PipingSoilProfile(equalProfileName, -1, new[] + { + new PipingSoilLayer(0) + }, SoilProfileType.SoilProfile1D, -1)); + var otherStochasticProfileB = new PipingStochasticSoilProfile(0.3, new TestPipingSoilProfile("other profile name")); + otherModel.StochasticSoilProfiles.Add(otherStochasticProfileA); + otherModel.StochasticSoilProfiles.Add(otherStochasticProfileB); + + // Call + PipingStochasticSoilModelProfileDifference difference = model.Update(otherModel); + + // Assert + Assert.AreEqual(otherName, model.Name); + Assert.AreSame(otherPointA, model.Geometry[0]); + Assert.AreSame(otherPointB, model.Geometry[1]); + Assert.AreEqual(2, model.StochasticSoilProfiles.Count); + Assert.AreSame(stochasticProfileA, model.StochasticSoilProfiles[0]); + Assert.AreSame(otherStochasticProfileA.SoilProfile, model.StochasticSoilProfiles[0].SoilProfile); + Assert.AreNotSame(stochasticProfileB, model.StochasticSoilProfiles[1]); + Assert.AreSame(otherStochasticProfileB.SoilProfile, model.StochasticSoilProfiles[1].SoilProfile); + + CollectionAssert.AreEqual(new[] + { + stochasticProfileA + }, difference.UpdatedProfiles); + CollectionAssert.AreEqual(new[] + { + stochasticProfileB + }, difference.RemovedProfiles); + CollectionAssert.AreEqual(new[] + { + otherStochasticProfileB + }, difference.AddedProfiles); + } + + [Test] + public void Update_ModelsWithAddedProfilesWithSameNames_ThrowsInvalidOperationException() + { + // Setup + var addedProfile = new PipingStochasticSoilProfile(0.2, new TestPipingSoilProfile()); + PipingStochasticSoilModel otherModel = CreateEmptyModel(); + otherModel.StochasticSoilProfiles.Add(addedProfile); + + var existingProfile = new PipingStochasticSoilProfile(0.2, new TestPipingSoilProfile()); + PipingStochasticSoilModel model = CreateEmptyModel(); + model.StochasticSoilProfiles.Add(existingProfile); + model.StochasticSoilProfiles.Add(existingProfile); + + // Call + TestDelegate call = () => model.Update(otherModel); + + // Assert + Assert.Throws(call); + + Assert.AreEqual(1, otherModel.StochasticSoilProfiles.Count); + Assert.AreEqual(addedProfile, otherModel.StochasticSoilProfiles[0]); + + Assert.AreEqual(2, model.StochasticSoilProfiles.Count); + CollectionAssert.AreEqual(new[] + { + existingProfile, + existingProfile + }, model.StochasticSoilProfiles); + } + + private static IEnumerable CreateLayers() + { + return new[] + { + new PipingSoilLayer(2) + }; + } + + private static PipingStochasticSoilModel CreateEmptyModel() + { + return new PipingStochasticSoilModel("name"); + } } } \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/SoilProfile/PipingStochasticSoilProfileTest.cs =================================================================== diff -u -r94ce658a9488c346f114446f0e37dabab7acaa38 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/SoilProfile/PipingStochasticSoilProfileTest.cs (.../PipingStochasticSoilProfileTest.cs) (revision 94ce658a9488c346f114446f0e37dabab7acaa38) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/SoilProfile/PipingStochasticSoilProfileTest.cs (.../PipingStochasticSoilProfileTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -26,6 +26,7 @@ using NUnit.Framework; using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Data.TestUtil; +using Ringtoets.Piping.KernelWrapper.TestUtil; using Ringtoets.Piping.Primitives; namespace Ringtoets.Piping.Data.Test.SoilProfile @@ -84,6 +85,55 @@ } [Test] + public void Update_WithNullProfile_ThrowsArgumentNullException() + { + // Setup + var stochasticProfile = new PipingStochasticSoilProfile(0.0, PipingSoilProfileTestFactory.CreatePipingSoilProfile()); + + // Call + TestDelegate test = () => stochasticProfile.Update(null); + + // Assert + string paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("fromProfile", paramName); + } + + [Test] + [TestCaseSource(nameof(PipingStochasticProfileUnequalCombinations))] + public void Update_WithValidProfile_UpdatesProperties(PipingStochasticSoilProfile stochasticProfile, + PipingStochasticSoilProfile otherStochasticProfile) + { + // Call + bool updated = stochasticProfile.Update(otherStochasticProfile); + + // Assert + Assert.IsTrue(updated); + Assert.AreEqual(otherStochasticProfile.Probability, stochasticProfile.Probability); + Assert.AreSame(otherStochasticProfile.SoilProfile, stochasticProfile.SoilProfile); + } + + [Test] + public void Update_WithEqualProfile_ReturnsFalse() + { + // Setup + const double probability = 1.0; + var profile = new TestPipingSoilProfile(); + var stochasticProfile = new PipingStochasticSoilProfile(probability, profile); + var otherStochasticProfile = new PipingStochasticSoilProfile(probability, profile); + + // Precondition + Assert.AreEqual(stochasticProfile, otherStochasticProfile); + + // Call + bool updated = stochasticProfile.Update(otherStochasticProfile); + + // Assert + Assert.IsFalse(updated); + Assert.AreEqual(probability, stochasticProfile.Probability); + Assert.AreSame(profile, stochasticProfile.SoilProfile); + } + + [Test] public void Equals_OtherType_ReturnsFalse() { // Setup @@ -142,6 +192,29 @@ Assert.AreEqual(hashCodeOne, hashCodeTwo); } + private static TestCaseData[] PipingStochasticProfileUnequalCombinations() + { + const string profileName = "newProfile"; + var stochasticSoilProfileA = new PipingStochasticSoilProfile(1.0, new TestPipingSoilProfile( + profileName, SoilProfileType.SoilProfile1D)); + var stochasticSoilProfileB = new PipingStochasticSoilProfile(0.5, new TestPipingSoilProfile( + profileName, SoilProfileType.SoilProfile1D)); + var stochasticSoilProfileC = new PipingStochasticSoilProfile(1.0, new TestPipingSoilProfile( + profileName, SoilProfileType.SoilProfile2D)); + + return new[] + { + new TestCaseData(stochasticSoilProfileA, stochasticSoilProfileB) + { + TestName = "Update_ProfileWithProfileA_UpdatesProperties" + }, + new TestCaseData(stochasticSoilProfileA, stochasticSoilProfileC) + { + TestName = "Update_ProfileWithProfileB_UpdatesProperties" + } + }; + } + private static TestCaseData[] StochasticProfileCombinations() { PipingStochasticSoilProfile profileA = CreateRandomStochasticProfile(21); Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/SoilProfile/StochasticSoilModelExtensionsTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/SoilProfile/StochasticSoilModelExtensionsTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/SoilProfile/StochasticSoilModelExtensionsTest.cs (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -0,0 +1,118 @@ +// Copyright (C) Stichting Deltares 2017. 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.Piping.Data.SoilProfile; +using Ringtoets.Piping.Primitives; + +namespace Ringtoets.Piping.Data.Test.SoilProfile +{ + [TestFixture] + public class PipingStochasticSoilModelExtensionsTest + { + [Test] + public void IntersectsWithSurfaceLineGeometry_SoilModelNull_ThrowArgumentNullException() + { + // Setup + var surfaceLine = new PipingSurfaceLine(); + + // Call + TestDelegate test = () => ((PipingStochasticSoilModel) null).IntersectsWithSurfaceLineGeometry(surfaceLine); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("stochasticSoilModel", exception.ParamName); + } + + [Test] + public void IntersectsWithSurfaceLineGeometry_SurfaceLineNull_ThrowArgumentNullException() + { + // Setup + var soilModel = new PipingStochasticSoilModel("A"); + soilModel.Geometry.AddRange(new[] + { + new Point2D(1.0, 0.0), + new Point2D(5.0, 0.0) + }); + + // Call + TestDelegate test = () => soilModel.IntersectsWithSurfaceLineGeometry(null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("surfaceLine", exception.ParamName); + } + + [Test] + public void IntersectsWithSurfaceLineGeometry_SurfaceLineIntersectingSoilModel_ReturnTrue() + { + // Setup + var soilModel = new PipingStochasticSoilModel("A"); + soilModel.Geometry.AddRange(new[] + { + new Point2D(1.0, 0.0), + new Point2D(5.0, 0.0) + }); + + var surfaceLine = new PipingSurfaceLine(); + surfaceLine.SetGeometry(new[] + { + new Point3D(3.0, 5.0, 0.0), + new Point3D(3.0, 0.0, 1.0), + new Point3D(3.0, -5.0, 0.0) + }); + + // Call + bool intersecting = soilModel.IntersectsWithSurfaceLineGeometry(surfaceLine); + + // Assert + Assert.IsTrue(intersecting); + } + + [Test] + public void IntersectsWithSurfaceLineGeometry_SurfaceLineNotIntersectingSoilModel_ReturnFalse() + { + // Setup + var soilModel = new PipingStochasticSoilModel("A"); + soilModel.Geometry.AddRange(new[] + { + new Point2D(1.0, 0.0), + new Point2D(5.0, 0.0) + }); + + var surfaceLine = new PipingSurfaceLine(); + surfaceLine.SetGeometry(new[] + { + new Point3D(0.0, 1.0, 0.0), + new Point3D(2.5, 1.0, 1.0), + new Point3D(5.0, 1.0, 0.0) + }); + + // Call + bool intersecting = soilModel.IntersectsWithSurfaceLineGeometry(surfaceLine); + + // Assert + Assert.IsFalse(intersecting); + } + } +} \ No newline at end of file Fisheye: Tag 26f527fb809a2325c8f883ece9da01a8f8040eb3 refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/StochasticSoilModelCollectionTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 26f527fb809a2325c8f883ece9da01a8f8040eb3 refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/StochasticSoilModelExtensionsTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 26f527fb809a2325c8f883ece9da01a8f8040eb3 refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/StochasticSoilModelTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 26f527fb809a2325c8f883ece9da01a8f8040eb3 refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/StochasticSoilProfileTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 26f527fb809a2325c8f883ece9da01a8f8040eb3 refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil.Test/PipingSoilProfileTestFactoryTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil.Test/PipingStochasticSoilModelTestFactoryTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil.Test/PipingStochasticSoilModelTestFactoryTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil.Test/PipingStochasticSoilModelTestFactoryTest.cs (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -0,0 +1,70 @@ +// Copyright (C) Stichting Deltares 2017. 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 NUnit.Framework; +using Ringtoets.Piping.Data.SoilProfile; + +namespace Ringtoets.Piping.Data.TestUtil.Test +{ + [TestFixture] + public class PipingStochasticSoilModelTestFactoryTest + { + [Test] + public void CreatePipingStochasticSoilModel_ExpectedPropertiesSet() + { + // Call + PipingStochasticSoilModel model = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(); + + // Assert + Assert.IsInstanceOf(model); + Assert.IsEmpty(model.Name); + Assert.AreEqual(2, model.StochasticSoilProfiles.Count); + CollectionAssert.AreEquivalent(new[] + { + 0.5, + 0.5 + }, model.StochasticSoilProfiles.Select(p => p.Probability)); + CollectionAssert.AllItemsAreNotNull(model.StochasticSoilProfiles.Select(p => p.SoilProfile)); + } + + [Test] + public void CreatePipingStochasticSoilModelWithName_ExpectedPropertiesSet() + { + // Setup + const string name = "some name"; + + // Call + PipingStochasticSoilModel model = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(name); + + // Assert + Assert.IsInstanceOf(model); + Assert.AreEqual(name, model.Name); + Assert.AreEqual(2, model.StochasticSoilProfiles.Count); + CollectionAssert.AreEquivalent(new[] + { + 0.5, + 0.5 + }, model.StochasticSoilProfiles.Select(p => p.Probability)); + CollectionAssert.AllItemsAreNotNull(model.StochasticSoilProfiles.Select(p => p.SoilProfile)); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil.Test/Ringtoets.Piping.Data.TestUtil.Test.csproj =================================================================== diff -u -r6a52cac961e58ff9ff5cfda5d2519d34974770fb -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil.Test/Ringtoets.Piping.Data.TestUtil.Test.csproj (.../Ringtoets.Piping.Data.TestUtil.Test.csproj) (revision 6a52cac961e58ff9ff5cfda5d2519d34974770fb) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil.Test/Ringtoets.Piping.Data.TestUtil.Test.csproj (.../Ringtoets.Piping.Data.TestUtil.Test.csproj) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -51,12 +51,11 @@ - + - Fisheye: Tag 26f527fb809a2325c8f883ece9da01a8f8040eb3 refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil.Test/TestStochasticSoilModelTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/PipingCalculationScenarioFactory.cs =================================================================== diff -u -raa49537188229065df91b1a931f088c32115702a -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/PipingCalculationScenarioFactory.cs (.../PipingCalculationScenarioFactory.cs) (revision aa49537188229065df91b1a931f088c32115702a) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/PipingCalculationScenarioFactory.cs (.../PipingCalculationScenarioFactory.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -26,6 +26,7 @@ using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.KernelWrapper.TestUtil; using Ringtoets.Piping.Primitives; @@ -141,9 +142,8 @@ { const double bottom = 1.12; const double top = 10.56; - var stochasticSoilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) - { - SoilProfile = new PipingSoilProfile(string.Empty, 0.0, new[] + var stochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile(string.Empty, 0.0, new[] { new PipingSoilLayer(top) { @@ -160,8 +160,7 @@ PermeabilityCoefficientOfVariation = 0.5, PermeabilityMean = 1.0 } - }, SoilProfileType.SoilProfile1D, 0) - }; + }, SoilProfileType.SoilProfile1D, 0)); var surfaceLine = new PipingSurfaceLine(); var firstCharacteristicPointLocation = new Point3D(0.2, 0.0, bottom + 3 * top / 4); var secondCharacteristicPointLocation = new Point3D(0.3, 0.0, bottom + 2 * top / 4); Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/PipingInputFactory.cs =================================================================== diff -u -rd6fe8399e8398224cf1bda9259052232d85b85a4 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/PipingInputFactory.cs (.../PipingInputFactory.cs) (revision d6fe8399e8398224cf1bda9259052232d85b85a4) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/PipingInputFactory.cs (.../PipingInputFactory.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -21,6 +21,7 @@ using Core.Common.Base.Data; using Core.Common.Base.Geometry; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Primitives; namespace Ringtoets.Piping.Data.TestUtil @@ -37,17 +38,17 @@ /// The thickness of the aquifer layer. /// The thickness of the coverage layer. /// A new . - public static PipingInput CreateInputWithAquiferAndCoverageLayer(double thicknessAquiferLayer = 1.0, double thicknessCoverageLayer = 2.0) + public static PipingInput CreateInputWithAquiferAndCoverageLayer(double thicknessAquiferLayer = 1.0, + double thicknessCoverageLayer = 2.0) { var surfaceLine = new PipingSurfaceLine(); surfaceLine.SetGeometry(new[] { new Point3D(0, 0, thicknessCoverageLayer), new Point3D(1.0, 0, thicknessCoverageLayer) }); - var stochasticSoilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) - { - SoilProfile = new PipingSoilProfile(string.Empty, -thicknessAquiferLayer, new[] + var stochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile(string.Empty, -thicknessAquiferLayer, new[] { new PipingSoilLayer(thicknessCoverageLayer) { @@ -57,8 +58,7 @@ { IsAquifer = true } - }, SoilProfileType.SoilProfile1D, 0) - }; + }, SoilProfileType.SoilProfile1D, 0)); return new PipingInput(new GeneralPipingInput()) { @@ -81,16 +81,14 @@ new Point3D(0, 0, 0.0), new Point3D(1.0, 0, 0.0) }); - var stochasticSoilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) - { - SoilProfile = new PipingSoilProfile(string.Empty, -thicknessAquiferLayer, new[] + var stochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile(string.Empty, -thicknessAquiferLayer, new[] { new PipingSoilLayer(0.0) { IsAquifer = true } - }, SoilProfileType.SoilProfile1D, 0) - }; + }, SoilProfileType.SoilProfile1D, 0)); return new PipingInput(new GeneralPipingInput()) { @@ -114,9 +112,8 @@ new Point3D(0, 0, surfaceLineTopLevel), new Point3D(1.0, 0, surfaceLineTopLevel) }); - var stochasticSoilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) - { - SoilProfile = new PipingSoilProfile(string.Empty, 0, new[] + var stochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile(string.Empty, 0, new[] { new PipingSoilLayer(surfaceLineTopLevel + deltaAboveSurfaceLine + 2) { @@ -130,8 +127,7 @@ { IsAquifer = false } - }, SoilProfileType.SoilProfile1D, 0) - }; + }, SoilProfileType.SoilProfile1D, 0)); var input = new PipingInput(new GeneralPipingInput()) { SurfaceLine = surfaceLine, @@ -154,9 +150,8 @@ new Point3D(0, 0, 3.3), new Point3D(1.0, 0, 3.3) }); - var stochasticSoilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) - { - SoilProfile = new PipingSoilProfile(string.Empty, 0, new[] + var stochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile(string.Empty, 0, new[] { new PipingSoilLayer(4.3) { @@ -170,8 +165,7 @@ { IsAquifer = true } - }, SoilProfileType.SoilProfile1D, 0) - }; + }, SoilProfileType.SoilProfile1D, 0)); var input = new PipingInput(new GeneralPipingInput()) { SurfaceLine = surfaceLine, Fisheye: Tag 26f527fb809a2325c8f883ece9da01a8f8040eb3 refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/PipingSoilProfileTestFactory.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/PipingStochasticSoilModelTestFactory.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/PipingStochasticSoilModelTestFactory.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/PipingStochasticSoilModelTestFactory.cs (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -0,0 +1,56 @@ +// Copyright (C) Stichting Deltares 2017. 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 Ringtoets.Piping.Data.SoilProfile; +using Ringtoets.Piping.KernelWrapper.TestUtil; + +namespace Ringtoets.Piping.Data.TestUtil +{ + /// + /// Factory to create simple instances that can be used for testing. + /// + public static class PipingStochasticSoilModelTestFactory + { + /// + /// Creates a new instance of . + /// + /// The name of the stochastic soil model. + public static PipingStochasticSoilModel CreatePipingStochasticSoilModel(string name) + { + return new PipingStochasticSoilModel(name) + { + StochasticSoilProfiles = + { + new PipingStochasticSoilProfile(0.5, new TestPipingSoilProfile("A")), + new PipingStochasticSoilProfile(0.5, new TestPipingSoilProfile("B")) + } + }; + } + + /// + /// Creates a new instance of . + /// + public static PipingStochasticSoilModel CreatePipingStochasticSoilModel() + { + return CreatePipingStochasticSoilModel(string.Empty); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/PipingTestDataGenerator.cs =================================================================== diff -u -rd6fe8399e8398224cf1bda9259052232d85b85a4 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/PipingTestDataGenerator.cs (.../PipingTestDataGenerator.cs) (revision d6fe8399e8398224cf1bda9259052232d85b85a4) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/PipingTestDataGenerator.cs (.../PipingTestDataGenerator.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -24,6 +24,7 @@ using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Data.Probabilistics; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.KernelWrapper.TestUtil; using Ringtoets.Piping.Primitives; @@ -146,14 +147,12 @@ { HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "PUNT_KAT_18", 0, 0), SurfaceLine = surfaceLine, - StochasticSoilModel = new StochasticSoilModel("PK001_0001_Piping"), - StochasticSoilProfile = new StochasticSoilProfile(0, SoilProfileType.SoilProfile1D, 0) - { - SoilProfile = new PipingSoilProfile("W1-6_0_1D1", 0, new[] + StochasticSoilModel = new PipingStochasticSoilModel("PK001_0001_Piping"), + StochasticSoilProfile = new PipingStochasticSoilProfile( + 0, new PipingSoilProfile("W1-6_0_1D1", 0, new[] { new PipingSoilLayer(0) - }, SoilProfileType.SoilProfile1D, 0) - }, + }, SoilProfileType.SoilProfile1D, 0)), PhreaticLevelExit = { Mean = (RoundedDouble) 0, @@ -267,7 +266,7 @@ surfaceLine1, surfaceLine2 }, "some/path/to/surfacelines"); - var stochasticSoilModel1 = new StochasticSoilModel("A") + var stochasticSoilModel1 = new PipingStochasticSoilModel("A") { Geometry = { @@ -276,10 +275,10 @@ }, StochasticSoilProfiles = { - new StochasticSoilProfile(1.0, SoilProfileType.SoilProfile1D, 1) + new PipingStochasticSoilProfile(1.0, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) } }; - var stochasticSoilModel2 = new StochasticSoilModel("C") + var stochasticSoilModel2 = new PipingStochasticSoilModel("C") { Geometry = { @@ -288,7 +287,7 @@ }, StochasticSoilProfiles = { - new StochasticSoilProfile(1.0, SoilProfileType.SoilProfile2D, 2) + new PipingStochasticSoilProfile(1.0, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) } }; Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/Ringtoets.Piping.Data.TestUtil.csproj =================================================================== diff -u -r94ce658a9488c346f114446f0e37dabab7acaa38 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/Ringtoets.Piping.Data.TestUtil.csproj (.../Ringtoets.Piping.Data.TestUtil.csproj) (revision 94ce658a9488c346f114446f0e37dabab7acaa38) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/Ringtoets.Piping.Data.TestUtil.csproj (.../Ringtoets.Piping.Data.TestUtil.csproj) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -52,14 +52,13 @@ - + - Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/TestPipingFailureMechanism.cs =================================================================== diff -u -rd6fe8399e8398224cf1bda9259052232d85b85a4 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/TestPipingFailureMechanism.cs (.../TestPipingFailureMechanism.cs) (revision d6fe8399e8398224cf1bda9259052232d85b85a4) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/TestPipingFailureMechanism.cs (.../TestPipingFailureMechanism.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -64,7 +64,7 @@ }, "path/to/surfaceLines"); failureMechanism.StochasticSoilModels.AddRange(new[] { - new TestStochasticSoilModel() + PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel() }, "path/to/stochasticSoilModels"); failureMechanism.AddSection(new FailureMechanismSection("Section", new List Fisheye: Tag 26f527fb809a2325c8f883ece9da01a8f8040eb3 refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/TestStochasticSoilModel.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Factories/PipingMapDataFeaturesFactoryTest.cs =================================================================== diff -u -rd6fe8399e8398224cf1bda9259052232d85b85a4 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Factories/PipingMapDataFeaturesFactoryTest.cs (.../PipingMapDataFeaturesFactoryTest.cs) (revision d6fe8399e8398224cf1bda9259052232d85b85a4) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Factories/PipingMapDataFeaturesFactoryTest.cs (.../PipingMapDataFeaturesFactoryTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -27,6 +27,7 @@ using NUnit.Framework; using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Data.TestUtil; using Ringtoets.Piping.Forms.Factories; using Ringtoets.Piping.Primitives; @@ -113,7 +114,7 @@ public void CreateStochasticSoilModelFeatures_NoStochasticSoilModels_ReturnsEmptyFeaturesArray() { // Call - MapFeature[] features = PipingMapDataFeaturesFactory.CreateStochasticSoilModelFeatures(new StochasticSoilModel[0]); + MapFeature[] features = PipingMapDataFeaturesFactory.CreateStochasticSoilModelFeatures(new PipingStochasticSoilModel[0]); // Assert CollectionAssert.IsEmpty(features); @@ -135,8 +136,8 @@ }; var stochasticSoilModels = new[] { - new StochasticSoilModel("StochasticSoilModelName1"), - new StochasticSoilModel("StochasticSoilModelName2") + PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("StochasticSoilModelName1"), + PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("StochasticSoilModelName2") }; stochasticSoilModels[0].Geometry.AddRange(pointsOne); stochasticSoilModels[1].Geometry.AddRange(pointsTwo); Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PipingCalculationConfigurationHelperTest.cs =================================================================== diff -u -rfe90a6d174a01975381e6cda55ed1f7f4e831a51 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PipingCalculationConfigurationHelperTest.cs (.../PipingCalculationConfigurationHelperTest.cs) (revision fe90a6d174a01975381e6cda55ed1f7f4e831a51) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PipingCalculationConfigurationHelperTest.cs (.../PipingCalculationConfigurationHelperTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -28,6 +28,7 @@ using NUnit.Framework; using Ringtoets.Common.Data.Calculation; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Primitives; namespace Ringtoets.Piping.Forms.Test @@ -56,38 +57,37 @@ public void GetStochasticSoilModelsForSurfaceLine_SurfaceLineIntersectingSoilModel_ReturnSoilModel() { // Setup - var soilProfile1 = new StochasticSoilProfile(0.3, SoilProfileType.SoilProfile1D, 1) - { - SoilProfile = new PipingSoilProfile("Profile 1", -10.0, new[] + var soilProfile1 = new PipingStochasticSoilProfile( + 0.3, new PipingSoilProfile("Profile 1", -10.0, new[] { new PipingSoilLayer(-5.0), new PipingSoilLayer(-2.0), new PipingSoilLayer(1.0) - }, SoilProfileType.SoilProfile1D, 1) - }; - var soilProfile2 = new StochasticSoilProfile(0.7, SoilProfileType.SoilProfile1D, 2) - { - SoilProfile = new PipingSoilProfile("Profile 2", -8.0, new[] + }, SoilProfileType.SoilProfile1D, 1)); + var soilProfile2 = new PipingStochasticSoilProfile( + 0.7, new PipingSoilProfile("Profile 2", -8.0, new[] { new PipingSoilLayer(-4.0), new PipingSoilLayer(0.0), new PipingSoilLayer(4.0) - }, SoilProfileType.SoilProfile1D, 2) + }, SoilProfileType.SoilProfile1D, 2)); + + var soilModel = new PipingStochasticSoilModel("A") + { + Geometry = + { + new Point2D(1.0, 0.0), + new Point2D(5.0, 0.0) + }, + StochasticSoilProfiles = + { + soilProfile1, + soilProfile2 + } }; - var soilModel = new StochasticSoilModel("A"); - soilModel.Geometry.AddRange(new[] + PipingStochasticSoilModel[] availableSoilModels = { - new Point2D(1.0, 0.0), - new Point2D(5.0, 0.0) - }); - soilModel.StochasticSoilProfiles.AddRange(new[] - { - soilProfile1, - soilProfile2 - }); - StochasticSoilModel[] availableSoilModels = - { soilModel }; @@ -100,12 +100,12 @@ }); // Call - IEnumerable result = PipingCalculationConfigurationHelper.GetStochasticSoilModelsForSurfaceLine( + IEnumerable result = PipingCalculationConfigurationHelper.GetStochasticSoilModelsForSurfaceLine( surfaceLine, availableSoilModels); // Assert - StochasticSoilModel[] expected = + PipingStochasticSoilModel[] expected = { soilModel }; @@ -129,30 +129,27 @@ new PipingSoilLayer(4.0) }, SoilProfileType.SoilProfile1D, 2); - var soilModel = new StochasticSoilModel("A"); - soilModel.Geometry.AddRange(new[] + var soilModel = new PipingStochasticSoilModel("A") { - new Point2D(1.0, 0.0), - new Point2D(5.0, 0.0) - }); - soilModel.StochasticSoilProfiles.AddRange(new[] - { - new StochasticSoilProfile(0.3, SoilProfileType.SoilProfile1D, 1) + Geometry = { - SoilProfile = soilProfile1 + new Point2D(1.0, 0.0), + new Point2D(5.0, 0.0) }, - new StochasticSoilProfile(0.7, SoilProfileType.SoilProfile1D, 2) + StochasticSoilProfiles = { - SoilProfile = soilProfile2 + new PipingStochasticSoilProfile(0.3, soilProfile1), + new PipingStochasticSoilProfile(0.7, soilProfile2) } - }); - StochasticSoilModel[] availableSoilModels = + }; + + PipingStochasticSoilModel[] availableSoilModels = { soilModel }; // Call - IEnumerable result = PipingCalculationConfigurationHelper.GetStochasticSoilModelsForSurfaceLine( + IEnumerable result = PipingCalculationConfigurationHelper.GetStochasticSoilModelsForSurfaceLine( null, availableSoilModels); @@ -173,9 +170,9 @@ }); // Call - IEnumerable result = PipingCalculationConfigurationHelper.GetStochasticSoilModelsForSurfaceLine( + IEnumerable result = PipingCalculationConfigurationHelper.GetStochasticSoilModelsForSurfaceLine( surfaceLine, - Enumerable.Empty()); + Enumerable.Empty()); // Assert CollectionAssert.IsEmpty(result); @@ -185,12 +182,14 @@ public void GetStochasticSoilModelsForSurfaceLine_NoSoilProfiles_ReturnEmpty() { // Setup - var soilModel = new StochasticSoilModel("A"); - soilModel.Geometry.AddRange(new[] + var soilModel = new PipingStochasticSoilModel("A") { - new Point2D(1.0, 0.0), - new Point2D(5.0, 0.0) - }); + Geometry = + { + new Point2D(1.0, 0.0), + new Point2D(5.0, 0.0) + } + }; var availableSoilModels = new[] { @@ -206,7 +205,7 @@ }); // Call - IEnumerable result = PipingCalculationConfigurationHelper.GetStochasticSoilModelsForSurfaceLine( + IEnumerable result = PipingCalculationConfigurationHelper.GetStochasticSoilModelsForSurfaceLine( surfaceLine, availableSoilModels); @@ -231,24 +230,21 @@ new PipingSoilLayer(4.0) }, SoilProfileType.SoilProfile1D, 2); - var soilModel = new StochasticSoilModel("A"); - soilModel.Geometry.AddRange(new[] + var soilModel = new PipingStochasticSoilModel("A") { - new Point2D(1.0, 0.0), - new Point2D(5.0, 0.0) - }); - soilModel.StochasticSoilProfiles.AddRange(new[] - { - new StochasticSoilProfile(0.3, SoilProfileType.SoilProfile1D, 1) + Geometry = { - SoilProfile = soilProfile1 + new Point2D(1.0, 0.0), + new Point2D(5.0, 0.0) }, - new StochasticSoilProfile(0.7, SoilProfileType.SoilProfile1D, 2) + StochasticSoilProfiles = { - SoilProfile = soilProfile2 + new PipingStochasticSoilProfile(0.3, soilProfile1), + new PipingStochasticSoilProfile(0.7, soilProfile2) } - }); - StochasticSoilModel[] availableSoilModels = + }; + + PipingStochasticSoilModel[] availableSoilModels = { soilModel }; @@ -262,7 +258,8 @@ }); // Call - IEnumerable result = PipingCalculationConfigurationHelper.GetStochasticSoilModelsForSurfaceLine(surfaceLine, availableSoilModels); + IEnumerable result = PipingCalculationConfigurationHelper.GetStochasticSoilModelsForSurfaceLine( + surfaceLine, availableSoilModels); // Assert CollectionAssert.IsEmpty(result); @@ -272,47 +269,50 @@ public void GetStochasticSoilModelsForSurfaceLine_SurfaceLineOverlappingSoilModels_ReturnSoilModels() { // Setup - var soilProfile1 = new StochasticSoilProfile(1.0, SoilProfileType.SoilProfile1D, 1) - { - SoilProfile = new PipingSoilProfile("Profile 1", -10.0, new[] + var soilProfile1 = new PipingStochasticSoilProfile( + 1.0, new PipingSoilProfile("Profile 1", -10.0, new[] { new PipingSoilLayer(-5.0), new PipingSoilLayer(-2.0), new PipingSoilLayer(1.0) }, SoilProfileType.SoilProfile1D, 1) - }; - var soilProfile2 = new StochasticSoilProfile(1.0, SoilProfileType.SoilProfile1D, 2) - { - SoilProfile = new PipingSoilProfile("Profile 2", -8.0, new[] + ); + var soilProfile2 = new PipingStochasticSoilProfile( + 1.0, new PipingSoilProfile("Profile 2", -8.0, new[] { new PipingSoilLayer(-4.0), new PipingSoilLayer(0.0), new PipingSoilLayer(4.0) }, SoilProfileType.SoilProfile1D, 2) - }; + ); const double y = 1.1; - var soilModel1 = new StochasticSoilModel("A"); - soilModel1.Geometry.AddRange(new[] + var soilModel1 = new PipingStochasticSoilModel("A") { - new Point2D(1.0, y), - new Point2D(2.0, y) - }); - soilModel1.StochasticSoilProfiles.AddRange(new[] - { - soilProfile1 - }); + Geometry = + { + new Point2D(1.0, y), + new Point2D(2.0, y) + }, + StochasticSoilProfiles = + { + soilProfile1 + } + }; - var soilModel2 = new StochasticSoilModel("A"); - soilModel2.Geometry.AddRange(new[] + var soilModel2 = new PipingStochasticSoilModel("A") { - new Point2D(3.0, y), - new Point2D(4.0, y) - }); - soilModel2.StochasticSoilProfiles.AddRange(new[] - { - soilProfile2 - }); + Geometry = + { + new Point2D(3.0, y), + new Point2D(4.0, y) + }, + StochasticSoilProfiles = + { + soilProfile2 + } + }; + var availableSoilModels = new[] { soilModel1, @@ -328,12 +328,12 @@ }); // Call - IEnumerable result = PipingCalculationConfigurationHelper.GetStochasticSoilModelsForSurfaceLine( + IEnumerable result = PipingCalculationConfigurationHelper.GetStochasticSoilModelsForSurfaceLine( surfaceLine, availableSoilModels); // Assert - StochasticSoilModel[] expected = + PipingStochasticSoilModel[] expected = { soilModel1, soilModel2 @@ -351,7 +351,7 @@ // Call TestDelegate test = () => PipingCalculationConfigurationHelper.GenerateCalculationItemsStructure( null, - Enumerable.Empty(), + Enumerable.Empty(), new GeneralPipingInput()); // Assert @@ -379,7 +379,7 @@ // Call TestDelegate test = () => PipingCalculationConfigurationHelper.GenerateCalculationItemsStructure( Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), null); // Assert @@ -422,7 +422,7 @@ { result = PipingCalculationConfigurationHelper.GenerateCalculationItemsStructure( pipingSurfaceLines, - Enumerable.Empty(), + Enumerable.Empty(), new GeneralPipingInput()).ToArray(); }; @@ -443,36 +443,36 @@ public void GenerateCalculationItemsStructure_SurfaceLineIntersectingSoilModel_ReturnOneGroupWithTwoCalculations() { // Setup - var soilProfile1 = new StochasticSoilProfile(0.3, SoilProfileType.SoilProfile1D, 1) - { - SoilProfile = new PipingSoilProfile("Profile 1", -10.0, new[] + var soilProfile1 = new PipingStochasticSoilProfile( + 0.3, new PipingSoilProfile("Profile 1", -10.0, new[] { new PipingSoilLayer(-5.0), new PipingSoilLayer(-2.0), new PipingSoilLayer(1.0) }, SoilProfileType.SoilProfile1D, 1) - }; - var soilProfile2 = new StochasticSoilProfile(0.7, SoilProfileType.SoilProfile1D, 2) - { - SoilProfile = new PipingSoilProfile("Profile 2", -8.0, new[] + ); + var soilProfile2 = new PipingStochasticSoilProfile(0.7, new PipingSoilProfile("Profile 2", -8.0, new[] { new PipingSoilLayer(-4.0), new PipingSoilLayer(0.0), new PipingSoilLayer(4.0) }, SoilProfileType.SoilProfile1D, 2) - }; + ); - var soilModel = new StochasticSoilModel("A"); - soilModel.Geometry.AddRange(new[] + var soilModel = new PipingStochasticSoilModel("A") { - new Point2D(1.0, 0.0), - new Point2D(5.0, 0.0) - }); - soilModel.StochasticSoilProfiles.AddRange(new[] - { - soilProfile1, - soilProfile2 - }); + Geometry = + { + new Point2D(1.0, 0.0), + new Point2D(5.0, 0.0) + }, + StochasticSoilProfiles = + { + soilProfile1, + soilProfile2 + } + }; + var availableSoilModels = new[] { soilModel @@ -524,12 +524,14 @@ public void GenerateCalculationItemsStructure_NoSoilProfiles_LogWarning() { // Setup - var soilModel = new StochasticSoilModel("A"); - soilModel.Geometry.AddRange(new[] + var soilModel = new PipingStochasticSoilModel("A") { - new Point2D(1.0, 0.0), - new Point2D(5.0, 0.0) - }); + Geometry = + { + new Point2D(1.0, 0.0), + new Point2D(5.0, 0.0) + } + }; var availableSoilModels = new[] { @@ -589,24 +591,21 @@ new PipingSoilLayer(4.0) }, SoilProfileType.SoilProfile1D, 2); - var soilModel = new StochasticSoilModel("A"); - soilModel.Geometry.AddRange(new[] + var soilModel = new PipingStochasticSoilModel("A") { - new Point2D(1.0, 0.0), - new Point2D(5.0, 0.0) - }); - soilModel.StochasticSoilProfiles.AddRange(new[] - { - new StochasticSoilProfile(0.3, SoilProfileType.SoilProfile1D, 1) + Geometry = { - SoilProfile = soilProfile1 + new Point2D(1.0, 0.0), + new Point2D(5.0, 0.0) }, - new StochasticSoilProfile(0.7, SoilProfileType.SoilProfile1D, 2) + StochasticSoilProfiles = { - SoilProfile = soilProfile2 + new PipingStochasticSoilProfile(0.3, soilProfile1), + new PipingStochasticSoilProfile(0.7, soilProfile2) } - }); - StochasticSoilModel[] availableSoilModels = + }; + + PipingStochasticSoilModel[] availableSoilModels = { soilModel }; @@ -652,47 +651,50 @@ public void GenerateCalculationItemsStructure_SurfaceLineOverlappingSoilModel_ReturnOneGroupWithProfilesFromBothSoilModels() { // Setup - var soilProfile1 = new StochasticSoilProfile(1.0, SoilProfileType.SoilProfile1D, 1) - { - SoilProfile = new PipingSoilProfile("Profile 1", -10.0, new[] + var soilProfile1 = new PipingStochasticSoilProfile( + 1.0, new PipingSoilProfile("Profile 1", -10.0, new[] { new PipingSoilLayer(-5.0), new PipingSoilLayer(-2.0), new PipingSoilLayer(1.0) }, SoilProfileType.SoilProfile1D, 1) - }; - var soilProfile2 = new StochasticSoilProfile(1.0, SoilProfileType.SoilProfile1D, 2) - { - SoilProfile = new PipingSoilProfile("Profile 2", -8.0, new[] + ); + var soilProfile2 = new PipingStochasticSoilProfile( + 1.0, new PipingSoilProfile("Profile 2", -8.0, new[] { new PipingSoilLayer(-4.0), new PipingSoilLayer(0.0), new PipingSoilLayer(4.0) }, SoilProfileType.SoilProfile1D, 2) - }; + ); const double y = 1.1; - var soilModel1 = new StochasticSoilModel("A"); - soilModel1.Geometry.AddRange(new[] + var soilModel1 = new PipingStochasticSoilModel("A") { - new Point2D(1.0, y), - new Point2D(2.0, y) - }); - soilModel1.StochasticSoilProfiles.AddRange(new[] - { - soilProfile1 - }); + Geometry = + { + new Point2D(1.0, y), + new Point2D(2.0, y) + }, + StochasticSoilProfiles = + { + soilProfile1 + } + }; - var soilModel2 = new StochasticSoilModel("A"); - soilModel2.Geometry.AddRange(new[] + var soilModel2 = new PipingStochasticSoilModel("A") { - new Point2D(3.0, y), - new Point2D(4.0, y) - }); - soilModel2.StochasticSoilProfiles.AddRange(new[] - { - soilProfile2 - }); + Geometry = + { + new Point2D(3.0, y), + new Point2D(4.0, y) + }, + StochasticSoilProfiles = + { + soilProfile2 + } + }; + var availableSoilModels = new[] { soilModel1, @@ -745,48 +747,50 @@ public void GenerateCalculationItemsStructure_SurfaceLinesEachIntersectingSoilModel_ReturnTwoGroupsWithProfilesFromIntersectingSoilModels() { // Setup - var soilProfile1 = new StochasticSoilProfile(1.0, SoilProfileType.SoilProfile1D, 1) - { - SoilProfile = new PipingSoilProfile("Profile 1", -10.0, new[] + var soilProfile1 = new PipingStochasticSoilProfile( + 1.0, new PipingSoilProfile("Profile 1", -10.0, new[] { new PipingSoilLayer(-5.0), new PipingSoilLayer(-2.0), new PipingSoilLayer(1.0) }, SoilProfileType.SoilProfile1D, 1) - }; - var soilProfile2 = new StochasticSoilProfile(1.0, SoilProfileType.SoilProfile1D, 2) - { - SoilProfile = new PipingSoilProfile("Profile 2", -8.0, new[] + ); + var soilProfile2 = new PipingStochasticSoilProfile( + 1.0, new PipingSoilProfile("Profile 2", -8.0, new[] { new PipingSoilLayer(-4.0), new PipingSoilLayer(0.0), new PipingSoilLayer(4.0) }, SoilProfileType.SoilProfile1D, 2) - }; + ); const double y = 1.1; - var soilModel1 = new StochasticSoilModel("A"); - soilModel1.Geometry.AddRange(new[] + var soilModel1 = new PipingStochasticSoilModel("A") { - new Point2D(1.0, y), - new Point2D(2.0, y) - }); - soilModel1.StochasticSoilProfiles.AddRange(new[] - { - soilProfile1, - soilProfile2 - }); + Geometry = + { + new Point2D(1.0, y), + new Point2D(2.0, y) + }, + StochasticSoilProfiles = + { + soilProfile1, + soilProfile2 + } + }; - var soilModel2 = new StochasticSoilModel("A"); - soilModel2.Geometry.AddRange(new[] + var soilModel2 = new PipingStochasticSoilModel("A") { - new Point2D(3.0, y), - new Point2D(4.0, y) - }); - soilModel2.StochasticSoilProfiles.AddRange(new[] - { - soilProfile2 - }); + Geometry = + { + new Point2D(3.0, y), + new Point2D(4.0, y) + }, + StochasticSoilProfiles = + { + soilProfile2 + } + }; var availableSoilModels = new[] { soilModel1, @@ -866,48 +870,51 @@ public void GenerateCalculationItemsStructure_OneSurfaceLineIntersectingSoilModelOneSurfaceLineNoIntersection_ReturnOneGroupsWithProfilesAndLogOneWarning() { // Setup - var soilProfile1 = new StochasticSoilProfile(1.0, SoilProfileType.SoilProfile1D, 1) - { - SoilProfile = new PipingSoilProfile("Profile 1", -10.0, new[] + var soilProfile1 = new PipingStochasticSoilProfile( + 1.0, new PipingSoilProfile("Profile 1", -10.0, new[] { new PipingSoilLayer(-5.0), new PipingSoilLayer(-2.0), new PipingSoilLayer(1.0) }, SoilProfileType.SoilProfile1D, 1) - }; - var soilProfile2 = new StochasticSoilProfile(1.0, SoilProfileType.SoilProfile1D, 2) - { - SoilProfile = new PipingSoilProfile("Profile 2", -8.0, new[] + ); + var soilProfile2 = new PipingStochasticSoilProfile( + 1.0, new PipingSoilProfile("Profile 2", -8.0, new[] { new PipingSoilLayer(-4.0), new PipingSoilLayer(0.0), new PipingSoilLayer(4.0) }, SoilProfileType.SoilProfile1D, 2) - }; + ); const double y = 1.1; - var soilModel1 = new StochasticSoilModel("A"); - soilModel1.Geometry.AddRange(new[] + var soilModel1 = new PipingStochasticSoilModel("A") { - new Point2D(1.0, y), - new Point2D(2.0, y) - }); - soilModel1.StochasticSoilProfiles.AddRange(new[] - { - soilProfile1, - soilProfile2 - }); + Geometry = + { + new Point2D(1.0, y), + new Point2D(2.0, y) + }, - var soilModel2 = new StochasticSoilModel("A"); - soilModel2.Geometry.AddRange(new[] + StochasticSoilProfiles = + { + soilProfile1, + soilProfile2 + } + }; + + var soilModel2 = new PipingStochasticSoilModel("A") { - new Point2D(3.0, y), - new Point2D(4.0, y) - }); - soilModel2.StochasticSoilProfiles.AddRange(new[] - { - soilProfile2 - }); + Geometry = + { + new Point2D(3.0, y), + new Point2D(4.0, y) + }, + StochasticSoilProfiles = + { + soilProfile2 + } + }; var availableSoilModels = new[] { soilModel1, @@ -996,23 +1003,19 @@ new PipingSoilLayer(4.0) }, SoilProfileType.SoilProfile1D, 2); - var soilModel = new StochasticSoilModel("A"); - soilModel.Geometry.AddRange(new[] + var soilModel = new PipingStochasticSoilModel("A") { - new Point2D(1.0, 0.0), - new Point2D(5.0, 0.0) - }); - soilModel.StochasticSoilProfiles.AddRange(new[] - { - new StochasticSoilProfile(0.3, SoilProfileType.SoilProfile1D, 1) + Geometry = { - SoilProfile = soilProfile1 + new Point2D(1.0, 0.0), + new Point2D(5.0, 0.0) }, - new StochasticSoilProfile(0.7, SoilProfileType.SoilProfile1D, 2) + StochasticSoilProfiles = { - SoilProfile = soilProfile2 + new PipingStochasticSoilProfile(0.3, soilProfile1), + new PipingStochasticSoilProfile(0.7, soilProfile2) } - }); + }; var availableSoilModels = new[] { soilModel @@ -1078,27 +1081,20 @@ new PipingSoilLayer(4.0) }, SoilProfileType.SoilProfile1D, 2); - var soilModel = new StochasticSoilModel("A"); - soilModel.Geometry.AddRange(new[] + var soilModel = new PipingStochasticSoilModel("A") { - new Point2D(1.0, 0.0), - new Point2D(5.0, 0.0) - }); - soilModel.StochasticSoilProfiles.AddRange(new[] - { - new StochasticSoilProfile(0.3, SoilProfileType.SoilProfile1D, 1) + Geometry = { - SoilProfile = soilProfile1 + new Point2D(1.0, 0.0), + new Point2D(5.0, 0.0) }, - new StochasticSoilProfile(0.2, SoilProfileType.SoilProfile1D, 2) + StochasticSoilProfiles = { - SoilProfile = soilProfile2 - }, - new StochasticSoilProfile(0.5, SoilProfileType.SoilProfile1D, 3) - { - SoilProfile = soilProfile3 + new PipingStochasticSoilProfile(0.3, soilProfile1), + new PipingStochasticSoilProfile(0.2, soilProfile2), + new PipingStochasticSoilProfile(0.5, soilProfile3) } - }); + }; var availableSoilModels = new[] { soilModel Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/PipingCalculationGroupContextTest.cs =================================================================== diff -u -r8b60c9e846480f3ffeeb263bfea5d3367bf6bee3 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/PipingCalculationGroupContextTest.cs (.../PipingCalculationGroupContextTest.cs) (revision 8b60c9e846480f3ffeeb263bfea5d3367bf6bee3) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/PipingCalculationGroupContextTest.cs (.../PipingCalculationGroupContextTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -49,9 +49,9 @@ { new PipingSurfaceLine() }; - var soilModels = new StochasticSoilModel[] + var soilModels = new[] { - new TestStochasticSoilModel() + PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel() }; CalculationGroup parent = withParent ? new CalculationGroup() : null; Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/PipingCalculationScenarioContextTest.cs =================================================================== diff -u -r66a3c8b86b4ada9239a31cfc47e6c1979c11e000 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/PipingCalculationScenarioContextTest.cs (.../PipingCalculationScenarioContextTest.cs) (revision 66a3c8b86b4ada9239a31cfc47e6c1979c11e000) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/PipingCalculationScenarioContextTest.cs (.../PipingCalculationScenarioContextTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -49,7 +49,7 @@ }; var soilModels = new[] { - new TestStochasticSoilModel() + PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel() }; var calculation = new PipingCalculationScenario(new GeneralPipingInput()); var failureMechanism = new PipingFailureMechanism(); @@ -89,7 +89,7 @@ }; var soilModels = new[] { - new TestStochasticSoilModel() + PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel() }; var calculation = new PipingCalculationScenario(new GeneralPipingInput()); var failureMechanism = new PipingFailureMechanism(); Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/PipingContextTest.cs =================================================================== diff -u -rf7a5d22408a43c70b20a9eb5ee79cb336bacdf9e -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/PipingContextTest.cs (.../PipingContextTest.cs) (revision f7a5d22408a43c70b20a9eb5ee79cb336bacdf9e) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/PipingContextTest.cs (.../PipingContextTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -28,6 +28,7 @@ using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Data.TestUtil; using Ringtoets.Piping.Forms.PresentationObjects; using Ringtoets.Piping.Primitives; @@ -53,7 +54,7 @@ var soilModels = new[] { - new TestStochasticSoilModel() + PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel() }; var target = new ObservableObject(); @@ -88,7 +89,7 @@ // Call TestDelegate call = () => new SimplePipingContext(new ObservableObject(), null, - Enumerable.Empty(), + Enumerable.Empty(), failureMechanism, assessmentSection); @@ -130,7 +131,7 @@ // Call TestDelegate call = () => new SimplePipingContext(new ObservableObject(), Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), null, assessmentSection); @@ -146,7 +147,7 @@ // Call TestDelegate call = () => new SimplePipingContext(new ObservableObject(), Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), new PipingFailureMechanism(), null); @@ -157,7 +158,11 @@ private class SimplePipingContext : PipingContext where T : IObservable { - public SimplePipingContext(T target, IEnumerable surfaceLines, IEnumerable stochasticSoilModels, PipingFailureMechanism pipingFailureMechanism, IAssessmentSection assessmentSection) + public SimplePipingContext(T target, + IEnumerable surfaceLines, + IEnumerable stochasticSoilModels, + PipingFailureMechanism pipingFailureMechanism, + IAssessmentSection assessmentSection) : base(target, surfaceLines, stochasticSoilModels, pipingFailureMechanism, assessmentSection) {} } Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/PipingInputContextTest.cs =================================================================== diff -u -rf7a5d22408a43c70b20a9eb5ee79cb336bacdf9e -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/PipingInputContextTest.cs (.../PipingInputContextTest.cs) (revision f7a5d22408a43c70b20a9eb5ee79cb336bacdf9e) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/PipingInputContextTest.cs (.../PipingInputContextTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -48,7 +48,7 @@ }; var stochasticSoilModels = new[] { - new TestStochasticSoilModel() + PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel() }; var failureMechanism = new PipingFailureMechanism(); @@ -82,7 +82,7 @@ }; var stochasticSoilModels = new[] { - new TestStochasticSoilModel() + PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel() }; var failureMechanism = new PipingFailureMechanism(); Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/StochasticSoilModelCollectionContextTest.cs =================================================================== diff -u -r81fa8a9bf3bd503cbd280e88b8f6037a840cff12 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/StochasticSoilModelCollectionContextTest.cs (.../StochasticSoilModelCollectionContextTest.cs) (revision 81fa8a9bf3bd503cbd280e88b8f6037a840cff12) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/StochasticSoilModelCollectionContextTest.cs (.../StochasticSoilModelCollectionContextTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -25,6 +25,7 @@ using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Forms.PresentationObjects; namespace Ringtoets.Piping.Forms.Test.PresentationObjects @@ -46,7 +47,7 @@ var context = new StochasticSoilModelCollectionContext(failureMechanism.StochasticSoilModels, failureMechanism, assessmentSection); // Assert - Assert.IsInstanceOf>(context); + Assert.IsInstanceOf>(context); Assert.AreSame(failureMechanism.StochasticSoilModels, context.WrappedData); Assert.AreSame(failureMechanism, context.FailureMechanism); Assert.AreSame(assessmentSection, context.AssessmentSection); @@ -61,7 +62,7 @@ var assessmentSection = mocks.Stub(); mocks.ReplayAll(); - var stochasticSoilModels = new StochasticSoilModelCollection(); + var stochasticSoilModels = new PipingStochasticSoilModelCollection(); // Call TestDelegate test = () => new StochasticSoilModelCollectionContext(stochasticSoilModels, null, assessmentSection); Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingInputContextPropertiesTest.cs =================================================================== diff -u -rbcdabbbbd7fae323c339fdabc8bcb390962ccbcc -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingInputContextPropertiesTest.cs (.../PipingInputContextPropertiesTest.cs) (revision bcdabbbbd7fae323c339fdabc8bcb390962ccbcc) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingInputContextPropertiesTest.cs (.../PipingInputContextPropertiesTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -40,6 +40,7 @@ using Ringtoets.Common.Forms.TestUtil; using Ringtoets.Common.Forms.UITypeEditors; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Forms.PresentationObjects; using Ringtoets.Piping.Forms.PropertyClasses; using Ringtoets.Piping.KernelWrapper.TestUtil; @@ -102,7 +103,7 @@ var context = new PipingInputContext(inputParameters, calculationItem, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), failureMechanism, assessmentSection); @@ -131,7 +132,7 @@ var context = new PipingInputContext(inputParameters, calculationItem, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), failureMechanism, assessmentSection); @@ -162,7 +163,7 @@ var context = new PipingInputContext(inputParameters, calculationItem, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), failureMechanism, assessmentSection); @@ -346,7 +347,7 @@ var context = new PipingInputContext(inputParameters, calculationItem, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), failureMechanism, assessmentSection); @@ -396,7 +397,7 @@ var context = new PipingInputContext(inputParameters, calculationItem, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), failureMechanism, assessmentSection); @@ -456,18 +457,22 @@ var random = new Random(22); PipingSurfaceLine surfaceLine = ValidSurfaceLine(0.0, 4.0); - var stochasticSoilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) - { - SoilProfile = new PipingSoilProfile(string.Empty, random.NextDouble(), new[] + var stochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile(string.Empty, random.NextDouble(), new[] { new PipingSoilLayer(random.NextDouble()) { IsAquifer = true } }, SoilProfileType.SoilProfile1D, 0) + ); + var stochasticSoilModel = new PipingStochasticSoilModel("StochasticSoilModelName") + { + StochasticSoilProfiles = + { + stochasticSoilProfile + } }; - var stochasticSoilModel = new StochasticSoilModel("StochasticSoilModelName"); - stochasticSoilModel.StochasticSoilProfiles.Add(stochasticSoilProfile); HydraulicBoundaryLocation testHydraulicBoundaryLocation = TestHydraulicBoundaryLocation.CreateDesignWaterLevelCalculated(0.0); @@ -486,7 +491,7 @@ var context = new PipingInputContext(inputParameters, calculationItem, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), failureMechanism, assessmentSection); @@ -551,7 +556,7 @@ var context = new PipingInputContext(inputParameters, calculationItem, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), failureMechanism, assessmentSection); @@ -562,8 +567,8 @@ const double entryPointL = 0.12; const double exitPointL = 0.44; PipingSurfaceLine surfaceLine = ValidSurfaceLine(0.0, 4.0); - StochasticSoilModel soilModel = ValidStochasticSoilModel(0.0, 4.0); - StochasticSoilProfile soilProfile = soilModel.StochasticSoilProfiles.First(); + PipingStochasticSoilModel soilModel = ValidStochasticSoilModel(0.0, 4.0); + PipingStochasticSoilProfile soilProfile = soilModel.StochasticSoilProfiles.First(); var dampingFactorExit = new LogNormalDistributionDesignVariable( new LogNormalDistribution(3) { @@ -617,7 +622,7 @@ public void StochasticSoilModel_SetValidValue_SetsValueAndUpdatesObservers() { // Setup - StochasticSoilModel newSoilModel = ValidStochasticSoilModel(0.0, 4.0); + PipingStochasticSoilModel newSoilModel = ValidStochasticSoilModel(0.0, 4.0); var calculation = new PipingCalculationScenario(new GeneralPipingInput()); // Call & Assert @@ -628,7 +633,7 @@ public void StochasticSoilProfile_SetValidValue_SetsValueAndUpdatesObservers() { // Setup - StochasticSoilProfile newSoilProfile = ValidStochasticSoilModel(0.0, 4.0).StochasticSoilProfiles.First(); + PipingStochasticSoilProfile newSoilProfile = ValidStochasticSoilModel(0.0, 4.0).StochasticSoilProfiles.First(); var calculation = new PipingCalculationScenario(new GeneralPipingInput()); // Call & Assert @@ -756,7 +761,7 @@ var context = new PipingInputContext(inputParameters, calculationItem, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), failureMechanism, assessmentSection); @@ -799,7 +804,7 @@ var context = new PipingInputContext(inputParameters, calculationItem, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), failureMechanism, assessmentSection); @@ -844,7 +849,7 @@ var context = new PipingInputContext(inputParameters, calculationItem, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), failureMechanism, assessmentSection); @@ -891,7 +896,7 @@ var context = new PipingInputContext(inputParameters, calculationItem, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), failureMechanism, assessmentSection); @@ -935,7 +940,7 @@ var context = new PipingInputContext(inputParameters, calculationItem, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), failureMechanism, assessmentSection); @@ -980,7 +985,7 @@ var context = new PipingInputContext(inputParameters, calculationItem, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), failureMechanism, assessmentSection); @@ -1021,7 +1026,7 @@ var context = new PipingInputContext(calculationItem.InputParameters, calculationItem, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), failureMechanism, assessmentSection); @@ -1061,7 +1066,7 @@ var context = new PipingInputContext(calculationItem.InputParameters, calculationItem, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), failureMechanism, assessmentSection); @@ -1101,7 +1106,7 @@ var context = new PipingInputContext(inputParameters, calculationItem, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), failureMechanism, assessmentSection); @@ -1151,7 +1156,7 @@ var context = new PipingInputContext(inputParameters, calculationItem, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), failureMechanism, assessmentSection); @@ -1194,7 +1199,7 @@ var context = new PipingInputContext(inputParameters, calculationItem, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), failureMechanism, assessmentSection); @@ -1241,7 +1246,7 @@ var context = new PipingInputContext(inputParameters, calculationItem, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), failureMechanism, assessmentSection); @@ -1251,10 +1256,7 @@ var properties = new PipingInputContextProperties(context, handler); - inputParameters.StochasticSoilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) - { - SoilProfile = new TestPipingSoilProfile() - }; + inputParameters.StochasticSoilProfile = new PipingStochasticSoilProfile(0.0, new TestPipingSoilProfile()); // Call properties.SurfaceLine = newSurfaceLine; @@ -1275,12 +1277,14 @@ mocks.ReplayAll(); PipingSurfaceLine testSurfaceLine = ValidSurfaceLine(0, 2); - var stochasticSoilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) + var stochasticSoilProfile = new PipingStochasticSoilProfile(0.0, new TestPipingSoilProfile()); + var stochasticSoilModel = new PipingStochasticSoilModel("StochasticSoilModelName") { - SoilProfile = new TestPipingSoilProfile() + StochasticSoilProfiles = + { + stochasticSoilProfile + } }; - var stochasticSoilModel = new StochasticSoilModel("StochasticSoilModelName"); - stochasticSoilModel.StochasticSoilProfiles.Add(stochasticSoilProfile); var calculationItem = new PipingCalculationScenario(new GeneralPipingInput()); var failureMechanism = new PipingFailureMechanism(); @@ -1320,19 +1324,21 @@ var assessmentSection = mocks.Stub(); mocks.ReplayAll(); - var testPipingSoilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) + var stochasticSoilProfile = new PipingStochasticSoilProfile(0.0, new TestPipingSoilProfile()); + var stochasticSoilModel = new PipingStochasticSoilModel("StochasticSoilModelName") { - SoilProfile = new TestPipingSoilProfile() + StochasticSoilProfiles = + { + stochasticSoilProfile + } }; - var stochasticSoilModel = new StochasticSoilModel("StochasticSoilModelName"); - stochasticSoilModel.StochasticSoilProfiles.Add(testPipingSoilProfile); var calculationItem = new PipingCalculationScenario(new GeneralPipingInput()) { InputParameters = { SurfaceLine = ValidSurfaceLine(0, 4), StochasticSoilModel = stochasticSoilModel, - StochasticSoilProfile = testPipingSoilProfile + StochasticSoilProfile = stochasticSoilProfile } }; @@ -1365,62 +1371,6 @@ } [Test] - public void StochasticSoilProfile_DifferentStochasticSoilModel_SoilProfileSetToNull() - { - // Setup - var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); - var observable = mocks.StrictMock(); - observable.Expect(o => o.NotifyObservers()); - mocks.ReplayAll(); - - PipingSurfaceLine testSurfaceLine = ValidSurfaceLine(0, 2); - var stochasticSoilProfile1 = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) - { - SoilProfile = new TestPipingSoilProfile() - }; - var stochasticSoilModel1 = new StochasticSoilModel("StochasticSoilModel1Name"); - stochasticSoilModel1.StochasticSoilProfiles.Add(stochasticSoilProfile1); - - var stochasticSoilProfile2 = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) - { - SoilProfile = new TestPipingSoilProfile() - }; - var stochasticSoilModel2 = new StochasticSoilModel("StochasticSoilModel2Name"); - stochasticSoilModel1.StochasticSoilProfiles.Add(stochasticSoilProfile2); - - var inputParameters = new PipingInput(new GeneralPipingInput()) - { - SurfaceLine = testSurfaceLine, - StochasticSoilModel = stochasticSoilModel1, - StochasticSoilProfile = stochasticSoilProfile1 - }; - var calculationItem = new PipingCalculationScenario(new GeneralPipingInput()); - var failureMechanism = new PipingFailureMechanism(); - - var context = new PipingInputContext(inputParameters, - calculationItem, - Enumerable.Empty(), - Enumerable.Empty(), - failureMechanism, - assessmentSection); - - var handler = new SetPropertyValueAfterConfirmationParameterTester(new[] - { - observable - }); - - var properties = new PipingInputContextProperties(context, handler); - - // Call - properties.StochasticSoilModel = stochasticSoilModel2; - - // Assert - Assert.IsNull(inputParameters.StochasticSoilProfile); - mocks.VerifyAll(); - } - - [Test] [TestCase(1)] [TestCase(2)] public void GivenCompletePipingInputContextProperties_WhenPhreaticLevelExitPropertiesSetThroughProperties_ThenPiezometricHeadExitUpdated(int propertyIndexToChange) @@ -1436,7 +1386,7 @@ var context = new PipingInputContext(inputParameters, calculationItem, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), failureMechanism, assessmentSection); @@ -1507,7 +1457,7 @@ Assert.IsNull(calculation.InputParameters.SurfaceLine); // Call - IEnumerable soilModels = properties.GetAvailableStochasticSoilModels(); + IEnumerable soilModels = properties.GetAvailableStochasticSoilModels(); // Assert Assert.AreSame(context.AvailableStochasticSoilModels, soilModels); @@ -1532,7 +1482,7 @@ var failureMechanism = new PipingFailureMechanism(); var soilModels = new[] { - new StochasticSoilModel("A") + new PipingStochasticSoilModel("A") { Geometry = { @@ -1541,10 +1491,10 @@ }, StochasticSoilProfiles = { - new StochasticSoilProfile(0.2, SoilProfileType.SoilProfile1D, 1) + new PipingStochasticSoilProfile(0.2, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) } }, - new StochasticSoilModel("C") + new PipingStochasticSoilModel("C") { Geometry = { @@ -1553,10 +1503,10 @@ }, StochasticSoilProfiles = { - new StochasticSoilProfile(0.3, SoilProfileType.SoilProfile1D, 2) + new PipingStochasticSoilProfile(0.3, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) } }, - new StochasticSoilModel("E") + new PipingStochasticSoilModel("E") { Geometry = { @@ -1565,7 +1515,7 @@ }, StochasticSoilProfiles = { - new StochasticSoilProfile(0.3, SoilProfileType.SoilProfile1D, 3) + new PipingStochasticSoilProfile(0.3, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) } } }; @@ -1586,7 +1536,7 @@ Assert.IsNotNull(calculation.InputParameters.SurfaceLine); // Call - IEnumerable availableStochasticSoilModels = properties.GetAvailableStochasticSoilModels(); + IEnumerable availableStochasticSoilModels = properties.GetAvailableStochasticSoilModels(); // Assert CollectionAssert.AreEqual(new[] @@ -1617,7 +1567,7 @@ Assert.IsNull(calculation.InputParameters.StochasticSoilModel); // Call - IEnumerable profiles = properties.GetAvailableStochasticSoilProfiles(); + IEnumerable profiles = properties.GetAvailableStochasticSoilProfiles(); // Assert CollectionAssert.IsEmpty(profiles); @@ -1634,11 +1584,11 @@ mocks.ReplayAll(); var failureMechanism = new PipingFailureMechanism(); - var model = new StochasticSoilModel("A") + var model = new PipingStochasticSoilModel("A") { StochasticSoilProfiles = { - new StochasticSoilProfile(1.0, SoilProfileType.SoilProfile1D, 1) + new PipingStochasticSoilProfile(1.0, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) } }; var calculation = new PipingCalculationScenario(failureMechanism.GeneralInput) @@ -1657,7 +1607,7 @@ Assert.IsNotNull(calculation.InputParameters.StochasticSoilModel); // Call - IEnumerable profiles = properties.GetAvailableStochasticSoilProfiles(); + IEnumerable profiles = properties.GetAvailableStochasticSoilProfiles(); // Assert CollectionAssert.AreEqual(model.StochasticSoilProfiles, profiles); @@ -1710,8 +1660,8 @@ var failureMechanism = new PipingFailureMechanism(); - StochasticSoilModel soilModel = ValidStochasticSoilModel(0.0, 4.0); - StochasticSoilProfile soilProfile = soilModel.StochasticSoilProfiles.First(); + PipingStochasticSoilModel soilModel = ValidStochasticSoilModel(0.0, 4.0); + PipingStochasticSoilProfile soilProfile = soilModel.StochasticSoilProfiles.First(); var calculation = new PipingCalculationScenario(failureMechanism.GeneralInput) { InputParameters = @@ -1929,7 +1879,7 @@ var context = new PipingInputContext(calculation.InputParameters, calculation, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), failureMechanism, assessmentSection); var properties = new PipingInputContextProperties(context, handler); @@ -1956,7 +1906,7 @@ var context = new PipingInputContext(calculation.InputParameters, calculation, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), failureMechanism, assessmentSection); var properties = new PipingInputContextProperties(context, handler); @@ -1992,7 +1942,7 @@ var context = new PipingInputContext(calculation.InputParameters, calculation, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), failureMechanism, assessmentSection); var properties = new PipingInputContextProperties(context, handler); @@ -2019,7 +1969,7 @@ var context = new PipingInputContext(calculation.InputParameters, calculation, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), failureMechanism, assessmentSection); var properties = new PipingInputContextProperties(context, handler); @@ -2049,7 +1999,7 @@ var context = new PipingInputContext(inputParameters, calculation, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), failureMechanism, assessmentSection); @@ -2068,16 +2018,20 @@ mocks.VerifyAll(); } - private static StochasticSoilModel ValidStochasticSoilModel(double xMin, double xMax) + private static PipingStochasticSoilModel ValidStochasticSoilModel(double xMin, double xMax) { - var stochasticSoilModel = new StochasticSoilModel("StochasticSoilModelName"); - stochasticSoilModel.StochasticSoilProfiles.Add(new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 1234) + return new PipingStochasticSoilModel("StochasticSoilModelName") { - SoilProfile = new TestPipingSoilProfile() - }); - stochasticSoilModel.Geometry.Add(new Point2D(xMin, 1.0)); - stochasticSoilModel.Geometry.Add(new Point2D(xMax, 0.0)); - return stochasticSoilModel; + Geometry = + { + new Point2D(xMin, 1.0), + new Point2D(xMax, 0.0) + }, + StochasticSoilProfiles = + { + new PipingStochasticSoilProfile(0.0, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) + } + }; } private static PipingSurfaceLine ValidSurfaceLine(double xMin, double xMax) Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingStochasticSoilModelPropertiesTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingStochasticSoilModelPropertiesTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingStochasticSoilModelPropertiesTest.cs (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -0,0 +1,138 @@ +// Copyright (C) Stichting Deltares 2017. 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.Geometry; +using Core.Common.Gui.PropertyBag; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.Piping.Data.SoilProfile; +using Ringtoets.Piping.Forms.PropertyClasses; +using Ringtoets.Piping.KernelWrapper.TestUtil; + +namespace Ringtoets.Piping.Forms.Test.PropertyClasses +{ + [TestFixture] + public class PipingStochasticSoilModelPropertiesTest + { + private const int stochasticSoilModelNamePropertyIndex = 0; + private const int stochasticSoilModelGeometryPropertyIndex = 1; + private const int stochasticSoilModelStochasticSoilProfilesPropertyIndex = 2; + + [Test] + public void Constructor_StochasticSoilModelNull_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new PipingStochasticSoilModelProperties(null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("stochasticSoilModel", exception.ParamName); + } + + [Test] + public void Constructor_ValidStochasticSoilModel_ExpectedValues() + { + // Setup + var stochasticSoilModel = new PipingStochasticSoilModel("Name"); + + // Call + var properties = new PipingStochasticSoilModelProperties(stochasticSoilModel); + + // Assert + Assert.IsInstanceOf>(properties); + Assert.AreSame(stochasticSoilModel, properties.Data); + } + + [Test] + public void GetProperties_WithData_ReturnExpectedValues() + { + // Setup + var stochasticSoilModel = new PipingStochasticSoilModel("Name") + { + Geometry = + { + new Point2D(1.0, 2.0) + }, + StochasticSoilProfiles = + { + new PipingStochasticSoilProfile(1.0, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) + } + }; + + // Call + var properties = new PipingStochasticSoilModelProperties(stochasticSoilModel); + + // Assert + Assert.AreEqual(stochasticSoilModel.Name, properties.Name); + Assert.AreEqual(stochasticSoilModel.Geometry[0], properties.Geometry[0]); + + Assert.IsInstanceOf(properties.StochasticSoilProfiles); + Assert.AreEqual(1, properties.StochasticSoilProfiles.Length); + } + + [Test] + public void Constructor_Always_PropertiesHaveExpectedAttributesValues() + { + // Setup + var stochasticSoilModel = new PipingStochasticSoilModel("Name") + { + Geometry = + { + new Point2D(1.0, 2.0) + }, + StochasticSoilProfiles = + { + new PipingStochasticSoilProfile(1.0, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) + } + }; + + // Call + var properties = new PipingStochasticSoilModelProperties(stochasticSoilModel); + + // Assert + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + Assert.AreEqual(3, dynamicProperties.Count); + + PropertyDescriptor stochasticSoilModelNameProperty = dynamicProperties[stochasticSoilModelNamePropertyIndex]; + Assert.IsNotNull(stochasticSoilModelNameProperty); + Assert.IsTrue(stochasticSoilModelNameProperty.IsReadOnly); + Assert.AreEqual("Algemeen", stochasticSoilModelNameProperty.Category); + Assert.AreEqual("Naam", stochasticSoilModelNameProperty.DisplayName); + Assert.AreEqual("Naam van het stochastische ondergrondmodel.", stochasticSoilModelNameProperty.Description); + + PropertyDescriptor stochasticSoilModelGeometryProperty = dynamicProperties[stochasticSoilModelGeometryPropertyIndex]; + Assert.IsNotNull(stochasticSoilModelGeometryProperty); + Assert.IsTrue(stochasticSoilModelGeometryProperty.IsReadOnly); + Assert.AreEqual("Algemeen", stochasticSoilModelGeometryProperty.Category); + Assert.AreEqual("Geometrie", stochasticSoilModelGeometryProperty.DisplayName); + Assert.AreEqual("Geometrie uit de database.", stochasticSoilModelGeometryProperty.Description); + + PropertyDescriptor stochasticSoilModelStochasticSoilProfilesProperty = dynamicProperties[stochasticSoilModelStochasticSoilProfilesPropertyIndex]; + Assert.IsNotNull(stochasticSoilModelStochasticSoilProfilesProperty); + Assert.IsTrue(stochasticSoilModelStochasticSoilProfilesProperty.IsReadOnly); + Assert.AreEqual("Algemeen", stochasticSoilModelStochasticSoilProfilesProperty.Category); + Assert.AreEqual("Ondergrondschematisaties", stochasticSoilModelStochasticSoilProfilesProperty.DisplayName); + Assert.AreEqual("Ondergrondschematisaties uit de database.", stochasticSoilModelStochasticSoilProfilesProperty.Description); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingStochasticSoilProfilePropertiesTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingStochasticSoilProfilePropertiesTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingStochasticSoilProfilePropertiesTest.cs (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -0,0 +1,110 @@ +// Copyright (C) Stichting Deltares 2017. 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 System.Linq; +using Core.Common.Gui.PropertyBag; +using NUnit.Framework; +using Ringtoets.Piping.Data.SoilProfile; +using Ringtoets.Piping.Forms.PropertyClasses; +using Ringtoets.Piping.KernelWrapper.TestUtil; +using Ringtoets.Piping.Primitives; + +namespace Ringtoets.Piping.Forms.Test.PropertyClasses +{ + [TestFixture] + public class PipingStochasticSoilProfilePropertiesTest + { + [Test] + public void Constructor_StochasticSoilProfileNull_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new PipingStochasticSoilProfileProperties(null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("stochasticSoilProfile", exception.ParamName); + } + + [Test] + public void Constructor_ValidStochasticSoilProfile_ExpectedValues() + { + // Setup + var stochasticSoilProfile = new PipingStochasticSoilProfile(1, new TestPipingSoilProfile()); + + // Call + var properties = new PipingStochasticSoilProfileProperties(stochasticSoilProfile); + + // Assert + Assert.IsInstanceOf>(properties); + Assert.AreSame(stochasticSoilProfile, properties.Data); + } + + [Test] + [TestCase(0.142, "14,2")] + [TestCase(1.0, "100")] + [TestCase(0.5 + 1e-6, "50")] + [SetCulture("nl-NL")] + public void GetProperties_WithDataAndDutchLocale_ReturnExpectedValues(double probability, string expectedProbability) + { + GetProperties_WithData_ReturnExpectedValues(probability, expectedProbability); + } + + [Test] + [TestCase(0.142, "14.2")] + [TestCase(1.0, "100")] + [TestCase(0.5 + 1e-6, "50")] + [SetCulture("en-US")] + public void GetProperties_WithDataAndEnglishLocale_ReturnExpectedValues(double probability, string expectedProbability) + { + GetProperties_WithData_ReturnExpectedValues(probability, expectedProbability); + } + + private static void GetProperties_WithData_ReturnExpectedValues(double probability, string expectedProbability) + { + // Setup + const string expectedName = ""; + IEnumerable layers = new[] + { + new PipingSoilLayer(-2), + new PipingSoilLayer(-4) + { + IsAquifer = true + } + }; + + var soilProfile = new PipingSoilProfile(expectedName, -5.0, layers, SoilProfileType.SoilProfile1D, 0); + var stochasticSoilProfile = new PipingStochasticSoilProfile(probability, soilProfile); + + // Call + var properties = new PipingStochasticSoilProfileProperties(stochasticSoilProfile); + + // Assert + Assert.AreEqual(expectedName, properties.Name); + Assert.AreEqual(expectedName, properties.ToString()); + CollectionAssert.AreEqual(soilProfile.Layers.Select(l => l.Top), properties.TopLevels); + Assert.AreEqual(soilProfile.Bottom, properties.Bottom); + Assert.AreEqual(expectedProbability, properties.Probability); + Assert.AreEqual("1D profiel", properties.Type); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/StochasticSoilModelCollectionPropertiesTest.cs =================================================================== diff -u -ra1e976b5692d931d9bf7bc79ad667a2587125978 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/StochasticSoilModelCollectionPropertiesTest.cs (.../StochasticSoilModelCollectionPropertiesTest.cs) (revision a1e976b5692d931d9bf7bc79ad667a2587125978) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/StochasticSoilModelCollectionPropertiesTest.cs (.../StochasticSoilModelCollectionPropertiesTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -26,6 +26,7 @@ using Core.Common.TestUtil; using NUnit.Framework; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Forms.PropertyClasses; namespace Ringtoets.Piping.Forms.Test.PropertyClasses @@ -37,7 +38,7 @@ public void Constructor_WithoutCollection_ThrowsArgumentNullException() { // Call - TestDelegate test = () => new StochasticSoilModelCollectionProperties(null); + TestDelegate test = () => new PipingStochasticSoilModelCollectionProperties(null); // Assert string paramName = Assert.Throws(test).ParamName; @@ -49,14 +50,14 @@ { // Setup const string someFilePath = "location/to/a/file"; - var collection = new StochasticSoilModelCollection(); - collection.AddRange(Enumerable.Empty(), someFilePath); + var collection = new PipingStochasticSoilModelCollection(); + collection.AddRange(Enumerable.Empty(), someFilePath); // Call - var properties = new StochasticSoilModelCollectionProperties(collection); + var properties = new PipingStochasticSoilModelCollectionProperties(collection); // Assert - Assert.IsInstanceOf>(properties); + Assert.IsInstanceOf>(properties); Assert.AreSame(collection, properties.Data); Assert.AreEqual(someFilePath, properties.SourcePath); } @@ -65,10 +66,10 @@ public void Constructor_WithData_PropertiesHaveExpectedAttributesValues() { // Setup - var collection = new StochasticSoilModelCollection(); + var collection = new PipingStochasticSoilModelCollection(); // Call - var properties = new StochasticSoilModelCollectionProperties(collection); + var properties = new PipingStochasticSoilModelCollectionProperties(collection); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); Fisheye: Tag 26f527fb809a2325c8f883ece9da01a8f8040eb3 refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/StochasticSoilModelPropertiesTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 26f527fb809a2325c8f883ece9da01a8f8040eb3 refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/StochasticSoilProfilePropertiesTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Ringtoets.Piping.Forms.Test.csproj =================================================================== diff -u -raa49537188229065df91b1a931f088c32115702a -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Ringtoets.Piping.Forms.Test.csproj (.../Ringtoets.Piping.Forms.Test.csproj) (revision aa49537188229065df91b1a931f088c32115702a) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Ringtoets.Piping.Forms.Test.csproj (.../Ringtoets.Piping.Forms.Test.csproj) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -78,14 +78,14 @@ - + - + Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/UITypeEditors/PipingInputContextStochasticSoilModelSelectionEditorTest.cs =================================================================== diff -u -rd6fe8399e8398224cf1bda9259052232d85b85a4 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/UITypeEditors/PipingInputContextStochasticSoilModelSelectionEditorTest.cs (.../PipingInputContextStochasticSoilModelSelectionEditorTest.cs) (revision d6fe8399e8398224cf1bda9259052232d85b85a4) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/UITypeEditors/PipingInputContextStochasticSoilModelSelectionEditorTest.cs (.../PipingInputContextStochasticSoilModelSelectionEditorTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -30,6 +30,7 @@ using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Forms.PropertyClasses; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Data.TestUtil; using Ringtoets.Piping.Forms.PresentationObjects; using Ringtoets.Piping.Forms.PropertyClasses; @@ -58,14 +59,14 @@ var pipingInput = new PipingInput(new GeneralPipingInput()) { - StochasticSoilModel = new StochasticSoilModel("StochasticSoilModelName") + StochasticSoilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("StochasticSoilModelName") }; var pipingInputContext = new PipingInputContext(pipingInput, calculationItem, Enumerable.Empty(), new[] { - new TestStochasticSoilModel() + PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel() }, failureMechanism, assessmentSection); @@ -102,12 +103,9 @@ var assessmentSection = mockRepository.Stub(); var handler = mockRepository.Stub(); - var stochasticSoilProfile = new StochasticSoilProfile(1.0, SoilProfileType.SoilProfile1D, 0) + var stochasticSoilProfile = new PipingStochasticSoilProfile(1.0, new TestPipingSoilProfile()); + var stochasticSoilModel = new PipingStochasticSoilModel("Model") { - SoilProfile = new TestPipingSoilProfile() - }; - var stochasticSoilModel = new StochasticSoilModel("Model") - { Geometry = { new Point2D(0, 2), Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/UITypeEditors/PipingInputContextStochasticSoilProfileSelectionEditorTest.cs =================================================================== diff -u -rd6fe8399e8398224cf1bda9259052232d85b85a4 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/UITypeEditors/PipingInputContextStochasticSoilProfileSelectionEditorTest.cs (.../PipingInputContextStochasticSoilProfileSelectionEditorTest.cs) (revision d6fe8399e8398224cf1bda9259052232d85b85a4) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/UITypeEditors/PipingInputContextStochasticSoilProfileSelectionEditorTest.cs (.../PipingInputContextStochasticSoilProfileSelectionEditorTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -30,6 +30,7 @@ using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Forms.PropertyClasses; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Data.TestUtil; using Ringtoets.Piping.Forms.PresentationObjects; using Ringtoets.Piping.Forms.PropertyClasses; @@ -58,17 +59,14 @@ var pipingInput = new PipingInput(new GeneralPipingInput()) { - StochasticSoilProfile = new StochasticSoilProfile(1.0, SoilProfileType.SoilProfile1D, 2) - { - SoilProfile = new TestPipingSoilProfile() - } + StochasticSoilProfile = new PipingStochasticSoilProfile(1.0, new TestPipingSoilProfile()) }; var pipingInputContext = new PipingInputContext(pipingInput, calculationItem, Enumerable.Empty(), new[] { - new TestStochasticSoilModel() + PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel() }, failureMechanism, assessmentSection); @@ -105,12 +103,9 @@ var assessmentSection = mockRepository.Stub(); var handler = mockRepository.Stub(); - var stochasticSoilProfile = new StochasticSoilProfile(1.0, SoilProfileType.SoilProfile1D, 0) + var stochasticSoilProfile = new PipingStochasticSoilProfile(1.0, new TestPipingSoilProfile()); + var stochasticSoilModel = new PipingStochasticSoilModel("Model") { - SoilProfile = new TestPipingSoilProfile() - }; - var stochasticSoilModel = new StochasticSoilModel("Model") - { Geometry = { new Point2D(0, 2), Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/UITypeEditors/PipingInputContextSurfaceLineSelectionEditorTest.cs =================================================================== diff -u -rd6fe8399e8398224cf1bda9259052232d85b85a4 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/UITypeEditors/PipingInputContextSurfaceLineSelectionEditorTest.cs (.../PipingInputContextSurfaceLineSelectionEditorTest.cs) (revision d6fe8399e8398224cf1bda9259052232d85b85a4) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/UITypeEditors/PipingInputContextSurfaceLineSelectionEditorTest.cs (.../PipingInputContextSurfaceLineSelectionEditorTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -30,6 +30,7 @@ using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Forms.PropertyClasses; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Forms.PresentationObjects; using Ringtoets.Piping.Forms.PropertyClasses; using Ringtoets.Piping.Forms.UITypeEditors; @@ -64,7 +65,7 @@ { new PipingSurfaceLine() }, - Enumerable.Empty(), + Enumerable.Empty(), failureMechanism, assessmentSection); @@ -119,7 +120,7 @@ { surfaceLine }, - Enumerable.Empty(), + Enumerable.Empty(), failureMechanism, assessmentSection); Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationRowTest.cs =================================================================== diff -u -rbcdabbbbd7fae323c339fdabc8bcb390962ccbcc -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationRowTest.cs (.../PipingCalculationRowTest.cs) (revision bcdabbbbd7fae323c339fdabc8bcb390962ccbcc) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationRowTest.cs (.../PipingCalculationRowTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -33,6 +33,7 @@ using Ringtoets.Common.Forms.PropertyClasses; using Ringtoets.Common.Forms.TestUtil; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Data.TestUtil; using Ringtoets.Piping.Forms.Views; using Ringtoets.Piping.KernelWrapper.TestUtil; @@ -148,8 +149,8 @@ public void StochasticSoilModel_AlwaysOnChange_NotifyObserverCalculationPropertyChangedOutputCleared() { // Setup - var newModel = new StochasticSoilModel("test"); - var newValue = new DataGridViewComboBoxItemWrapper(newModel); + PipingStochasticSoilModel newModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(); + var newValue = new DataGridViewComboBoxItemWrapper(newModel); var calculation = new PipingCalculationScenario(new GeneralPipingInput()); @@ -161,7 +162,7 @@ public void StochasticSoilModel_ChangeToEqualValue_NoNotificationsOutputNotCleared() { // Setup - DataGridViewComboBoxItemWrapper oldValue = null; + DataGridViewComboBoxItemWrapper oldValue = null; // Call AssertPropertyNotChanged( @@ -182,8 +183,8 @@ public void StochasticSoilProfile_AlwaysOnChange_NotifyObserverAndCalculationPropertyChanged() { // Setup - var newProfile = new StochasticSoilProfile(0, 0, 0); - var newValue = new DataGridViewComboBoxItemWrapper(newProfile); + var newProfile = new PipingStochasticSoilProfile(0, PipingSoilProfileTestFactory.CreatePipingSoilProfile()); + var newValue = new DataGridViewComboBoxItemWrapper(newProfile); var calculation = new PipingCalculationScenario(new GeneralPipingInput()); @@ -195,7 +196,7 @@ public void StochasticSoilProfile_ChangeToEqualValue_NoNotificationsOutputNotCleared() { // Setup - DataGridViewComboBoxItemWrapper oldValue = null; + DataGridViewComboBoxItemWrapper oldValue = null; // Call AssertPropertyNotChanged( Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationsViewTest.cs =================================================================== diff -u -rfe90a6d174a01975381e6cda55ed1f7f4e831a51 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationsViewTest.cs (.../PipingCalculationsViewTest.cs) (revision fe90a6d174a01975381e6cda55ed1f7f4e831a51) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationsViewTest.cs (.../PipingCalculationsViewTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -36,6 +36,7 @@ using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Data.TestUtil; using Ringtoets.Piping.Forms.PresentationObjects; using Ringtoets.Piping.Forms.Views; @@ -58,20 +59,6 @@ private const int exitPointLColumnIndex = 8; private Form testForm; - public override void Setup() - { - base.Setup(); - - testForm = new Form(); - } - - public override void TearDown() - { - base.TearDown(); - - testForm.Dispose(); - } - [Test] public void Constructor_DefaultValues() { @@ -495,7 +482,7 @@ var pipingFailureMechanism = new PipingFailureMechanism(); pipingFailureMechanism.StochasticSoilModels.AddRange(new[] { - new TestStochasticSoilModel() + PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel() }, "path"); using (PipingCalculationsView pipingCalculationsView = ShowPipingCalculationsView()) @@ -546,7 +533,7 @@ }, arbitrarySourcePath); pipingFailureMechanism.StochasticSoilModels.AddRange(new[] { - new TestStochasticSoilModel() + PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel() }, arbitrarySourcePath); using (PipingCalculationsView pipingCalculationsView = ShowPipingCalculationsView()) @@ -627,7 +614,7 @@ }, arbitraryFilePath); pipingFailureMechanism.StochasticSoilModels.AddRange(new[] { - new TestStochasticSoilModel() + PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel() }, arbitraryFilePath); using (PipingCalculationsView pipingCalculationsView = ShowPipingCalculationsView()) @@ -679,7 +666,7 @@ }, arbitraryFilePath); pipingFailureMechanism.StochasticSoilModels.AddRange(new[] { - new TestStochasticSoilModel() + PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel() }, arbitraryFilePath); pipingFailureMechanism.CalculationsGroup.Attach(observer); @@ -723,7 +710,7 @@ }, arbitryFilePath); pipingFailureMechanism.StochasticSoilModels.AddRange(new[] { - new TestStochasticSoilModel() + PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel() }, arbitryFilePath); pipingFailureMechanism.CalculationsGroup.Attach(observer); @@ -834,7 +821,7 @@ // When pipingFailureMechanism.StochasticSoilModels.AddRange(new[] { - new TestStochasticSoilModel() + PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel() }, "path"); pipingFailureMechanism.NotifyObservers(); @@ -883,7 +870,7 @@ }, arbitraryFilePath); pipingFailureMechanism.StochasticSoilModels.AddRange(new[] { - new TestStochasticSoilModel() + PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel() }, arbitraryFilePath); // Then @@ -909,7 +896,7 @@ }, arbitraryFilePath); pipingFailureMechanism.StochasticSoilModels.AddRange(new[] { - new TestStochasticSoilModel() + PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel() }, arbitraryFilePath); pipingCalculationsView.PipingFailureMechanism.NotifyObservers(); @@ -933,7 +920,7 @@ }, arbitraryFilePath); pipingFailureMechanism.StochasticSoilModels.AddRange(new[] { - new TestStochasticSoilModel() + PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel() }, arbitraryFilePath); pipingCalculationsView.PipingFailureMechanism = pipingFailureMechanism; @@ -1221,14 +1208,9 @@ var currentCell = (DataGridViewTextBoxCell) dataGridView.Rows[1].Cells[stochasticSoilProfilesProbabilityColumnIndex]; Assert.AreEqual("30", currentCell.FormattedValue); - StochasticSoilProfile stochasticSoilProfileToChange = pipingCalculation.InputParameters.StochasticSoilProfile; - var updatedProfile = new StochasticSoilProfile( - 0.5, - stochasticSoilProfileToChange.SoilProfileType, - stochasticSoilProfileToChange.SoilProfileId) - { - SoilProfile = stochasticSoilProfileToChange.SoilProfile - }; + PipingStochasticSoilProfile stochasticSoilProfileToChange = pipingCalculation.InputParameters.StochasticSoilProfile; + var updatedProfile = new PipingStochasticSoilProfile(0.5, + stochasticSoilProfileToChange.SoilProfile); dataGridView.Invalidated += (sender, args) => refreshed++; // When @@ -1300,6 +1282,20 @@ mocks.VerifyAll(); } + public override void Setup() + { + base.Setup(); + + testForm = new Form(); + } + + public override void TearDown() + { + base.TearDown(); + + testForm.Dispose(); + } + private PipingCalculationsView ShowFullyConfiguredPipingCalculationsView( IAssessmentSection assessmentSection) { @@ -1504,11 +1500,17 @@ }, arbirtraryFilePath); pipingFailureMechanism.StochasticSoilModels.AddRange(new[] { - new TestStochasticSoilModel + new PipingStochasticSoilModel("PipingStochasticSoilModel") { Geometry = { - new Point2D(0.0, 0.0), new Point2D(5.0, 0.0) + new Point2D(0.0, 0.0), + new Point2D(5.0, 0.0) + }, + StochasticSoilProfiles = + { + new PipingStochasticSoilProfile(0.5, new TestPipingSoilProfile("A")), + new PipingStochasticSoilProfile(0.5, new TestPipingSoilProfile("B")) } } }, arbirtraryFilePath); @@ -1530,7 +1532,7 @@ private static CalculationGroup ConfigureCalculationGroup(IAssessmentSection assessmentSection, PipingFailureMechanism failureMechanism) { - StochasticSoilModel stochasticSoilModelForCalculation2 = failureMechanism.StochasticSoilModels.Last(); + PipingStochasticSoilModel stochasticSoilModelForCalculation2 = failureMechanism.StochasticSoilModels.Last(); return new CalculationGroup("Group", true) { Children = @@ -1628,52 +1630,47 @@ new Point2D(10.0, 0.0) })); - var stochasticSoilProfile1 = new StochasticSoilProfile(0.3, SoilProfileType.SoilProfile1D, 1) - { - SoilProfile = new PipingSoilProfile("Profile 1", -10.0, new[] + var stochasticSoilProfile1 = new PipingStochasticSoilProfile( + 0.3, new PipingSoilProfile("Profile 1", -10.0, new[] { new PipingSoilLayer(-5.0), new PipingSoilLayer(-2.0), new PipingSoilLayer(1.0) - }, SoilProfileType.SoilProfile1D, 1) - }; + }, SoilProfileType.SoilProfile1D, 1)); - var stochasticSoilModelA = new StochasticSoilModel("Model A") + var stochasticSoilModelA = new PipingStochasticSoilModel("Model A") { Geometry = { - new Point2D(0.0, 0.0), new Point2D(5.0, 0.0) + new Point2D(0.0, 0.0), + new Point2D(5.0, 0.0) }, StochasticSoilProfiles = { stochasticSoilProfile1, - new StochasticSoilProfile(0.7, SoilProfileType.SoilProfile1D, 2) + new PipingStochasticSoilProfile(0.7, new PipingSoilProfile("Profile 2", -8.0, new[] { - SoilProfile = new PipingSoilProfile("Profile 2", -8.0, new[] - { - new PipingSoilLayer(-4.0), - new PipingSoilLayer(0.0), - new PipingSoilLayer(4.0) - }, SoilProfileType.SoilProfile1D, 2) - } + new PipingSoilLayer(-4.0), + new PipingSoilLayer(0.0), + new PipingSoilLayer(4.0) + }, SoilProfileType.SoilProfile1D, 2)) } }; - var stochasticSoilProfile5 = new StochasticSoilProfile(0.3, SoilProfileType.SoilProfile1D, 1) - { - SoilProfile = new PipingSoilProfile("Profile 5", -10.0, new[] + var stochasticSoilProfile5 = new PipingStochasticSoilProfile( + 0.3, new PipingSoilProfile("Profile 5", -10.0, new[] { new PipingSoilLayer(-5.0), new PipingSoilLayer(-2.0), new PipingSoilLayer(1.0) - }, SoilProfileType.SoilProfile1D, 1) - }; + }, SoilProfileType.SoilProfile1D, 1)); - var stochasticSoilModelE = new StochasticSoilModel("Model E") + var stochasticSoilModelE = new PipingStochasticSoilModel("Model E") { Geometry = { - new Point2D(1.0, 0.0), new Point2D(6.0, 0.0) + new Point2D(1.0, 0.0), + new Point2D(6.0, 0.0) }, StochasticSoilProfiles = { @@ -1684,32 +1681,27 @@ pipingFailureMechanism.StochasticSoilModels.AddRange(new[] { stochasticSoilModelA, - new StochasticSoilModel("Model C") + new PipingStochasticSoilModel("Model C") { Geometry = { - new Point2D(1.0, 0.0), new Point2D(4.0, 0.0) + new Point2D(1.0, 0.0), + new Point2D(4.0, 0.0) }, StochasticSoilProfiles = { - new StochasticSoilProfile(0.3, SoilProfileType.SoilProfile1D, 1) + new PipingStochasticSoilProfile(0.3, new PipingSoilProfile("Profile 3", -10.0, new[] { - SoilProfile = new PipingSoilProfile("Profile 3", -10.0, new[] - { - new PipingSoilLayer(-5.0), - new PipingSoilLayer(-2.0), - new PipingSoilLayer(1.0) - }, SoilProfileType.SoilProfile1D, 1) - }, - new StochasticSoilProfile(0.7, SoilProfileType.SoilProfile1D, 2) + new PipingSoilLayer(-5.0), + new PipingSoilLayer(-2.0), + new PipingSoilLayer(1.0) + }, SoilProfileType.SoilProfile1D, 1)), + new PipingStochasticSoilProfile(0.7, new PipingSoilProfile("Profile 4", -8.0, new[] { - SoilProfile = new PipingSoilProfile("Profile 4", -8.0, new[] - { - new PipingSoilLayer(-4.0), - new PipingSoilLayer(0.0), - new PipingSoilLayer(4.0) - }, SoilProfileType.SoilProfile1D, 2) - } + new PipingSoilLayer(-4.0), + new PipingSoilLayer(0.0), + new PipingSoilLayer(4.0) + }, SoilProfileType.SoilProfile1D, 2)) } }, stochasticSoilModelE Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingFailureMechanismViewTest.cs =================================================================== diff -u -rd6fe8399e8398224cf1bda9259052232d85b85a4 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingFailureMechanismViewTest.cs (.../PipingFailureMechanismViewTest.cs) (revision d6fe8399e8398224cf1bda9259052232d85b85a4) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingFailureMechanismViewTest.cs (.../PipingFailureMechanismViewTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -41,6 +41,7 @@ using Ringtoets.Common.Forms.Views; using Ringtoets.Common.Utils.TypeConverters; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Data.TestUtil; using Ringtoets.Piping.Forms.PresentationObjects; using Ringtoets.Piping.Forms.Views; @@ -254,18 +255,22 @@ ReferenceLine = referenceLine }; - var stochasticSoilModel1 = new StochasticSoilModel("name1"); - stochasticSoilModel1.Geometry.AddRange(new[] + var stochasticSoilModel1 = new PipingStochasticSoilModel("name1") { - new Point2D(1.0, 2.0), - new Point2D(1.1, 2.2) - }); - var stochasticSoilModel2 = new StochasticSoilModel("name2"); - stochasticSoilModel2.Geometry.AddRange(new[] + Geometry = + { + new Point2D(1.0, 2.0), + new Point2D(1.1, 2.2) + } + }; + var stochasticSoilModel2 = new PipingStochasticSoilModel("name2") { - new Point2D(3.0, 4.0), - new Point2D(3.3, 4.4) - }); + Geometry = + { + new Point2D(3.0, 4.0), + new Point2D(3.3, 4.4) + } + }; var surfaceLineA = new PipingSurfaceLine { @@ -684,13 +689,14 @@ var failureMechanism = new PipingFailureMechanism(); var failureMechanismContext = new PipingFailureMechanismContext(failureMechanism, new ObservableTestAssessmentSectionStub()); - var stochasticSoilModel = new StochasticSoilModel(""); - - stochasticSoilModel.Geometry.AddRange(new[] + var stochasticSoilModel = new PipingStochasticSoilModel("") { - new Point2D(1, 2), - new Point2D(1, 2) - }); + Geometry = + { + new Point2D(1, 2), + new Point2D(1, 2) + } + }; view.Data = failureMechanismContext; @@ -1012,18 +1018,18 @@ Assert.AreEqual("Profielschematisaties", mapData.Name); } - private static void AssertStochasticSoilModelsMapData(IEnumerable soilModels, MapData mapData) + private static void AssertStochasticSoilModelsMapData(IEnumerable soilModels, MapData mapData) { Assert.IsInstanceOf(mapData); var soilModelsMapData = (MapLineData) mapData; MapFeature[] soilModelsFeatures = soilModelsMapData.Features.ToArray(); - StochasticSoilModel[] stochasticSoilModelsArray = soilModels.ToArray(); + PipingStochasticSoilModel[] stochasticSoilModelsArray = soilModels.ToArray(); Assert.AreEqual(stochasticSoilModelsArray.Length, soilModelsFeatures.Length); for (var index = 0; index < stochasticSoilModelsArray.Length; index++) { Assert.AreEqual(1, soilModelsFeatures[index].MapGeometries.Count()); - StochasticSoilModel stochasticSoilModel = stochasticSoilModelsArray[index]; + PipingStochasticSoilModel stochasticSoilModel = stochasticSoilModelsArray[index]; CollectionAssert.AreEquivalent(stochasticSoilModel.Geometry.Select(p => new Point2D(p)), soilModelsFeatures[index].MapGeometries.First().PointCollections.First()); } Assert.AreEqual("Stochastische ondergrondmodellen", mapData.Name); Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingInputViewTest.cs =================================================================== diff -u -rd6fe8399e8398224cf1bda9259052232d85b85a4 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingInputViewTest.cs (.../PipingInputViewTest.cs) (revision d6fe8399e8398224cf1bda9259052232d85b85a4) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingInputViewTest.cs (.../PipingInputViewTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -29,6 +29,7 @@ using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Forms.Views; using Ringtoets.Piping.Primitives; @@ -157,9 +158,8 @@ { InputParameters = { - StochasticSoilProfile = new StochasticSoilProfile(0.1, SoilProfileType.SoilProfile1D, 1) - { - SoilProfile = new PipingSoilProfile( + StochasticSoilProfile = new PipingStochasticSoilProfile( + 0.1, new PipingSoilProfile( "profile", -1, new[] @@ -169,8 +169,7 @@ new PipingSoilLayer(0) }, SoilProfileType.SoilProfile1D, - 1) - } + 1)) } }; @@ -208,7 +207,7 @@ surfaceLine.SetDikeToeAtPolderAt(new Point3D(1.2, 2.3, 4.0)); surfaceLine.SetDikeToeAtRiverAt(new Point3D(1.2, 2.3, 4.0)); - StochasticSoilProfile stochasticSoilProfile = GetStochasticSoilProfile(); + PipingStochasticSoilProfile stochasticSoilProfile = GetStochasticSoilProfile(); var calculation = new PipingCalculationScenario(new GeneralPipingInput()) { InputParameters = @@ -280,36 +279,6 @@ } [Test] - public void Data_WithSurfaceLineWithoutSoilProfile_CollectionOfEmptyChartDataSetForSoilProfile() - { - // Setup - using (var view = new PipingInputView()) - { - PipingSurfaceLine surfaceLine = GetSurfaceLineWithGeometry(); - var calculation = new PipingCalculationScenario(new GeneralPipingInput()) - { - InputParameters = - { - SurfaceLine = surfaceLine, - StochasticSoilProfile = new StochasticSoilProfile(0.5, SoilProfileType.SoilProfile1D, 1) - } - }; - - // Call - view.Data = calculation; - - // Assert - Assert.AreSame(calculation, view.Data); - ChartDataCollection chartData = view.Chart.Data; - Assert.IsInstanceOf(chartData); - Assert.AreEqual(10, chartData.Collection.Count()); - var soilProfileData = (ChartDataCollection) chartData.Collection.ElementAt(soilProfileIndex); - CollectionAssert.IsEmpty(soilProfileData.Collection); - Assert.AreEqual("Ondergrondschematisatie", soilProfileData.Name); - } - } - - [Test] public void Data_WithoutStochasticSoilProfile_SoilLayerTableEmpty() { // Setup @@ -326,28 +295,6 @@ } [Test] - public void Data_WithoutSoilProfile_SoilLayerTableEmpty() - { - // Setup - using (var view = new PipingInputView()) - { - var calculation = new PipingCalculationScenario(new GeneralPipingInput()) - { - InputParameters = - { - StochasticSoilProfile = new StochasticSoilProfile(0.5, SoilProfileType.SoilProfile1D, 1) - } - }; - - // Call - view.Data = calculation; - - // Assert - AssertEmptySoilLayerTable(view); - } - } - - [Test] public void UpdateObserver_CalculationNameUpdated_ChartTitleUpdated() { // Setup @@ -512,16 +459,14 @@ using (var view = new PipingInputView()) { PipingSurfaceLine surfaceLine = GetSurfaceLineWithGeometry(); - StochasticSoilProfile soilProfile = GetStochasticSoilProfile(); - var soilProfile2 = new StochasticSoilProfile(0.5, SoilProfileType.SoilProfile1D, 1) - { - SoilProfile = new PipingSoilProfile("profile", -2, new[] + PipingStochasticSoilProfile soilProfile = GetStochasticSoilProfile(); + var soilProfile2 = new PipingStochasticSoilProfile( + 0.5, new PipingSoilProfile("profile", -2, new[] { new PipingSoilLayer(0), new PipingSoilLayer(2), new PipingSoilLayer(3) - }, SoilProfileType.SoilProfile1D, 1) - }; + }, SoilProfileType.SoilProfile1D, 1)); var calculation = new PipingCalculationScenario(new GeneralPipingInput()) { @@ -685,7 +630,7 @@ using (var view = new PipingInputView()) { PipingSurfaceLine surfaceLine = GetSurfaceLineWithGeometry(); - StochasticSoilProfile stochasticSoilProfile = GetStochasticSoilProfile(); + PipingStochasticSoilProfile stochasticSoilProfile = GetStochasticSoilProfile(); var calculation = new PipingCalculationScenario(new GeneralPipingInput()) { InputParameters = @@ -713,17 +658,15 @@ } } - private static StochasticSoilProfile GetStochasticSoilProfile() + private static PipingStochasticSoilProfile GetStochasticSoilProfile() { - return new StochasticSoilProfile(0.5, SoilProfileType.SoilProfile1D, 1) - { - SoilProfile = new PipingSoilProfile("profile", -1, new[] - { - new PipingSoilLayer(1), - new PipingSoilLayer(3), - new PipingSoilLayer(5) - }, SoilProfileType.SoilProfile1D, 1) - }; + return new PipingStochasticSoilProfile(0.5, + new PipingSoilProfile("profile", -1, new[] + { + new PipingSoilLayer(1), + new PipingSoilLayer(3), + new PipingSoilLayer(5) + }, SoilProfileType.SoilProfile1D, 1)); } private static PipingSurfaceLine GetSurfaceLineWithGeometry() @@ -809,7 +752,7 @@ Assert.AreEqual("Teen dijk buitenwaarts", dikeToeAtRiverData.Name); } - private static void AssertSoilProfileChartData(StochasticSoilProfile soilProfile, ChartData chartData, bool mapDataShouldContainAreas) + private static void AssertSoilProfileChartData(PipingStochasticSoilProfile soilProfile, ChartData chartData, bool mapDataShouldContainAreas) { Assert.IsInstanceOf(chartData); var soilProfileChartData = (ChartDataCollection) chartData; Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Configurations/PipingCalculationConfigurationImporterTest.cs =================================================================== diff -u -rd6fe8399e8398224cf1bda9259052232d85b85a4 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Configurations/PipingCalculationConfigurationImporterTest.cs (.../PipingCalculationConfigurationImporterTest.cs) (revision d6fe8399e8398224cf1bda9259052232d85b85a4) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Configurations/PipingCalculationConfigurationImporterTest.cs (.../PipingCalculationConfigurationImporterTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -31,6 +31,8 @@ using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.IO.Configurations.Import; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; +using Ringtoets.Piping.Data.TestUtil; using Ringtoets.Piping.IO.Configurations; using Ringtoets.Piping.Primitives; @@ -227,7 +229,7 @@ new Point3D(2.5, 1.0, 1.0), new Point3D(5.0, 1.0, 0.0) }); - var stochasticSoilModel = new StochasticSoilModel("Ondergrondmodel"); + PipingStochasticSoilModel stochasticSoilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("Ondergrondmodel"); stochasticSoilModel.Geometry.AddRange(new[] { new Point2D(1.0, 0.0), @@ -254,7 +256,8 @@ Action call = () => successful = importer.Import(); // Assert - const string expectedMessage = "Het stochastische ondergrondmodel 'Ondergrondmodel'doorkruist de profielschematisatie 'Profielschematisatie' niet. Berekening 'Calculation' is overgeslagen."; + const string expectedMessage = "Het stochastische ondergrondmodel 'Ondergrondmodel'doorkruist de profielschematisatie 'Profielschematisatie' niet." + + " Berekening 'Calculation' is overgeslagen."; TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1); Assert.IsTrue(successful); CollectionAssert.IsEmpty(calculationGroup.Children); @@ -277,7 +280,7 @@ new Point3D(3.0, 0.0, 1.0), new Point3D(3.0, -5.0, 0.0) }); - var stochasticSoilModel = new StochasticSoilModel("Ondergrondmodel"); + PipingStochasticSoilModel stochasticSoilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("Ondergrondmodel"); stochasticSoilModel.Geometry.AddRange(new[] { new Point2D(1.0, 0.0), @@ -304,7 +307,8 @@ Action call = () => successful = importer.Import(); // Assert - const string expectedMessage = "De ondergrondschematisatie 'Ondergrondschematisatie' bestaat niet binnen het stochastische ondergrondmodel 'Ondergrondmodel'. Berekening 'Calculation' is overgeslagen."; + const string expectedMessage = "De ondergrondschematisatie 'Ondergrondschematisatie' bestaat niet binnen het stochastische ondergrondmodel 'Ondergrondmodel'. " + + "Berekening 'Calculation' is overgeslagen."; TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1); Assert.IsTrue(successful); CollectionAssert.IsEmpty(calculationGroup.Children); @@ -328,7 +332,8 @@ Action call = () => successful = importer.Import(); // Assert - const string expectedMessage = "Er is geen stochastisch ondergrondmodel opgegeven bij ondergrondschematisatie 'Ondergrondschematisatie'. Berekening 'Calculation' is overgeslagen."; + const string expectedMessage = "Er is geen stochastisch ondergrondmodel opgegeven bij ondergrondschematisatie 'Ondergrondschematisatie'. " + + "Berekening 'Calculation' is overgeslagen."; TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1); Assert.IsTrue(successful); CollectionAssert.IsEmpty(calculationGroup.Children); @@ -356,7 +361,8 @@ Action call = () => successful = importer.Import(); // Assert - const string expectedMessage = "Er is geen profielschematisatie, maar wel een intrede- of uittredepunt opgegeven. Berekening 'Calculation' is overgeslagen."; + const string expectedMessage = "Er is geen profielschematisatie, maar wel een intrede- of uittredepunt opgegeven. " + + "Berekening 'Calculation' is overgeslagen."; TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1); Assert.IsTrue(successful); CollectionAssert.IsEmpty(calculationGroup.Children); @@ -583,15 +589,12 @@ new Point3D(3.0, 0.0, 1.0), new Point3D(3.0, -5.0, 0.0) }); - var stochasticSoilProfile = new StochasticSoilProfile(0, SoilProfileType.SoilProfile1D, 1) + var stochasticSoilProfile = new PipingStochasticSoilProfile(0, new PipingSoilProfile("Ondergrondschematisatie", 0, new[] { - SoilProfile = new PipingSoilProfile("Ondergrondschematisatie", 0, new[] - { - new PipingSoilLayer(0) - }, SoilProfileType.SoilProfile1D, 0) - }; + new PipingSoilLayer(0) + }, SoilProfileType.SoilProfile1D, 0)); - var stochasticSoilModel = new StochasticSoilModel("Ondergrondmodel"); + PipingStochasticSoilModel stochasticSoilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("Ondergrondmodel"); stochasticSoilModel.StochasticSoilProfiles.Add(stochasticSoilProfile); stochasticSoilModel.Geometry.AddRange(new[] { Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Importers/PipingStochasticSoilProfileTransformerTest.cs =================================================================== diff -u -r15ba57d868f00dfd3d6b52ac2e03a202d47d0303 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Importers/PipingStochasticSoilProfileTransformerTest.cs (.../PipingStochasticSoilProfileTransformerTest.cs) (revision 15ba57d868f00dfd3d6b52ac2e03a202d47d0303) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Importers/PipingStochasticSoilProfileTransformerTest.cs (.../PipingStochasticSoilProfileTransformerTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -24,8 +24,8 @@ using Rhino.Mocks; using Ringtoets.Common.IO.SoilProfile; using Ringtoets.Piping.Data.SoilProfile; -using Ringtoets.Piping.Data.TestUtil; using Ringtoets.Piping.IO.Importers; +using Ringtoets.Piping.KernelWrapper.TestUtil; using Ringtoets.Piping.Primitives; namespace Ringtoets.Piping.IO.Test.Importers Fisheye: Tag 26f527fb809a2325c8f883ece9da01a8f8040eb3 refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Importers/StochasticSoilModelImporterTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Ringtoets.Piping.IO.Test.csproj =================================================================== diff -u -ra5f97617cc03e3535d369676ae09179c82947b17 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Ringtoets.Piping.IO.Test.csproj (.../Ringtoets.Piping.IO.Test.csproj) (revision a5f97617cc03e3535d369676ae09179c82947b17) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Ringtoets.Piping.IO.Test.csproj (.../Ringtoets.Piping.IO.Test.csproj) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -88,10 +88,7 @@ - - - @@ -150,9 +147,9 @@ {955E574D-67CE-4347-AA6B-7DF8A04ED754} Ringtoets.Piping.Data.TestUtil - - {4A675B7E-96AD-4911-B154-85385C9330C3} - Ringtoets.Piping.IO.TestUtil + + {27E0A5C9-3ABF-426A-A3DA-7D0B83A218C8} + Ringtoets.Piping.KernelWrapper.TestUtil Fisheye: Tag 26f527fb809a2325c8f883ece9da01a8f8040eb3 refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/StochasticSoilModelReaderTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 26f527fb809a2325c8f883ece9da01a8f8040eb3 refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/StochasticSoilProfileReaderTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.TestUtil.Test/Ringtoets.Piping.IO.TestUtil.Test.csproj =================================================================== diff -u -r320aceee6e754aa37aa80a80b371a0150cbf2496 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.IO.TestUtil.Test/Ringtoets.Piping.IO.TestUtil.Test.csproj (.../Ringtoets.Piping.IO.TestUtil.Test.csproj) (revision 320aceee6e754aa37aa80a80b371a0150cbf2496) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.TestUtil.Test/Ringtoets.Piping.IO.TestUtil.Test.csproj (.../Ringtoets.Piping.IO.TestUtil.Test.csproj) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -53,7 +53,6 @@ Properties\GlobalAssembly.cs - @@ -66,6 +65,14 @@ {3BBFD65B-B277-4E50-AE6D-BD24C3434609} Core.Common.Base + + {d4200f43-3f72-4f42-af0a-8ced416a38ec} + Ringtoets.Common.Data + + + {52BA7627-CBAB-4209-BE77-3B5F31378277} + Ringtoets.Common.IO + {CE994CC9-6F6A-48AC-B4BE-02C30A21F4DB} Ringtoets.Piping.Data Fisheye: Tag 26f527fb809a2325c8f883ece9da01a8f8040eb3 refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.IO.TestUtil.Test/TestStochasticSoilModelUpdateModelStrategyTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.TestUtil/Ringtoets.Piping.IO.TestUtil.csproj =================================================================== diff -u -rfc2878b0779c6ae4c80720910ea9fbb1b3694420 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.IO.TestUtil/Ringtoets.Piping.IO.TestUtil.csproj (.../Ringtoets.Piping.IO.TestUtil.csproj) (revision fc2878b0779c6ae4c80720910ea9fbb1b3694420) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.TestUtil/Ringtoets.Piping.IO.TestUtil.csproj (.../Ringtoets.Piping.IO.TestUtil.csproj) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -49,7 +49,6 @@ Properties\GlobalAssembly.cs - @@ -61,6 +60,14 @@ {3bbfd65b-b277-4e50-ae6d-bd24c3434609} Core.Common.Base + + {d4200f43-3f72-4f42-af0a-8ced416a38ec} + Ringtoets.Common.Data + + + {52BA7627-CBAB-4209-BE77-3B5F31378277} + Ringtoets.Common.IO + {ce994cc9-6f6a-48ac-b4be-02c30a21f4db} Ringtoets.Piping.Data Fisheye: Tag 26f527fb809a2325c8f883ece9da01a8f8040eb3 refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.IO.TestUtil/TestStochasticSoilModelUpdateModelStrategy.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/test/Ringtoets.Piping.InputParameterCalculation.Test/InputParameterCalculationServiceTest.cs =================================================================== diff -u -rd6fe8399e8398224cf1bda9259052232d85b85a4 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.InputParameterCalculation.Test/InputParameterCalculationServiceTest.cs (.../InputParameterCalculationServiceTest.cs) (revision d6fe8399e8398224cf1bda9259052232d85b85a4) +++ Ringtoets/Piping/test/Ringtoets.Piping.InputParameterCalculation.Test/InputParameterCalculationServiceTest.cs (.../InputParameterCalculationServiceTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -22,15 +22,17 @@ using System.Linq; using Core.Common.Base.Data; using Core.Common.Base.Geometry; -using Deltares.WTIPiping; using NUnit.Framework; using Ringtoets.Common.Data.TestUtil; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Data.TestUtil; using Ringtoets.Piping.KernelWrapper.SubCalculator; using Ringtoets.Piping.KernelWrapper.TestUtil.SubCalculator; using Ringtoets.Piping.Primitives; -using PipingSurfaceLine = Ringtoets.Piping.Primitives.PipingSurfaceLine; +using WTIPipingSurfaceLine = Deltares.WTIPiping.PipingSurfaceLine; +using WTIPipingPoint = Deltares.WTIPiping.PipingPoint; +using WTIPipingProfile = Deltares.WTIPiping.PipingProfile; namespace Ringtoets.Piping.InputParameterCalculation.Test { @@ -47,24 +49,24 @@ double highestLevelSurfaceLine = invalidPipingCalculation.InputParameters.SurfaceLine.Points.Max(p => p.Z); double soilProfileTop = highestLevelSurfaceLine - 0.5; double soilProfileBottom = soilProfileTop - 0.5; - invalidPipingCalculation.InputParameters.StochasticSoilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) - { - SoilProfile = new PipingSoilProfile("A", soilProfileBottom, new[] + invalidPipingCalculation.InputParameters.StochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, + new PipingSoilProfile("A", soilProfileBottom, new[] { new PipingSoilLayer(soilProfileTop) { IsAquifer = true } - }, SoilProfileType.SoilProfile1D, 0) - }; + }, SoilProfileType.SoilProfile1D, 0)); // Call PipingInput input = invalidPipingCalculation.InputParameters; - double result = InputParameterCalculationService.CalculateEffectiveThicknessCoverageLayer(input.WaterVolumetricWeight, - PipingSemiProbabilisticDesignValueFactory.GetPhreaticLevelExit(input).GetDesignValue(), - input.ExitPointL, - input.SurfaceLine, - input.StochasticSoilProfile.SoilProfile); + double result = InputParameterCalculationService.CalculateEffectiveThicknessCoverageLayer( + input.WaterVolumetricWeight, + PipingSemiProbabilisticDesignValueFactory.GetPhreaticLevelExit(input).GetDesignValue(), + input.ExitPointL, + input.SurfaceLine, + input.StochasticSoilProfile.SoilProfile); // Assert Assert.IsNaN(result); @@ -87,9 +89,8 @@ surfaceLine.SetBottomDitchDikeSideAt(surfaceLine.Points[1]); surfaceLine.SetDitchPolderSideAt(surfaceLine.Points[1]); - var stochasticSoilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) - { - SoilProfile = new PipingSoilProfile(string.Empty, 0, new[] + var stochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile(string.Empty, 0, new[] { new PipingSoilLayer(5) { @@ -99,8 +100,7 @@ { IsAquifer = false } - }, SoilProfileType.SoilProfile1D, 0) - }; + }, SoilProfileType.SoilProfile1D, 0)); var input = new PipingInput(new GeneralPipingInput()) { @@ -132,9 +132,8 @@ new Point3D(20, 0, 10) }); - var stochasticSoilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) - { - SoilProfile = new PipingSoilProfile(string.Empty, 0, new[] + var stochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile(string.Empty, 0, new[] { new PipingSoilLayer(5) { @@ -144,8 +143,7 @@ { IsAquifer = false } - }, SoilProfileType.SoilProfile1D, 0) - }; + }, SoilProfileType.SoilProfile1D, 0)); var input = new PipingInput(new GeneralPipingInput()) { @@ -247,7 +245,7 @@ } } - private static void AssertEqualSurfaceLines(PipingSurfaceLine pipingSurfaceLine, Deltares.WTIPiping.PipingSurfaceLine otherSurfaceLine) + private static void AssertEqualSurfaceLines(PipingSurfaceLine pipingSurfaceLine, WTIPipingSurfaceLine otherSurfaceLine) { AssertPointsAreEqual(pipingSurfaceLine.DitchDikeSide, otherSurfaceLine.DitchDikeSide); AssertPointsAreEqual(pipingSurfaceLine.BottomDitchDikeSide, otherSurfaceLine.BottomDitchDikeSide); @@ -262,7 +260,7 @@ } } - private static void AssertPointsAreEqual(Point3D point, PipingPoint otherPoint) + private static void AssertPointsAreEqual(Point3D point, WTIPipingPoint otherPoint) { if (point == null) { @@ -278,7 +276,7 @@ Assert.AreEqual(point.Z, otherPoint.Z, 1e-2); } - private static void AssertEqualSoilProfiles(PipingSoilProfile pipingProfile, PipingProfile otherPipingProfile) + private static void AssertEqualSoilProfiles(PipingSoilProfile pipingProfile, WTIPipingProfile otherPipingProfile) { Assert.AreEqual(pipingProfile.Bottom, otherPipingProfile.BottomLevel); Assert.AreEqual(pipingProfile.Layers.First().Top, otherPipingProfile.TopLevel); Fisheye: Tag 26f527fb809a2325c8f883ece9da01a8f8040eb3 refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Integration.Test/ImportSoilProfileFromDatabaseTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/test/Ringtoets.Piping.Integration.Test/PipingCalculationsViewIntegrationTest.cs =================================================================== diff -u -r81fa8a9bf3bd503cbd280e88b8f6037a840cff12 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Integration.Test/PipingCalculationsViewIntegrationTest.cs (.../PipingCalculationsViewIntegrationTest.cs) (revision 81fa8a9bf3bd503cbd280e88b8f6037a840cff12) +++ Ringtoets/Piping/test/Ringtoets.Piping.Integration.Test/PipingCalculationsViewIntegrationTest.cs (.../PipingCalculationsViewIntegrationTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -31,6 +31,7 @@ using Ringtoets.Integration.Data; using Ringtoets.Integration.TestUtils; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Forms.Views; namespace Ringtoets.Piping.Integration.Test @@ -98,7 +99,7 @@ // Import soil models and profiles and ensure the corresponding combobox items are updated DataImportHelper.ImportPipingStochasticSoilModels(assessmentSection); - StochasticSoilModelCollection stochasticSoilModelCollection = assessmentSection.PipingFailureMechanism.StochasticSoilModels; + PipingStochasticSoilModelCollection stochasticSoilModelCollection = assessmentSection.PipingFailureMechanism.StochasticSoilModels; pipingCalculation1.InputParameters.StochasticSoilModel = stochasticSoilModelCollection.First(sl => sl.Name == "PK001_0001_Piping"); Assert.AreEqual(1, ((DataGridViewComboBoxCell) dataGridView.Rows[0].Cells[stochasticSoilModelsColumnIndex]).Items.Count); Assert.AreEqual("PK001_0001_Piping", dataGridView.Rows[0].Cells[stochasticSoilModelsColumnIndex].FormattedValue); Index: Ringtoets/Piping/test/Ringtoets.Piping.Integration.Test/Ringtoets.Piping.Integration.Test.csproj =================================================================== diff -u -r08b3bcba439831d547684b194ecdf903f2519700 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Integration.Test/Ringtoets.Piping.Integration.Test.csproj (.../Ringtoets.Piping.Integration.Test.csproj) (revision 08b3bcba439831d547684b194ecdf903f2519700) +++ Ringtoets/Piping/test/Ringtoets.Piping.Integration.Test/Ringtoets.Piping.Integration.Test.csproj (.../Ringtoets.Piping.Integration.Test.csproj) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -66,7 +66,6 @@ - Index: Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.TestUtil.Test/PipingSoilProfileTestFactoryTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.TestUtil.Test/PipingSoilProfileTestFactoryTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.TestUtil.Test/PipingSoilProfileTestFactoryTest.cs (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -0,0 +1,101 @@ +// Copyright (C) Stichting Deltares 2017. 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 Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.Piping.Primitives; + +namespace Ringtoets.Piping.KernelWrapper.TestUtil.Test +{ + [TestFixture] + public class PipingSoilProfileTestFactoryTest + { + [Test] + public void CreatePipingSoilProfile_ReturnsPipingSoilProfile() + { + // Call + PipingSoilProfile soilProfile = PipingSoilProfileTestFactory.CreatePipingSoilProfile(); + + // Assert + Assert.AreEqual("name", soilProfile.Name); + Assert.AreEqual(0, soilProfile.Bottom); + Assert.AreEqual(SoilProfileType.SoilProfile1D, soilProfile.SoilProfileType); + + var expectedLayer = new PipingSoilLayer(1.0); + Assert.AreEqual(1, soilProfile.Layers.Count()); + AssertAreEqual(expectedLayer, soilProfile.Layers.Single()); + } + + [Test] + public void CreatePipingSoilProfileWithName_ReturnsPipingSoilProfile() + { + // Setup + const string name = "Some name"; + + // Call + PipingSoilProfile soilProfile = PipingSoilProfileTestFactory.CreatePipingSoilProfile(name); + + // Assert + Assert.AreEqual(name, soilProfile.Name); + Assert.AreEqual(0, soilProfile.Bottom); + Assert.AreEqual(SoilProfileType.SoilProfile1D, soilProfile.SoilProfileType); + + var expectedLayer = new PipingSoilLayer(1.0); + Assert.AreEqual(1, soilProfile.Layers.Count()); + AssertAreEqual(expectedLayer, soilProfile.Layers.Single()); + } + + [Test] + public void CreatePipingSoilProfileWithNameAndType_ReturnsPipingSoilProfile() + { + // Setup + const string name = "Some name"; + var type = new Random(123).NextEnumValue(); + + // Call + PipingSoilProfile soilProfile = PipingSoilProfileTestFactory.CreatePipingSoilProfile(name, type); + + // Assert + Assert.AreEqual(name, soilProfile.Name); + Assert.AreEqual(0, soilProfile.Bottom); + Assert.AreEqual(type, soilProfile.SoilProfileType); + + var expectedLayer = new PipingSoilLayer(1.0); + Assert.AreEqual(1, soilProfile.Layers.Count()); + AssertAreEqual(expectedLayer, soilProfile.Layers.Single()); + } + + private static void AssertAreEqual(PipingSoilLayer expected, PipingSoilLayer actual) + { + Assert.AreEqual(expected.Top, actual.Top); + Assert.AreEqual(expected.MaterialName, actual.MaterialName); + Assert.AreEqual(expected.BelowPhreaticLevelMean, actual.BelowPhreaticLevelMean); + Assert.AreEqual(expected.BelowPhreaticLevelDeviation, actual.BelowPhreaticLevelDeviation); + Assert.AreEqual(expected.BelowPhreaticLevelShift, actual.BelowPhreaticLevelShift); + Assert.AreEqual(expected.DiameterD70Mean, actual.DiameterD70Mean); + Assert.AreEqual(expected.DiameterD70CoefficientOfVariation, actual.DiameterD70CoefficientOfVariation); + Assert.AreEqual(expected.PermeabilityMean, actual.PermeabilityMean); + Assert.AreEqual(expected.PermeabilityCoefficientOfVariation, actual.PermeabilityCoefficientOfVariation); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.TestUtil.Test/Ringtoets.Piping.KernelWrapper.TestUtil.Test.csproj =================================================================== diff -u -r5906f61fff270a7526253bea07dfecdf680898ed -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.TestUtil.Test/Ringtoets.Piping.KernelWrapper.TestUtil.Test.csproj (.../Ringtoets.Piping.KernelWrapper.TestUtil.Test.csproj) (revision 5906f61fff270a7526253bea07dfecdf680898ed) +++ Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.TestUtil.Test/Ringtoets.Piping.KernelWrapper.TestUtil.Test.csproj (.../Ringtoets.Piping.KernelWrapper.TestUtil.Test.csproj) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -51,6 +51,7 @@ Properties\GlobalAssembly.cs + Index: Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.TestUtil/PipingSoilProfileTestFactory.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.TestUtil/PipingSoilProfileTestFactory.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.TestUtil/PipingSoilProfileTestFactory.cs (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -0,0 +1,74 @@ +// Copyright (C) Stichting Deltares 2017. 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 Ringtoets.Piping.Primitives; + +namespace Ringtoets.Piping.KernelWrapper.TestUtil +{ + /// + /// Factory to create simple instances that can be used for testing. + /// + public static class PipingSoilProfileTestFactory + { + /// + /// Creates a new instance of with arbitrary values. + /// + /// The name to set for the . + /// The created . + public static PipingSoilProfile CreatePipingSoilProfile(string name) + { + return CreatePipingSoilProfile(name, SoilProfileType.SoilProfile1D); + } + + /// + /// Creates a new instance of with arbitrary values. + /// + /// The created . + public static PipingSoilProfile CreatePipingSoilProfile() + { + return CreatePipingSoilProfile("name"); + } + + /// + /// Creates a new instance of that has: + /// + /// set to + /// set to 0.0 + /// set to a collection with a single + /// with set to 0.0. + /// set to . + /// + /// + /// The name for the profile. + /// The type of the profile. + /// The created . + public static PipingSoilProfile CreatePipingSoilProfile(string name, SoilProfileType soilProfileType) + { + return new PipingSoilProfile(name, 0.0, new[] + { + new PipingSoilLayer(1.0) + { + IsAquifer = true + } + }, soilProfileType, 0L); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.TestUtil/Ringtoets.Piping.KernelWrapper.TestUtil.csproj =================================================================== diff -u -re70ec50a6371d80781c51e5266226ab58b4d4b15 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.TestUtil/Ringtoets.Piping.KernelWrapper.TestUtil.csproj (.../Ringtoets.Piping.KernelWrapper.TestUtil.csproj) (revision e70ec50a6371d80781c51e5266226ab58b4d4b15) +++ Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.TestUtil/Ringtoets.Piping.KernelWrapper.TestUtil.csproj (.../Ringtoets.Piping.KernelWrapper.TestUtil.csproj) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -51,6 +51,7 @@ Properties\GlobalAssembly.cs + Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ExportInfos/PipingCalculationContextExportInfoTest.cs =================================================================== diff -u -r8b60c9e846480f3ffeeb263bfea5d3367bf6bee3 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ExportInfos/PipingCalculationContextExportInfoTest.cs (.../PipingCalculationContextExportInfoTest.cs) (revision 8b60c9e846480f3ffeeb263bfea5d3367bf6bee3) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ExportInfos/PipingCalculationContextExportInfoTest.cs (.../PipingCalculationContextExportInfoTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -29,6 +29,7 @@ using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Calculation; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Forms.PresentationObjects; using Ringtoets.Piping.IO.Configurations; using Ringtoets.Piping.Primitives; @@ -69,7 +70,7 @@ var context = new PipingCalculationScenarioContext(new PipingCalculationScenario(new GeneralPipingInput()), new CalculationGroup(), Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), new PipingFailureMechanism(), assessmentSection); @@ -113,7 +114,7 @@ var context = new PipingCalculationScenarioContext(new PipingCalculationScenario(new GeneralPipingInput()), new CalculationGroup(), Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), new PipingFailureMechanism(), assessmentSection); Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ExportInfos/PipingCalculationGroupContextExportInfoTest.cs =================================================================== diff -u -r8b60c9e846480f3ffeeb263bfea5d3367bf6bee3 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ExportInfos/PipingCalculationGroupContextExportInfoTest.cs (.../PipingCalculationGroupContextExportInfoTest.cs) (revision 8b60c9e846480f3ffeeb263bfea5d3367bf6bee3) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ExportInfos/PipingCalculationGroupContextExportInfoTest.cs (.../PipingCalculationGroupContextExportInfoTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -29,6 +29,7 @@ using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Calculation; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Forms.PresentationObjects; using Ringtoets.Piping.IO.Configurations; using Ringtoets.Piping.Primitives; @@ -69,7 +70,7 @@ var context = new PipingCalculationGroupContext(new CalculationGroup(), null, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), new PipingFailureMechanism(), assessmentSection); @@ -113,7 +114,7 @@ var context = new PipingCalculationGroupContext(new CalculationGroup(), null, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), new PipingFailureMechanism(), assessmentSection); @@ -155,7 +156,7 @@ var context = new PipingCalculationGroupContext(calculationGroup, null, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), new PipingFailureMechanism(), assessmentSection); Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingStochasticSoilModelReplaceDataStrategyTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingStochasticSoilModelReplaceDataStrategyTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingStochasticSoilModelReplaceDataStrategyTest.cs (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -0,0 +1,230 @@ +// Copyright (C) Stichting Deltares 2017. 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 System.Linq; +using Core.Common.Base; +using NUnit.Framework; +using Ringtoets.Common.Data.Exceptions; +using Ringtoets.Common.Data.UpdateDataStrategies; +using Ringtoets.Common.IO.SoilProfile; +using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; +using Ringtoets.Piping.Data.TestUtil; +using Ringtoets.Piping.Plugin.FileImporter; + +namespace Ringtoets.Piping.Plugin.Test.FileImporter +{ + [TestFixture] + public class PipingStochasticSoilModelReplaceDataStrategyTest + { + private const string sourceFilePath = "path"; + + [Test] + public void Constructor_WithoutCalculations_CreatesNewInstance() + { + // Call + TestDelegate test = () => new PipingStochasticSoilModelReplaceDataStrategy(null); + + // Assert + string paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("failureMechanism", paramName); + } + + [Test] + public void Constructor_WithCalculations_CreatesNewInstance() + { + // Call + var strategy = new PipingStochasticSoilModelReplaceDataStrategy(new PipingFailureMechanism()); + + // Assert + Assert.IsInstanceOf>(strategy); + Assert.IsInstanceOf>(strategy); + } + + [Test] + public void UpdateModelWithImportedData_ReadStochasticSoilModelsNull_ThrowsArgumentNullException() + { + // Setup + var strategy = new PipingStochasticSoilModelReplaceDataStrategy(new PipingFailureMechanism()); + + // Call + TestDelegate test = () => strategy.UpdateModelWithImportedData(null, string.Empty); + + // Assert + string paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("importedDataCollection", paramName); + } + + [Test] + public void UpdateModelWithImportedData_SourceFilePathNull_ThrowsArgumentNullException() + { + // Setup + var strategy = new PipingStochasticSoilModelReplaceDataStrategy(new PipingFailureMechanism()); + + // Call + TestDelegate test = () => strategy.UpdateModelWithImportedData(new List(), null); + + // Assert + string paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("sourceFilePath", paramName); + } + + [Test] + public void UpdateModelWithImportedData_WithoutCurrentModelAndModelsImported_NewModelsAdded() + { + // Setup + var importedStochasticSoilModels = new[] + { + PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("A"), + PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("B") + }; + var pipingFailureMechanism = new PipingFailureMechanism(); + pipingFailureMechanism.StochasticSoilModels.AddRange(importedStochasticSoilModels, sourceFilePath); + var strategy = new PipingStochasticSoilModelReplaceDataStrategy(pipingFailureMechanism); + + // Call + IEnumerable affectedObjects = strategy.UpdateModelWithImportedData(importedStochasticSoilModels, + "path"); + + // Assert + CollectionAssert.AreEqual(importedStochasticSoilModels, pipingFailureMechanism.StochasticSoilModels); + CollectionAssert.AreEqual(new[] + { + pipingFailureMechanism.StochasticSoilModels + }, affectedObjects); + } + + [Test] + public void UpdateModelWithImportedData_WithCurrentModelsAndImportedDataEmpty_ModelsRemoved() + { + // Setup + var failureMechanism = new PipingFailureMechanism(); + failureMechanism.StochasticSoilModels.AddRange(new[] + { + PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("A"), + PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("B") + }, sourceFilePath); + + var strategy = new PipingStochasticSoilModelReplaceDataStrategy(failureMechanism); + + // Call + IEnumerable affectedObjects = strategy.UpdateModelWithImportedData(new List(), sourceFilePath); + + // Assert + CollectionAssert.IsEmpty(failureMechanism.StochasticSoilModels); + CollectionAssert.AreEqual(new[] + { + failureMechanism.StochasticSoilModels + }, affectedObjects); + } + + [Test] + public void UpdateModelWithImportedData_WithCurrentModelAndImportedModel_ModelReplaced() + { + // Setup + PipingStochasticSoilModel existingModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("existing"); + + var pipingFailureMechanism = new PipingFailureMechanism(); + pipingFailureMechanism.StochasticSoilModels.AddRange(new[] + { + existingModel + }, sourceFilePath); + var strategy = new PipingStochasticSoilModelReplaceDataStrategy(pipingFailureMechanism); + PipingStochasticSoilModel readModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("read"); + + // Call + IEnumerable affectedObjects = strategy.UpdateModelWithImportedData(new[] + { + readModel + }, sourceFilePath); + + // Assert + Assert.AreSame(readModel, pipingFailureMechanism.StochasticSoilModels[0]); + CollectionAssert.AreEqual(new[] + { + pipingFailureMechanism.StochasticSoilModels + }, affectedObjects); + } + + [Test] + public void UpdateModelWithImportedData_CalculationWithOutputAssignedRemovedSoilModelAndProfile_CalculationUpdatedAndCalculationAndInputReturned() + { + // Setup + PipingStochasticSoilModel existingModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(); + var calculation = new PipingCalculationScenario(new GeneralPipingInput()) + { + InputParameters = + { + StochasticSoilModel = existingModel, + StochasticSoilProfile = existingModel.StochasticSoilProfiles[0] + }, + Output = new PipingOutput(new PipingOutput.ConstructionProperties()) + }; + + var failureMechanism = new PipingFailureMechanism(); + failureMechanism.CalculationsGroup.Children.Add(calculation); + + var strategy = new PipingStochasticSoilModelReplaceDataStrategy(failureMechanism); + + var targetCollection = new PipingStochasticSoilModelCollection(); + targetCollection.AddRange(new[] + { + existingModel + }, sourceFilePath); + + // Call + IEnumerable affectedObjects = strategy.UpdateModelWithImportedData(new List(), sourceFilePath).ToArray(); + + // Assert + Assert.IsFalse(calculation.HasOutput); + Assert.IsNull(calculation.InputParameters.StochasticSoilModel); + Assert.IsNull(calculation.InputParameters.StochasticSoilProfile); + CollectionAssert.AreEquivalent(new IObservable[] + { + calculation, + calculation.InputParameters, + failureMechanism.StochasticSoilModels + }, affectedObjects); + } + + [Test] + public void UpdateModelWithImportedData_ImportedModelsContainDuplicateNames_ThrowsUpdateDataException() + { + // Setup + var importedStochasticSoilModels = new[] + { + PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("B"), + PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("B") + }; + var strategy = new PipingStochasticSoilModelReplaceDataStrategy(new PipingFailureMechanism()); + + // Call + TestDelegate test = () => strategy.UpdateModelWithImportedData(importedStochasticSoilModels, "path"); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("Stochastische ondergrondmodellen moeten een unieke naam hebben. " + + "Gevonden dubbele elementen: B.", exception.Message); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingStochasticSoilModelUpdateDataStrategyTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingStochasticSoilModelUpdateDataStrategyTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingStochasticSoilModelUpdateDataStrategyTest.cs (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -0,0 +1,499 @@ +// Copyright (C) Stichting Deltares 2017. 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 System.Linq; +using Core.Common.Base; +using NUnit.Framework; +using Ringtoets.Common.Data.Exceptions; +using Ringtoets.Common.Data.UpdateDataStrategies; +using Ringtoets.Common.IO.SoilProfile; +using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; +using Ringtoets.Piping.Data.TestUtil; +using Ringtoets.Piping.KernelWrapper.TestUtil; +using Ringtoets.Piping.Plugin.FileImporter; +using Ringtoets.Piping.Primitives; + +namespace Ringtoets.Piping.Plugin.Test.FileImporter +{ + [TestFixture] + public class PipingStochasticSoilModelUpdateDataStrategyTest + { + private const string sourceFilePath = "path"; + + [Test] + public void Constructor_WithoutCalculations_CreatesNewInstance() + { + // Call + TestDelegate test = () => new PipingStochasticSoilModelUpdateDataStrategy(null); + + // Assert + string paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("failureMechanism", paramName); + } + + [Test] + public void Constructor_WithCalculations_CreatesNewInstance() + { + // Call + var strategy = new PipingStochasticSoilModelUpdateDataStrategy(new PipingFailureMechanism()); + + // Assert + Assert.IsInstanceOf>(strategy); + Assert.IsInstanceOf>(strategy); + } + + [Test] + public void UpdateModelWithImportedData_ReadStochasticSoilModelsNull_ThrowsArgumentNullException() + { + // Setup + var strategy = new PipingStochasticSoilModelUpdateDataStrategy(new PipingFailureMechanism()); + + // Call + TestDelegate test = () => strategy.UpdateModelWithImportedData(null, string.Empty); + + // Assert + string paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("importedDataCollection", paramName); + } + + [Test] + public void UpdateModelWithImportedData_SourceFilePathNull_ThrowsArgumentNullException() + { + // Setup + var strategy = new PipingStochasticSoilModelUpdateDataStrategy(new PipingFailureMechanism()); + + // Call + TestDelegate test = () => strategy.UpdateModelWithImportedData(new List(), null); + + // Assert + string paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("sourceFilePath", paramName); + } + + [Test] + public void UpdateModelWithImportedData_WithCurrentModelsAndImportedMultipleModelsWithSameName_ThrowsUpdateDataException() + { + // Setup + const string nonUniqueName = "non-unique name"; + + var targetCollection = new PipingStochasticSoilModelCollection(); + targetCollection.AddRange(new[] + { + PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(nonUniqueName) + }, sourceFilePath); + + var strategy = new PipingStochasticSoilModelUpdateDataStrategy(new PipingFailureMechanism()); + var importedStochasticSoilModels = new[] + { + PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(nonUniqueName), + PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(nonUniqueName) + }; + + // Call + TestDelegate test = () => strategy.UpdateModelWithImportedData(importedStochasticSoilModels, sourceFilePath); + + // Assert + var exception = Assert.Throws(test); + const string expectedMessage = "Geïmporteerde data moet unieke elementen bevatten."; + Assert.AreEqual(expectedMessage, exception.Message); + } + + [Test] + public void UpdateModelWithImportedData_WithoutCurrentModelsAndImportedMultipleModelsWithSameName_ThrowsUpdateDataException() + { + // Setup + const string nonUniqueName = "non-unique name"; + + var targetCollection = new PipingStochasticSoilModelCollection(); + + var strategy = new PipingStochasticSoilModelUpdateDataStrategy(new PipingFailureMechanism()); + var importedStochasticSoilModels = new[] + { + PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(nonUniqueName), + PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(nonUniqueName) + }; + + // Call + TestDelegate test = () => strategy.UpdateModelWithImportedData(importedStochasticSoilModels, sourceFilePath); + + // Assert + var exception = Assert.Throws(test); + const string expectedMessage = "Geïmporteerde data moet unieke elementen bevatten."; + Assert.AreEqual(expectedMessage, exception.Message); + + CollectionAssert.IsEmpty(targetCollection); + } + + [Test] + public void UpdateModelWithImportedData_WithoutCurrentModelAndNoImportedModels_NoChangeNoNotification() + { + // Setup + var strategy = new PipingStochasticSoilModelUpdateDataStrategy(new PipingFailureMechanism()); + var targetCollection = new PipingStochasticSoilModelCollection(); + + // Call + IEnumerable affectedObjects = strategy.UpdateModelWithImportedData(Enumerable.Empty(), "path"); + + // Assert + CollectionAssert.IsEmpty(targetCollection); + CollectionAssert.IsEmpty(affectedObjects); + } + + [Test] + public void UpdateModelWithImportedData_WithCurrentModelAndImportedModelWithOtherName_ModelReplaced() + { + // Setup + PipingStochasticSoilModel existingModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("existing"); + + var pipingFailureMechanism = new PipingFailureMechanism(); + pipingFailureMechanism.StochasticSoilModels.AddRange(new[] + { + existingModel + }, sourceFilePath); + var strategy = new PipingStochasticSoilModelUpdateDataStrategy(pipingFailureMechanism); + PipingStochasticSoilModel readModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("read"); + + // Call + IEnumerable affectedObjects = strategy.UpdateModelWithImportedData(new[] + { + readModel + }, sourceFilePath); + + // Assert + Assert.AreSame(readModel, pipingFailureMechanism.StochasticSoilModels[0]); + CollectionAssert.AreEqual(new[] + { + pipingFailureMechanism.StochasticSoilModels + }, affectedObjects); + } + + [Test] + public void UpdateModelWithImportedData_WithCurrentModelAndImportedModelWithSameName_ModelUpdated() + { + // Setup + const string modelsName = "same model"; + PipingStochasticSoilModel existingModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(modelsName); + + var failureMechanism = new PipingFailureMechanism(); + PipingStochasticSoilModelCollection targetCollection = failureMechanism.StochasticSoilModels; + targetCollection.AddRange(new[] + { + existingModel + }, sourceFilePath); + + var strategy = new PipingStochasticSoilModelUpdateDataStrategy(failureMechanism); + PipingStochasticSoilModel readModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(modelsName); + + // Call + IEnumerable affectedObjects = strategy.UpdateModelWithImportedData(new[] + { + readModel + }, sourceFilePath); + + // Assert + Assert.AreEqual(1, targetCollection.Count); + Assert.AreSame(existingModel, targetCollection[0]); + CollectionAssert.AreEquivalent(new IObservable[] + { + targetCollection, + existingModel + }, affectedObjects); + } + + [Test] + public void UpdateModelWithImportedData_UpdateCurrentModelWithImportedModelWithOtherProfiles_ProfilesAdded() + { + // Setup + const string modelsName = "same model"; + PipingStochasticSoilModel existingModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(modelsName); + + var failureMechanism = new PipingFailureMechanism(); + PipingStochasticSoilModelCollection targetCollection = failureMechanism.StochasticSoilModels; + targetCollection.AddRange(new[] + { + existingModel + }, sourceFilePath); + + var strategy = new PipingStochasticSoilModelUpdateDataStrategy(failureMechanism); + PipingStochasticSoilModel readModel = CreateSimpleModel(modelsName, "new profile A", "new profile B"); + + // Call + IEnumerable affectedObjects = strategy.UpdateModelWithImportedData(new[] + { + readModel + }, sourceFilePath); + + // Assert + Assert.AreEqual(1, targetCollection.Count); + Assert.AreSame(existingModel, targetCollection[0]); + Assert.AreEqual(2, targetCollection[0].StochasticSoilProfiles.Count); + CollectionAssert.AreEquivalent(new IObservable[] + { + targetCollection, + existingModel + }, affectedObjects); + } + + [Test] + public void UpdateModelWithImportedData_ProfilesAssignedToCalculationsWithOneImportedModelProfileRemoved_OneProfileRemovedCalculationUpdatedAccordingly() + { + // Setup + const string modelsName = "same model"; + PipingStochasticSoilModel existingModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(modelsName); + + var failureMechanism = new PipingFailureMechanism(); + PipingStochasticSoilModelCollection targetCollection = failureMechanism.StochasticSoilModels; + targetCollection.AddRange(new[] + { + existingModel + }, sourceFilePath); + + PipingStochasticSoilProfile firstExistingProfile = existingModel.StochasticSoilProfiles[0]; + PipingStochasticSoilModel readModel = CreateSimpleModel(modelsName, firstExistingProfile.SoilProfile.Name); + + var calculationWithNotUpdatedProfile = new PipingCalculationScenario(new GeneralPipingInput()); + calculationWithNotUpdatedProfile.InputParameters.StochasticSoilModel = existingModel; + calculationWithNotUpdatedProfile.InputParameters.StochasticSoilProfile = existingModel.StochasticSoilProfiles[0]; + calculationWithNotUpdatedProfile.Output = new PipingOutput(new PipingOutput.ConstructionProperties()); + + var calculationWithDeletedProfile = new PipingCalculationScenario(new GeneralPipingInput()); + calculationWithDeletedProfile.InputParameters.StochasticSoilModel = existingModel; + calculationWithDeletedProfile.InputParameters.StochasticSoilProfile = existingModel.StochasticSoilProfiles[1]; + calculationWithDeletedProfile.Output = new PipingOutput(new PipingOutput.ConstructionProperties()); + + failureMechanism.CalculationsGroup.Children.Add(calculationWithDeletedProfile); + failureMechanism.CalculationsGroup.Children.Add(calculationWithNotUpdatedProfile); + + var strategy = new PipingStochasticSoilModelUpdateDataStrategy(failureMechanism); + + // Call + IEnumerable affectedObjects = strategy.UpdateModelWithImportedData(new[] + { + readModel + }, sourceFilePath).ToArray(); + + // Assert + PipingStochasticSoilModel firstSoilModel = targetCollection[0]; + Assert.AreSame(existingModel, firstSoilModel); + Assert.AreEqual(1, firstSoilModel.StochasticSoilProfiles.Count); + Assert.AreSame(firstExistingProfile, firstSoilModel.StochasticSoilProfiles[0]); + + Assert.IsTrue(calculationWithNotUpdatedProfile.HasOutput); + CollectionAssert.DoesNotContain(affectedObjects, calculationWithNotUpdatedProfile); + CollectionAssert.DoesNotContain(affectedObjects, calculationWithNotUpdatedProfile.InputParameters); + + Assert.IsFalse(calculationWithDeletedProfile.HasOutput); + Assert.IsNull(calculationWithDeletedProfile.InputParameters.StochasticSoilProfile); + CollectionAssert.Contains(affectedObjects, calculationWithDeletedProfile); + CollectionAssert.Contains(affectedObjects, calculationWithDeletedProfile.InputParameters); + } + + [Test] + public void UpdateModelWithImportedData_ProfilesAssignedToCalculationsOneWithNoChangeInProfile_OnlyCalculationWithChangedProfileUpdated() + { + // Setup + const string modelsName = "same model"; + PipingStochasticSoilModel existingModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(modelsName); + + var failureMechanism = new PipingFailureMechanism(); + PipingStochasticSoilModelCollection targetCollection = failureMechanism.StochasticSoilModels; + targetCollection.AddRange(new[] + { + existingModel + }, sourceFilePath); + + PipingStochasticSoilModel readModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(modelsName); + PipingStochasticSoilProfile changedProfile = CloneAndSlightlyModify(readModel.StochasticSoilProfiles.ElementAt(0)); + readModel.StochasticSoilProfiles[0] = changedProfile; + + var calculationWithUpdatedProfile = new PipingCalculationScenario(new GeneralPipingInput()); + calculationWithUpdatedProfile.InputParameters.StochasticSoilModel = existingModel; + calculationWithUpdatedProfile.InputParameters.StochasticSoilProfile = existingModel.StochasticSoilProfiles[0]; + calculationWithUpdatedProfile.Output = new PipingOutput(new PipingOutput.ConstructionProperties()); + + var calculationWithNotUpdatedProfile = new PipingCalculationScenario(new GeneralPipingInput()); + calculationWithNotUpdatedProfile.InputParameters.StochasticSoilModel = existingModel; + calculationWithNotUpdatedProfile.InputParameters.StochasticSoilProfile = existingModel.StochasticSoilProfiles[1]; + calculationWithNotUpdatedProfile.Output = new PipingOutput(new PipingOutput.ConstructionProperties()); + + failureMechanism.CalculationsGroup.Children.Add(calculationWithNotUpdatedProfile); + failureMechanism.CalculationsGroup.Children.Add(calculationWithUpdatedProfile); + + var strategy = new PipingStochasticSoilModelUpdateDataStrategy(failureMechanism); + + // Call + IEnumerable affectedObjects = strategy.UpdateModelWithImportedData(new[] + { + readModel + }, sourceFilePath).ToArray(); + + // Assert + PipingStochasticSoilModel firstSoilModel = targetCollection[0]; + Assert.AreSame(existingModel, firstSoilModel); + Assert.AreEqual(2, firstSoilModel.StochasticSoilProfiles.Count); + Assert.AreSame(existingModel.StochasticSoilProfiles[0], firstSoilModel.StochasticSoilProfiles[0]); + Assert.AreSame(existingModel.StochasticSoilProfiles[1], firstSoilModel.StochasticSoilProfiles[1]); + + Assert.IsFalse(calculationWithUpdatedProfile.HasOutput); + Assert.AreSame(existingModel.StochasticSoilProfiles[0], calculationWithUpdatedProfile.InputParameters.StochasticSoilProfile); + + Assert.IsTrue(calculationWithNotUpdatedProfile.HasOutput); + Assert.AreSame(existingModel.StochasticSoilProfiles[1], calculationWithNotUpdatedProfile.InputParameters.StochasticSoilProfile); + + CollectionAssert.AreEquivalent(new IObservable[] + { + targetCollection, + firstSoilModel, + calculationWithUpdatedProfile, + calculationWithUpdatedProfile.InputParameters, + calculationWithUpdatedProfile.InputParameters.StochasticSoilProfile + }, affectedObjects); + } + + [Test] + public void UpdateModelWithImportedData_CalculationWithOutputAssignedRemovedSoilModelAndProfile_CalculationUpdatedAndCalculationAndInputReturned() + { + // Setup + PipingStochasticSoilModel existingModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(); + var calculation = new PipingCalculationScenario(new GeneralPipingInput()); + calculation.InputParameters.StochasticSoilModel = existingModel; + calculation.InputParameters.StochasticSoilProfile = existingModel.StochasticSoilProfiles[0]; + calculation.Output = new PipingOutput(new PipingOutput.ConstructionProperties()); + + var failureMechanism = new PipingFailureMechanism(); + failureMechanism.CalculationsGroup.Children.Add(calculation); + PipingStochasticSoilModelCollection PipingStochasticSoilModelCollection = failureMechanism.StochasticSoilModels; + PipingStochasticSoilModelCollection.AddRange(new[] + { + existingModel + }, sourceFilePath); + + var strategy = new PipingStochasticSoilModelUpdateDataStrategy(failureMechanism); + + // Call + IEnumerable affectedObjects = strategy.UpdateModelWithImportedData(new List(), sourceFilePath).ToArray(); + + // Assert + Assert.IsFalse(calculation.HasOutput); + Assert.IsNull(calculation.InputParameters.StochasticSoilModel); + Assert.IsNull(calculation.InputParameters.StochasticSoilProfile); + CollectionAssert.AreEquivalent(new IObservable[] + { + PipingStochasticSoilModelCollection, + calculation, + calculation.InputParameters + }, affectedObjects); + } + + [Test] + public void UpdateModelWithImportedData_ProfilesAssignedToCalculationsOneWithRemovedProfile_OnlyCalculationWithRemovedProfileUpdated() + { + // Setup + const string modelsName = "same model"; + PipingStochasticSoilModel existingModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(modelsName); + + var failureMechanism = new PipingFailureMechanism(); + PipingStochasticSoilModelCollection targetCollection = failureMechanism.StochasticSoilModels; + targetCollection.AddRange(new[] + { + existingModel + }, sourceFilePath); + PipingStochasticSoilProfile removedProfile = existingModel.StochasticSoilProfiles[0]; + PipingStochasticSoilProfile unaffectedProfile = existingModel.StochasticSoilProfiles[1]; + + PipingStochasticSoilModel readModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(modelsName); + readModel.StochasticSoilProfiles.RemoveAt(0); + + var calculationWithRemovedProfile = new PipingCalculationScenario(new GeneralPipingInput()); + calculationWithRemovedProfile.InputParameters.StochasticSoilModel = existingModel; + calculationWithRemovedProfile.InputParameters.StochasticSoilProfile = removedProfile; + calculationWithRemovedProfile.Output = new PipingOutput(new PipingOutput.ConstructionProperties()); + + var calculationWithNotUpdatedProfile = new PipingCalculationScenario(new GeneralPipingInput()); + calculationWithNotUpdatedProfile.InputParameters.StochasticSoilModel = existingModel; + calculationWithNotUpdatedProfile.InputParameters.StochasticSoilProfile = unaffectedProfile; + calculationWithNotUpdatedProfile.Output = new PipingOutput(new PipingOutput.ConstructionProperties()); + + failureMechanism.CalculationsGroup.Children.Add(calculationWithNotUpdatedProfile); + failureMechanism.CalculationsGroup.Children.Add(calculationWithRemovedProfile); + + var strategy = new PipingStochasticSoilModelUpdateDataStrategy(failureMechanism); + + // Call + IEnumerable affectedObjects = strategy.UpdateModelWithImportedData(new[] + { + readModel + }, sourceFilePath).ToArray(); + + // Assert + PipingStochasticSoilModel firstSoilModel = targetCollection[0]; + Assert.AreSame(existingModel, firstSoilModel); + Assert.AreEqual(1, firstSoilModel.StochasticSoilProfiles.Count); + Assert.AreSame(unaffectedProfile, firstSoilModel.StochasticSoilProfiles[0]); + + Assert.IsFalse(calculationWithRemovedProfile.HasOutput); + Assert.IsNull(calculationWithRemovedProfile.InputParameters.StochasticSoilProfile); + + Assert.IsTrue(calculationWithNotUpdatedProfile.HasOutput); + Assert.AreSame(unaffectedProfile, calculationWithNotUpdatedProfile.InputParameters.StochasticSoilProfile); + + CollectionAssert.AreEquivalent(new IObservable[] + { + targetCollection, + firstSoilModel, + calculationWithRemovedProfile, + calculationWithRemovedProfile.InputParameters + }, affectedObjects); + } + + /// + /// Creates a simple model with names for the model and profiles in the model set as specified. + /// + /// Name of the created model. + /// List of names for the profiles to be added to the model. + /// A new . + private static PipingStochasticSoilModel CreateSimpleModel(string modelName, params string[] profileNames) + { + var model = new PipingStochasticSoilModel(modelName); + foreach (string profileName in profileNames) + { + model.StochasticSoilProfiles.Add(new PipingStochasticSoilProfile( + 1.0 / profileNames.Length, + new TestPipingSoilProfile(profileName))); + } + return model; + } + + private static PipingStochasticSoilProfile CloneAndSlightlyModify(PipingStochasticSoilProfile profile) + { + return new PipingStochasticSoilProfile(profile.Probability, + new PipingSoilProfile( + profile.SoilProfile.Name, + profile.SoilProfile.Bottom - 0.2, + profile.SoilProfile.Layers, + profile.SoilProfile.SoilProfileType, + profile.SoilProfile.PipingSoilProfileId)); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSurfaceLineUpdateDataStrategyTest.cs =================================================================== diff -u -raa49537188229065df91b1a931f088c32115702a -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSurfaceLineUpdateDataStrategyTest.cs (.../PipingSurfaceLineUpdateDataStrategyTest.cs) (revision aa49537188229065df91b1a931f088c32115702a) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSurfaceLineUpdateDataStrategyTest.cs (.../PipingSurfaceLineUpdateDataStrategyTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -30,6 +30,7 @@ using Ringtoets.Common.Data.UpdateDataStrategies; using Ringtoets.Common.IO.SurfaceLines; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Data.TestUtil; using Ringtoets.Piping.KernelWrapper.TestUtil; using Ringtoets.Piping.Plugin.FileImporter; @@ -704,7 +705,7 @@ var soilModels = new[] { - new StochasticSoilModel("A") + new PipingStochasticSoilModel("A") { Geometry = { @@ -713,10 +714,10 @@ }, StochasticSoilProfiles = { - new StochasticSoilProfile(0.2, SoilProfileType.SoilProfile1D, 1) + new PipingStochasticSoilProfile(0.2, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) } }, - new StochasticSoilModel("C") + new PipingStochasticSoilModel("C") { Geometry = { @@ -725,7 +726,7 @@ }, StochasticSoilProfiles = { - new StochasticSoilProfile(0.3, SoilProfileType.SoilProfile1D, 2) + new PipingStochasticSoilProfile(0.3, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) } } }; @@ -772,7 +773,7 @@ // Setup var soilModels = new[] { - new StochasticSoilModel("A") + new PipingStochasticSoilModel("A") { Geometry = { @@ -781,10 +782,10 @@ }, StochasticSoilProfiles = { - new StochasticSoilProfile(0.2, SoilProfileType.SoilProfile1D, 1) + new PipingStochasticSoilProfile(0.2, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) } }, - new StochasticSoilModel("C") + new PipingStochasticSoilModel("C") { Geometry = { @@ -793,10 +794,10 @@ }, StochasticSoilProfiles = { - new StochasticSoilProfile(0.3, SoilProfileType.SoilProfile1D, 2) + new PipingStochasticSoilProfile(0.3, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) } }, - new StochasticSoilModel("E") + new PipingStochasticSoilModel("E") { Geometry = { @@ -805,7 +806,7 @@ }, StochasticSoilProfiles = { - new StochasticSoilProfile(0.3, SoilProfileType.SoilProfile1D, 3) + new PipingStochasticSoilProfile(0.3, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) } } }; @@ -860,7 +861,7 @@ public void UpdateSurfaceLinesWithImportedData_WithCalculationAssignedToRemovedLine_UpdatesCalculationAndDoesNotRemoveStochasticSoilInputs() { // Setup - var soilModel = new StochasticSoilModel("A") + var soilModel = new PipingStochasticSoilModel("A") { Geometry = { @@ -869,7 +870,7 @@ }, StochasticSoilProfiles = { - new StochasticSoilProfile(0.2, SoilProfileType.SoilProfile1D, 1) + new PipingStochasticSoilProfile(0.2, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) } }; @@ -917,7 +918,7 @@ public void UpdateSurfaceLinesWithImportedData_WithCalculationAssignedToRemovedLine_UpdatesCalculationAndDoesNotRemoveStochasticSoilModelInput() { // Setup - var soilModel = new StochasticSoilModel("A") + var soilModel = new PipingStochasticSoilModel("A") { Geometry = { @@ -1005,7 +1006,7 @@ var soilModels = new[] { - new StochasticSoilModel("A") + new PipingStochasticSoilModel("A") { Geometry = { @@ -1014,10 +1015,10 @@ }, StochasticSoilProfiles = { - new StochasticSoilProfile(0.2, SoilProfileType.SoilProfile1D, 1) + new PipingStochasticSoilProfile(0.2, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) } }, - new StochasticSoilModel("C") + new PipingStochasticSoilModel("C") { Geometry = { @@ -1026,7 +1027,7 @@ }, StochasticSoilProfiles = { - new StochasticSoilProfile(0.3, SoilProfileType.SoilProfile1D, 2) + new PipingStochasticSoilProfile(0.3, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) } } }; Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/StochasticSoilModelImporterConfigurationFactoryTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/StochasticSoilModelImporterConfigurationFactoryTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/StochasticSoilModelImporterConfigurationFactoryTest.cs (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -0,0 +1,83 @@ +// Copyright (C) Stichting Deltares 2017. 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 NUnit.Framework; +using Ringtoets.Common.IO.SoilProfile; +using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; +using Ringtoets.Piping.IO.Importers; +using Ringtoets.Piping.Plugin.FileImporter; + +namespace Ringtoets.Piping.Plugin.Test.FileImporter +{ + [TestFixture] + public class StochasticSoilModelImporterConfigurationFactoryTest + { + [Test] + public void CreateUpdateStrategyConfiguration_WithoutFailureMechanism_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => StochasticSoilModelImporterConfigurationFactory.CreateUpdateStrategyConfiguration(null); + + // Assert + Assert.Throws(test); + } + + [Test] + public void CreateUpdateStrategyConfiguration_ValidArgument_ReturnsUpdateStrategyAndTransformerForPiping() + { + // Call + StochasticSoilModelImporterConfiguration result = + StochasticSoilModelImporterConfigurationFactory.CreateUpdateStrategyConfiguration(new PipingFailureMechanism()); + + // Assert + Assert.IsNotNull(result); + Assert.IsInstanceOf(result.Transformer); + Assert.IsInstanceOf(result.MechanismFilter); + Assert.IsInstanceOf(result.UpdateStrategy); + } + + [Test] + public void CreateReplaceStrategyConfiguration_WithoutFailureMechanism_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => StochasticSoilModelImporterConfigurationFactory.CreateReplaceStrategyConfiguration(null); + + // Assert + Assert.Throws(test); + } + + [Test] + public void CreateReplaceStrategyConfiguration_ValidArgument_ReturnsReplaceStrategyAndTransformerForPiping() + { + // Call + StochasticSoilModelImporterConfiguration result = + StochasticSoilModelImporterConfigurationFactory.CreateReplaceStrategyConfiguration(new PipingFailureMechanism()); + + // Assert + Assert.IsNotNull(result); + Assert.IsInstanceOf(result.Transformer); + Assert.IsInstanceOf(result.MechanismFilter); + Assert.IsInstanceOf(result.UpdateStrategy); + } + } +} \ No newline at end of file Fisheye: Tag 26f527fb809a2325c8f883ece9da01a8f8040eb3 refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/StochasticSoilModelReplaceDataStrategyTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 26f527fb809a2325c8f883ece9da01a8f8040eb3 refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/StochasticSoilModelUpdateDataStrategyTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ImportInfos/PipingCalculationGroupContextImportInfoTest.cs =================================================================== diff -u -r8b60c9e846480f3ffeeb263bfea5d3367bf6bee3 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ImportInfos/PipingCalculationGroupContextImportInfoTest.cs (.../PipingCalculationGroupContextImportInfoTest.cs) (revision 8b60c9e846480f3ffeeb263bfea5d3367bf6bee3) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ImportInfos/PipingCalculationGroupContextImportInfoTest.cs (.../PipingCalculationGroupContextImportInfoTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -31,6 +31,7 @@ using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.TestUtil; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Forms.PresentationObjects; using Ringtoets.Piping.IO.Configurations; using Ringtoets.Piping.Primitives; @@ -120,7 +121,7 @@ var context = new PipingCalculationGroupContext(new CalculationGroup(), null, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), failureMechanism, assessmentSection); Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ImportInfos/StochasticSoilModelCollectionContextImportInfoTest.cs =================================================================== diff -u -r38499aa6936706c30ac12e481233d3f13545dd8b -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ImportInfos/StochasticSoilModelCollectionContextImportInfoTest.cs (.../StochasticSoilModelCollectionContextImportInfoTest.cs) (revision 38499aa6936706c30ac12e481233d3f13545dd8b) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ImportInfos/StochasticSoilModelCollectionContextImportInfoTest.cs (.../StochasticSoilModelCollectionContextImportInfoTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -32,9 +32,10 @@ using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.IO.SoilProfile; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Forms.PresentationObjects; -using Ringtoets.Piping.IO.Importers; using Ringtoets.Piping.KernelWrapper.TestUtil; using PipingFormsResources = Ringtoets.Piping.Forms.Properties.Resources; @@ -46,17 +47,6 @@ private ImportInfo importInfo; private PipingPlugin plugin; - public override void Setup() - { - plugin = new PipingPlugin(); - importInfo = plugin.GetImportInfos().First(i => i.DataType == typeof(StochasticSoilModelCollectionContext)); - } - - public override void TearDown() - { - plugin.Dispose(); - } - [Test] public void Name_Always_ReturnExpectedName() { @@ -156,7 +146,7 @@ var failureMechanism = new PipingFailureMechanism(); failureMechanism.CalculationsGroup.Children.Add(new PipingCalculationScenario(new GeneralPipingInput())); - var stochasticSoilModelCollection = new StochasticSoilModelCollection(); + var stochasticSoilModelCollection = new PipingStochasticSoilModelCollection(); var context = new StochasticSoilModelCollectionContext(stochasticSoilModelCollection, failureMechanism, assessmentSection); // Call @@ -190,7 +180,7 @@ }; failureMechanism.CalculationsGroup.Children.Add(calculationWithOutput); - var stochasticSoilModelCollection = new StochasticSoilModelCollection(); + var stochasticSoilModelCollection = new PipingStochasticSoilModelCollection(); var context = new StochasticSoilModelCollectionContext(stochasticSoilModelCollection, failureMechanism, assessmentSection); string textBoxMessage = null; @@ -237,8 +227,19 @@ IFileImporter importer = importInfo.CreateFileImporter(importTarget, ""); // Assert - Assert.IsInstanceOf(importer); + Assert.IsInstanceOf>(importer); mocks.VerifyAll(); } + + public override void Setup() + { + plugin = new PipingPlugin(); + importInfo = plugin.GetImportInfos().First(i => i.DataType == typeof(StochasticSoilModelCollectionContext)); + } + + public override void TearDown() + { + plugin.Dispose(); + } } } \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/PipingPluginTest.cs =================================================================== diff -u -rd240a17fa742ff4c460dd12eb300e3196100ffab -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/PipingPluginTest.cs (.../PipingPluginTest.cs) (revision d240a17fa742ff4c460dd12eb300e3196100ffab) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/PipingPluginTest.cs (.../PipingPluginTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -29,6 +29,7 @@ using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Forms.PresentationObjects; using Ringtoets.Piping.Forms.PropertyClasses; using Ringtoets.Piping.Forms.Views; @@ -91,17 +92,17 @@ PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, typeof(StochasticSoilModelCollectionContext), - typeof(StochasticSoilModelCollectionProperties)); + typeof(PipingStochasticSoilModelCollectionProperties)); PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, - typeof(StochasticSoilModel), - typeof(StochasticSoilModelProperties)); + typeof(PipingStochasticSoilModel), + typeof(PipingStochasticSoilModelProperties)); PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, - typeof(StochasticSoilProfile), - typeof(StochasticSoilProfileProperties)); + typeof(PipingStochasticSoilProfile), + typeof(PipingStochasticSoilProfileProperties)); } } @@ -119,8 +120,8 @@ Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(PipingSurfaceLinesContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(PipingSurfaceLine))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(StochasticSoilModelCollectionContext))); - Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(StochasticSoilModel))); - Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(StochasticSoilProfile))); + Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(PipingStochasticSoilModel))); + Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(PipingStochasticSoilProfile))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(PipingCalculationScenarioContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(PipingCalculationGroupContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(PipingInputContext))); Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/PropertyInfos/PipingInputContextPropertyInfoTest.cs =================================================================== diff -u -rd6fe8399e8398224cf1bda9259052232d85b85a4 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/PropertyInfos/PipingInputContextPropertyInfoTest.cs (.../PipingInputContextPropertyInfoTest.cs) (revision d6fe8399e8398224cf1bda9259052232d85b85a4) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/PropertyInfos/PipingInputContextPropertyInfoTest.cs (.../PipingInputContextPropertyInfoTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -26,6 +26,7 @@ using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Forms.PresentationObjects; using Ringtoets.Piping.Forms.PropertyClasses; using Ringtoets.Piping.Primitives; @@ -74,7 +75,7 @@ scenario.InputParameters, scenario, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), failureMechanism, assessmentSection); // Call Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/PropertyInfos/PipingStochasticSoilModelCollectionContextPropertyInfoTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/PropertyInfos/PipingStochasticSoilModelCollectionContextPropertyInfoTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/PropertyInfos/PipingStochasticSoilModelCollectionContextPropertyInfoTest.cs (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -0,0 +1,85 @@ +// Copyright (C) Stichting Deltares 2017. 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.Gui.Plugin; +using Core.Common.Gui.PropertyBag; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; +using Ringtoets.Piping.Forms.PresentationObjects; +using Ringtoets.Piping.Forms.PropertyClasses; + +namespace Ringtoets.Piping.Plugin.Test.PropertyInfos +{ + [TestFixture] + public class PipingStochasticSoilModelCollectionContextPropertyInfoTest + { + private PipingPlugin plugin; + private PropertyInfo info; + + [SetUp] + public void SetUp() + { + plugin = new PipingPlugin(); + info = plugin.GetPropertyInfos().First(tni => tni.PropertyObjectType == typeof(PipingStochasticSoilModelCollectionProperties)); + } + + [TearDown] + public void TearDown() + { + plugin.Dispose(); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Assert + Assert.AreEqual(typeof(StochasticSoilModelCollectionContext), info.DataType); + Assert.AreEqual(typeof(PipingStochasticSoilModelCollectionProperties), info.PropertyObjectType); + } + + [Test] + public void CreateInstance_Always_NewPropertiesWithInputContextAsData() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new PipingFailureMechanism(); + + var collection = new PipingStochasticSoilModelCollection(); + var context = new StochasticSoilModelCollectionContext(collection, failureMechanism, assessmentSection); + + // Call + IObjectProperties objectProperties = info.CreateInstance(context); + + // Assert + Assert.IsInstanceOf(objectProperties); + Assert.AreSame(collection, objectProperties.Data); + + mocks.VerifyAll(); + } + } +} \ No newline at end of file Fisheye: Tag 26f527fb809a2325c8f883ece9da01a8f8040eb3 refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/PropertyInfos/StochasticSoilModelCollectionContextPropertyInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/Ringtoets.Piping.Plugin.Test.csproj =================================================================== diff -u -raa49537188229065df91b1a931f088c32115702a -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/Ringtoets.Piping.Plugin.Test.csproj (.../Ringtoets.Piping.Plugin.Test.csproj) (revision aa49537188229065df91b1a931f088c32115702a) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/Ringtoets.Piping.Plugin.Test.csproj (.../Ringtoets.Piping.Plugin.Test.csproj) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -70,16 +70,17 @@ + - - + + - + @@ -93,8 +94,8 @@ - - + + Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -r12dd75e49af7d033f00f1c6d05bfadd11eba85cc -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingCalculationGroupContextTreeNodeInfoTest.cs (.../PipingCalculationGroupContextTreeNodeInfoTest.cs) (revision 12dd75e49af7d033f00f1c6d05bfadd11eba85cc) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingCalculationGroupContextTreeNodeInfoTest.cs (.../PipingCalculationGroupContextTreeNodeInfoTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -43,6 +43,7 @@ using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Service.TestUtil; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Data.TestUtil; using Ringtoets.Piping.Forms; using Ringtoets.Piping.Forms.PresentationObjects; @@ -88,21 +89,6 @@ private PipingPlugin plugin; private TreeNodeInfo info; - public override void Setup() - { - mocks = new MockRepository(); - plugin = new PipingPlugin(); - info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(PipingCalculationGroupContext)); - } - - public override void TearDown() - { - plugin.Dispose(); - mocks.VerifyAll(); - - base.TearDown(); - } - [Test] public void Initialized_Always_ExpectedPropertiesSet() { @@ -142,7 +128,7 @@ var groupContext = new PipingCalculationGroupContext(group, null, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); @@ -176,7 +162,7 @@ var nodeData = new PipingCalculationGroupContext(group, null, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); @@ -215,13 +201,13 @@ var nodeData = new PipingCalculationGroupContext(group, parentGroup, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); var parentNodeData = new PipingCalculationGroupContext(parentGroup, null, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); @@ -344,7 +330,7 @@ var nodeData = new PipingCalculationGroupContext(group, null, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); @@ -466,7 +452,7 @@ Enumerable.Empty(), new[] { - new TestStochasticSoilModel() + PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel() }, pipingFailureMechanism, assessmentSection); @@ -508,7 +494,7 @@ { new PipingSurfaceLine() }, - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); @@ -553,7 +539,7 @@ }, new[] { - new TestStochasticSoilModel() + PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel() }, pipingFailureMechanism, assessmentSection); @@ -598,7 +584,7 @@ var nodeData = new PipingCalculationGroupContext(group, null, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); @@ -648,7 +634,7 @@ var nodeData = new PipingCalculationGroupContext(group, null, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); @@ -691,7 +677,7 @@ var nodeData = new PipingCalculationGroupContext(group, null, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); var gui = mocks.Stub(); @@ -733,7 +719,7 @@ var nodeData = new PipingCalculationGroupContext(group, null, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); @@ -776,7 +762,7 @@ var nodeData = new PipingCalculationGroupContext(group, null, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); @@ -820,7 +806,7 @@ var nodeData = new PipingCalculationGroupContext(group, null, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); @@ -858,13 +844,13 @@ var nodeData = new PipingCalculationGroupContext(group, parentGroup, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); var parentNodeData = new PipingCalculationGroupContext(parentGroup, null, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); @@ -918,13 +904,13 @@ var nodeData = new PipingCalculationGroupContext(group, parentGroup, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); var parentNodeData = new PipingCalculationGroupContext(parentGroup, null, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); @@ -993,13 +979,13 @@ var nodeData = new PipingCalculationGroupContext(group, parentGroup, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); var parentNodeData = new PipingCalculationGroupContext(parentGroup, null, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); @@ -1061,13 +1047,13 @@ var nodeData = new PipingCalculationGroupContext(group, parentGroup, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); var parentNodeData = new PipingCalculationGroupContext(parentGroup, null, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); @@ -1139,13 +1125,13 @@ var nodeData = new PipingCalculationGroupContext(group, parentGroup, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); var parentNodeData = new PipingCalculationGroupContext(parentGroup, null, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); @@ -1217,7 +1203,7 @@ surfaceLines, new[] { - new TestStochasticSoilModel() + PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel() }, pipingFailureMechanism, assessmentSection); @@ -1308,22 +1294,28 @@ new Point2D(10.0, 0.0) })); - var nodeData = new PipingCalculationGroupContext(pipingFailureMechanism.CalculationsGroup, - null, - surfaceLines, - new[] - { - new TestStochasticSoilModel - { - Geometry = - { - new Point2D(0.0, 0.0), - new Point2D(5.0, 0.0) - } - } - }, - pipingFailureMechanism, - assessmentSection); + var nodeData = new PipingCalculationGroupContext( + pipingFailureMechanism.CalculationsGroup, + null, + surfaceLines, + new[] + { + new PipingStochasticSoilModel("name") + { + Geometry = + { + new Point2D(0.0, 0.0), + new Point2D(5.0, 0.0) + }, + StochasticSoilProfiles = + { + new PipingStochasticSoilProfile(0.5, new TestPipingSoilProfile("A")), + new PipingStochasticSoilProfile(0.5, new TestPipingSoilProfile("B")) + } + } + }, + pipingFailureMechanism, + assessmentSection); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var mainWindow = mocks.Stub(); @@ -1427,7 +1419,7 @@ surfaceLines, new[] { - new TestStochasticSoilModel + new PipingStochasticSoilModel("name") { Geometry = { @@ -1494,7 +1486,7 @@ var nodeData = new PipingCalculationGroupContext(group, null, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); @@ -1503,7 +1495,7 @@ var parentNodeData = new PipingCalculationGroupContext(parentGroup, null, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); parentNodeData.Attach(observer); @@ -1547,13 +1539,13 @@ var nodeData = new PipingCalculationGroupContext(group, parentGroup, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); var parentNodeData = new PipingCalculationGroupContext(parentGroup, null, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); parentNodeData.Attach(observer); @@ -1634,13 +1626,13 @@ var nodeData = new PipingCalculationGroupContext(group, parentGroup, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); var parentNodeData = new PipingCalculationGroupContext(parentGroup, null, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); @@ -1733,13 +1725,13 @@ var nodeData = new PipingCalculationGroupContext(group, parentGroup, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); var parentNodeData = new PipingCalculationGroupContext(parentGroup, null, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); @@ -1851,13 +1843,13 @@ var nodeData = new PipingCalculationGroupContext(group, parentGroup, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); var parentNodeData = new PipingCalculationGroupContext(parentGroup, null, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); @@ -1900,6 +1892,21 @@ } } + public override void Setup() + { + mocks = new MockRepository(); + plugin = new PipingPlugin(); + info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(PipingCalculationGroupContext)); + } + + public override void TearDown() + { + plugin.Dispose(); + mocks.VerifyAll(); + + base.TearDown(); + } + private static void ChangeSurfaceLine(PipingSurfaceLine surfaceLine) { surfaceLine.SetGeometry(new[] Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingCalculationScenarioContextTreeNodeInfoTest.cs =================================================================== diff -u -r8b60c9e846480f3ffeeb263bfea5d3367bf6bee3 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingCalculationScenarioContextTreeNodeInfoTest.cs (.../PipingCalculationScenarioContextTreeNodeInfoTest.cs) (revision 8b60c9e846480f3ffeeb263bfea5d3367bf6bee3) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingCalculationScenarioContextTreeNodeInfoTest.cs (.../PipingCalculationScenarioContextTreeNodeInfoTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -43,6 +43,7 @@ using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Service.TestUtil; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Data.TestUtil; using Ringtoets.Piping.Forms.PresentationObjects; using Ringtoets.Piping.KernelWrapper.TestUtil; @@ -141,7 +142,7 @@ }, new[] { - new TestStochasticSoilModel() + PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel() }, pipingFailureMechanism, assessmentSection); @@ -175,7 +176,7 @@ var pipingCalculationContext = new PipingCalculationScenarioContext(new PipingCalculationScenario(new GeneralPipingInput()), new CalculationGroup(), Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); @@ -207,7 +208,7 @@ var nodeData = new PipingCalculationScenarioContext(calculation, new CalculationGroup(), Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); @@ -247,7 +248,7 @@ var nodeData = new PipingCalculationScenarioContext(calculation, new CalculationGroup(), Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); @@ -282,7 +283,7 @@ var nodeData = new PipingCalculationScenarioContext(calculation, new CalculationGroup(), Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); @@ -326,7 +327,7 @@ var nodeData = new PipingCalculationScenarioContext(calculation, new CalculationGroup(), Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); @@ -366,7 +367,7 @@ var nodeData = new PipingCalculationScenarioContext(new PipingCalculationScenario(new GeneralPipingInput()), new CalculationGroup(), Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); @@ -417,7 +418,7 @@ var nodeData = new PipingCalculationScenarioContext(calculation, new CalculationGroup(), Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); @@ -465,7 +466,7 @@ var nodeData = new PipingCalculationScenarioContext(calculation, new CalculationGroup(), Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); @@ -513,7 +514,7 @@ var nodeData = new PipingCalculationScenarioContext(calculation, new CalculationGroup(), Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); @@ -553,7 +554,7 @@ var nodeData = new PipingCalculationScenarioContext(calculation, new CalculationGroup(), Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); @@ -604,7 +605,7 @@ var nodeData = new PipingCalculationScenarioContext(calculation, new CalculationGroup(), Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); @@ -667,7 +668,7 @@ var nodeData = new PipingCalculationScenarioContext(calculation, new CalculationGroup(), Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); @@ -738,13 +739,13 @@ var calculationContext = new PipingCalculationScenarioContext(elementToBeRemoved, group, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); var groupContext = new PipingCalculationGroupContext(group, null, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); @@ -792,13 +793,13 @@ var calculationContext = new PipingCalculationScenarioContext(elementToBeRemoved, group, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); var groupContext = new PipingCalculationGroupContext(group, null, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); @@ -834,7 +835,7 @@ var pipingCalculationContext = new PipingCalculationScenarioContext(calculation, new CalculationGroup(), Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); @@ -901,7 +902,7 @@ var pipingCalculationContext = new PipingCalculationScenarioContext(calculation, new CalculationGroup(), Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); @@ -949,7 +950,7 @@ var pipingCalculationContext = new PipingCalculationScenarioContext(calculation, new CalculationGroup(), Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); @@ -1016,7 +1017,7 @@ var pipingCalculationContext = new PipingCalculationScenarioContext(calculation, new CalculationGroup(), Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingInputContextTreeNodeInfoTest.cs =================================================================== diff -u -r3178e116f5e59e03078d465efeb303c5e232c7bf -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingInputContextTreeNodeInfoTest.cs (.../PipingInputContextTreeNodeInfoTest.cs) (revision 3178e116f5e59e03078d465efeb303c5e232c7bf) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingInputContextTreeNodeInfoTest.cs (.../PipingInputContextTreeNodeInfoTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -29,6 +29,7 @@ using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Forms.PresentationObjects; using Ringtoets.Piping.Forms.Properties; using Ringtoets.Piping.Primitives; @@ -92,7 +93,7 @@ new PipingInput(new GeneralPipingInput()), new PipingCalculationScenario(new GeneralPipingInput()), Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), new PipingFailureMechanism(), mocks.Stub()); @@ -113,7 +114,7 @@ new PipingInput(new GeneralPipingInput()), new PipingCalculationScenario(new GeneralPipingInput()), Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), new PipingFailureMechanism(), mocks.Stub()); Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingStochasticSoilModelTreeNodeInfoTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingStochasticSoilModelTreeNodeInfoTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingStochasticSoilModelTreeNodeInfoTest.cs (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -0,0 +1,167 @@ +// Copyright (C) Stichting Deltares 2017. 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.Drawing; +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.Piping.Data.SoilProfile; +using Ringtoets.Piping.KernelWrapper.TestUtil; +using PipingFormsResources = Ringtoets.Piping.Forms.Properties.Resources; + +namespace Ringtoets.Piping.Plugin.Test.TreeNodeInfos +{ + [TestFixture] + public class PipingStochasticSoilModelTreeNodeInfoTest + { + private PipingPlugin plugin; + private TreeNodeInfo info; + + [SetUp] + public void SetUp() + { + plugin = new PipingPlugin(); + info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(PipingStochasticSoilModel)); + } + + [TearDown] + public void TearDown() + { + plugin.Dispose(); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Assert + Assert.IsNotNull(info.Text); + Assert.IsNull(info.ForeColor); + Assert.IsNotNull(info.Image); + Assert.IsNotNull(info.ContextMenuStrip); + Assert.IsNull(info.EnsureVisibleOnCreate); + Assert.IsNull(info.ExpandOnCreate); + Assert.IsNotNull(info.ChildNodeObjects); + 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_ReturnsTextFromResource() + { + // Setup + const string name = "test test 123"; + var model = new PipingStochasticSoilModel(name); + + // Call + string text = info.Text(model); + + // Assert + Assert.AreEqual(name, text); + } + + [Test] + public void Image_Always_ReturnsSetImage() + { + // Setup + var model = new PipingStochasticSoilModel("A"); + + // Call + Image image = info.Image(model); + + // Assert + TestHelper.AssertImagesAreEqual(PipingFormsResources.StochasticSoilModelIcon, image); + } + + [Test] + public void ChildNodeObjects_Always_ReturnsChildrenOfData() + { + // Setup + var stochasticSoilProfile1 = new PipingStochasticSoilProfile(0.5, PipingSoilProfileTestFactory.CreatePipingSoilProfile()); + var stochasticSoilProfile2 = new PipingStochasticSoilProfile(0.5, PipingSoilProfileTestFactory.CreatePipingSoilProfile()); + + var stochasticSoilModel = new PipingStochasticSoilModel("Name") + { + StochasticSoilProfiles = + { + stochasticSoilProfile1, + stochasticSoilProfile2 + } + }; + + // Call + object[] objects = info.ChildNodeObjects(stochasticSoilModel); + + // Assert + var expectedChildren = new[] + { + stochasticSoilProfile1, + stochasticSoilProfile2 + }; + CollectionAssert.AreEqual(expectedChildren, objects); + } + + [Test] + public void ContextMenuStrip_Always_CallsBuilder() + { + // Setup + var model = new PipingStochasticSoilModel("A"); + + var mocks = new MockRepository(); + + var menuBuilder = mocks.StrictMock(); + using (mocks.Ordered()) + { + menuBuilder.Expect(mb => mb.AddCollapseAllItem()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddExpandAllItem()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.Build()).Return(null); + } + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocks.Stub(); + gui.Stub(g => g.Get(model, treeViewControl)).Return(menuBuilder); + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + info.ContextMenuStrip(model, null, treeViewControl); + } + // Assert + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingStochasticSoilProfileTreeNodeInfoTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingStochasticSoilProfileTreeNodeInfoTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingStochasticSoilProfileTreeNodeInfoTest.cs (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -0,0 +1,138 @@ +// Copyright (C) Stichting Deltares 2017. 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.Drawing; +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.Piping.Data.SoilProfile; +using Ringtoets.Piping.Forms.Properties; +using Ringtoets.Piping.KernelWrapper.TestUtil; + +namespace Ringtoets.Piping.Plugin.Test.TreeNodeInfos +{ + [TestFixture] + public class PipingStochasticSoilProfileTreeNodeInfoTest + { + private MockRepository mocks; + private PipingPlugin plugin; + private TreeNodeInfo info; + + [SetUp] + public void SetUp() + { + mocks = new MockRepository(); + plugin = new PipingPlugin(); + info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(PipingStochasticSoilProfile)); + } + + [TearDown] + public void TearDown() + { + plugin.Dispose(); + mocks.VerifyAll(); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Setup + mocks.ReplayAll(); + + // Assert + Assert.IsNotNull(info.Text); + Assert.IsNull(info.ForeColor); + Assert.IsNotNull(info.Image); + Assert.IsNotNull(info.ContextMenuStrip); + Assert.IsNull(info.EnsureVisibleOnCreate); + Assert.IsNull(info.ExpandOnCreate); + Assert.IsNull(info.ChildNodeObjects); + 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 + const string testName = "ttt"; + var stochasticSoilProfile = new PipingStochasticSoilProfile(0.1, + PipingSoilProfileTestFactory.CreatePipingSoilProfile(testName)); + + // Call + string text = info.Text(stochasticSoilProfile); + + // Assert + Assert.AreEqual(testName, text); + } + + [Test] + public void Image_Always_ReturnsSetImage() + { + // Setup + var stochasticSoilProfile = new PipingStochasticSoilProfile(0.1, + PipingSoilProfileTestFactory.CreatePipingSoilProfile()); + + // Call + Image image = info.Image(stochasticSoilProfile); + + // Assert + TestHelper.AssertImagesAreEqual(Resources.PipingSoilProfileIcon, image); + } + + [Test] + public void ContextMenuStrip_Always_CallsBuilder() + { + // Setup + var menuBuilder = mocks.StrictMock(); + + menuBuilder.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.Build()).Return(null); + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocks.Stub(); + gui.Stub(g => g.Get(null, treeViewControl)).Return(menuBuilder); + 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/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/StochasticSoilModelCollectionContextTreeNodeInfoTest.cs =================================================================== diff -u -r3178e116f5e59e03078d465efeb303c5e232c7bf -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/StochasticSoilModelCollectionContextTreeNodeInfoTest.cs (.../StochasticSoilModelCollectionContextTreeNodeInfoTest.cs) (revision 3178e116f5e59e03078d465efeb303c5e232c7bf) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/StochasticSoilModelCollectionContextTreeNodeInfoTest.cs (.../StochasticSoilModelCollectionContextTreeNodeInfoTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -19,7 +19,6 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. -using System.Collections.Generic; using System.Drawing; using System.Linq; using Core.Common.Controls.TreeView; @@ -31,8 +30,9 @@ using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Forms.PresentationObjects; -using Ringtoets.Piping.Primitives; +using Ringtoets.Piping.KernelWrapper.TestUtil; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; namespace Ringtoets.Piping.Plugin.Test.TreeNodeInfos @@ -44,21 +44,6 @@ private PipingPlugin plugin; private TreeNodeInfo info; - public override void Setup() - { - mocks = new MockRepository(); - plugin = new PipingPlugin(); - info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(StochasticSoilModelCollectionContext)); - } - - public override void TearDown() - { - plugin.Dispose(); - mocks.VerifyAll(); - - base.TearDown(); - } - [Test] public void Initialized_Always_ExpectedPropertiesSet() { @@ -129,7 +114,7 @@ } [Test] - public void ForeColor_CollectionWithoutSoilProfiles_ReturnsGrayText() + public void ForeColor_CollectionWithoutSoilModels_ReturnsGrayText() { // Setup var assessmentSection = mocks.Stub(); @@ -150,7 +135,7 @@ } [Test] - public void ForeColor_CollectionWithSoilProfiles_ReturnsControlText() + public void ForeColor_CollectionWithSoilModels_ReturnsControlText() { // Setup var assessmentSection = mocks.Stub(); @@ -159,7 +144,7 @@ var failureMechanism = new PipingFailureMechanism(); failureMechanism.StochasticSoilModels.AddRange(new[] { - new StochasticSoilModel("Name") + new PipingStochasticSoilModel("Name") }, "path"); var stochasticSoilModelCollectionContext = new StochasticSoilModelCollectionContext( @@ -181,27 +166,15 @@ var assessmentSection = mocks.Stub(); mocks.ReplayAll(); - var pipingSoilProfile1 = new PipingSoilProfile("pipingSoilProfile1", 0, new List + var stochasticSoilModel = new PipingStochasticSoilModel("Name") { - new PipingSoilLayer(10) - }, SoilProfileType.SoilProfile1D, 0); - var pipingSoilProfile2 = new PipingSoilProfile("pipingSoilProfile2", 0, new List - { - new PipingSoilLayer(10) - }, SoilProfileType.SoilProfile1D, 0); - var stochasticSoilProfile1 = new StochasticSoilProfile(1.0, SoilProfileType.SoilProfile1D, 1) - { - SoilProfile = pipingSoilProfile1 + StochasticSoilProfiles = + { + new PipingStochasticSoilProfile(0.5, PipingSoilProfileTestFactory.CreatePipingSoilProfile()), + new PipingStochasticSoilProfile(0.5, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) + } }; - var stochasticSoilProfile2 = new StochasticSoilProfile(1.0, SoilProfileType.SoilProfile1D, 1) - { - SoilProfile = pipingSoilProfile2 - }; - var stochasticSoilModel = new StochasticSoilModel("Name"); - stochasticSoilModel.StochasticSoilProfiles.Add(stochasticSoilProfile1); - stochasticSoilModel.StochasticSoilProfiles.Add(stochasticSoilProfile2); - var failureMechanism = new PipingFailureMechanism(); var stochasticSoilModelCollectionContext = new StochasticSoilModelCollectionContext( failureMechanism.StochasticSoilModels, @@ -244,7 +217,7 @@ using (var treeViewControl = new TreeViewControl()) { var context = new StochasticSoilModelCollectionContext( - new StochasticSoilModelCollection(), + new PipingStochasticSoilModelCollection(), new PipingFailureMechanism(), assessmentSection); var gui = mocks.Stub(); @@ -260,5 +233,20 @@ // Assert // Assert expectancies are called in TearDown() } + + public override void Setup() + { + mocks = new MockRepository(); + plugin = new PipingPlugin(); + info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(StochasticSoilModelCollectionContext)); + } + + public override void TearDown() + { + plugin.Dispose(); + mocks.VerifyAll(); + + base.TearDown(); + } } } \ No newline at end of file Fisheye: Tag 26f527fb809a2325c8f883ece9da01a8f8040eb3 refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/StochasticSoilModelTreeNodeInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 26f527fb809a2325c8f883ece9da01a8f8040eb3 refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/StochasticSoilProfileTreeNodeInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/UpdateInfos/StochasticSoilModelCollectionContextUpdateInfoTest.cs =================================================================== diff -u -r5906f61fff270a7526253bea07dfecdf680898ed -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/UpdateInfos/StochasticSoilModelCollectionContextUpdateInfoTest.cs (.../StochasticSoilModelCollectionContextUpdateInfoTest.cs) (revision 5906f61fff270a7526253bea07dfecdf680898ed) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/UpdateInfos/StochasticSoilModelCollectionContextUpdateInfoTest.cs (.../StochasticSoilModelCollectionContextUpdateInfoTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -32,10 +32,11 @@ using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.IO.SoilProfile; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Data.TestUtil; using Ringtoets.Piping.Forms.PresentationObjects; -using Ringtoets.Piping.IO.Importers; using Ringtoets.Piping.KernelWrapper.TestUtil; using PipingFormsResources = Ringtoets.Piping.Forms.Properties.Resources; @@ -47,17 +48,6 @@ private UpdateInfo updateInfo; private PipingPlugin plugin; - public override void Setup() - { - plugin = new PipingPlugin(); - updateInfo = plugin.GetUpdateInfos().First(i => i.DataType == typeof(StochasticSoilModelCollectionContext)); - } - - public override void TearDown() - { - plugin.Dispose(); - } - [Test] public void Name_Always_ReturnExpectedName() { @@ -97,7 +87,7 @@ mocks.ReplayAll(); var failureMechanism = new PipingFailureMechanism(); - var stochasticSoilModel = new StochasticSoilModelCollection(); + var stochasticSoilModel = new PipingStochasticSoilModelCollection(); var context = new StochasticSoilModelCollectionContext(stochasticSoilModel, failureMechanism, assessmentSection); @@ -118,8 +108,8 @@ mocks.ReplayAll(); var failureMechanism = new PipingFailureMechanism(); - var stochasticSoilModel = new StochasticSoilModelCollection(); - stochasticSoilModel.AddRange(Enumerable.Empty(), "some/path"); + var stochasticSoilModel = new PipingStochasticSoilModelCollection(); + stochasticSoilModel.AddRange(Enumerable.Empty(), "some/path"); var context = new StochasticSoilModelCollectionContext(stochasticSoilModel, failureMechanism, assessmentSection); @@ -158,7 +148,7 @@ var failureMechanism = new PipingFailureMechanism(); failureMechanism.CalculationsGroup.Children.Add(new PipingCalculationScenario(new GeneralPipingInput())); - var stochasticSoilModelCollection = new StochasticSoilModelCollection(); + var stochasticSoilModelCollection = new PipingStochasticSoilModelCollection(); var context = new StochasticSoilModelCollectionContext(stochasticSoilModelCollection, failureMechanism, assessmentSection); // Call @@ -192,7 +182,7 @@ }; failureMechanism.CalculationsGroup.Children.Add(calculationWithOutput); - var stochasticSoilModelCollection = new StochasticSoilModelCollection(); + var stochasticSoilModelCollection = new PipingStochasticSoilModelCollection(); var context = new StochasticSoilModelCollectionContext(stochasticSoilModelCollection, failureMechanism, assessmentSection); string textBoxMessage = null; @@ -232,10 +222,10 @@ mocks.ReplayAll(); const string expectedFilePath = "some/path"; - var stochasticSoilModelCollection = new StochasticSoilModelCollection(); + var stochasticSoilModelCollection = new PipingStochasticSoilModelCollection(); stochasticSoilModelCollection.AddRange(new[] { - new TestStochasticSoilModel() + PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel() }, expectedFilePath); var failureMechanism = new PipingFailureMechanism(); @@ -266,8 +256,19 @@ IFileImporter importer = updateInfo.CreateFileImporter(importTarget, ""); // Assert - Assert.IsInstanceOf(importer); + Assert.IsInstanceOf>(importer); mocks.VerifyAll(); } + + public override void Setup() + { + plugin = new PipingPlugin(); + updateInfo = plugin.GetUpdateInfos().First(i => i.DataType == typeof(StochasticSoilModelCollectionContext)); + } + + public override void TearDown() + { + plugin.Dispose(); + } } } \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ViewInfos/PipingCalculationsViewInfoTest.cs =================================================================== diff -u -r8b60c9e846480f3ffeeb263bfea5d3367bf6bee3 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ViewInfos/PipingCalculationsViewInfoTest.cs (.../PipingCalculationsViewInfoTest.cs) (revision 8b60c9e846480f3ffeeb263bfea5d3367bf6bee3) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ViewInfos/PipingCalculationsViewInfoTest.cs (.../PipingCalculationsViewInfoTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -28,6 +28,7 @@ using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Forms.PresentationObjects; using Ringtoets.Piping.Forms.Views; using Ringtoets.Piping.Primitives; @@ -78,7 +79,7 @@ var calculationGroupContext = new PipingCalculationGroupContext(calculationGroup, null, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), failureMechanism, assessmentSection); @@ -118,7 +119,7 @@ var pipingCalculationGroupContext = new PipingCalculationGroupContext(pipingFailureMechanism.CalculationsGroup, null, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); @@ -142,7 +143,7 @@ var pipingCalculationGroupContext = new PipingCalculationGroupContext(calculationGroup, null, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), failureMechanism, assessmentSection); @@ -315,7 +316,7 @@ var pipingCalculationGroupContext = new PipingCalculationGroupContext(pipingCalculationsGroup, null, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), pipingFailureMechanism, assessmentSection); view.Expect(v => v.AssessmentSection = assessmentSection); Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ViewInfos/PipingInputViewInfoTest.cs =================================================================== diff -u -r8b60c9e846480f3ffeeb263bfea5d3367bf6bee3 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ViewInfos/PipingInputViewInfoTest.cs (.../PipingInputViewInfoTest.cs) (revision 8b60c9e846480f3ffeeb263bfea5d3367bf6bee3) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ViewInfos/PipingInputViewInfoTest.cs (.../PipingInputViewInfoTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -27,6 +27,7 @@ using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Calculation; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Forms.PresentationObjects; using Ringtoets.Piping.Forms.Views; using Ringtoets.Piping.Primitives; @@ -91,7 +92,7 @@ var calculation = new PipingCalculationScenario(new GeneralPipingInput()); var calculationInputContext = new PipingInputContext(pipingInput, calculation, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), new PipingFailureMechanism(), assessmentSection); @@ -114,7 +115,7 @@ var pipingCalculationScenarioContext = new PipingCalculationScenarioContext(pipingCalculation, new CalculationGroup(), Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), new PipingFailureMechanism(), assessmentSection); @@ -145,7 +146,7 @@ var pipingCalculationScenarioContext = new PipingCalculationScenarioContext(calculationToRemove, new CalculationGroup(), Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), new PipingFailureMechanism(), assessmentSection); @@ -177,7 +178,7 @@ var calculationGroupContext = new PipingCalculationGroupContext(calculationGroup, null, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), new PipingFailureMechanism(), assessmentSection); using (var view = new PipingInputView @@ -208,7 +209,7 @@ var calculationGroupContext = new PipingCalculationGroupContext(new CalculationGroup(), null, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), new PipingFailureMechanism(), assessmentSection); using (var view = new PipingInputView @@ -241,7 +242,7 @@ var calculationGroupContext = new PipingCalculationGroupContext(calculationGroup, null, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), new PipingFailureMechanism(), assessmentSection); using (var view = new PipingInputView @@ -274,7 +275,7 @@ var calculationGroupContext = new PipingCalculationGroupContext(new CalculationGroup(), null, Enumerable.Empty(), - Enumerable.Empty(), + Enumerable.Empty(), new PipingFailureMechanism(), assessmentSection); using (var view = new PipingInputView Index: Ringtoets/Piping/test/Ringtoets.Piping.Service.Test/PipingCalculationServiceTest.cs =================================================================== diff -u -ra1e976b5692d931d9bf7bc79ad667a2587125978 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Service.Test/PipingCalculationServiceTest.cs (.../PipingCalculationServiceTest.cs) (revision a1e976b5692d931d9bf7bc79ad667a2587125978) +++ Ringtoets/Piping/test/Ringtoets.Piping.Service.Test/PipingCalculationServiceTest.cs (.../PipingCalculationServiceTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -28,6 +28,7 @@ using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Service.TestUtil; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Data.TestUtil; using Ringtoets.Piping.KernelWrapper.SubCalculator; using Ringtoets.Piping.KernelWrapper.TestUtil; @@ -346,14 +347,15 @@ PermeabilityCoefficientOfVariation = 0.5, PermeabilityMean = 1 }; - testCalculation.InputParameters.StochasticSoilProfile.SoilProfile = new PipingSoilProfile( - string.Empty, 0.0, - new[] - { - topLayer, - bottomLayer - }, - SoilProfileType.SoilProfile1D, -1); + testCalculation.InputParameters.StochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile( + string.Empty, 0.0, + new[] + { + topLayer, + bottomLayer + }, + SoilProfileType.SoilProfile1D, -1)); testCalculation.Name = name; @@ -391,7 +393,7 @@ }, SoilProfileType.SoilProfile1D, -1); - testCalculation.InputParameters.StochasticSoilProfile.SoilProfile = profile; + testCalculation.InputParameters.StochasticSoilProfile = new PipingStochasticSoilProfile(0.0, profile); testCalculation.Name = name; var isValid = false; @@ -435,7 +437,7 @@ }, SoilProfileType.SoilProfile1D, -1); - testCalculation.InputParameters.StochasticSoilProfile.SoilProfile = profile; + testCalculation.InputParameters.StochasticSoilProfile = new PipingStochasticSoilProfile(0.0, profile); testCalculation.Name = name; var isValid = false; @@ -482,7 +484,7 @@ }, SoilProfileType.SoilProfile1D, -1); - testCalculation.InputParameters.StochasticSoilProfile.SoilProfile = profile; + testCalculation.InputParameters.StochasticSoilProfile = new PipingStochasticSoilProfile(0.0, profile); testCalculation.Name = name; var isValid = false; @@ -546,7 +548,7 @@ }, SoilProfileType.SoilProfile1D, -1); - testCalculation.InputParameters.StochasticSoilProfile.SoilProfile = profile; + testCalculation.InputParameters.StochasticSoilProfile = new PipingStochasticSoilProfile(0.0, profile); testCalculation.Name = name; var isValid = false; @@ -607,7 +609,7 @@ }, SoilProfileType.SoilProfile1D, -1); - testCalculation.InputParameters.StochasticSoilProfile.SoilProfile = profile; + testCalculation.InputParameters.StochasticSoilProfile = new PipingStochasticSoilProfile(0.0, profile); testCalculation.Name = name; var isValid = false; @@ -660,7 +662,7 @@ SoilProfileType.SoilProfile1D, -1); testCalculation.Name = name; - testCalculation.InputParameters.StochasticSoilProfile.SoilProfile = profile; + testCalculation.InputParameters.StochasticSoilProfile = new PipingStochasticSoilProfile(0.0, profile); var isValid = false; @@ -720,7 +722,7 @@ }, SoilProfileType.SoilProfile1D, -1); - testCalculation.InputParameters.StochasticSoilProfile.SoilProfile = profile; + testCalculation.InputParameters.StochasticSoilProfile = new PipingStochasticSoilProfile(0.0, profile); testCalculation.Name = name; var isValid = false; @@ -785,7 +787,7 @@ }, SoilProfileType.SoilProfile1D, -1); - testCalculation.InputParameters.StochasticSoilProfile.SoilProfile = profile; + testCalculation.InputParameters.StochasticSoilProfile = new PipingStochasticSoilProfile(0.0, profile); testCalculation.Name = name; var isValid = false; @@ -835,7 +837,7 @@ SoilProfileType.SoilProfile1D, -1); testCalculation.Name = name; - testCalculation.InputParameters.StochasticSoilProfile.SoilProfile = profile; + testCalculation.InputParameters.StochasticSoilProfile = new PipingStochasticSoilProfile(0.0, profile); var isValid = false; @@ -895,7 +897,7 @@ SoilProfileType.SoilProfile1D, -1); testCalculation.Name = name; - testCalculation.InputParameters.StochasticSoilProfile.SoilProfile = profile; + testCalculation.InputParameters.StochasticSoilProfile = new PipingStochasticSoilProfile(0.0, profile); // Call Action call = () => PipingCalculationService.Validate(testCalculation); Index: Ringtoets/Piping/test/Ringtoets.Piping.Service.Test/PipingDataSynchronizationServiceTest.cs =================================================================== diff -u -rfe90a6d174a01975381e6cda55ed1f7f4e831a51 -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Service.Test/PipingDataSynchronizationServiceTest.cs (.../PipingDataSynchronizationServiceTest.cs) (revision fe90a6d174a01975381e6cda55ed1f7f4e831a51) +++ Ringtoets/Piping/test/Ringtoets.Piping.Service.Test/PipingDataSynchronizationServiceTest.cs (.../PipingDataSynchronizationServiceTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -27,6 +27,7 @@ using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Service; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Data.TestUtil; using Ringtoets.Piping.KernelWrapper.TestUtil; using Ringtoets.Piping.Primitives; @@ -352,7 +353,7 @@ { // Setup PipingFailureMechanism failureMechanism = null; - var soilModel = new StochasticSoilModel("A"); + PipingStochasticSoilModel soilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(); // Call TestDelegate call = () => PipingDataSynchronizationService.RemoveStochasticSoilModel(failureMechanism, soilModel); @@ -367,7 +368,7 @@ { // Setup var failureMechanism = new PipingFailureMechanism(); - StochasticSoilModel soilModel = null; + PipingStochasticSoilModel soilModel = null; // Call TestDelegate call = () => PipingDataSynchronizationService.RemoveStochasticSoilModel(failureMechanism, soilModel); @@ -382,7 +383,7 @@ { // Setup PipingFailureMechanism failureMechanism = PipingTestDataGenerator.GetPipingFailureMechanismWithAllCalculationConfigurations(); - StochasticSoilModel soilModel = failureMechanism.StochasticSoilModels[1]; + PipingStochasticSoilModel soilModel = failureMechanism.StochasticSoilModels[1]; PipingCalculation[] calculationsWithSoilModel = failureMechanism.Calculations .Cast() .Where(c => ReferenceEquals(c.InputParameters.StochasticSoilModel, soilModel)) @@ -489,10 +490,12 @@ [Test] public void RemoveStochasticSoilProfileFromInput_WithoutFailureMechanism_ThrowsArgumentNullException() { + // Setup + var stochasticSoilProfile = new PipingStochasticSoilProfile(0.5, PipingSoilProfileTestFactory.CreatePipingSoilProfile()); + // Call TestDelegate test = () => PipingDataSynchronizationService.RemoveStochasticSoilProfileFromInput( - null, - new StochasticSoilProfile(0.5, SoilProfileType.SoilProfile1D, -1)); + null, stochasticSoilProfile); // Assert var exception = Assert.Throws(test); @@ -520,12 +523,12 @@ IEnumerable calculations = failureMechanism .Calculations .Cast(); - StochasticSoilProfile profileToDelete = null; + PipingStochasticSoilProfile profileToDelete = null; foreach (PipingCalculationScenario pipingCalculationScenario in calculations) { PipingInput input = pipingCalculationScenario.InputParameters; - StochasticSoilProfile currentProfile = input.StochasticSoilProfile; + PipingStochasticSoilProfile currentProfile = input.StochasticSoilProfile; if (profileToDelete == null) { profileToDelete = currentProfile; @@ -551,14 +554,14 @@ IEnumerable calculations = failureMechanism .Calculations .Cast(); - StochasticSoilProfile profileToDelete = null; + PipingStochasticSoilProfile profileToDelete = null; var expectedInputs = new List(); foreach (PipingCalculationScenario pipingCalculationScenario in calculations) { PipingInput input = pipingCalculationScenario.InputParameters; - StochasticSoilProfile currentProfile = input.StochasticSoilProfile; + PipingStochasticSoilProfile currentProfile = input.StochasticSoilProfile; if (profileToDelete == null) { profileToDelete = currentProfile; @@ -589,12 +592,12 @@ var expectedAffectedObjects = new List(); - StochasticSoilProfile profileToDelete = null; + PipingStochasticSoilProfile profileToDelete = null; foreach (PipingCalculationScenario pipingCalculationScenario in calculations) { PipingInput input = pipingCalculationScenario.InputParameters; - StochasticSoilProfile currentProfile = input.StochasticSoilProfile; + PipingStochasticSoilProfile currentProfile = input.StochasticSoilProfile; if (profileToDelete == null) { profileToDelete = currentProfile; @@ -620,10 +623,12 @@ [Test] public void ClearStochasticSoilProfileDependentData_WithoutFailureMechanism_ThrowsArgumentNullException() { + // Setup + var stochasticSoilProfile = new PipingStochasticSoilProfile(0.5, PipingSoilProfileTestFactory.CreatePipingSoilProfile()); + // Call TestDelegate test = () => PipingDataSynchronizationService.ClearStochasticSoilProfileDependentData( - null, - new StochasticSoilProfile(0.5, SoilProfileType.SoilProfile1D, -1)); + null, stochasticSoilProfile); // Assert var exception = Assert.Throws(test); @@ -651,12 +656,12 @@ IEnumerable calculations = failureMechanism .Calculations .Cast(); - StochasticSoilProfile profileToDelete = null; + PipingStochasticSoilProfile profileToDelete = null; foreach (PipingCalculationScenario pipingCalculationScenario in calculations) { PipingInput input = pipingCalculationScenario.InputParameters; - StochasticSoilProfile currentProfile = input.StochasticSoilProfile; + PipingStochasticSoilProfile currentProfile = input.StochasticSoilProfile; if (profileToDelete == null) { profileToDelete = currentProfile; @@ -682,14 +687,14 @@ IEnumerable calculations = failureMechanism .Calculations .Cast(); - StochasticSoilProfile profileToDelete = null; + PipingStochasticSoilProfile profileToDelete = null; var expectedInputs = new List(); foreach (PipingCalculationScenario pipingCalculationScenario in calculations) { PipingInput input = pipingCalculationScenario.InputParameters; - StochasticSoilProfile currentProfile = input.StochasticSoilProfile; + PipingStochasticSoilProfile currentProfile = input.StochasticSoilProfile; if (profileToDelete == null) { profileToDelete = currentProfile; @@ -720,12 +725,12 @@ var expectedAffectedObjects = new List(); - StochasticSoilProfile profileToDelete = null; + PipingStochasticSoilProfile profileToDelete = null; foreach (PipingCalculationScenario pipingCalculationScenario in calculations) { PipingInput input = pipingCalculationScenario.InputParameters; - StochasticSoilProfile currentProfile = input.StochasticSoilProfile; + PipingStochasticSoilProfile currentProfile = input.StochasticSoilProfile; if (profileToDelete == null) { profileToDelete = currentProfile; Index: Ringtoets/Piping/test/Ringtoets.Piping.Service.Test/PipingInputServiceTest.cs =================================================================== diff -u -r16df8541528639fd1e8d9f2584fae28808b63fad -r26f527fb809a2325c8f883ece9da01a8f8040eb3 --- Ringtoets/Piping/test/Ringtoets.Piping.Service.Test/PipingInputServiceTest.cs (.../PipingInputServiceTest.cs) (revision 16df8541528639fd1e8d9f2584fae28808b63fad) +++ Ringtoets/Piping/test/Ringtoets.Piping.Service.Test/PipingInputServiceTest.cs (.../PipingInputServiceTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) @@ -21,7 +21,9 @@ using NUnit.Framework; using Ringtoets.Piping.Data; -using Ringtoets.Piping.Primitives; +using Ringtoets.Piping.Data.SoilProfile; +using Ringtoets.Piping.Data.TestUtil; +using Ringtoets.Piping.KernelWrapper.TestUtil; namespace Ringtoets.Piping.Service.Test { @@ -32,7 +34,7 @@ public void SetMatchingStochasticSoilModel_SurfaceLineOverlappingSingleSoilModel_SetsSoilModel() { // Setup - var soilModel = new StochasticSoilModel("A"); + PipingStochasticSoilModel soilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(); var pipingInput = new PipingInput(new GeneralPipingInput()); // Call @@ -42,16 +44,16 @@ }); // Assert - Assert.AreEqual(soilModel, pipingInput.StochasticSoilModel); + Assert.AreSame(soilModel, pipingInput.StochasticSoilModel); } [Test] public void SetMatchingStochasticSoilModel_SurfaceLineOverlappingMultipleSoilModels_DoesNotSetModel() { // Setup var pipingInput = new PipingInput(new GeneralPipingInput()); - var soilModel1 = new StochasticSoilModel("A"); - var soilModel2 = new StochasticSoilModel("C"); + PipingStochasticSoilModel soilModel1 = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("A"); + PipingStochasticSoilModel soilModel2 = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("C"); // Call PipingInputService.SetMatchingStochasticSoilModel(pipingInput, new[] @@ -68,14 +70,14 @@ public void SetMatchingStochasticSoilModel_CurrentSoilModelNotInOverlappingMultipleSoilModels_ClearsModel() { // Setup - var nonOverlappingSoilModel = new StochasticSoilModel("A"); + PipingStochasticSoilModel nonOverlappingSoilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(); var pipingInput = new PipingInput(new GeneralPipingInput()) { StochasticSoilModel = nonOverlappingSoilModel }; - var soilModel1 = new StochasticSoilModel("A"); - var soilModel2 = new StochasticSoilModel("C"); + PipingStochasticSoilModel soilModel1 = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("A"); + PipingStochasticSoilModel soilModel2 = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("C"); // Call PipingInputService.SetMatchingStochasticSoilModel(pipingInput, new[] @@ -92,10 +94,15 @@ public void SyncStochasticSoilProfileWithStochasticSoilModel_SingleStochasticSoilProfileInStochasticSoilModel_SetsStochasticSoilProfile() { // Setup - var soilProfile = new StochasticSoilProfile(0.3, SoilProfileType.SoilProfile1D, 1); + var soilProfile = new PipingStochasticSoilProfile(1, PipingSoilProfileTestFactory.CreatePipingSoilProfile()); - var soilModel = new StochasticSoilModel("A"); - soilModel.StochasticSoilProfiles.Add(soilProfile); + var soilModel = new PipingStochasticSoilModel("A") + { + StochasticSoilProfiles = + { + soilProfile + } + }; var pipingInput = new PipingInput(new GeneralPipingInput()) { @@ -106,18 +113,18 @@ PipingInputService.SyncStochasticSoilProfileWithStochasticSoilModel(pipingInput); // Assert - Assert.AreEqual(soilProfile, pipingInput.StochasticSoilProfile); + Assert.AreSame(soilProfile, pipingInput.StochasticSoilProfile); } [Test] public void SyncStochasticSoilProfileWithStochasticSoilModel_MultipleStochasticSoilProfilesInStochasticSoilModel_DoesNotSetStochasticSoilProfile() { // Setup - var soilModel = new StochasticSoilModel("A"); + PipingStochasticSoilModel soilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(); soilModel.StochasticSoilProfiles.AddRange(new[] { - new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 1), - new StochasticSoilProfile(1.0, SoilProfileType.SoilProfile1D, 2) + new PipingStochasticSoilProfile(0.0, PipingSoilProfileTestFactory.CreatePipingSoilProfile()), + new PipingStochasticSoilProfile(1.0, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) }); var pipingInput = new PipingInput(new GeneralPipingInput()) { @@ -135,9 +142,9 @@ public void SyncStochasticSoilProfileWithStochasticSoilModel_SingleStochasticSoilProfileInSoilModelAlreadySet_StochasticSoilProfileDoesNotChange() { // Setup - var soilProfile = new StochasticSoilProfile(0.3, SoilProfileType.SoilProfile1D, 1); + var soilProfile = new PipingStochasticSoilProfile(0.3, PipingSoilProfileTestFactory.CreatePipingSoilProfile()); - var soilModel = new StochasticSoilModel("A"); + PipingStochasticSoilModel soilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(); soilModel.StochasticSoilProfiles.Add(soilProfile); var pipingInput = new PipingInput(new GeneralPipingInput())