// 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.Collections.Generic; using System.Linq; using Core.Common.Base.Data; using Core.Common.Base.Geometry; using Core.Components.Gis.Data; using Core.Components.Gis.Features; using Core.Components.Gis.Geometries; using NUnit.Framework; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Data.TestUtil; namespace Ringtoets.Common.Forms.TestUtil.Test { [TestFixture] public class MapDataTestHelperTest { private static IEnumerable NotEqualToDefaultPdokMapData() { var defaultMapData = WmtsMapData.CreateDefaultPdokMapData(); var otherName = new WmtsMapData("otherName", defaultMapData.SourceCapabilitiesUrl, defaultMapData.SelectedCapabilityIdentifier, defaultMapData.PreferredFormat); yield return new TestCaseData(otherName); var otherPreferredFormat = new WmtsMapData(defaultMapData.Name, defaultMapData.SourceCapabilitiesUrl, defaultMapData.SelectedCapabilityIdentifier, "image/otherPreferredFormat"); yield return new TestCaseData(otherPreferredFormat); var otherSelectedCapabilityIdentifier = new WmtsMapData(defaultMapData.Name, defaultMapData.SourceCapabilitiesUrl, "otherSelectedCapabilityIdentifier", defaultMapData.PreferredFormat); yield return new TestCaseData(otherSelectedCapabilityIdentifier); var otherSourceCapabilitiesUrl = new WmtsMapData(defaultMapData.Name, "otherSourceCapabilitiesUrl", defaultMapData.SelectedCapabilityIdentifier, defaultMapData.PreferredFormat); yield return new TestCaseData(otherSourceCapabilitiesUrl); WmtsMapData otherVisibility = defaultMapData; otherVisibility.IsVisible = !otherVisibility.IsVisible; yield return new TestCaseData(otherVisibility); WmtsMapData otherTransparency = defaultMapData; otherTransparency.Transparency = (RoundedDouble) ((otherVisibility.Transparency + 0.5) % 1); yield return new TestCaseData(otherTransparency); } #region AssertFailureMechanismSectionsMapData [Test] public void AssertFailureMechanismSectionsMapData_MapDataNotMapLineData_ThrowAssertionException() { // Setup var mapData = new MapPointData("Vakindeling"); // Call TestDelegate test = () => MapDataTestHelper.AssertFailureMechanismSectionsMapData(Enumerable.Empty(), mapData); // Assert Assert.Throws(test); } [Test] public void AssertFailureMechanismSectionsMapData_FeaturesLengthDifferentFromSectionsLength_ThrowAssertionException() { // Setup var sections = new[] { new FailureMechanismSection("section1", new[] { new Point2D(0, 0) }) }; var mapData = new MapLineData("Vakindeling"); // Precondition CollectionAssert.IsEmpty(mapData.Features); // Call TestDelegate test = () => MapDataTestHelper.AssertFailureMechanismSectionsMapData(sections, mapData); // Assert Assert.Throws(test); } [Test] public void AssertFailureMechanismSectionsMapData_GeometryNotSame_ThrowAssertionException() { // Setup var sections = new[] { new FailureMechanismSection("section1", new[] { new Point2D(0, 0), new Point2D(1, 1), new Point2D(2, 2) }) }; var mapData = new MapLineData("Vakindeling") { Features = new[] { new MapFeature(new[] { new MapGeometry(new[] { new[] { new Point2D(0, 0), new Point2D(1, 1) } }) }) } }; // Call TestDelegate test = () => MapDataTestHelper.AssertFailureMechanismSectionsMapData(sections, mapData); // Assert Assert.Throws(test); } [Test] public void AssertFailureMechanismSectionsMapData_MapDataNameNotCorrect_ThrowAssertionException() { // Setup var geometryPoints = new[] { new Point2D(0, 0), new Point2D(1, 1), new Point2D(2, 2) }; var sections = new[] { new FailureMechanismSection("section1", geometryPoints) }; var mapData = new MapLineData("test") { Features = new[] { new MapFeature(new[] { new MapGeometry(new[] { geometryPoints }) }) } }; // Call TestDelegate test = () => MapDataTestHelper.AssertFailureMechanismSectionsMapData(sections, mapData); // Assert Assert.Throws(test); } [Test] public void AssertFailureMechanismSectionsMapData_MapDataCorrectToSections_DoesNotThrow() { // Setup var geometryPoints = new[] { new Point2D(0, 0), new Point2D(1, 1), new Point2D(2, 2) }; var sections = new[] { new FailureMechanismSection("section1", geometryPoints) }; var mapData = new MapLineData("Vakindeling") { Features = new[] { new MapFeature(new[] { new MapGeometry(new[] { geometryPoints }) }) } }; // Call TestDelegate test = () => MapDataTestHelper.AssertFailureMechanismSectionsMapData(sections, mapData); // Assert Assert.DoesNotThrow(test); } #endregion #region AssertHydraulicBoundaryLocationsMapData [Test] public void AssertHydraulicBoundaryLocationsMapData_MapDataNotPointData_ThrowAssertionException() { // Setup var mapData = new MapLineData("Hydraulische randvoorwaarden"); // Call TestDelegate test = () => MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(Enumerable.Empty(), mapData); // Assert Assert.Throws(test); } [Test] public void AssertHydraulicBoundaryLocationsMapData_DatabaseNullMapDataHasFeatures_ThrowAssertionException() { // Setup var mapData = new MapPointData("Hydraulische randvoorwaarden") { Features = new[] { new MapFeature(new[] { new MapGeometry(new[] { Enumerable.Empty() }) }), new MapFeature(new[] { new MapGeometry(new[] { Enumerable.Empty() }) }) } }; // Call TestDelegate test = () => MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(null, mapData); // Assert Assert.Throws(test); } [Test] public void AssertHydraulicBoundaryLocationsMapData_FeaturesNotSameAsLocations_ThrowAssertionException() { // Setup var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase { Locations = { new HydraulicBoundaryLocation(1, "test1", 0, 0) } }; var mapData = new MapPointData("Hydraulische randvoorwaarden"); // Call TestDelegate test = () => MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(hydraulicBoundaryDatabase.Locations, mapData); // Assert Assert.Throws(test); } [Test] public void AssertHydraulicBoundaryLocationsMapData_FeatureGeometryNotSameAsLocations_ThrowAssertionException() { // Setup var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase { Locations = { new HydraulicBoundaryLocation(1, "test1", 1, 0) } }; var mapData = new MapPointData("Hydraulische randvoorwaarden") { Features = new[] { new MapFeature(new[] { new MapGeometry(new[] { new[] { new Point2D(0, 0) } }) }) } }; // Call TestDelegate test = () => MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(hydraulicBoundaryDatabase.Locations, mapData); // Assert Assert.Throws(test); } [Test] public void AssertHydraulicBoundaryLocationsMapData_MapDataNameNotCorrect_ThrowAssertionException() { // Setup var mapData = new MapPointData("test"); // Call TestDelegate test = () => MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(null, mapData); // Assert Assert.Throws(test); } [Test] public void AssertHydraulicBoundaryLocationsMapData_WithoutDatabaseMapDataCorrect_DoesNotThrow() { // Setup var mapData = new MapPointData("Hydraulische randvoorwaarden"); // Call TestDelegate test = () => MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(null, mapData); // Assert Assert.DoesNotThrow(test); } [Test] public void AssertHydraulicBoundaryLocationsMapData_WithDatabaseMapDataCorrect_DoesNotThrow() { // Setup var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase { Locations = { new HydraulicBoundaryLocation(1, "test1", 1, 0) } }; var mapData = new MapPointData("Hydraulische randvoorwaarden") { Features = new[] { new MapFeature(new[] { new MapGeometry(new[] { new[] { new Point2D(1, 0) } }) }) } }; // Call TestDelegate test = () => MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(hydraulicBoundaryDatabase.Locations, mapData); // Assert Assert.DoesNotThrow(test); } #endregion #region AssertReferenceLineMapData [Test] public void AssertReferenceLineMapData_MapDataNotLineData_ThrowAssertionException() { // Setup var mapData = new MapPolygonData("Referentielijn"); // Call TestDelegate test = () => MapDataTestHelper.AssertReferenceLineMapData(new ReferenceLine(), mapData); // Assert Assert.Throws(test); } [Test] public void AssertReferenceLineMapData_ReferenceLineNullMapDataHasFeatures_ThrowAssertionException() { // Setup var mapData = new MapLineData("Referentielijn") { Features = new[] { new MapFeature(new[] { new MapGeometry(new[] { Enumerable.Empty() }) }) } }; // Call TestDelegate test = () => MapDataTestHelper.AssertReferenceLineMapData(null, mapData); // Assert Assert.Throws(test); } [Test] public void AssertReferenceLineMapData_MapDataMoreThanOneFeature_ThrowAssertionException() { // Setup var mapData = new MapLineData("Referentielijn") { Features = new[] { new MapFeature(new[] { new MapGeometry(new[] { Enumerable.Empty() }) }), new MapFeature(new[] { new MapGeometry(new[] { Enumerable.Empty() }) }) } }; var referenceLine = new ReferenceLine(); referenceLine.SetGeometry(new[] { new Point2D(0.0, 0.0), new Point2D(1.0, 1.0), new Point2D(2.0, 2.0) }); // Call TestDelegate test = () => MapDataTestHelper.AssertReferenceLineMapData(referenceLine, mapData); // Assert Assert.Throws(test); } [Test] public void AssertReferenceLineMapData_FeatureGeometryNotSameAsReferenceLinePoints_ThrowAssertionException() { // Setup var mapData = new MapLineData("Referentielijn") { Features = new[] { new MapFeature(new[] { new MapGeometry(new[] { new[] { new Point2D(0.0, 0.0), new Point2D(2.0, 2.0), new Point2D(1.0, 1.0) } }) }) } }; var referenceLine = new ReferenceLine(); referenceLine.SetGeometry(new[] { new Point2D(0.0, 0.0), new Point2D(1.0, 1.0), new Point2D(2.0, 2.0) }); // Call TestDelegate test = () => MapDataTestHelper.AssertReferenceLineMapData(referenceLine, mapData); // Assert Assert.Throws(test); } [Test] public void AssertReferenceLineMapData_MapDataNameNotCorrect_ThrowAssertionException() { // Setup var mapData = new MapLineData("test"); // Call TestDelegate test = () => MapDataTestHelper.AssertReferenceLineMapData(null, mapData); // Assert Assert.Throws(test); } [Test] public void AssertReferenceLineMapData_ReferenceLineNullMapDataCorrect_DoesNotThrow() { // Setup var mapData = new MapLineData("Referentielijn"); // Call TestDelegate test = () => MapDataTestHelper.AssertReferenceLineMapData(null, mapData); // Assert Assert.DoesNotThrow(test); } [Test] public void AssertReferenceLineMapData_WithReferenceLineMapDataCorrect_DoesNotThrow() { // Setup // Setup var mapData = new MapLineData("Referentielijn") { Features = new[] { new MapFeature(new[] { new MapGeometry(new[] { new[] { new Point2D(0.0, 0.0), new Point2D(1.0, 1.0), new Point2D(2.0, 2.0) } }) }) } }; var referenceLine = new ReferenceLine(); referenceLine.SetGeometry(new[] { new Point2D(0.0, 0.0), new Point2D(1.0, 1.0), new Point2D(2.0, 2.0) }); // Call TestDelegate test = () => MapDataTestHelper.AssertReferenceLineMapData(referenceLine, mapData); // Assert Assert.DoesNotThrow(test); } #endregion #region AssertFailureMechanismSectionsStartPointMapData [Test] public void AssertFailureMechanismSectionsStartPointMapData_MapDataNotMapPointData_ThrowAssertionException() { // Setup var mapData = new MapLineData("Vakindeling (startpunten)"); // Call TestDelegate test = () => MapDataTestHelper.AssertFailureMechanismSectionsStartPointMapData(Enumerable.Empty(), mapData); // Assert Assert.Throws(test); } [Test] public void AssertFailureMechanismSectionsStartPointMapData_MapDataMoreThanOneFeature_ThrowAssertionException() { // Setup var mapData = new MapPointData("Vakindeling (startpunten)") { Features = new[] { new MapFeature(new[] { new MapGeometry(new[] { Enumerable.Empty() }) }), new MapFeature(new[] { new MapGeometry(new[] { Enumerable.Empty() }) }) } }; var sections = new[] { new FailureMechanismSection("section1", new[] { new Point2D(0, 0), new Point2D(1, 1), new Point2D(2, 2) }) }; // Call TestDelegate test = () => MapDataTestHelper.AssertFailureMechanismSectionsStartPointMapData(sections, mapData); // Assert Assert.Throws(test); } [Test] public void AssertFailureMechanismSectionsStartPointMapData_SectionsEmptyMapDataHasGeometry_ThrowAssertionException() { // Setup var mapData = new MapPointData("Vakindeling (startpunten)") { Features = new[] { new MapFeature(new[] { new MapGeometry(new[] { new[] { new Point2D(1, 1) } }) }) } }; // Call TestDelegate test = () => MapDataTestHelper.AssertFailureMechanismSectionsStartPointMapData(Enumerable.Empty(), mapData); // Assert Assert.Throws(test); } [Test] public void AssertFailureMechanismSectionsStartPointMapData_GeometryNotSameAsStartPoints_ThrowAssertionException() { // Setup var mapData = new MapPointData("Vakindeling (startpunten)") { Features = new[] { new MapFeature(new[] { new MapGeometry(new[] { new[] { new Point2D(1, 1) } }) }) } }; var sections = new[] { new FailureMechanismSection("section1", new[] { new Point2D(0, 0), new Point2D(1, 1), new Point2D(2, 2) }) }; // Call TestDelegate test = () => MapDataTestHelper.AssertFailureMechanismSectionsStartPointMapData(sections, mapData); // Assert Assert.Throws(test); } [Test] public void AssertFailureMechanismSectionsStartPointMapData_MapDataNameNotCorrect_ThrowAssertionException() { // Setup var geometryPoints = new[] { new Point2D(0, 0), new Point2D(1, 1), new Point2D(2, 2) }; var sections = new[] { new FailureMechanismSection("section1", geometryPoints) }; var mapData = new MapLineData("test") { Features = new[] { new MapFeature(new[] { new MapGeometry(new[] { new[] { new Point2D(0, 0) } }) }) } }; // Call TestDelegate test = () => MapDataTestHelper.AssertFailureMechanismSectionsStartPointMapData(sections, mapData); // Assert Assert.Throws(test); } [Test] public void AssertFailureMechanismSectionsStartPointMapData_MapDataCorrect_DoesNotThrow() { // Setup var mapData = new MapPointData("Vakindeling (startpunten)") { Features = new[] { new MapFeature(new[] { new MapGeometry(new[] { new[] { new Point2D(0, 0) } }) }) } }; var sections = new[] { new FailureMechanismSection("section1", new[] { new Point2D(0, 0), new Point2D(1, 1), new Point2D(2, 2) }) }; // Call TestDelegate test = () => MapDataTestHelper.AssertFailureMechanismSectionsStartPointMapData(sections, mapData); // Assert Assert.DoesNotThrow(test); } #endregion #region AssertFailureMechanismSectionsEndPointMapData [Test] public void AssertFailureMechanismSectionsEndPointMapData_MapDataNotMapPointData_ThrowAssertionException() { // Setup var mapData = new MapLineData("Vakindeling (eindpunten)"); // Call TestDelegate test = () => MapDataTestHelper.AssertFailureMechanismSectionsEndPointMapData(Enumerable.Empty(), mapData); // Assert Assert.Throws(test); } [Test] public void AssertFailureMechanismSectionsEndPointMapData_MapDataMoreThanOneFeature_ThrowAssertionException() { // Setup var mapData = new MapPointData("Vakindeling (eindpunten)") { Features = new[] { new MapFeature(new[] { new MapGeometry(new[] { Enumerable.Empty() }) }), new MapFeature(new[] { new MapGeometry(new[] { Enumerable.Empty() }) }) } }; var sections = new[] { new FailureMechanismSection("section1", new[] { new Point2D(0, 0), new Point2D(1, 1), new Point2D(2, 2) }) }; // Call TestDelegate test = () => MapDataTestHelper.AssertFailureMechanismSectionsEndPointMapData(sections, mapData); // Assert Assert.Throws(test); } [Test] public void AssertFailureMechanismSectionsEndPointMapData_SectionsEmptyMapDataHasGeometry_ThrowAssertionException() { // Setup var mapData = new MapPointData("Vakindeling (eindpunten)") { Features = new[] { new MapFeature(new[] { new MapGeometry(new[] { new[] { new Point2D(1, 1) } }) }) } }; // Call TestDelegate test = () => MapDataTestHelper.AssertFailureMechanismSectionsEndPointMapData(Enumerable.Empty(), mapData); // Assert Assert.Throws(test); } [Test] public void AssertFailureMechanismSectionsEndPointMapData_GeometryNotSameAsEndPoints_ThrowAssertionException() { // Setup var mapData = new MapPointData("Vakindeling (eindpunten)") { Features = new[] { new MapFeature(new[] { new MapGeometry(new[] { new[] { new Point2D(1, 1) } }) }) } }; var sections = new[] { new FailureMechanismSection("section1", new[] { new Point2D(0, 0), new Point2D(1, 1), new Point2D(2, 2) }) }; // Call TestDelegate test = () => MapDataTestHelper.AssertFailureMechanismSectionsEndPointMapData(sections, mapData); // Assert Assert.Throws(test); } [Test] public void AssertFailureMechanismSectionsEndPointMapData_MapDataNameNotCorrect_ThrowAssertionException() { // Setup var geometryPoints = new[] { new Point2D(0, 0), new Point2D(1, 1), new Point2D(2, 2) }; var sections = new[] { new FailureMechanismSection("section1", geometryPoints) }; var mapData = new MapLineData("test") { Features = new[] { new MapFeature(new[] { new MapGeometry(new[] { new[] { new Point2D(0, 0) } }) }) } }; // Call TestDelegate test = () => MapDataTestHelper.AssertFailureMechanismSectionsEndPointMapData(sections, mapData); // Assert Assert.Throws(test); } [Test] public void AssertFailureMechanismSectionsEndPointMapData_MapDataCorrect_DoesNotThrow() { // Setup var mapData = new MapPointData("Vakindeling (eindpunten)") { Features = new[] { new MapFeature(new[] { new MapGeometry(new[] { new[] { new Point2D(2, 2) } }) }) } }; var sections = new[] { new FailureMechanismSection("section1", new[] { new Point2D(0, 0), new Point2D(1, 1), new Point2D(2, 2) }) }; // Call TestDelegate test = () => MapDataTestHelper.AssertFailureMechanismSectionsEndPointMapData(sections, mapData); // Assert Assert.DoesNotThrow(test); } #endregion #region AssertForeshoreProfilesMapData [Test] public void AssertForeshoreProfilesMapData_MapDataNotMapLineData_ThrowAssertionException() { // Setup var mapData = new MapPointData("Voorlandprofielen"); // Call TestDelegate test = () => MapDataTestHelper.AssertForeshoreProfilesMapData(Enumerable.Empty(), mapData); // Assert Assert.Throws(test); } [Test] public void AssertForeshoreProfilesMapData_MapDataFeaturesLengthNotSameAsExpectedForeshoreProfilesLength_ThrowsAssertionException() { // Setup var mapData = new MapLineData("Voorlandprofielen") { Features = new[] { new MapFeature(Enumerable.Empty()) } }; var foreshoreProfiles = new[] { new TestForeshoreProfile(), new TestForeshoreProfile() }; // Call TestDelegate test = () => MapDataTestHelper.AssertForeshoreProfilesMapData(foreshoreProfiles, mapData); // Assert Assert.Throws(test); } [Test] public void AssertForeshoreProfilesMapData_FeatureGeometryNotSameAsExpectedGeometry_ThrowAssertionException() { // Setup var mapData = new MapLineData("Voorlandprofielen") { Features = new[] { new MapFeature(new[] { new MapGeometry(new[] { new[] { new Point2D(0, 1), new Point2D(0, -2) } }) }) } }; var foreshoreProfiles = new[] { new TestForeshoreProfile(new[] { new Point2D(0, 0), new Point2D(1, 1) }) }; // Call TestDelegate test = () => MapDataTestHelper.AssertForeshoreProfilesMapData(foreshoreProfiles, mapData); // Assert Assert.Throws(test); } [Test] public void AssertForeshoreProfilesMapData_MapDataNameNotCorrect_ThrowAssertionException() { // Setup var mapData = new MapLineData("test") { Features = new[] { new MapFeature(new[] { new MapGeometry(new[] { new[] { new Point2D(0, 0), new Point2D(0, -1) } }) }) } }; var foreshoreProfiles = new[] { new TestForeshoreProfile(new[] { new Point2D(0, 0), new Point2D(1, 1) }) }; // Call TestDelegate test = () => MapDataTestHelper.AssertForeshoreProfilesMapData(foreshoreProfiles, mapData); // Assert Assert.Throws(test); } [Test] public void AssertForeshoreProfilesMapData_DataCorrect_DoesNotThrow() { // Setup var mapData = new MapLineData("Voorlandprofielen") { Features = new[] { new MapFeature(new[] { new MapGeometry(new[] { new[] { new Point2D(0, 0), new Point2D(0, -1) } }) }) } }; var foreshoreProfiles = new[] { new TestForeshoreProfile(new[] { new Point2D(0, 0), new Point2D(1, 1) }) }; // Call TestDelegate test = () => MapDataTestHelper.AssertForeshoreProfilesMapData(foreshoreProfiles, mapData); // Assert Assert.DoesNotThrow(test); } #endregion #region AssertImageBasedMapData [Test] public void AssertImageBasedMapData_MapDataNotImageBasedMapData_ThrowAssertionException() { // Setup var mapData = new MapPointData("MapPointData"); // Call TestDelegate test = () => MapDataTestHelper.AssertImageBasedMapData(WmtsMapData.CreateUnconnectedMapData(), mapData); // Assert Assert.Throws(test); } [Test] public void AssertImageBasedMapData_ImageBasedMapDataNotSupported_ThrowAssertionException() { // Setup var mapData = new MapPointData("MapPointData"); var imageBasedMapData = new SimpleImageBasedMapData(); // Call TestDelegate test = () => MapDataTestHelper.AssertImageBasedMapData(imageBasedMapData, mapData); // Assert Assert.Throws(test); } [Test] public void AssertImageBasedMapData_ImageBasedMapDataNull_ThrowAssertionException() { // Setup var mapData = new MapPointData("MapPointData"); // Call TestDelegate test = () => MapDataTestHelper.AssertImageBasedMapData(null, mapData); // Assert Assert.Throws(test); } [Test] public void AssertImageBasedMapData_DataNull_ThrowAssertionException() { // Call TestDelegate test = () => MapDataTestHelper.AssertImageBasedMapData(WmtsMapData.CreateUnconnectedMapData(), null); // Assert Assert.Throws(test); } [Test] [TestCaseSource(nameof(NotEqualToDefaultPdokMapData))] public void AssertImageBasedMapData_WmtsMapDataNotEqual_ThrowAssertionException(WmtsMapData wmtsMapData) { // Setup var mapData = WmtsMapData.CreateDefaultPdokMapData(); // Call TestDelegate test = () => MapDataTestHelper.AssertImageBasedMapData(wmtsMapData, mapData); // Assert Assert.Throws(test); } [Test] [TestCaseSource(nameof(NotEqualToBingAerial))] public void AssertImageBasedMapData_WellKnownTileSourceMapDataNotEqual_ThrowAssertionException(WellKnownTileSourceMapData wellKnownTileSourceMapData) { // Setup var mapData = new WellKnownTileSourceMapData(WellKnownTileSource.BingAerial); // Call TestDelegate test = () => MapDataTestHelper.AssertImageBasedMapData(wellKnownTileSourceMapData, mapData); // Assert Assert.Throws(test); } [Test] public void AssertImageBasedMapData_WellKnownDataCorrect_DoesNotThrow() { // Setup var expectedMapData = new WellKnownTileSourceMapData(WellKnownTileSource.BingAerial); var actualMapData = new WellKnownTileSourceMapData(WellKnownTileSource.BingAerial); // Call TestDelegate test = () => MapDataTestHelper.AssertImageBasedMapData(expectedMapData, actualMapData); // Assert Assert.DoesNotThrow(test); } [Test] public void AssertImageBasedMapData_WmtsDataCorrect_DoesNotThrow() { // Setup var expectedMapData = WmtsMapData.CreateUnconnectedMapData(); var actualMapData = WmtsMapData.CreateUnconnectedMapData(); // Call TestDelegate test = () => MapDataTestHelper.AssertImageBasedMapData(expectedMapData, actualMapData); // Assert Assert.DoesNotThrow(test); } private class SimpleImageBasedMapData : ImageBasedMapData { public SimpleImageBasedMapData() : base("name") {} } private static IEnumerable NotEqualToBingAerial() { var defaultMapData = new WellKnownTileSourceMapData(WellKnownTileSource.BingAerial); var otherName = new WellKnownTileSourceMapData(defaultMapData.TileSource) { Name = "otherName" }; yield return new TestCaseData(otherName); var otherPreferredFormat = new WellKnownTileSourceMapData(WellKnownTileSource.EsriWorldShadedRelief) { Name = "Bing Maps - Satelliet" }; yield return new TestCaseData(otherPreferredFormat); WellKnownTileSourceMapData otherVisibility = defaultMapData; otherVisibility.IsVisible = !otherVisibility.IsVisible; yield return new TestCaseData(otherVisibility); WellKnownTileSourceMapData otherTransparency = defaultMapData; otherTransparency.Transparency = (RoundedDouble) ((otherVisibility.Transparency + 0.5) % 1); yield return new TestCaseData(otherTransparency); } #endregion } }