Пример #1
0
        /// <summary>
        /// Create a <see cref="WmtsTileSchema"/> based on a <see cref="WmtsMapData"/> instance.
        /// </summary>
        /// <param name="mapData">The data for which the schema will be based upon.</param>
        /// <returns>The newly created tile schema.</returns>
        /// <exception cref="ArgumentException">Thrown when <paramref name="mapData"/> isn't
        /// configured.</exception>
        public static WmtsTileSchema CreateWmtsTileSchema(WmtsMapData mapData)
        {
            if (!mapData.IsConfigured)
            {
                throw new ArgumentException($@"Only configured {typeof(WmtsMapData).Name} instances can be used to create a schema for.",
                                            nameof(mapData));
            }

            WmtsTileSchema schema = ConstructWmtsTileSchema();

            schema.Title  = mapData.Name;
            schema.Format = mapData.PreferredFormat;

            schema.Resolutions[1] = new Resolution(1, 1);

            var   capabilityIdRegex = new Regex(@"(?<Layer>.+)\((?<TileMatrixSet>.+)\)");
            Match match             = capabilityIdRegex.Match(mapData.SelectedCapabilityIdentifier);

            schema.Layer         = match.Groups["Layer"].Value;
            schema.TileMatrixSet = match.Groups["TileMatrixSet"].Value;

            var   coordinateSystemRegex = new Regex(@"EPSG:(?<SrsNumber>\d+)");
            Match potentialMatch        = coordinateSystemRegex.Match(schema.TileMatrixSet);

            schema.Srs = potentialMatch.Success ? $"EPSG:{potentialMatch.Groups["SrsNumber"]}" : "EPSG:3857";

            return(schema);
        }
