Index: Core/Components/src/Core.Components.DotSpatial.Forms/BackgroundLayerStatusFactory.cs =================================================================== diff -u --- Core/Components/src/Core.Components.DotSpatial.Forms/BackgroundLayerStatusFactory.cs (revision 0) +++ Core/Components/src/Core.Components.DotSpatial.Forms/BackgroundLayerStatusFactory.cs (revision 13a7121f09c123fe08031a03d3aa598d9800b372) @@ -0,0 +1,59 @@ +// 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 Lesser 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 Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser 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.Components.Gis.Data; + +namespace Core.Components.DotSpatial.Forms +{ + /// + /// Factory for creating . + /// + public static class BackgroundLayerStatusFactory + { + /// + /// Creates a new instance of corresponding to the type of . + /// + /// The type of to create a for. + /// A new instance of . + /// Thrown when + /// is null. + /// Thrown when the type of is not supported. + internal static IBackgroundLayerStatus CreateBackgroundLayerStatus(ImageBasedMapData mapData) + { + if (mapData == null) + { + throw new ArgumentNullException(nameof(mapData)); + } + + if (mapData is WmtsMapData) + { + return new WmtsBackgroundLayerStatus(); + } + if (mapData is WellKnownTileSourceMapData) + { + return new WellKnownBackgroundLayerStatus(); + } + + throw new NotSupportedException("Unsupported type of mapData"); + } + } +} \ No newline at end of file Index: Core/Components/src/Core.Components.DotSpatial.Forms/Core.Components.DotSpatial.Forms.csproj =================================================================== diff -u -r6f806998a17fa46d14678596d71c9c935408b948 -r13a7121f09c123fe08031a03d3aa598d9800b372 --- Core/Components/src/Core.Components.DotSpatial.Forms/Core.Components.DotSpatial.Forms.csproj (.../Core.Components.DotSpatial.Forms.csproj) (revision 6f806998a17fa46d14678596d71c9c935408b948) +++ Core/Components/src/Core.Components.DotSpatial.Forms/Core.Components.DotSpatial.Forms.csproj (.../Core.Components.DotSpatial.Forms.csproj) (revision 13a7121f09c123fe08031a03d3aa598d9800b372) @@ -72,6 +72,7 @@ Properties\GlobalAssembly.cs + UserControl Index: Core/Components/test/Core.Components.DotSpatial.Forms.Test/BackgroundLayerStatusFactoryTest.cs =================================================================== diff -u --- Core/Components/test/Core.Components.DotSpatial.Forms.Test/BackgroundLayerStatusFactoryTest.cs (revision 0) +++ Core/Components/test/Core.Components.DotSpatial.Forms.Test/BackgroundLayerStatusFactoryTest.cs (revision 13a7121f09c123fe08031a03d3aa598d9800b372) @@ -0,0 +1,88 @@ +// 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 Lesser 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 Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser 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.Components.Gis.Data; +using DotSpatial.Symbology; +using NUnit.Framework; + +namespace Core.Components.DotSpatial.Forms.Test +{ + [TestFixture] + public class BackgroundLayerStatusFactoryTest + { + [Test] + public void CreateBackgroundLayerStatus_MapDataNull_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => BackgroundLayerStatusFactory.CreateBackgroundLayerStatus(null); + + // Assert + string paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("mapData", paramName); + } + + [Test] + public void CreateBackgroundLayerStatus_InvalidImageBasedMapData_ThrowsNotSupportedException() + { + // Setup + var mapData = new SimpleImageBasedMapData(); + + // Call + TestDelegate test = () => BackgroundLayerStatusFactory.CreateBackgroundLayerStatus(mapData); + + // Assert + string message = Assert.Throws(test).Message; + Assert.AreEqual("Unsupported type of mapData", message); + } + + [Test] + public void CreateBackgroundLayerStatus_WmtsMapData_ReturnsWmtsBackgroundLayerStatus() + { + // Setup + WmtsMapData mapData = WmtsMapData.CreateAlternativePdokMapData(); + + // Call + IBackgroundLayerStatus backgroundLayerStatus = BackgroundLayerStatusFactory.CreateBackgroundLayerStatus(mapData); + + // Assert + Assert.IsInstanceOf(backgroundLayerStatus); + } + + [Test] + public void CreateBackgroundLayerStatus_WellKnownTileSourceMapData_ReturnsWellKnownBackgroundLayerStatus() + { + // Setup + var mapData = new WellKnownTileSourceMapData(new Random().NextEnum()); + + // Call + IBackgroundLayerStatus backgroundLayerStatus = BackgroundLayerStatusFactory.CreateBackgroundLayerStatus(mapData); + + // Assert + Assert.IsInstanceOf(backgroundLayerStatus); + } + + private class SimpleImageBasedMapData : ImageBasedMapData + { + public SimpleImageBasedMapData() : base("SimpleImageBasedMapData") {} + } + } +} \ No newline at end of file Index: Core/Components/test/Core.Components.DotSpatial.Forms.Test/Core.Components.DotSpatial.Forms.Test.csproj =================================================================== diff -u -r6f806998a17fa46d14678596d71c9c935408b948 -r13a7121f09c123fe08031a03d3aa598d9800b372 --- Core/Components/test/Core.Components.DotSpatial.Forms.Test/Core.Components.DotSpatial.Forms.Test.csproj (.../Core.Components.DotSpatial.Forms.Test.csproj) (revision 6f806998a17fa46d14678596d71c9c935408b948) +++ Core/Components/test/Core.Components.DotSpatial.Forms.Test/Core.Components.DotSpatial.Forms.Test.csproj (.../Core.Components.DotSpatial.Forms.Test.csproj) (revision 13a7121f09c123fe08031a03d3aa598d9800b372) @@ -79,6 +79,7 @@ Properties\GlobalAssembly.cs +