Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj =================================================================== diff -u -rfbb3779ff111f2d9c0b6a1a63a91b6b797698db9 -r4938d7e24964edb84ebeb51f96d021bd03501d1f --- Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision fbb3779ff111f2d9c0b6a1a63a91b6b797698db9) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 4938d7e24964edb84ebeb51f96d021bd03501d1f) @@ -232,6 +232,7 @@ + RingtoetsEntities.tt @@ -360,6 +361,7 @@ + @@ -632,6 +634,7 @@ Designer + Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/IllustrationPoints/IllustrationPointResultCreateExtensions.cs =================================================================== diff -u -rfbb3779ff111f2d9c0b6a1a63a91b6b797698db9 -r4938d7e24964edb84ebeb51f96d021bd03501d1f --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/IllustrationPoints/IllustrationPointResultCreateExtensions.cs (.../IllustrationPointResultCreateExtensions.cs) (revision fbb3779ff111f2d9c0b6a1a63a91b6b797698db9) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/IllustrationPoints/IllustrationPointResultCreateExtensions.cs (.../IllustrationPointResultCreateExtensions.cs) (revision 4938d7e24964edb84ebeb51f96d021bd03501d1f) @@ -19,13 +19,75 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using Application.Ringtoets.Storage.DbContext; +using Core.Common.Utils.Extensions; using Ringtoets.Common.Data.Hydraulics.IllustrationPoints; namespace Application.Ringtoets.Storage.Create.IllustrationPoints { /// - /// Extension methods for related to creating a . + /// Extension methods for related to creating an instance + /// of . /// - internal static class IllustrationPointResultCreateExtensions {} + internal static class IllustrationPointResultCreateExtensions + { + /// + /// Creates a based on the + /// information of the . + /// + /// The illustration point result to create a database + /// entity for. + /// The index at which + /// resides within its parent. + /// A new . + /// Thrown when + /// is null. + public static HydraulicLocationIllustrationPointResultEntity CreateHydraulicLocationIllustrationPointResultEntity( + this IllustrationPointResult illustrationPointResult, int order) + { + if (illustrationPointResult == null) + { + throw new ArgumentNullException(nameof(illustrationPointResult)); + } + + var entity = new HydraulicLocationIllustrationPointResultEntity + { + Description = illustrationPointResult.Description.DeepClone(), + Value = illustrationPointResult.Value, + Order = order + }; + + return entity; + } + + /// + /// Creates a based on the + /// information of the . + /// + /// The illustration point result to create a database + /// entity for. + /// The index at which + /// resides within its parent. + /// A new . + /// Thrown when + /// is null. + public static GrassCoverErosionOutwardsHydraulicLocationIllustrationPointResultEntity CreateGrassCoverErosionOutwardsHydraulicLocationIllustrationPointResultEntity( + this IllustrationPointResult illustrationPointResult, int order) + { + if (illustrationPointResult == null) + { + throw new ArgumentNullException(nameof(illustrationPointResult)); + } + + var entity = new GrassCoverErosionOutwardsHydraulicLocationIllustrationPointResultEntity + { + Description = illustrationPointResult.Description.DeepClone(), + Value = illustrationPointResult.Value, + Order = order + }; + + return entity; + } + } } \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/GrassCoverErosionOutwardsHydraulicLocationIllustrationPointResultEntity.cs =================================================================== diff -u -rab5185b4950e4d02d6334996028cd65239e152dc -r4938d7e24964edb84ebeb51f96d021bd03501d1f --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/GrassCoverErosionOutwardsHydraulicLocationIllustrationPointResultEntity.cs (.../GrassCoverErosionOutwardsHydraulicLocationIllustrationPointResultEntity.cs) (revision ab5185b4950e4d02d6334996028cd65239e152dc) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/GrassCoverErosionOutwardsHydraulicLocationIllustrationPointResultEntity.cs (.../GrassCoverErosionOutwardsHydraulicLocationIllustrationPointResultEntity.cs) (revision 4938d7e24964edb84ebeb51f96d021bd03501d1f) @@ -30,7 +30,7 @@ namespace Application.Ringtoets.Storage.DbContext { - public class GrassCoverErosionOutwardsHydraulicLocationIllustrationPointResultEntity + public partial class GrassCoverErosionOutwardsHydraulicLocationIllustrationPointResultEntity { public long GrassCoverErosionOutwardsHydraulicLocationIllustrationPointResultEntityId { get; set; } public long GrassCoverErosionOutwardsHydraulicLocationWindDirectionClosingSituationIllustrationPointEntityId { get; set; } Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/PartialGrassCoverErosionOutwardsHydraulicLocationIllustrationPointResultEntity.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/PartialGrassCoverErosionOutwardsHydraulicLocationIllustrationPointResultEntity.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/PartialGrassCoverErosionOutwardsHydraulicLocationIllustrationPointResultEntity.cs (revision 4938d7e24964edb84ebeb51f96d021bd03501d1f) @@ -0,0 +1,29 @@ +// 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. + +namespace Application.Ringtoets.Storage.DbContext +{ + /// + /// Partial implementation of + /// that implements . + /// + public partial class GrassCoverErosionOutwardsHydraulicLocationIllustrationPointResultEntity : IIllustrationPointResultEntity {} +} \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/IllustrationPoints/IIllustrationPointResultEntityReadExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/IllustrationPoints/IIllustrationPointResultEntityReadExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/IllustrationPoints/IIllustrationPointResultEntityReadExtensions.cs (revision 4938d7e24964edb84ebeb51f96d021bd03501d1f) @@ -0,0 +1,52 @@ +// 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.Common.Data.Hydraulics.IllustrationPoints; + +namespace Application.Ringtoets.Storage.Read.IllustrationPoints +{ + /// + /// Extension methods for related to creating an + /// . + /// + internal static class IIllustrationPointResultEntityReadExtensions + { + /// + /// Reads the and use the information to + /// construct an . + /// + /// The to create + /// for. + /// A new . + /// Thrown when is null. + public static IllustrationPointResult Read(this IIllustrationPointResultEntity entity) + { + if (entity == null) + { + throw new ArgumentNullException(nameof(entity)); + } + return new IllustrationPointResult(entity.Description, + entity.Value); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj =================================================================== diff -u -rfbb3779ff111f2d9c0b6a1a63a91b6b797698db9 -r4938d7e24964edb84ebeb51f96d021bd03501d1f --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision fbb3779ff111f2d9c0b6a1a63a91b6b797698db9) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 4938d7e24964edb84ebeb51f96d021bd03501d1f) @@ -122,6 +122,7 @@ + Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/IllustrationPoints/IllustrationPointResultCreateExtensionsTest.cs =================================================================== diff -u -rfbb3779ff111f2d9c0b6a1a63a91b6b797698db9 -r4938d7e24964edb84ebeb51f96d021bd03501d1f --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/IllustrationPoints/IllustrationPointResultCreateExtensionsTest.cs (.../IllustrationPointResultCreateExtensionsTest.cs) (revision fbb3779ff111f2d9c0b6a1a63a91b6b797698db9) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/IllustrationPoints/IllustrationPointResultCreateExtensionsTest.cs (.../IllustrationPointResultCreateExtensionsTest.cs) (revision 4938d7e24964edb84ebeb51f96d021bd03501d1f) @@ -19,10 +19,79 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; +using Application.Ringtoets.Storage.Create.IllustrationPoints; +using Application.Ringtoets.Storage.DbContext; +using Core.Common.TestUtil; using NUnit.Framework; +using Ringtoets.Common.Data.Hydraulics.IllustrationPoints; +using Ringtoets.Common.Data.TestUtil; namespace Application.Ringtoets.Storage.Test.Create.IllustrationPoints { [TestFixture] - public class IllustrationPointResultCreateExtensionsTest {} + public class IllustrationPointResultCreateExtensionsTest + { + [Test] + public void CreateHydraulicLocationIllustrationPointResultEntity_IllustrationPointResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => ((IllustrationPointResult) null).CreateHydraulicLocationIllustrationPointResultEntity(0); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("illustrationPointResult", paramName); + } + + [Test] + public void CreateHydraulicLocationIllustrationPointResultEntity_ValidIllustrationPointResult_ReturnEntity() + { + // Setup + var random = new Random(123); + var illustrationPointResult = new IllustrationPointResult("Some description", + random.NextDouble()); + int order = random.Next(); + + // Call + HydraulicLocationIllustrationPointResultEntity entity = + illustrationPointResult.CreateHydraulicLocationIllustrationPointResultEntity(order); + + // Assert + Assert.IsInstanceOf(entity); + TestHelper.AssertAreEqualButNotSame(illustrationPointResult.Description, entity.Description); + Assert.AreEqual(illustrationPointResult.Value, entity.Value, illustrationPointResult.Value.GetAccuracy()); + Assert.AreEqual(order, entity.Order); + } + + [Test] + public void CreateGrassCoverErosionOutwardsHydraulicLocationIllustrationPointResultEntity_IllustrationPointResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => ((IllustrationPointResult) null).CreateGrassCoverErosionOutwardsHydraulicLocationIllustrationPointResultEntity(0); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("illustrationPointResult", paramName); + } + + [Test] + public void CreateGrassCoverErosionOutwardsHydraulicLocationIllustrationPointResultEntity_ValidIllustrationPointResult_ReturnEntity() + { + // Setup + var random = new Random(123); + var illustrationPointResult = new IllustrationPointResult("Some description", + random.NextDouble()); + int order = random.Next(); + + // Call + GrassCoverErosionOutwardsHydraulicLocationIllustrationPointResultEntity entity = + illustrationPointResult.CreateGrassCoverErosionOutwardsHydraulicLocationIllustrationPointResultEntity(order); + + // Assert + Assert.IsInstanceOf(entity); + TestHelper.AssertAreEqualButNotSame(illustrationPointResult.Description, entity.Description); + Assert.AreEqual(illustrationPointResult.Value, entity.Value, illustrationPointResult.Value.GetAccuracy()); + Assert.AreEqual(order, entity.Order); + } + } } \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/IllustrationPoints/IIllustrationPointResultEntityReadExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/IllustrationPoints/IIllustrationPointResultEntityReadExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/IllustrationPoints/IIllustrationPointResultEntityReadExtensionsTest.cs (revision 4938d7e24964edb84ebeb51f96d021bd03501d1f) @@ -0,0 +1,66 @@ +// 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.Read.IllustrationPoints; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.Hydraulics.IllustrationPoints; +using Ringtoets.Common.Data.TestUtil; + +namespace Application.Ringtoets.Storage.Test.Read.IllustrationPoints +{ + [TestFixture] + public class IIllustrationPointResultEntityReadExtensionsTest + { + [Test] + public void Read_EntityNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => ((IIllustrationPointResultEntity) null).Read(); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("entity", paramName); + } + + [Test] + public void Read_ValidEntity_ReturnIllustrationPointResult() + { + // Setup + var random = new Random(123); + var mockRepository = new MockRepository(); + var entity = mockRepository.Stub(); + entity.Description = "Description"; + entity.Value = random.NextDouble(); + mockRepository.ReplayAll(); + + // Call + IllustrationPointResult illustrationPointResult = entity.Read(); + + // Assert + Assert.AreEqual(entity.Description, illustrationPointResult.Description); + Assert.AreEqual(entity.Value, illustrationPointResult.Value, illustrationPointResult.Value.GetAccuracy()); + mockRepository.VerifyAll(); + } + } +} \ No newline at end of file