Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj =================================================================== diff -u -r3014d0ced22c45300938639e7958ea0850485240 -r258acae55e0ae70bcc094a2f7a577b7fbc8d8f2e --- Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 3014d0ced22c45300938639e7958ea0850485240) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 258acae55e0ae70bcc094a2f7a577b7fbc8d8f2e) @@ -81,7 +81,7 @@ - + RingtoetsEntities.tt Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/AssessmentSectionCreateExtensions.cs =================================================================== diff -u -r0fbb881c5c82f540f01772234b3c1faadfab07f9 -r258acae55e0ae70bcc094a2f7a577b7fbc8d8f2e --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/AssessmentSectionCreateExtensions.cs (.../AssessmentSectionCreateExtensions.cs) (revision 0fbb881c5c82f540f01772234b3c1faadfab07f9) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/AssessmentSectionCreateExtensions.cs (.../AssessmentSectionCreateExtensions.cs) (revision 258acae55e0ae70bcc094a2f7a577b7fbc8d8f2e) @@ -79,8 +79,7 @@ AddEntityForHydraulicDatabase(section, entity, registry); AddEntityForReferenceLine(section, entity); - // TODO: WTI-1141 - BackgroundMapDataEntity backgroundMapDataEntity = section.BackgroundMapData.Create(); + BackgroundMapDataEntity backgroundMapDataEntity = section.BackgroundData.Create(); if (backgroundMapDataEntity != null) { entity.BackgroundMapDataEntities.Add(backgroundMapDataEntity); Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/BackgroundDataCreateExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/BackgroundDataCreateExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/BackgroundDataCreateExtensions.cs (revision 258acae55e0ae70bcc094a2f7a577b7fbc8d8f2e) @@ -0,0 +1,74 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using Application.Ringtoets.Storage.DbContext; +using Core.Common.Utils.Extensions; +using Ringtoets.Common.Data.AssessmentSection; + +namespace Application.Ringtoets.Storage.Create +{ + /// + /// Extensions methods for related to + /// creating a . + /// + internal static class BackgroundDataCreateExtensions + { + /// + /// Creates a based on the information of the + /// . + /// + /// The container to create a for. + /// The entity, or null if is not supported. + internal static BackgroundMapDataEntity Create(this BackgroundData backgroundData) + { + if (backgroundData == null) + { + throw new ArgumentNullException(nameof(backgroundData)); + } + + if (backgroundData.BackgroundMapDataType == BackgroundMapDataType.Wmts) + { + return CreateWithWmtsData(backgroundData); + } + return null; // TODO: WTI-1141 + } + + private static BackgroundMapDataEntity CreateWithWmtsData(BackgroundData backgroundData) + { + var entity = new BackgroundMapDataEntity + { + Name = backgroundData.Name.DeepClone(), + IsVisible = Convert.ToByte(backgroundData.IsVisible), + Transparency = backgroundData.Transparency + }; + + if (backgroundData.IsConfigured) + { + entity.SelectedCapabilityName = backgroundData.Parameters[BackgroundDataIdentifiers.SelectedCapabilityIdentifier].DeepClone(); + entity.SourceCapabilitiesUrl = backgroundData.Parameters[BackgroundDataIdentifiers.SourceCapabilitiesUrl].DeepClone(); + entity.PreferredFormat = backgroundData.Parameters[BackgroundDataIdentifiers.PreferredFormat].DeepClone(); + } + + return entity; + } + } +} \ No newline at end of file Fisheye: Tag 258acae55e0ae70bcc094a2f7a577b7fbc8d8f2e refers to a dead (removed) revision in file `Application/Ringtoets/src/Application.Ringtoets.Storage/Create/BackgroundMapDataContainerCreateExtensions.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/AssessmentSectionEntityReadExtensions.cs =================================================================== diff -u -r7799a03be5a1c2ad6bebcddea11e3e10c6c03ea7 -r258acae55e0ae70bcc094a2f7a577b7fbc8d8f2e --- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/AssessmentSectionEntityReadExtensions.cs (.../AssessmentSectionEntityReadExtensions.cs) (revision 7799a03be5a1c2ad6bebcddea11e3e10c6c03ea7) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/AssessmentSectionEntityReadExtensions.cs (.../AssessmentSectionEntityReadExtensions.cs) (revision 258acae55e0ae70bcc094a2f7a577b7fbc8d8f2e) @@ -20,6 +20,7 @@ // All rights reserved. using System; +using System.Collections.Generic; using System.Linq; using Application.Ringtoets.Storage.DbContext; using Application.Ringtoets.Storage.Serializers; @@ -109,11 +110,17 @@ private static void ReadBackgroundMapData(this AssessmentSectionEntity entity, IAssessmentSection assessmentSection) { - BackgroundMapDataContainer container = entity.BackgroundMapDataEntities.Single().Read(); + BackgroundData backgroundData = entity.BackgroundMapDataEntities.Single().Read(); - assessmentSection.BackgroundMapData.IsVisible = container.IsVisible; - assessmentSection.BackgroundMapData.Transparency = container.Transparency; - assessmentSection.BackgroundMapData.MapData = container.MapData; + assessmentSection.BackgroundData.IsVisible = backgroundData.IsVisible; + assessmentSection.BackgroundData.Transparency = backgroundData.Transparency; + assessmentSection.BackgroundData.IsConfigured = backgroundData.IsConfigured; + assessmentSection.BackgroundData.Name = backgroundData.Name; + + foreach (KeyValuePair backgroundDataParameter in backgroundData.Parameters) + { + assessmentSection.BackgroundData.Parameters.Add(backgroundDataParameter.Key, backgroundDataParameter.Value); + } } private static void ReadReferenceLine(this AssessmentSectionEntity entity, IAssessmentSection assessmentSection) Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/BackgroundMapDataEntityReadExtensions.cs =================================================================== diff -u -r7799a03be5a1c2ad6bebcddea11e3e10c6c03ea7 -r258acae55e0ae70bcc094a2f7a577b7fbc8d8f2e --- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/BackgroundMapDataEntityReadExtensions.cs (.../BackgroundMapDataEntityReadExtensions.cs) (revision 7799a03be5a1c2ad6bebcddea11e3e10c6c03ea7) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/BackgroundMapDataEntityReadExtensions.cs (.../BackgroundMapDataEntityReadExtensions.cs) (revision 258acae55e0ae70bcc094a2f7a577b7fbc8d8f2e) @@ -22,53 +22,49 @@ using System; using Application.Ringtoets.Storage.DbContext; using Core.Common.Base.Data; -using Core.Components.Gis; -using Core.Components.Gis.Data; +using Ringtoets.Common.Data.AssessmentSection; namespace Application.Ringtoets.Storage.Read { /// - /// Extension methods for read operations for + /// Extension methods for read operations for /// based on the . /// internal static class BackgroundMapDataEntityReadExtensions { /// /// Read the and use the information - /// to construct a . + /// to construct . /// /// The - /// to create for. - /// A new . + /// to create for. + /// A new . /// Thrown when /// is null. - internal static BackgroundMapDataContainer Read(this BackgroundMapDataEntity entity) + internal static BackgroundData Read(this BackgroundMapDataEntity entity) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } - var container = new BackgroundMapDataContainer + var backgroundData = new BackgroundData { IsVisible = Convert.ToBoolean(entity.IsVisible), Transparency = (RoundedDouble) entity.Transparency, - MapData = CreateMapData(entity) + Name = entity.Name }; - return container; - } - - private static WmtsMapData CreateMapData(BackgroundMapDataEntity entity) - { - WmtsMapData mapData = WmtsMapData.CreateUnconnectedMapData(); - mapData.Name = entity.Name; - if (entity.SourceCapabilitiesUrl != null && entity.SelectedCapabilityName != null && entity.PreferredFormat != null) { - mapData.Configure(entity.SourceCapabilitiesUrl, entity.SelectedCapabilityName, entity.PreferredFormat); + backgroundData.Parameters[BackgroundDataIdentifiers.SourceCapabilitiesUrl] = entity.SourceCapabilitiesUrl; + backgroundData.Parameters[BackgroundDataIdentifiers.SelectedCapabilityIdentifier] = entity.SelectedCapabilityName; + backgroundData.Parameters[BackgroundDataIdentifiers.PreferredFormat] = entity.PreferredFormat; + + backgroundData.IsConfigured = true; } - return mapData; + + return backgroundData; } } } \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj =================================================================== diff -u -r7a140d35031595b2a411de33cb2bc427221824b2 -r258acae55e0ae70bcc094a2f7a577b7fbc8d8f2e --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 7a140d35031595b2a411de33cb2bc427221824b2) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 258acae55e0ae70bcc094a2f7a577b7fbc8d8f2e) @@ -78,7 +78,7 @@ Properties\GlobalAssembly.cs - + Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/AssessmentSectionCreateExtensionsTest.cs =================================================================== diff -u -r3014d0ced22c45300938639e7958ea0850485240 -r258acae55e0ae70bcc094a2f7a577b7fbc8d8f2e --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/AssessmentSectionCreateExtensionsTest.cs (.../AssessmentSectionCreateExtensionsTest.cs) (revision 3014d0ced22c45300938639e7958ea0850485240) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/AssessmentSectionCreateExtensionsTest.cs (.../AssessmentSectionCreateExtensionsTest.cs) (revision 258acae55e0ae70bcc094a2f7a577b7fbc8d8f2e) @@ -81,12 +81,9 @@ { Norm = norm }, - BackgroundMapData = + BackgroundData = { - MapData = - { - Name = mapDataName - }, + Name = mapDataName, Transparency = (RoundedDouble) transparency, IsVisible = isVisible } Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/BackgroundDataCreateExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/BackgroundDataCreateExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/BackgroundDataCreateExtensionsTest.cs (revision 258acae55e0ae70bcc094a2f7a577b7fbc8d8f2e) @@ -0,0 +1,116 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using Application.Ringtoets.Storage.Create; +using Application.Ringtoets.Storage.DbContext; +using Core.Common.Base.Data; +using Core.Components.Gis; +using Core.Components.Gis.Data; +using NUnit.Framework; +using Ringtoets.Common.Data; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.TestUtil; + +namespace Application.Ringtoets.Storage.Test.Create +{ + [TestFixture] + public class BackgroundDataCreateExtensionsTest + { + [Test] + public void Create_BackgroundDataNull_ThrowArgumentNullException() + { + // Setup + BackgroundData backgroundData = null; + + // Call + TestDelegate test = () => backgroundData.Create(); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("backgroundData", exception.ParamName); + } + + + [Test] + [TestCase(true)] + [TestCase(false)] + public void Create_BackgroundDataWithTypeWmts_ReturnsBackgroundMapDataEntity(bool isConfigured) + { + // Setup + const string name = "background"; + const string sourceCapabilitiesUrl = "//url"; + const string selectedCapabilityName = "selectedName"; + const string preferredFormat = "image/png"; + const bool isVisible = true; + RoundedDouble transparancy = (RoundedDouble)0.3; + + var backgroundData = new BackgroundData + { + IsVisible = isVisible, + Transparency = transparancy, + Name = name, + IsConfigured = isConfigured, + Parameters = + { + { BackgroundDataIdentifiers.SourceCapabilitiesUrl, sourceCapabilitiesUrl }, + { BackgroundDataIdentifiers.SelectedCapabilityIdentifier, selectedCapabilityName }, + { BackgroundDataIdentifiers.PreferredFormat, preferredFormat } + }, + BackgroundMapDataType = BackgroundMapDataType.Wmts + }; + + // Call + BackgroundMapDataEntity entity = backgroundData.Create(); + + // Assert + Assert.AreEqual(name, entity.Name); + Assert.AreEqual(Convert.ToByte(isVisible), entity.IsVisible); + Assert.AreEqual(transparancy, entity.Transparency); + + if (isConfigured) + { + Assert.AreEqual(sourceCapabilitiesUrl, entity.SourceCapabilitiesUrl); + Assert.AreEqual(selectedCapabilityName, entity.SelectedCapabilityName); + Assert.AreEqual(preferredFormat, entity.PreferredFormat); + } + else + { + Assert.IsNull(entity.SourceCapabilitiesUrl); + Assert.IsNull(entity.SelectedCapabilityName); + Assert.IsNull(entity.PreferredFormat); + } + } + + [Test] + public void Create_BackgroundDataTypeWellKnown_ReturnsNull() + { + // Setup + var backgroundData = BackgroundDataTestDataGenerator.GetWellKnownBackgroundMapData(); + + // Call + BackgroundMapDataEntity entity = backgroundData.Create(); + + // Assert + Assert.IsNull(entity); // TODO: WTI-1141 + } + } +} \ No newline at end of file Fisheye: Tag 258acae55e0ae70bcc094a2f7a577b7fbc8d8f2e refers to a dead (removed) revision in file `Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/BackgroundMapDataContainerCreateExtensionsTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/AssessmentSectionEntityReadExtensionsTest.cs =================================================================== diff -u -rd34720bc7fe019afec92b91f017b56618dafa95d -r258acae55e0ae70bcc094a2f7a577b7fbc8d8f2e --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/AssessmentSectionEntityReadExtensionsTest.cs (.../AssessmentSectionEntityReadExtensionsTest.cs) (revision d34720bc7fe019afec92b91f017b56618dafa95d) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/AssessmentSectionEntityReadExtensionsTest.cs (.../AssessmentSectionEntityReadExtensionsTest.cs) (revision 258acae55e0ae70bcc094a2f7a577b7fbc8d8f2e) @@ -97,7 +97,7 @@ [Test] [TestCase(false)] [TestCase(true)] - public void Read_WithBackgroundMapData_ReturnsNewAssessmentSectionWithBackgroundMapData(bool isConfigured) + public void Read_WithBackgroundData_ReturnsNewAssessmentSectionWithBackgroundData(bool isConfigured) { // Setup const string mapDataName = "Background"; @@ -128,28 +128,24 @@ var collector = new ReadConversionCollector(); // Call - var section = entity.Read(collector); + AssessmentSection section = entity.Read(collector); // Assert - BackgroundMapDataContainer container = section.BackgroundMapData; - Assert.AreEqual(isVisible, container.IsVisible); - Assert.AreEqual(transparency, container.Transparency); + BackgroundData backgroundData = section.BackgroundData; + Assert.AreEqual(isVisible, backgroundData.IsVisible); + Assert.AreEqual(transparency, backgroundData.Transparency); + Assert.AreEqual(isConfigured, backgroundData.IsConfigured); + Assert.AreEqual(mapDataName, backgroundData.Name); - var backgroundMapData = (WmtsMapData)container.MapData; - Assert.AreEqual(isConfigured, backgroundMapData.IsConfigured); - Assert.AreEqual(mapDataName, backgroundMapData.Name); - if (isConfigured) { - Assert.AreEqual(sourceCapabilitiesUrl, backgroundMapData.SourceCapabilitiesUrl); - Assert.AreEqual(selectedCapabilityName, backgroundMapData.SelectedCapabilityIdentifier); - Assert.AreEqual(preferredFormat, backgroundMapData.PreferredFormat); + Assert.AreEqual(sourceCapabilitiesUrl, backgroundData.Parameters[BackgroundDataIdentifiers.SourceCapabilitiesUrl]); + Assert.AreEqual(selectedCapabilityName, backgroundData.Parameters[BackgroundDataIdentifiers.SelectedCapabilityIdentifier]); + Assert.AreEqual(preferredFormat, backgroundData.Parameters[BackgroundDataIdentifiers.PreferredFormat]); } else { - Assert.IsNull(backgroundMapData.SourceCapabilitiesUrl); - Assert.IsNull(backgroundMapData.SelectedCapabilityIdentifier); - Assert.IsNull(backgroundMapData.PreferredFormat); + CollectionAssert.IsEmpty(backgroundData.Parameters); } } Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/BackgroundMapDataEntityReadExtensionsTest.cs =================================================================== diff -u -r31012b85637f7fcf6b28f498fc996edcda2eb505 -r258acae55e0ae70bcc094a2f7a577b7fbc8d8f2e --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/BackgroundMapDataEntityReadExtensionsTest.cs (.../BackgroundMapDataEntityReadExtensionsTest.cs) (revision 31012b85637f7fcf6b28f498fc996edcda2eb505) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/BackgroundMapDataEntityReadExtensionsTest.cs (.../BackgroundMapDataEntityReadExtensionsTest.cs) (revision 258acae55e0ae70bcc094a2f7a577b7fbc8d8f2e) @@ -22,10 +22,8 @@ using System; using Application.Ringtoets.Storage.DbContext; using Application.Ringtoets.Storage.Read; -using Core.Components.Gis; -using Core.Components.Gis.Data; using NUnit.Framework; -using Ringtoets.Common.Data; +using Ringtoets.Common.Data.AssessmentSection; namespace Application.Ringtoets.Storage.Test.Read { @@ -47,7 +45,7 @@ } [Test] - public void Read_WithEntity_ReturnMapData() + public void Read_WithEntity_ReturnBackgroundData() { // Setup const string name = "map data"; @@ -68,22 +66,21 @@ }; // Call - BackgroundMapDataContainer container = entity.Read(); + BackgroundData backgroundData = entity.Read(); // Assert - Assert.AreEqual(isVisible, container.IsVisible); - Assert.AreEqual(transparancy, container.Transparency.Value); + Assert.AreEqual(isVisible, backgroundData.IsVisible); + Assert.AreEqual(transparancy, backgroundData.Transparency.Value); - var wmtsMapData = (WmtsMapData) container.MapData; - Assert.AreEqual(name, wmtsMapData.Name); - Assert.AreEqual(url, wmtsMapData.SourceCapabilitiesUrl); - Assert.AreEqual(capabilityName, wmtsMapData.SelectedCapabilityIdentifier); - Assert.AreEqual(preferredFormat, wmtsMapData.PreferredFormat); - Assert.IsTrue(wmtsMapData.IsConfigured); + Assert.AreEqual(name, backgroundData.Name); + Assert.AreEqual(url, backgroundData.Parameters[BackgroundDataIdentifiers.SourceCapabilitiesUrl]); + Assert.AreEqual(capabilityName, backgroundData.Parameters[BackgroundDataIdentifiers.SelectedCapabilityIdentifier]); + Assert.AreEqual(preferredFormat, backgroundData.Parameters[BackgroundDataIdentifiers.PreferredFormat]); + Assert.IsTrue(backgroundData.IsConfigured); } [Test] - public void Read_ConfigurableColumnsNull_ReturnUnConfiguredMapData() + public void Read_ConfigurableColumnsNull_ReturnBackgroundDataWithoutParameters() { // Setup const string name = "map data"; @@ -98,18 +95,15 @@ }; // Call - BackgroundMapDataContainer container = entity.Read(); + BackgroundData backgroundData = entity.Read(); // Assert - Assert.AreEqual(isVisible, container.IsVisible); - Assert.AreEqual(transparancy, container.Transparency.Value); + Assert.AreEqual(isVisible, backgroundData.IsVisible); + Assert.AreEqual(transparancy, backgroundData.Transparency.Value); - var wmtsMapData = (WmtsMapData)container.MapData; - Assert.AreEqual(name, wmtsMapData.Name); - Assert.IsNull(wmtsMapData.SourceCapabilitiesUrl); - Assert.IsNull(wmtsMapData.SelectedCapabilityIdentifier); - Assert.IsNull(wmtsMapData.PreferredFormat); - Assert.IsFalse(wmtsMapData.IsConfigured); + Assert.AreEqual(name, backgroundData.Name); + CollectionAssert.IsEmpty(backgroundData.Parameters); + Assert.IsFalse(backgroundData.IsConfigured); } } } \ No newline at end of file