Index: Ringtoets/Storage/src/Ringtoets.Storage.Core/Create/AssessmentSectionCreateExtensions.cs =================================================================== diff -u -r49f69c96ae5f4b3569f2acfd343e517c1c43b140 -r6ca04881a5491878ffe7c997f0d61272d83ffb92 --- Ringtoets/Storage/src/Ringtoets.Storage.Core/Create/AssessmentSectionCreateExtensions.cs (.../AssessmentSectionCreateExtensions.cs) (revision 49f69c96ae5f4b3569f2acfd343e517c1c43b140) +++ Ringtoets/Storage/src/Ringtoets.Storage.Core/Create/AssessmentSectionCreateExtensions.cs (.../AssessmentSectionCreateExtensions.cs) (revision 6ca04881a5491878ffe7c997f0d61272d83ffb92) @@ -121,6 +121,8 @@ { if (hydraulicBoundaryDatabase.IsLinked()) { + entity.HydraulicBoundaryDatabaseEntities.Add(hydraulicBoundaryDatabase.Create()); + for (var i = 0; i < hydraulicBoundaryDatabase.Locations.Count; i++) { HydraulicBoundaryLocation hydraulicBoundaryLocation = hydraulicBoundaryDatabase.Locations[i]; Index: Ringtoets/Storage/src/Ringtoets.Storage.Core/Create/HydraulicLocationConfigurationSettingsCreateExtensions.cs =================================================================== diff -u --- Ringtoets/Storage/src/Ringtoets.Storage.Core/Create/HydraulicLocationConfigurationSettingsCreateExtensions.cs (revision 0) +++ Ringtoets/Storage/src/Ringtoets.Storage.Core/Create/HydraulicLocationConfigurationSettingsCreateExtensions.cs (revision 6ca04881a5491878ffe7c997f0d61272d83ffb92) @@ -0,0 +1,69 @@ +// Copyright (C) Stichting Deltares 2018. 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.Util.Extensions; +using Ringtoets.Common.Data.Hydraulics; +using Ringtoets.Storage.Core.DbContext; + +namespace Ringtoets.Storage.Core.Create +{ + /// + /// Extension methods for related + /// to creating a + /// + public static class HydraulicLocationConfigurationSettingsCreateExtensions + { + /// + /// Creates a based on the information of the + /// . + /// + /// The to create a + /// for. + /// A new . + /// Thrown when + /// is null. + internal static HydraulicBoundaryDatabaseEntity Create(this HydraulicBoundaryDatabase hydraulicBoundaryDatabase) + { + if (hydraulicBoundaryDatabase == null) + { + throw new ArgumentNullException(nameof(hydraulicBoundaryDatabase)); + } + + HydraulicLocationConfigurationSettings settings = hydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings; + return new HydraulicBoundaryDatabaseEntity + { + HydraulicBoundaryDatabaseFilePath = hydraulicBoundaryDatabase.FilePath.DeepClone(), + HydraulicBoundaryDatabaseVersion = hydraulicBoundaryDatabase.Version.DeepClone(), + HydraulicLocationConfigurationSettingsFilePath = settings.FilePath.DeepClone(), + HydraulicLocationConfigurationSettingsScenarioName = settings.ScenarioName.DeepClone(), + HydraulicLocationConfigurationSettingsYear = settings.Year, + HydraulicLocationConfigurationSettingsScope = settings.Scope.DeepClone(), + HydraulicLocationConfigurationSettingsSeaLevel = settings.SeaLevel.DeepClone(), + HydraulicLocationConfigurationSettingsRiverDischarge = settings.RiverDischarge.DeepClone(), + HydraulicLocationConfigurationSettingsLakeLevel = settings.LakeLevel.DeepClone(), + HydraulicLocationConfigurationSettingsWindDirection = settings.WindDirection.DeepClone(), + HydraulicLocationConfigurationSettingsWindSpeed = settings.WindSpeed.DeepClone(), + HydraulicLocationConfigurationSettingsComment = settings.Comment.DeepClone() + }; + } + } +} \ No newline at end of file Index: Ringtoets/Storage/src/Ringtoets.Storage.Core/Ringtoets.Storage.Core.csproj =================================================================== diff -u -r0b2be41a22ade831f1784e44fb91cb8b5a570a43 -r6ca04881a5491878ffe7c997f0d61272d83ffb92 --- Ringtoets/Storage/src/Ringtoets.Storage.Core/Ringtoets.Storage.Core.csproj (.../Ringtoets.Storage.Core.csproj) (revision 0b2be41a22ade831f1784e44fb91cb8b5a570a43) +++ Ringtoets/Storage/src/Ringtoets.Storage.Core/Ringtoets.Storage.Core.csproj (.../Ringtoets.Storage.Core.csproj) (revision 6ca04881a5491878ffe7c997f0d61272d83ffb92) @@ -47,6 +47,7 @@ + Index: Ringtoets/Storage/test/Ringtoets.Storage.Core.Test/Create/AssessmentSectionCreateExtensionsTest.cs =================================================================== diff -u -r49f69c96ae5f4b3569f2acfd343e517c1c43b140 -r6ca04881a5491878ffe7c997f0d61272d83ffb92 --- Ringtoets/Storage/test/Ringtoets.Storage.Core.Test/Create/AssessmentSectionCreateExtensionsTest.cs (.../AssessmentSectionCreateExtensionsTest.cs) (revision 49f69c96ae5f4b3569f2acfd343e517c1c43b140) +++ Ringtoets/Storage/test/Ringtoets.Storage.Core.Test/Create/AssessmentSectionCreateExtensionsTest.cs (.../AssessmentSectionCreateExtensionsTest.cs) (revision 6ca04881a5491878ffe7c997f0d61272d83ffb92) @@ -231,6 +231,7 @@ HydraulicBoundaryDatabase hydraulicBoundaryDatabase = assessmentSection.HydraulicBoundaryDatabase; Assert.AreEqual(hydraulicBoundaryDatabase.FilePath, hydraulicBoundaryDatabaseEntity.HydraulicBoundaryDatabaseFilePath); + Assert.AreEqual(hydraulicBoundaryDatabase.Version, hydraulicBoundaryDatabaseEntity.HydraulicBoundaryDatabaseVersion); HydraulicLocationConfigurationSettings settings = hydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings; Assert.AreEqual(hydraulicBoundaryDatabase.Version, hydraulicBoundaryDatabaseEntity.HydraulicBoundaryDatabaseVersion); Index: Ringtoets/Storage/test/Ringtoets.Storage.Core.Test/Create/HydraulicLocationConfigurationSettingsCreateExtensionsTest.cs =================================================================== diff -u --- Ringtoets/Storage/test/Ringtoets.Storage.Core.Test/Create/HydraulicLocationConfigurationSettingsCreateExtensionsTest.cs (revision 0) +++ Ringtoets/Storage/test/Ringtoets.Storage.Core.Test/Create/HydraulicLocationConfigurationSettingsCreateExtensionsTest.cs (revision 6ca04881a5491878ffe7c997f0d61272d83ffb92) @@ -0,0 +1,86 @@ +// Copyright (C) Stichting Deltares 2018. 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.TestUtil; +using NUnit.Framework; +using Ringtoets.Common.Data.Hydraulics; +using Ringtoets.Storage.Core.Create; +using Ringtoets.Storage.Core.DbContext; + +namespace Ringtoets.Storage.Core.Test.Create +{ + [TestFixture] + public class HydraulicLocationConfigurationSettingsCreateExtensionsTest + { + [Test] + public void Create_HydraulicBoundaryDatabaseNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => ((HydraulicBoundaryDatabase) null).Create(); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("hydraulicBoundaryDatabase", exception.ParamName); + } + + [Test] + public void Create_ValidHydraulicBoundaryDatabase_ReturnsHydraulicBoundaryDatabaseEntity() + { + // Setup + var random = new Random(21); + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = "hydraulicBoundaryDatabasefilePath", + Version = "Version" + }; + hydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings.SetValues("hlcdFilePath", + "ScenarioName", + random.Next(), + "Scope", + "SeaLevel", + "RiverDischarge", + "LakeLevel", + "WindDirection", + "WindSpeed", + "Comment"); + + // Call + HydraulicBoundaryDatabaseEntity entity = hydraulicBoundaryDatabase.Create(); + + // Assert + TestHelper.AssertAreEqualButNotSame(hydraulicBoundaryDatabase.FilePath, entity.HydraulicBoundaryDatabaseFilePath); + TestHelper.AssertAreEqualButNotSame(hydraulicBoundaryDatabase.Version, entity.HydraulicBoundaryDatabaseVersion); + + HydraulicLocationConfigurationSettings settings = hydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings; + TestHelper.AssertAreEqualButNotSame(hydraulicBoundaryDatabase.Version, entity.HydraulicBoundaryDatabaseVersion); + TestHelper.AssertAreEqualButNotSame(settings.ScenarioName, entity.HydraulicLocationConfigurationSettingsScenarioName); + TestHelper.AssertAreEqualButNotSame(settings.Year, entity.HydraulicLocationConfigurationSettingsYear); + TestHelper.AssertAreEqualButNotSame(settings.Scope, entity.HydraulicLocationConfigurationSettingsScope); + TestHelper.AssertAreEqualButNotSame(settings.SeaLevel, entity.HydraulicLocationConfigurationSettingsSeaLevel); + TestHelper.AssertAreEqualButNotSame(settings.RiverDischarge, entity.HydraulicLocationConfigurationSettingsRiverDischarge); + TestHelper.AssertAreEqualButNotSame(settings.LakeLevel, entity.HydraulicLocationConfigurationSettingsLakeLevel); + TestHelper.AssertAreEqualButNotSame(settings.WindDirection, entity.HydraulicLocationConfigurationSettingsWindDirection); + TestHelper.AssertAreEqualButNotSame(settings.WindSpeed, entity.HydraulicLocationConfigurationSettingsWindSpeed); + TestHelper.AssertAreEqualButNotSame(settings.Comment, entity.HydraulicLocationConfigurationSettingsComment); + } + } +} \ No newline at end of file Index: Ringtoets/Storage/test/Ringtoets.Storage.Core.Test/Ringtoets.Storage.Core.Test.csproj =================================================================== diff -u -rba834431b63ea0985c60a0987ca8fb720f801ab6 -r6ca04881a5491878ffe7c997f0d61272d83ffb92 --- Ringtoets/Storage/test/Ringtoets.Storage.Core.Test/Ringtoets.Storage.Core.Test.csproj (.../Ringtoets.Storage.Core.Test.csproj) (revision ba834431b63ea0985c60a0987ca8fb720f801ab6) +++ Ringtoets/Storage/test/Ringtoets.Storage.Core.Test/Ringtoets.Storage.Core.Test.csproj (.../Ringtoets.Storage.Core.Test.csproj) (revision 6ca04881a5491878ffe7c997f0d61272d83ffb92) @@ -58,6 +58,7 @@ +