Index: Core/Components/src/Core.Components.Gis/Data/ImageBasedMapData.cs
===================================================================
diff -u -r4b32064801ece7ab70357a2a942e21f113abc679 -r9f3f7c10efcf38e5b49973744e52307ddda3c0f7
--- Core/Components/src/Core.Components.Gis/Data/ImageBasedMapData.cs (.../ImageBasedMapData.cs) (revision 4b32064801ece7ab70357a2a942e21f113abc679)
+++ Core/Components/src/Core.Components.Gis/Data/ImageBasedMapData.cs (.../ImageBasedMapData.cs) (revision 9f3f7c10efcf38e5b49973744e52307ddda3c0f7)
@@ -45,6 +45,8 @@
///
/// Gets or sets the transparency of the map data.
///
+ /// Thrown when setting a new value
+ /// that is not in the range [0.0, 1.0].
public RoundedDouble Transparency
{
get
Index: Ringtoets/Common/src/Ringtoets.Common.Data/BackgroundMapDataContainer.cs
===================================================================
diff -u
--- Ringtoets/Common/src/Ringtoets.Common.Data/BackgroundMapDataContainer.cs (revision 0)
+++ Ringtoets/Common/src/Ringtoets.Common.Data/BackgroundMapDataContainer.cs (revision 9f3f7c10efcf38e5b49973744e52307ddda3c0f7)
@@ -0,0 +1,102 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using Core.Common.Base.Data;
+using Core.Components.Gis.Data;
+
+namespace Ringtoets.Common.Data
+{
+ ///
+ /// Holds a to serve as the background map-data and allows
+ /// preconfiguration of properties.
+ ///
+ public class BackgroundMapDataContainer
+ {
+ private readonly ImageBasedMapDataConfigurationHolder configuration = new ImageBasedMapDataConfigurationHolder();
+ private ImageBasedMapData backgroundMapData;
+
+ ///
+ /// The background .
+ ///
+ public ImageBasedMapData BackgroundMapData
+ {
+ get
+ {
+ return backgroundMapData;
+ }
+ set
+ {
+ backgroundMapData = value;
+ if (backgroundMapData != null)
+ {
+ backgroundMapData.IsVisible = IsVisible;
+ backgroundMapData.Transparency = Transparency;
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets a value indicating whether the is visible.
+ ///
+ public bool IsVisible
+ {
+ get
+ {
+ return configuration.IsVisible;
+ }
+ set
+ {
+ configuration.IsVisible = value;
+ if (backgroundMapData != null)
+ {
+ backgroundMapData.IsVisible = value;
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the transparency of .
+ ///
+ /// Thrown when setting a new value
+ /// that is not in the range [0.0, 1.0].
+ public RoundedDouble Transparency
+ {
+ get
+ {
+ return configuration.Transparency;
+ }
+ set
+ {
+ configuration.Transparency = value;
+ if (backgroundMapData != null)
+ {
+ backgroundMapData.Transparency = value;
+ }
+ }
+ }
+
+ private class ImageBasedMapDataConfigurationHolder : ImageBasedMapData
+ {
+ public ImageBasedMapDataConfigurationHolder() : base("c") {}
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj
===================================================================
diff -u -r3722e29f53ce7db0f11fb184cdc2a76d33078cf2 -r9f3f7c10efcf38e5b49973744e52307ddda3c0f7
--- Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj (.../Ringtoets.Common.Data.csproj) (revision 3722e29f53ce7db0f11fb184cdc2a76d33078cf2)
+++ Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj (.../Ringtoets.Common.Data.csproj) (revision 9f3f7c10efcf38e5b49973744e52307ddda3c0f7)
@@ -42,6 +42,7 @@
+
Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/BackgroundMapDataContainerTest.cs
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.Data.Test/BackgroundMapDataContainerTest.cs (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/BackgroundMapDataContainerTest.cs (revision 9f3f7c10efcf38e5b49973744e52307ddda3c0f7)
@@ -0,0 +1,169 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using Core.Common.Base.Data;
+using Core.Common.TestUtil;
+using Core.Components.Gis.Data;
+using NUnit.Framework;
+using Rhino.Mocks;
+
+namespace Ringtoets.Common.Data.Test
+{
+ [TestFixture]
+ public class BackgroundMapDataContainerTest
+ {
+ [Test]
+ public void Constructor_ExpectedValues()
+ {
+ // Call
+ var container = new BackgroundMapDataContainer();
+
+ // Assert
+ Assert.IsNull(container.BackgroundMapData);
+ Assert.IsTrue(container.IsVisible);
+ Assert.AreEqual(2, container.Transparency.NumberOfDecimalPlaces);
+ Assert.AreEqual(0, container.Transparency.Value);
+ }
+
+ [Test]
+ [TestCase(0)]
+ [TestCase(0.8)]
+ [TestCase(1)]
+ public void Transparency_ValidValues_ReturnNewlySetValue(double newValue)
+ {
+ // Setup
+ var container = new BackgroundMapDataContainer();
+
+ // Call
+ container.Transparency = (RoundedDouble)newValue;
+
+ // Assert
+ Assert.AreEqual(newValue, container.Transparency);
+ }
+
+
+ [Test]
+ public void Transparency_WithBackgroundMapData_MapDataTransparencyUpdated()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var backgroundMapData = mocks.Stub("A");
+ mocks.ReplayAll();
+
+ var container = new BackgroundMapDataContainer();
+ container.BackgroundMapData = backgroundMapData;
+
+ // Call
+ container.Transparency = (RoundedDouble) 0.5;
+
+ // Assert
+ Assert.AreEqual(container.Transparency, backgroundMapData.Transparency);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ [TestCase(-123.56)]
+ [TestCase(0.0 - 1e-2)]
+ [TestCase(1.0 + 1e-2)]
+ [TestCase(456.876)]
+ [TestCase(double.NaN)]
+ public void Transparency_SetInvalidValue_ThrowArgumentOutOfRangeException(double invalidTransparency)
+ {
+ // Setup
+ var container = new BackgroundMapDataContainer();
+
+ // Call
+ TestDelegate call = () => container.Transparency = (RoundedDouble)invalidTransparency;
+
+ // Assert
+ var message = "De transparantie moet in het bereik [0.0, 1.0] liggen.";
+ string paramName = TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, message).ParamName;
+ Assert.AreEqual("value", paramName);
+ }
+
+
+ [Test]
+ [TestCase(true)]
+ [TestCase(false)]
+ public void IsVisible_SetNewValue_GetNewlySetValue(bool newValue)
+ {
+ // Setup
+ var container = new BackgroundMapDataContainer();
+
+ // Call
+ container.IsVisible = newValue;
+
+ // Assert
+ Assert.AreEqual(newValue, container.IsVisible);
+ }
+
+
+ [Test]
+ [TestCase(true)]
+ [TestCase(false)]
+ public void IsVisible_WithBackgroundMapData_MapDataIsVisibleUpdated(bool isVisible)
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var imageBasedMapData = mocks.Stub("A");
+ mocks.ReplayAll();
+
+ var container = new BackgroundMapDataContainer
+ {
+ BackgroundMapData = imageBasedMapData
+ };
+
+ // Call
+ container.IsVisible = isVisible;
+
+ // Assert
+ Assert.AreEqual(container.IsVisible, imageBasedMapData.IsVisible);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ [TestCase(true, 0.5)]
+ [TestCase(false, 0.8)]
+ public void BackgroundMapData_SetNewValue_GetNewValueAndInitializePreconfiguration(bool isVisible, double transparency)
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var imageBasedMapData = mocks.Stub("A");
+ mocks.ReplayAll();
+
+ var container = new BackgroundMapDataContainer
+ {
+ IsVisible = isVisible,
+ Transparency = (RoundedDouble)transparency
+ };
+
+ // Call
+ container.BackgroundMapData = imageBasedMapData;
+
+ // Assert
+ Assert.AreEqual(container.Transparency, imageBasedMapData.Transparency);
+ Assert.AreEqual(container.IsVisible, imageBasedMapData.IsVisible);
+ Assert.AreSame(imageBasedMapData, container.BackgroundMapData);
+ mocks.VerifyAll();
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/Ringtoets.Common.Data.Test.csproj
===================================================================
diff -u -r4b32064801ece7ab70357a2a942e21f113abc679 -r9f3f7c10efcf38e5b49973744e52307ddda3c0f7
--- Ringtoets/Common/test/Ringtoets.Common.Data.Test/Ringtoets.Common.Data.Test.csproj (.../Ringtoets.Common.Data.Test.csproj) (revision 4b32064801ece7ab70357a2a942e21f113abc679)
+++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/Ringtoets.Common.Data.Test.csproj (.../Ringtoets.Common.Data.Test.csproj) (revision 9f3f7c10efcf38e5b49973744e52307ddda3c0f7)
@@ -57,6 +57,7 @@
+
@@ -108,6 +109,10 @@
{D749EE4C-CE50-4C17-BF01-9A953028C126}
Core.Common.TestUtil
+
+ {318ba582-88c9-4816-a54a-a7e431461de3}
+ Core.Components.Gis
+
{d4200f43-3f72-4f42-af0a-8ced416a38ec}
Ringtoets.Common.Data