Пример #2
0
        public void RemoveAllData_Always_RemovesAllDataFromMapControl()
        {
            // Setup
            var            mapDataCollection = new MapDataCollection("Collection");
            WmtsMapData    backgroundMapData = WmtsMapDataTestHelper.CreateDefaultPdokMapData();
            BackgroundData backgroundData    = BackgroundDataConverter.ConvertTo(backgroundMapData);

            using (new UseCustomSettingsHelper(testSettingsHelper))
                using (new UseCustomTileSourceFactoryConfig(backgroundMapData))
                    using (var riskeerMapControl = new RiskeerMapControl())
                    {
                        riskeerMapControl.SetAllData(mapDataCollection, backgroundData);

                        // Precondition
                        Assert.IsNotNull(riskeerMapControl.MapControl.Data);
                        Assert.IsNotNull(riskeerMapControl.MapControl.BackgroundMapData);

                        // Call
                        riskeerMapControl.RemoveAllData();

                        // Assert
                        Assert.IsNull(riskeerMapControl.MapControl.Data);
                        Assert.IsNull(riskeerMapControl.MapControl.BackgroundMapData);
                    }
        }
        public void LayerInitializationSuccessful_InitializationPreviouslyFailed_PreviousBackgroundLayerCreationFailedFalse()
        {
            // Setup
            var            mocks         = new MockRepository();
            var            tileFetcher   = mocks.Stub <ITileFetcher>();
            IConfiguration configuration = CreateStubConfiguration(mocks, tileFetcher);

            mocks.ReplayAll();

            using (var layer = new BruTileLayer(configuration))
                using (var layerStatus = new WmtsBackgroundLayerStatus())
                {
                    layerStatus.LayerInitializationFailed();

                    // Precondition
                    Assert.IsTrue(layerStatus.PreviousBackgroundLayerCreationFailed);

                    WmtsMapData mapData = WmtsMapDataTestHelper.CreateDefaultPdokMapData();

                    // Call
                    layerStatus.LayerInitializationSuccessful(layer, mapData);

                    // Assert
                    Assert.IsFalse(layerStatus.PreviousBackgroundLayerCreationFailed);
                }
        }
        public void GetProperties_BackgroundDataWithConfiguredWmtsConfiguration_ReturnExpectedValues()
        {
            // Setup
            WmtsMapData mapData = WmtsMapDataTestHelper.CreateDefaultPdokMapData();

            var backgroundData = new BackgroundData(new WmtsBackgroundDataConfiguration(mapData.IsConfigured,
                                                                                        mapData.SourceCapabilitiesUrl,
                                                                                        mapData.SelectedCapabilityIdentifier,
                                                                                        mapData.PreferredFormat))
            {
                IsVisible    = false,
                Transparency = (RoundedDouble)0.5,
                Name         = mapData.Name
            };

            // Call
            var properties = new BackgroundDataProperties(backgroundData);

            // Assert
            Assert.AreEqual(backgroundData.IsVisible, properties.IsVisible);
            Assert.AreEqual(backgroundData.Transparency, properties.Transparency);
            Assert.AreEqual(mapData.Name, properties.Name);
            Assert.AreEqual(mapData.SourceCapabilitiesUrl, properties.SourceCapabilitiesUrl);
            Assert.AreEqual(mapData.SelectedCapabilityIdentifier, properties.SelectedCapabilityIdentifier);
            Assert.AreEqual(mapData.PreferredFormat, properties.PreferredFormat);
        }
        public void HasSameConfiguration_ForInitializedLayer_ReturnTrue()
        {
            // Setup
            var mocks       = new MockRepository();
            var tileFetcher = mocks.Stub <ITileFetcher>();

            using (var layerStatus = new WmtsBackgroundLayerStatus())
            {
                IConfiguration configuration = CreateStubConfiguration(mocks, tileFetcher);
                mocks.ReplayAll();

                using (var layer = new BruTileLayer(configuration))
                {
                    WmtsMapData mapData1 = WmtsMapDataTestHelper.CreateDefaultPdokMapData();
                    WmtsMapData mapData2 = WmtsMapDataTestHelper.CreateDefaultPdokMapData();

                    layerStatus.LayerInitializationSuccessful(layer, mapData1);

                    // Call
                    bool isSame = layerStatus.HasSameConfiguration(mapData2);

                    // Assert
                    Assert.IsTrue(isSame,
                                  "Should recognize same configuration even if instance is not the same.");
                }
            }

            mocks.VerifyAll();
        }
        public void HasSameConfiguration_ForDifferentInitializedLayer_ReturnFalse(WmtsMapData otherData)
        {
            // Setup
            var mocks       = new MockRepository();
            var tileFetcher = mocks.Stub <ITileFetcher>();

            using (var layerStatus = new WmtsBackgroundLayerStatus())
            {
                IConfiguration configuration = CreateStubConfiguration(mocks, tileFetcher);
                mocks.ReplayAll();

                using (var layer = new BruTileLayer(configuration))
                {
                    WmtsMapData mapData = WmtsMapDataTestHelper.CreateDefaultPdokMapData();

                    layerStatus.LayerInitializationSuccessful(layer, mapData);

                    // Call
                    bool isSame = layerStatus.HasSameConfiguration(otherData);

                    // Assert
                    Assert.IsFalse(isSame);
                }
            }

            mocks.VerifyAll();
        }
Пример #7
0
        public void GivenWmtsLocationControlWithActiveData_WhenConnectClicked_ThenDataGridUpdatedAndActiveDataSelected()
        {
            // Given
            WmtsMapData backgroundMapData = WmtsMapDataTestHelper.CreateDefaultPdokMapData();
            WmtsMapData selectedBackgroundMapData = WmtsMapDataTestHelper.CreateAlternativePdokMapData();

            wmtsCapabilityFactory.Expect(wcf => wcf.GetWmtsCapabilities(selectedBackgroundMapData.SourceCapabilitiesUrl))
                                 .Return(new[]
                                 {
                                     CreateWmtsCapability(new TestWmtsTileSource(backgroundMapData)),
                                     CreateWmtsCapability(new TestWmtsTileSource(selectedBackgroundMapData))
                                 });
            mockRepository.ReplayAll();

            using (new UseCustomTileSourceFactoryConfig(selectedBackgroundMapData))
            using (var form = new Form())
            using (var control = new WmtsLocationControl(selectedBackgroundMapData, wmtsCapabilityFactory))
            {
                form.Controls.Add(control);
                form.Show();

                var connectToButton = new ButtonTester("connectToButton", form);

                // When
                connectToButton.Click();

                // Then
                DataGridViewControl dataGridViewControl = form.Controls.Find("dataGridViewControl", true).OfType<DataGridViewControl>().First();
                DataGridViewRowCollection rows = dataGridViewControl.Rows;
                Assert.AreEqual(2, rows.Count);
                AssertAreEqual(selectedBackgroundMapData, control.SelectedMapData);
            }
        }
