Beispiel #1
0
        /// <summary>
        /// Attempts to initialize the background layer.
        /// </summary>
        /// <returns><c>true</c> if initialization of the background layer was successful,
        /// <c>false</c> otherwise.
        /// </returns>
        private bool InitializeBackgroundLayer()
        {
            BruTileLayer backgroundLayer;

            try
            {
                backgroundLayer = ImageBasedMapDataLayerFactory.Create(backgroundMapData);
            }
            catch (ConfigurationInitializationException e)
            {
                if (!backgroundLayerStatus.PreviousBackgroundLayerCreationFailed)
                {
                    string fullMessage = string.Format(Resources.MapControl_HandleBruTileInitializationException_Message_0_therefore_cannot_show_background_layer,
                                                       e.Message);
                    log.Error(fullMessage, e);
                }

                backgroundLayerStatus.LayerInitializationFailed();
                return(false);
            }

            if (backgroundLayer == null)
            {
                return(false);
            }

            backgroundLayerStatus.LayerInitializationSuccessful(backgroundLayer, backgroundMapData);

            return(true);
        }
Beispiel #2
0
        public void Create_MapDataNull_ThrowArgumentNullException()
        {
            // Call
            TestDelegate test = () => ImageBasedMapDataLayerFactory.Create(null);

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(test);

            Assert.AreEqual("backgroundMapData", exception.ParamName);
        }
Beispiel #3
0
        public void Create_MapDataNotWellKnownOrWmts_ThrowNotSupportedException()
        {
            // Setup
            var mapData = new TestImageBasedMapData("test", true);

            // Call
            TestDelegate test = () => ImageBasedMapDataLayerFactory.Create(mapData);

            // Assert
            var exception = Assert.Throws <NotSupportedException>(test);

            Assert.AreEqual($"Cannot create a configuration for type {mapData.GetType()}.", exception.Message);
        }
Beispiel #4
0
        public void Create_ProblematicTileSourceFactory_ThrowConfigurationInitializationException(ITileSourceFactory factory)
        {
            // Setup
            WmtsMapData backgroundMapData = WmtsMapDataTestHelper.CreateDefaultPdokMapData();

            using (new UseCustomTileSourceFactoryConfig(factory))
            {
                // Call
                TestDelegate test = () => ImageBasedMapDataLayerFactory.Create(backgroundMapData);

                // Assert
                var exception = Assert.Throws <ConfigurationInitializationException>(test);
                Assert.IsInstanceOf <CannotFindTileSourceException>(exception.InnerException);
                Assert.AreEqual("Verbinden met WMTS is mislukt waardoor geen kaartgegevens ingeladen kunnen worden.", exception.Message);
            }
        }
Beispiel #5
0
        public void Create_ValidData_ReturnBruTileLayer(ImageBasedMapData mapData)
        {
            // Setup
            using (new UseCustomSettingsHelper(new TestSettingsHelper
            {
                ApplicationLocalUserSettingsDirectory = Path.Combine(TestHelper.GetScratchPadPath(), nameof(ImageBasedMapDataLayerFactoryTest))
            }))
                using (new DirectoryDisposeHelper(TestHelper.GetScratchPadPath(), nameof(ImageBasedMapDataLayerFactoryTest)))
                    using (new UseCustomTileSourceFactoryConfig(mapData))
                    {
                        // Call
                        BruTileLayer layer = ImageBasedMapDataLayerFactory.Create(mapData);

                        // Assert
                        Assert.AreEqual(mapData.Transparency.Value, layer.Transparency);
                        Assert.AreEqual(mapData.IsVisible, layer.IsVisible);
                    }
        }
Beispiel #6
0
        public void Create_WellKnownTileSourceFactoryThrowsNotSupportedException_ThrowConfigurationInitializationException()
        {
            // Setup
            var factoryThrowingNotSupportedException = MockRepository.GenerateStub <ITileSourceFactory>();

            factoryThrowingNotSupportedException.Stub(f => f.GetKnownTileSource(Arg <KnownTileSource> .Is.NotNull))
            .Throw(new NotSupportedException());

            using (new UseCustomTileSourceFactoryConfig(factoryThrowingNotSupportedException))
            {
                var wellKnownMapData = new WellKnownTileSourceMapData(WellKnownTileSource.BingAerial);

                // Call
                TestDelegate test = () => ImageBasedMapDataLayerFactory.Create(wellKnownMapData);

                // Assert
                var exception = Assert.Throws <ConfigurationInitializationException>(test);
                Assert.IsInstanceOf <NotSupportedException>(exception.InnerException);
                Assert.AreEqual("Verbinden met 'Bing Maps - Satelliet' is mislukt waardoor geen kaartgegevens ingeladen kunnen worden.", exception.Message);
            }
        }
Beispiel #7
0
        public void Create_CannotCreateFileCache_ThrowConfigurationInitializationException(ImageBasedMapData mapData)
        {
            // Setup
            using (new UseCustomSettingsHelper(new TestSettingsHelper
            {
                ApplicationLocalUserSettingsDirectory = Path.Combine(TestHelper.GetScratchPadPath(), nameof(ImageBasedMapDataLayerFactoryTest))
            }))
                using (var disposeHelper = new DirectoryDisposeHelper(TestHelper.GetScratchPadPath(), nameof(ImageBasedMapDataLayerFactoryTest)))
                    using (new UseCustomTileSourceFactoryConfig(mapData))
                    {
                        disposeHelper.LockDirectory(FileSystemRights.Write);

                        // Call
                        TestDelegate test = () => ImageBasedMapDataLayerFactory.Create(mapData);

                        // Assert
                        var exception = Assert.Throws <ConfigurationInitializationException>(test);
                        Assert.IsInstanceOf <CannotCreateTileCacheException>(exception.InnerException);
                        Assert.AreEqual("Configuratie van kaartgegevens hulpbestanden is mislukt.", exception.Message);
                    }
        }