Index: Ringtoets/Common/src/Ringtoets.Common.Forms/TypeConverters/BackgroundDataConverter.cs
===================================================================
diff -u -r47b297452f61fb5201b05797634afed738751903 -rc2b4bf524f457472880c238cbc4ad0aa0ba589f0
--- Ringtoets/Common/src/Ringtoets.Common.Forms/TypeConverters/BackgroundDataConverter.cs (.../BackgroundDataConverter.cs) (revision 47b297452f61fb5201b05797634afed738751903)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/TypeConverters/BackgroundDataConverter.cs (.../BackgroundDataConverter.cs) (revision c2b4bf524f457472880c238cbc4ad0aa0ba589f0)
@@ -20,6 +20,7 @@
// All rights reserved.
using System;
+using System.ComponentModel;
using Core.Components.Gis.Data;
using Ringtoets.Common.Data.AssessmentSection;
@@ -76,6 +77,10 @@
/// is null.
/// Thrown when
/// is not valid.
+ /// Thrown when
+ /// contains an invalid value for when the
+ /// is of type
+ /// .
public static ImageBasedMapData ConvertFrom(BackgroundData backgroundData)
{
if (backgroundData == null)
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/RingtoetsBackgroundMapDataFactory.cs
===================================================================
diff -u -r47b297452f61fb5201b05797634afed738751903 -rc2b4bf524f457472880c238cbc4ad0aa0ba589f0
--- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/RingtoetsBackgroundMapDataFactory.cs (.../RingtoetsBackgroundMapDataFactory.cs) (revision 47b297452f61fb5201b05797634afed738751903)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/RingtoetsBackgroundMapDataFactory.cs (.../RingtoetsBackgroundMapDataFactory.cs) (revision c2b4bf524f457472880c238cbc4ad0aa0ba589f0)
@@ -20,6 +20,7 @@
// All rights reserved.
using System;
+using System.ComponentModel;
using Core.Components.Gis.Data;
using Ringtoets.Common.Data.AssessmentSection;
using Ringtoets.Common.Forms.TypeConverters;
@@ -41,6 +42,10 @@
/// is null.
/// Thrown when
/// is not valid.
+ /// Thrown when
+ /// contains an invalid value for when the
+ /// is of type
+ /// .
public static ImageBasedMapData CreateBackgroundMapData(BackgroundData backgroundData)
{
if (backgroundData == null)
Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/AssessmentSection/BackgroundDataTest.cs
===================================================================
diff -u -r68e06c08cb60c1c42e5c3b03fd3af070748a6bca -rc2b4bf524f457472880c238cbc4ad0aa0ba589f0
--- Ringtoets/Common/test/Ringtoets.Common.Data.Test/AssessmentSection/BackgroundDataTest.cs (.../BackgroundDataTest.cs) (revision 68e06c08cb60c1c42e5c3b03fd3af070748a6bca)
+++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/AssessmentSection/BackgroundDataTest.cs (.../BackgroundDataTest.cs) (revision c2b4bf524f457472880c238cbc4ad0aa0ba589f0)
@@ -112,7 +112,7 @@
}
[Test]
- public void Parameters_AddOtherThanAllowed_ThrowInvalidOperationException()
+ public void ParametersAdd_AddOtherThanAllowed_ThrowInvalidOperationException()
{
// Setup
var backgroundData = new BackgroundData();
@@ -130,7 +130,7 @@
}
[Test]
- public void Parameters_AddOtherThanAllowed_ThrowInvalidOperationExceptions()
+ public void ParametersIndexer_AddOtherThanAllowed_ThrowInvalidOperationException()
{
// Setup
var backgroundData = new BackgroundData();
Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/BackgroundDataTestDataGeneratorTest.cs
===================================================================
diff -u -rd2d96421974b56eb204dd8f756748aa582da0874 -rc2b4bf524f457472880c238cbc4ad0aa0ba589f0
--- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/BackgroundDataTestDataGeneratorTest.cs (.../BackgroundDataTestDataGeneratorTest.cs) (revision d2d96421974b56eb204dd8f756748aa582da0874)
+++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/BackgroundDataTestDataGeneratorTest.cs (.../BackgroundDataTestDataGeneratorTest.cs) (revision c2b4bf524f457472880c238cbc4ad0aa0ba589f0)
@@ -19,6 +19,10 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using System;
+using System.ComponentModel;
+using Core.Common.TestUtil;
+using Core.Common.Utils.Reflection;
using Core.Components.Gis.Data;
using NUnit.Framework;
using Ringtoets.Common.Data.AssessmentSection;
@@ -68,19 +72,39 @@
}
[Test]
- public void GetWellKnownBackgroundMapData_Always_ReturnBackgroundDataWithTypeSetToWellKnown()
+ public void GetWellKnownBackgroundMapData_WithValidWellKnownTileSourceValue_ReturnBackgroundDataWithTypeSetToWellKnown()
{
+ // Setup
+ var random = new Random(21);
+ WellKnownTileSource wellKnownTileSource = random.NextEnumValue();
+
// Call
- BackgroundData backgroundData = BackgroundDataTestDataGenerator.GetWellKnownBackgroundMapData(WellKnownTileSource.BingAerial);
+ BackgroundData backgroundData = BackgroundDataTestDataGenerator.GetWellKnownBackgroundMapData(wellKnownTileSource);
// Assert
Assert.AreEqual(BackgroundMapDataType.WellKnown, backgroundData.BackgroundMapDataType);
- Assert.AreEqual("Bing Maps - Satelliet", backgroundData.Name);
Assert.IsTrue(backgroundData.IsConfigured);
Assert.IsTrue(backgroundData.IsVisible);
Assert.AreEqual(0, backgroundData.Transparency.Value);
Assert.AreEqual(1, backgroundData.Parameters.Count);
- Assert.AreEqual("1", backgroundData.Parameters[BackgroundDataIdentifiers.WellKnownTileSource]);
+
+ string backgroundDataName = TypeUtils.GetDisplayName(wellKnownTileSource);
+ Assert.AreEqual(backgroundDataName, backgroundData.Name);
+ Assert.AreEqual(((int)wellKnownTileSource).ToString(),
+ backgroundData.Parameters[BackgroundDataIdentifiers.WellKnownTileSource]);
}
+
+ [Test]
+ public void GetWellKnownBackgroundMapData_WithInvalidWellKnownTileSourceValue_ThrowsInvalidEnumArgumentException()
+ {
+ // Setup
+ const WellKnownTileSource invalidWellKnownTileSource = (WellKnownTileSource) 1337;
+
+ // Call
+ TestDelegate call = () => BackgroundDataTestDataGenerator.GetWellKnownBackgroundMapData(invalidWellKnownTileSource);
+
+ // Assert
+ Assert.Throws(call);
+ }
}
}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/Ringtoets.Common.Data.TestUtil.Test.csproj
===================================================================
diff -u -r5735c9b5c663a0bc7762d1b1eb1483e5c4cfe526 -rc2b4bf524f457472880c238cbc4ad0aa0ba589f0
--- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/Ringtoets.Common.Data.TestUtil.Test.csproj (.../Ringtoets.Common.Data.TestUtil.Test.csproj) (revision 5735c9b5c663a0bc7762d1b1eb1483e5c4cfe526)
+++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/Ringtoets.Common.Data.TestUtil.Test.csproj (.../Ringtoets.Common.Data.TestUtil.Test.csproj) (revision c2b4bf524f457472880c238cbc4ad0aa0ba589f0)
@@ -79,6 +79,14 @@
{3BBFD65B-B277-4E50-AE6D-BD24C3434609}
Core.Common.Base
+
+ {F49BD8B2-332A-4C91-A196-8CCE0A2C7D98}
+ Core.Common.Utils
+
+
+ {D749EE4C-CE50-4C17-BF01-9A953028C126}
+ Core.Common.TestUtil
+
{318ba582-88c9-4816-a54a-a7e431461de3}
Core.Components.Gis
Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/BackgroundDataTestDataGenerator.cs
===================================================================
diff -u -rd2d96421974b56eb204dd8f756748aa582da0874 -rc2b4bf524f457472880c238cbc4ad0aa0ba589f0
--- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/BackgroundDataTestDataGenerator.cs (.../BackgroundDataTestDataGenerator.cs) (revision d2d96421974b56eb204dd8f756748aa582da0874)
+++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/BackgroundDataTestDataGenerator.cs (.../BackgroundDataTestDataGenerator.cs) (revision c2b4bf524f457472880c238cbc4ad0aa0ba589f0)
@@ -19,6 +19,7 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using System.ComponentModel;
using Core.Common.Utils.Reflection;
using Core.Components.Gis.Data;
using Ringtoets.Common.Data.AssessmentSection;
@@ -61,6 +62,8 @@
///
/// The to create the background data for.
/// The created .
+ /// Thrown when
+ /// is an invalid .
public static BackgroundData GetWellKnownBackgroundMapData(WellKnownTileSource tileSource)
{
return new BackgroundData
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TypeConverters/BackgroundDataConverterTest.cs
===================================================================
diff -u -rd2d96421974b56eb204dd8f756748aa582da0874 -rc2b4bf524f457472880c238cbc4ad0aa0ba589f0
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TypeConverters/BackgroundDataConverterTest.cs (.../BackgroundDataConverterTest.cs) (revision d2d96421974b56eb204dd8f756748aa582da0874)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TypeConverters/BackgroundDataConverterTest.cs (.../BackgroundDataConverterTest.cs) (revision c2b4bf524f457472880c238cbc4ad0aa0ba589f0)
@@ -21,6 +21,8 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel;
+using Core.Common.TestUtil;
using Core.Components.Gis.Data;
using NUnit.Framework;
using Ringtoets.Common.Data.AssessmentSection;
@@ -51,8 +53,8 @@
{
// Setup
WmtsMapData mapData = configured
- ? WmtsMapData.CreateDefaultPdokMapData()
- : WmtsMapData.CreateUnconnectedMapData();
+ ? WmtsMapData.CreateDefaultPdokMapData()
+ : WmtsMapData.CreateUnconnectedMapData();
// Call
BackgroundData backgroundData = BackgroundDataConverter.ConvertTo(mapData);
@@ -81,7 +83,9 @@
public void ConvertTo_WellKnownMapData_ReturnBackgroundData()
{
// Setup
- var mapData = new WellKnownTileSourceMapData(WellKnownTileSource.BingAerial);
+ var random = new Random(21);
+ WellKnownTileSource wellKnownTileSource = random.NextEnumValue();
+ var mapData = new WellKnownTileSourceMapData(wellKnownTileSource);
// Call
BackgroundData backgroundData = BackgroundDataConverter.ConvertTo(mapData);
@@ -94,8 +98,8 @@
Assert.AreEqual(BackgroundMapDataType.WellKnown, backgroundData.BackgroundMapDataType);
Assert.AreEqual(1, backgroundData.Parameters.Count);
- var wellKnownTileSource = (WellKnownTileSource) Convert.ToInt32(backgroundData.Parameters[BackgroundDataIdentifiers.WellKnownTileSource]);
- Assert.AreEqual(mapData.TileSource, wellKnownTileSource);
+ var actualWellKnownTileSource = (WellKnownTileSource) Convert.ToInt32(backgroundData.Parameters[BackgroundDataIdentifiers.WellKnownTileSource]);
+ Assert.AreEqual(mapData.TileSource, actualWellKnownTileSource);
}
[Test]
@@ -143,16 +147,33 @@
public void ConvertFrom_BackgroundData_ReturnWellKnownMapData()
{
// Setup
- const WellKnownTileSource wellKnownTileSource = WellKnownTileSource.BingAerial;
+ var random = new Random(21);
+ WellKnownTileSource wellKnownTileSource = random.NextEnumValue();
BackgroundData backgroundData = BackgroundDataTestDataGenerator.GetWellKnownBackgroundMapData(wellKnownTileSource);
// Call
ImageBasedMapData convertedMapData = BackgroundDataConverter.ConvertFrom(backgroundData);
-
+
// Assert
var expectedMapData = new WellKnownTileSourceMapData(wellKnownTileSource);
MapDataTestHelper.AssertImageBasedMapData(expectedMapData, convertedMapData);
+ }
+ [Test]
+ public void ConvertFrom_BackgroundDataWithInvalidWellKnownTileSourceValue_ThrowsInvalidEnumArgumentException()
+ {
+ // Setup
+ var backgroundData = new BackgroundData
+ {
+ BackgroundMapDataType = BackgroundMapDataType.WellKnown
+ };
+ backgroundData.Parameters[BackgroundDataIdentifiers.WellKnownTileSource] = "1337";
+
+ // Call
+ TestDelegate call = () => BackgroundDataConverter.ConvertFrom(backgroundData);
+
+ // Assert
+ Assert.Throws(call);
}
private static IEnumerable WmtsMapDatas
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/RingtoetsBackgroundMapDataFactoryTest.cs
===================================================================
diff -u -rd2d96421974b56eb204dd8f756748aa582da0874 -rc2b4bf524f457472880c238cbc4ad0aa0ba589f0
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/RingtoetsBackgroundMapDataFactoryTest.cs (.../RingtoetsBackgroundMapDataFactoryTest.cs) (revision d2d96421974b56eb204dd8f756748aa582da0874)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/RingtoetsBackgroundMapDataFactoryTest.cs (.../RingtoetsBackgroundMapDataFactoryTest.cs) (revision c2b4bf524f457472880c238cbc4ad0aa0ba589f0)
@@ -21,6 +21,8 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel;
+using Core.Common.TestUtil;
using Core.Components.Gis.Data;
using NUnit.Framework;
using Ringtoets.Common.Data.AssessmentSection;
@@ -73,7 +75,8 @@
public void CreateBackgroundMapData_WellKnownConfiguredBackgroundData_ReturnWellKnownMapData()
{
// Setup
- const WellKnownTileSource wellKnownTileSource = WellKnownTileSource.BingAerial;
+ var random = new Random(21);
+ WellKnownTileSource wellKnownTileSource = random.NextEnumValue();
BackgroundData backgroundData = BackgroundDataTestDataGenerator.GetWellKnownBackgroundMapData(wellKnownTileSource);
// Call
@@ -83,5 +86,22 @@
var expectedMapData = new WellKnownTileSourceMapData(wellKnownTileSource);
MapDataTestHelper.AssertImageBasedMapData(expectedMapData, backgroundMapData);
}
+
+ [Test]
+ public void CreateBackgroundMapData_InvalidWellKnownConfiguredBackgroundData_ThrowsInvalidEnumArgumentException()
+ {
+ // Setup
+ var backgroundData = new BackgroundData
+ {
+ BackgroundMapDataType = BackgroundMapDataType.WellKnown
+ };
+ backgroundData.Parameters[BackgroundDataIdentifiers.WellKnownTileSource] = "1337";
+
+ // Call
+ TestDelegate call = ()=> RingtoetsBackgroundMapDataFactory.CreateBackgroundMapData(backgroundData);
+
+ // Assert
+ Assert.Throws(call);
+ }
}
}
\ No newline at end of file