Пример #8
0
        public void GivenWmtsLocationControl_WhenConnectClickedAndValidDataFromUrl_ThenDataGridUpdated()
        {
            // Given
            WmtsMapData backgroundMapData = WmtsMapDataTestHelper.CreateDefaultPdokMapData();

            wmtsCapabilityFactory.Expect(wcf => wcf.GetWmtsCapabilities(backgroundMapData.SourceCapabilitiesUrl))
                                 .Return(new[]
                                 {
                                     CreateWmtsCapability(new TestWmtsTileSource(backgroundMapData))
                                 });
            mockRepository.ReplayAll();

            using (new UseCustomTileSourceFactoryConfig(backgroundMapData))
            using (var form = new Form())
            using (ShowValidWmtsLocationControl(form, wmtsCapabilityFactory))
            {
                form.Show();
                var connectToButton = new ButtonTester("connectToButton", form);

                // When
                connectToButton.Click();

                // Then
                DataGridViewControl dataGridViewControl = form.Controls.Find("dataGridViewControl", true).OfType<DataGridViewControl>().First();
                DataGridViewRowCollection rows = dataGridViewControl.Rows;
                Assert.AreEqual(1, rows.Count);

                DataGridViewCellCollection cells = rows[0].Cells;
                Assert.AreEqual(4, cells.Count);
                Assert.AreEqual("brtachtergrondkaart(EPSG:28992)", cells[mapLayerIdColumnIndex].FormattedValue);
                Assert.AreEqual("image/png", cells[mapLayerFormatColumnIndex].FormattedValue);
                Assert.AreEqual("Stub schema", cells[mapLayerTitleColumnIndex].FormattedValue);
                Assert.AreEqual("EPSG:28992", cells[mapLayerCoordinateSystemColumnIndex].FormattedValue);
            }
        }
Пример #9
0
        public void GivenBackgroundData_WhenBackgroundDataChangedButSameTypeAndNotified_ThenBackgroundMapDataUpdatedAndNotified()
        {
            // Given
            var mocks    = new MockRepository();
            var observer = mocks.StrictMock <IObserver>();

            observer.Expect(o => o.UpdateObserver());
            mocks.ReplayAll();

            WmtsMapData    mapData           = WmtsMapDataTestHelper.CreateDefaultPdokMapData();
            BackgroundData backgroundData    = BackgroundDataConverter.ConvertTo(mapData);
            var            mapDataCollection = new MapDataCollection("Collection");

            using (new UseCustomSettingsHelper(testSettingsHelper))
                using (new UseCustomTileSourceFactoryConfig(mapData))
                {
                    var riskeerMapControl = new RiskeerMapControl();
                    riskeerMapControl.SetAllData(mapDataCollection, backgroundData);
                    riskeerMapControl.MapControl.BackgroundMapData.Attach(observer);

                    ImageBasedMapData oldBackgroundMapData = riskeerMapControl.MapControl.BackgroundMapData;

                    // When
                    backgroundData.Transparency = (RoundedDouble)0.3;
                    backgroundData.NotifyObservers();

                    // Then
                    Assert.AreSame(oldBackgroundMapData, riskeerMapControl.MapControl.BackgroundMapData);
                    Assert.AreEqual(0.3, riskeerMapControl.MapControl.BackgroundMapData.Transparency.Value);
                    mocks.VerifyAll();
                }
        }
Пример #10
0
 private void SetWmtsTileSource(WmtsMapData backgroundMapData)
 {
     if (backgroundMapData.IsConfigured)
     {
         wmtsTileSource = new TestWmtsTileSource(backgroundMapData);
     }
 }
Пример #11
0
        public void GivenMapDataSet_WhenSelectingMapDataFromContextMenuCancelled_ThenNoObserversNotified()
        {
            // Given
            var mockRepository            = new MockRepository();
            var assessmentSectionObserver = mockRepository.StrictMock <IObserver>();
            var backgroundDataObserver    = mockRepository.StrictMock <IObserver>();

            WmtsMapData    mapData        = WmtsMapDataTestHelper.CreateUnconnectedMapData();
            BackgroundData backgroundData = BackgroundDataConverter.ConvertTo(mapData);

            WmtsMapData    newMapData        = WmtsMapDataTestHelper.CreateDefaultPdokMapData();
            BackgroundData newBackgroundData = BackgroundDataConverter.ConvertTo(newMapData);

            using (new UseCustomSettingsHelper(new TestSettingsHelper
            {
                ApplicationLocalUserSettingsDirectory = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO, "noConfig")
            }))
                using (new UseCustomTileSourceFactoryConfig(newMapData))
                    using (var treeViewControl = new TreeViewControl())
                        using (var plugin = new RiskeerPlugin())
                        {
                            var viewCommands = mockRepository.Stub <IViewCommands>();
                            var mainWindow   = mockRepository.Stub <IMainWindow>();

                            IGui gui = StubFactory.CreateGuiStub(mockRepository);
                            gui.Stub(g => g.MainWindow).Return(mainWindow);
                            gui.Stub(g => g.ViewCommands).Return(viewCommands);
                            gui.Stub(cmp => cmp.Get(newBackgroundData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
                            mockRepository.ReplayAll();

                            var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
                            var assessmentSectionStateRootContext = new AssessmentSectionStateRootContext(assessmentSection);
                            assessmentSection.Attach(assessmentSectionObserver);
                            assessmentSection.BackgroundData.Attach(backgroundDataObserver);

                            SetBackgroundData(assessmentSection, mapData);

                            DialogBoxHandler = (name, wnd) =>
                            {
                                var tester = (BackgroundMapDataSelectionDialog) new FormTester(name).TheObject;
                                tester.DialogResult = DialogResult.Cancel;
                                tester.Close();
                            };

                            TreeNodeInfo info = GetInfo(plugin);
                            plugin.Gui = gui;

                            using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(newBackgroundData, assessmentSectionStateRootContext, treeViewControl))
                            {
                                // When
                                contextMenuStrip.Items[selectContextMenuIndex].PerformClick();

                                // Then
                                BackgroundDataTestHelper.AssertBackgroundData(backgroundData, assessmentSection.BackgroundData);
                            }
                        }

            mockRepository.VerifyAll();
        }
Пример #12
0
        /// <summary>
        /// Create a new instance of <see cref="TestWmtsTileSource"/> suitable to work for
        /// a given <see cref="WmtsMapData"/>.
        /// </summary>
        /// <param name="mapData">The map data to work with.</param>
        /// <exception cref="ArgumentException">Thrown when <paramref name="mapData"/> isn't
        /// a configured.</exception>
        public TestWmtsTileSource(WmtsMapData mapData)
            : base(CreateWmtsTileSchema(mapData), new RequestStub(), "Stub schema", null, GetStubTile)
        {
            string imageFormatExtension = mapData.PreferredFormat.Split('/')[1];

            if (imageFormatExtension != "png")
            {
                throw new NotImplementedException($"Please extend this class to support the '*.{imageFormatExtension}' extension.");
            }
        }
Пример #13
0
        public void GivenValidDialog_WhenControlSwitched_ThenDoesNotListenToEventOfOldControl()
        {
            // Given
            WmtsMapData activeWmtsMapData = WmtsMapDataTestHelper.CreateDefaultPdokMapData();

            var capabilities = new[]
            {
                new TestWmtsTileSource(WmtsMapDataTestHelper.CreateAlternativePdokMapData()),
                new TestWmtsTileSource(activeWmtsMapData)
            };

            tileFactory.Expect(tf => tf.GetWmtsTileSources(activeWmtsMapData.SourceCapabilitiesUrl)).Return(capabilities);
            mockRepository.ReplayAll();

            var wmtsLocationControlSelectedMapDataChanged = 0;

            string settingsDirectory = Path.Combine(testPath, "EmptyWmtsConnectionInfo");

            using (new UseCustomSettingsHelper(new TestSettingsHelper
            {
                ApplicationLocalUserSettingsDirectory = settingsDirectory
            }))
                using (new UseCustomTileSourceFactoryConfig(tileFactory))
                    using (var dialogParent = new Form())
                        using (var dialog = new BackgroundMapDataSelectionDialog(dialogParent, activeWmtsMapData))
                        {
                            dialog.Show();

                            var comboBox = (ComboBox) new ComboBoxTester("mapLayerComboBox", dialog).TheObject;
                            var wellKnownMapDataControl = GetComboBoxItem <WellKnownMapDataControl>(comboBox);
                            var wmtsLocationControl     = GetComboBoxItem <WmtsLocationControl>(comboBox);

                            comboBox.SelectedItem = wmtsLocationControl;

                            Button connectButton = dialog.Controls.Find("connectToButton", true).OfType <Button>().First();
                            connectButton.PerformClick();

                            DataGridViewControl wmtsDataGridViewControl = dialog.Controls.Find("dataGridViewControl", true).OfType <DataGridViewControl>().First();
                            wmtsLocationControl.SelectedMapDataChanged += (sender, args) => wmtsLocationControlSelectedMapDataChanged++;

                            comboBox.SelectedItem = wellKnownMapDataControl;
                            DataGridViewControl wellKnownDataGridViewControl = dialog.Controls.Find("dataGridViewControl", true).OfType <DataGridViewControl>().First();
                            wellKnownDataGridViewControl.ClearCurrentCell();

                            var button = (Button) new ButtonTester("selectButton", dialog).TheObject;
                            Assert.IsFalse(button.Enabled);

                            // When
                            wmtsDataGridViewControl.SetCurrentCell(wmtsDataGridViewControl.GetCell(0, 0));

                            // Then
                            Assert.IsFalse(button.Enabled);
                            Assert.AreEqual(1, wmtsLocationControlSelectedMapDataChanged);
                        }
        }
Пример #14
0
        private static void SetBackgroundData(IAssessmentSection assessmentSection, WmtsMapData mapData)
        {
            assessmentSection.BackgroundData.Name         = mapData.Name;
            assessmentSection.BackgroundData.IsVisible    = mapData.IsVisible;
            assessmentSection.BackgroundData.Transparency = mapData.Transparency;

            assessmentSection.BackgroundData.Configuration = new WmtsBackgroundDataConfiguration(mapData.IsConfigured,
                                                                                                 mapData.SourceCapabilitiesUrl,
                                                                                                 mapData.SelectedCapabilityIdentifier,
                                                                                                 mapData.PreferredFormat);
        }
        public void ConvertFrom_BackgroundData_ReturnWmtsMapData(WmtsMapData mapData)
        {
            // Setup
            BackgroundData backgroundData = BackgroundDataConverter.ConvertTo(mapData);

            // Call
            ImageBasedMapData convertedMapData = BackgroundDataConverter.ConvertFrom(backgroundData);

            // Assert
            MapDataTestHelper.AssertImageBasedMapData(backgroundData, convertedMapData);
        }
Пример #16
0
        public void CreateBackgroundLayerStatus_WmtsMapData_ReturnsWmtsBackgroundLayerStatus()
        {
            // Setup
            WmtsMapData mapData = WmtsMapDataTestHelper.CreateAlternativePdokMapData();

            // Call
            BackgroundLayerStatus backgroundLayerStatus = BackgroundLayerStatusFactory.CreateBackgroundLayerStatus(mapData);

            // Assert
            Assert.IsInstanceOf <WmtsBackgroundLayerStatus>(backgroundLayerStatus);
        }
Пример #17
0
        public void Configure_CapabilitiesUrlNull_ThrowArgumentNullException()
        {
            // Setup
            WmtsMapData mapData = WmtsMapDataTestHelper.CreateUnconnectedMapData();

            // Call
            TestDelegate call = () => mapData.Configure(null, capabilityIdentifier, imageFormat);

            // Assert
            string paramName = Assert.Throws <ArgumentNullException>(call).ParamName;

            Assert.AreEqual("sourceCapabilitiesUrl", paramName);
        }
Пример #18
0
        private static void AssertBackgroundData(WmtsMapData mapData, BackgroundData backgroundData)
        {
            Assert.AreEqual(mapData.Name, backgroundData.Name);
            Assert.IsTrue(backgroundData.IsVisible);
            Assert.AreEqual(mapData.Transparency, backgroundData.Transparency);

            var configuration = (WmtsBackgroundDataConfiguration)backgroundData.Configuration;

            Assert.AreEqual(mapData.IsConfigured, configuration.IsConfigured);
            Assert.AreEqual(mapData.SourceCapabilitiesUrl, configuration.SourceCapabilitiesUrl);
            Assert.AreEqual(mapData.SelectedCapabilityIdentifier, configuration.SelectedCapabilityIdentifier);
            Assert.AreEqual(mapData.PreferredFormat, configuration.PreferredFormat);
        }
Пример #19
0
        public void Configure_PreferredImageFormatNull_ThrowArgumentNullException()
        {
            // Setup
            WmtsMapData mapData = WmtsMapDataTestHelper.CreateUnconnectedMapData();

            // Call
            TestDelegate call = () => mapData.Configure(url, capabilityIdentifier, null);

            // Assert
            string paramName = Assert.Throws <ArgumentNullException>(call).ParamName;

            Assert.AreEqual("preferredFormat", paramName);
        }
Пример #20
0
        public void Configure_SelectedCapabilityNameNull_ThrowArgumentNullException()
        {
            // Setup
            WmtsMapData mapData = WmtsMapDataTestHelper.CreateUnconnectedMapData();

            // Call
            TestDelegate call = () => mapData.Configure(url, null, imageFormat);

            // Assert
            string paramName = Assert.Throws <ArgumentNullException>(call).ParamName;

            Assert.AreEqual("selectedCapabilityName", paramName);
        }
Пример #21
0
        private static void AssertAreEqual(WmtsMapData expected, ImageBasedMapData actual)
        {
            if (expected == null)
            {
                Assert.IsNull(actual);
                return;
            }

            var actualWmtsMapData = (WmtsMapData) actual;
            Assert.AreEqual(expected.Name, actualWmtsMapData.Name);
            Assert.AreEqual(expected.PreferredFormat, actualWmtsMapData.PreferredFormat);
            Assert.AreEqual(expected.SelectedCapabilityIdentifier, actualWmtsMapData.SelectedCapabilityIdentifier);
            Assert.AreEqual(expected.SourceCapabilitiesUrl, actualWmtsMapData.SourceCapabilitiesUrl);
        }
        public void HasSameConfiguration_NoInitializedLayer_ReturnFalse()
        {
            // Setup
            using (var layerStatus = new WmtsBackgroundLayerStatus())
            {
                WmtsMapData mapData = WmtsMapDataTestHelper.CreateDefaultPdokMapData();

                // Call
                bool isSame = layerStatus.HasSameConfiguration(mapData);

                // Assert
                Assert.IsFalse(isSame);
            }
        }
Пример #23
0
        public void Configure_ValidArguments_SetConnectionProperties()
        {
            // Setup
            WmtsMapData mapData = WmtsMapDataTestHelper.CreateUnconnectedMapData();

            // Call
            mapData.Configure(url, capabilityIdentifier, imageFormat);

            // Assert
            Assert.AreEqual(url, mapData.SourceCapabilitiesUrl);
            Assert.AreEqual(capabilityIdentifier, mapData.SelectedCapabilityIdentifier);
            Assert.IsTrue(mapData.IsConfigured);
            Assert.IsTrue(mapData.IsVisible);
        }
Пример #24
0
        public void Configure_PreferredImageFormatNotMime_ThrowArgumentException()
        {
            // Setup
            WmtsMapData mapData = WmtsMapDataTestHelper.CreateUnconnectedMapData();

            // Call
            TestDelegate call = () => mapData.Configure(url, capabilityIdentifier, "png");

            // Assert
            const string message   = "Specified image format is not a MIME type.";
            string       paramName = TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentException>(call, message).ParamName;

            Assert.AreEqual("preferredFormat", paramName);
        }
Пример #25
0
        public void RemoveConfiguration_MapDataConfigured_ConfigurationRemoved()
        {
            // Setup
            WmtsMapData mapData = WmtsMapDataTestHelper.CreateDefaultPdokMapData();

            // Call
            mapData.RemoveConfiguration();

            // Assert
            Assert.IsNull(mapData.SourceCapabilitiesUrl);
            Assert.IsNull(mapData.SelectedCapabilityIdentifier);
            Assert.IsFalse(mapData.IsConfigured);
            Assert.IsFalse(mapData.IsVisible);
            Assert.AreEqual("<niet bepaald>", mapData.Name);
        }
Пример #26
0
        public void CreateInitializedConfiguration_ProblematicTileSourceFactory_ThrowConfigurationInitializationException(ITileSourceFactory factory)
        {
            // Setup
            WmtsMapData backgroundMapData = WmtsMapDataTestHelper.CreateDefaultPdokMapData();

            using (new UseCustomTileSourceFactoryConfig(factory))
            {
                // Call
                TestDelegate test = () => BrutileConfigurationFactory.CreateInitializedConfiguration(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);
            }
        }
        public void ClearConfiguration_WithFailedLayerInitializationAndExpectingRecreation_ConfigurationClearedButKeepFailedFlagSet()
        {
            // Setup
            using (var layerStatus = new WmtsBackgroundLayerStatus())
            {
                WmtsMapData mapData = WmtsMapDataTestHelper.CreateDefaultPdokMapData();
                layerStatus.LayerInitializationFailed();

                // Call
                layerStatus.ClearConfiguration(true);

                // Assert
                Assert.IsTrue(layerStatus.PreviousBackgroundLayerCreationFailed);
                Assert.IsFalse(layerStatus.HasSameConfiguration(mapData));
            }
        }
Пример #28
0
        public void ForeColor_UnconnectedWtmsBackgroundDataConfiguration_ReturnGrayText()
        {
            // Setup
            WmtsMapData    mapData        = WmtsMapDataTestHelper.CreateUnconnectedMapData();
            BackgroundData backgroundData = BackgroundDataConverter.ConvertTo(mapData);

            using (var plugin = new RiskeerPlugin())
            {
                TreeNodeInfo info = GetInfo(plugin);

                // Call
                Color image = info.ForeColor(backgroundData);

                // Assert
                Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), image);
            }
        }
Пример #29
0
        public void GivenValidWmtsConnectionInfos_WhenConstructedWithMapData_ThenExpectedProperties()
        {
            // Given
            mockRepository.ReplayAll();

            const string mapDataName = "Zeegraskartering";
            const string mapDataUrl = "https://geodata.nationaalgeoregister.nl/zeegraskartering/wfs?request=GetCapabilities";
            var mapData = new WmtsMapData(mapDataName, mapDataUrl, "capability", "image/png");

            var settingsHelper = new TestSettingsHelper
            {
                ApplicationLocalUserSettingsDirectory = TestHelper.GetTestDataPath(testPath)
            };
            settingsHelper.SetApplicationVersion("twoValidWmtsConnectionInfos");

            using (new UseCustomTileSourceFactoryConfig(tileFactory))
            using (new UseCustomSettingsHelper(settingsHelper))
            {
                // When
                using (var control = new WmtsLocationControl(mapData, wmtsCapabilityFactory))
                using (var form = new Form())
                {
                    form.Controls.Add(control);
                    form.Show();

                    // Then
                    ComboBox urlLocations = form.Controls.Find("urlLocationComboBox", true).OfType<ComboBox>().First();
                    var dataSource = (IList<WmtsConnectionInfo>) urlLocations.DataSource;
                    Assert.AreEqual(2, dataSource.Count);

                    var firstWmtsConnectionInfo = (WmtsConnectionInfo) urlLocations.Items[0];
                    Assert.AreEqual("Actueel Hoogtebestand Nederland (AHN1)", firstWmtsConnectionInfo.Name);
                    Assert.AreEqual("https://geodata.nationaalgeoregister.nl/tiles/service/wmts/ahn1?request=GetCapabilities",
                                    firstWmtsConnectionInfo.Url);

                    var secondWmtsConnectionInfo = (WmtsConnectionInfo) urlLocations.Items[1];
                    Assert.AreEqual(mapDataName, secondWmtsConnectionInfo.Name);
                    Assert.AreEqual(mapDataUrl, secondWmtsConnectionInfo.Url);

                    Assert.AreSame(urlLocations.SelectedItem, secondWmtsConnectionInfo);

                    DataGridViewControl dataGridViewControl = form.Controls.Find("dataGridViewControl", true).OfType<DataGridViewControl>().First();
                    CollectionAssert.IsEmpty(dataGridViewControl.Rows);
                }
            }
        }
Пример #30
0
        public void MapDataConstructor_WithWmtsMapData_DefaultProperties()
        {
            // Setup
            var dialogParent = mockRepository.Stub <IWin32Window>();

            mockRepository.ReplayAll();

            WmtsMapData mapData = WmtsMapDataTestHelper.CreateDefaultPdokMapData();

            using (new UseCustomTileSourceFactoryConfig(tileFactory))
            {
                // Call
                using (var dialog = new BackgroundMapDataSelectionDialog(dialogParent, mapData))
                {
                    // Assert
                    AssertMapDataControls <WmtsLocationControl>(dialog);
                }
            }
        }