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();
        }
Пример #2
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);
            }
        }
        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();
        }
Пример #4
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);
            }
        }
Пример #5
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);
                    }
        }
Пример #6
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();
                }
        }
        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 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);
                }
        }
Пример #9
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();
        }
Пример #10
0
        private static IEnumerable <TestCaseData> GetBackgroundData()
        {
            yield return(new TestCaseData(new WellKnownTileSourceMapData(WellKnownTileSource.BingAerial))
                         .SetName("WellKnownMapData"));

            yield return(new TestCaseData(WmtsMapDataTestHelper.CreateDefaultPdokMapData())
                         .SetName("WmtsMapData"));
        }
Пример #11
0
        private static IEnumerable <TestCaseData> Configurations(string prefix)
        {
            yield return(new TestCaseData(WmtsMapDataTestHelper.CreateDefaultPdokMapData())
                         .SetName($"{prefix}_Wmts"));

            yield return(new TestCaseData(new WellKnownTileSourceMapData(new Random(21).NextEnum <WellKnownTileSource>()))
                         .SetName($"{prefix}_WellKnown"));
        }
Пример #12
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);
                        }
        }
        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);
            }
        }
Пример #14
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);
        }
Пример #15
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));
            }
        }
Пример #17
0
        public void ForeColor_ConnectedWtmsBackgroundDataConfiguration_ReturnControlText()
        {
            // Setup
            WmtsMapData    mapData        = WmtsMapDataTestHelper.CreateDefaultPdokMapData();
            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.ControlText), image);
            }
        }
Пример #18
0
        public void GivenMapControl_WhenPdokDataSetAsBackground_ThenMapControlShowsBackgroundLayer()
        {
            // Given
            using (var form = new Form())
            {
                var mapControl = new MapControl();
                Map mapView    = mapControl.Controls.OfType <Map>().First();
                form.Controls.Add(mapControl);
                form.Show();

                // When
                mapControl.BackgroundMapData = WmtsMapDataTestHelper.CreateDefaultPdokMapData();

                // Then
                Assert.AreEqual(1, mapView.Layers.Count);
            }
        }
Пример #19
0
        public void CreateInitializedConfiguration_CannotCreateCache_ThrowCannotCreateCacheException()
        {
            // Setup
            WmtsMapData targetMapData = WmtsMapDataTestHelper.CreateDefaultPdokMapData();

            var tileSource = new HttpTileSource(TileSchemaFactory.CreateWmtsTileSchema(targetMapData),
                                                (IRequest)null);

            var mocks   = new MockRepository();
            var factory = mocks.Stub <ITileSourceFactory>();

            factory.Stub(f => f.GetWmtsTileSources(targetMapData.SourceCapabilitiesUrl))
            .Return(new[]
            {
                tileSource
            });
            mocks.ReplayAll();

            using (new UseCustomSettingsHelper(testSettingsHelper))
                using (new UseCustomTileSourceFactoryConfig(factory))
                {
                    directoryDisposeHelper.LockDirectory(FileSystemRights.Write);

                    // Call
                    TestDelegate call = () => WmtsLayerConfiguration.CreateInitializedConfiguration(targetMapData.SourceCapabilitiesUrl,
                                                                                                    targetMapData.SelectedCapabilityIdentifier,
                                                                                                    targetMapData.PreferredFormat);

                    try
                    {
                        // Assert
                        string       message         = Assert.Throws <CannotCreateTileCacheException>(call).Message;
                        const string expectedMessage = "Een kritieke fout is opgetreden bij het aanmaken van de cache.";
                        Assert.AreEqual(expectedMessage, message);
                    }
                    finally
                    {
                        directoryDisposeHelper.UnlockDirectory();
                    }
                }

            mocks.VerifyAll();
        }
Пример #20
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);
                }
            }
        }
Пример #21
0
        public void CreateInitializedConfiguration_ValidWmtsMapData_ReturnWmtsTileSourceLayerConfiguration()
        {
            // Setup
            WmtsMapData mapData = WmtsMapDataTestHelper.CreateDefaultPdokMapData();

            using (new UseCustomSettingsHelper(new TestSettingsHelper
            {
                ApplicationLocalUserSettingsDirectory = Path.Combine(TestHelper.GetScratchPadPath(), nameof(BrutileConfigurationFactoryTest))
            }))
                using (new DirectoryDisposeHelper(TestHelper.GetScratchPadPath(), nameof(BrutileConfigurationFactoryTest)))
                    using (new UseCustomTileSourceFactoryConfig(mapData))
                    {
                        // Call
                        IConfiguration configuration = BrutileConfigurationFactory.CreateInitializedConfiguration(mapData);

                        // Assert
                        Assert.IsInstanceOf <WmtsLayerConfiguration>(configuration);
                        Assert.IsTrue(configuration.Initialized);
                    }
        }
Пример #22
0
        public void SetAllData_Always_SetsAllDataToMapControl()
        {
            // 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())
                    {
                        // Call
                        riskeerMapControl.SetAllData(mapDataCollection, backgroundData);

                        // Assert
                        Assert.AreSame(mapDataCollection, riskeerMapControl.MapControl.Data);
                        Assert.IsNotNull(riskeerMapControl.MapControl.BackgroundMapData);
                        MapDataTestHelper.AssertImageBasedMapData(backgroundData, riskeerMapControl.MapControl.BackgroundMapData);
                    }
        }
        public void GetWmtsCapabilities_ValidUrl_ReturnsWmtsCapabilities()
        {
            // Setup
            const string url               = "validUrl";
            var          factory           = new BruTileWmtsCapabilityFactory();
            WmtsMapData  backgroundMapData = WmtsMapDataTestHelper.CreateDefaultPdokMapData();

            using (new UseCustomTileSourceFactoryConfig(backgroundMapData))
            {
                // Call
                WmtsCapability[] capabilities = factory.GetWmtsCapabilities(url).ToArray();

                // Assert
                Assert.AreEqual(1, capabilities.Length);
                WmtsCapability capability = capabilities[0];
                Assert.AreEqual("brtachtergrondkaart(EPSG:28992)", capability.Id);
                Assert.AreEqual("Stub schema", capability.Title);
                Assert.AreEqual("image/png", capability.Format);
                Assert.AreEqual("EPSG:28992", capability.CoordinateSystem);
            }
        }
        public void ConvertTo_WmtsMapData_ReturnBackgroundData(bool configured)
        {
            // Setup
            WmtsMapData mapData = configured
                                      ? WmtsMapDataTestHelper.CreateDefaultPdokMapData()
                                      : WmtsMapDataTestHelper.CreateUnconnectedMapData();

            // Call
            BackgroundData backgroundData = BackgroundDataConverter.ConvertTo(mapData);

            // Assert
            Assert.AreEqual(mapData.Name, backgroundData.Name);
            Assert.AreEqual(mapData.IsVisible, backgroundData.IsVisible);
            Assert.AreEqual(mapData.Transparency, backgroundData.Transparency);

            var configuration = (WmtsBackgroundDataConfiguration)backgroundData.Configuration;

            Assert.AreEqual(configured, configuration.IsConfigured);
            Assert.AreEqual(mapData.SourceCapabilitiesUrl, configuration.SourceCapabilitiesUrl);
            Assert.AreEqual(mapData.SelectedCapabilityIdentifier, configuration.SelectedCapabilityIdentifier);
            Assert.AreEqual(mapData.PreferredFormat, configuration.PreferredFormat);
        }
Пример #25
0
        public void GivenValidDialog_WhenControlSwitched_ThenListenToEventOfNewControl()
        {
            // Given
            WmtsMapData activeWmtsMapData = WmtsMapDataTestHelper.CreateDefaultPdokMapData();

            mockRepository.ReplayAll();

            var wellKnownSelectedMapDataChanged = 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 wellKnownControl = GetComboBoxItem <WellKnownMapDataControl>(comboBox);

                            comboBox.SelectedItem = wellKnownControl;

                            DataGridViewControl wellKnownDataGridViewControl = dialog.Controls.Find("dataGridViewControl", true).OfType <DataGridViewControl>().First();
                            wellKnownControl.SelectedMapDataChanged += (sender, args) => wellKnownSelectedMapDataChanged++;

                            // When
                            wellKnownDataGridViewControl.SetCurrentCell(wellKnownDataGridViewControl.GetCell(4, 0));
                            var button = new ButtonTester("selectButton", dialog);
                            button.Click();

                            // Then
                            Assert.IsInstanceOf <WellKnownTileSourceMapData>(dialog.SelectedMapData);
                            Assert.AreEqual(1, wellKnownSelectedMapDataChanged);
                        }
        }
        private static IEnumerable <TestCaseData> ValidBackgroundDatas()
        {
            var         wellKnownMapData = new WellKnownTileSourceMapData(WellKnownTileSource.BingRoads);
            WmtsMapData wmtsMapData      = WmtsMapDataTestHelper.CreateDefaultPdokMapData();

            yield return(new TestCaseData(
                             new BackgroundData(new TestBackgroundDataConfiguration()))
                         .SetName("Arbitrary BackgroundData Configuration"));

            yield return(new TestCaseData(
                             new BackgroundData(new WellKnownBackgroundDataConfiguration((RiskeerWellKnownTileSource)wellKnownMapData.TileSource))
            {
                Name = wellKnownMapData.Name
            }).SetName("WellKnown BingRoads BackgroundData"));

            yield return(new TestCaseData(new BackgroundData(new WmtsBackgroundDataConfiguration(wmtsMapData.IsConfigured,
                                                                                                 wmtsMapData.SourceCapabilitiesUrl,
                                                                                                 wmtsMapData.SelectedCapabilityIdentifier,
                                                                                                 wmtsMapData.PreferredFormat))
            {
                Name = wmtsMapData.Name
            }).SetName("Wmts DefaultPdok BackgroundData"));
        }
Пример #27
0
        public void GivenConfiguredWmtsBackgroundData_WhenWmtsConfigurationSetToFalseAndNotified_ThenBackgroundMapDataConfigurationRemovedAndNotified()
        {
            // 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.Configuration = new WmtsBackgroundDataConfiguration();
                    backgroundData.NotifyObservers();

                    // Then
                    Assert.AreSame(oldBackgroundMapData, riskeerMapControl.MapControl.BackgroundMapData);

                    var newWmtsMapData = (WmtsMapData)riskeerMapControl.MapControl.BackgroundMapData;
                    Assert.IsNull(newWmtsMapData.SourceCapabilitiesUrl);
                    Assert.IsNull(newWmtsMapData.SelectedCapabilityIdentifier);
                    Assert.IsNull(newWmtsMapData.PreferredFormat);
                    mocks.VerifyAll();
                }
        }
Пример #28
0
        public void CreateInitializedConfiguration_MatchingLayerAvailable_ReturnConfiguration()
        {
            // Setup
            WmtsMapData targetMapData = WmtsMapDataTestHelper.CreateAlternativePdokMapData();

            var tileSource1 = new HttpTileSource(TileSchemaFactory.CreateWmtsTileSchema(WmtsMapDataTestHelper.CreateDefaultPdokMapData()),
                                                 (IRequest)null);
            var tileSource2 = new HttpTileSource(TileSchemaFactory.CreateWmtsTileSchema(targetMapData),
                                                 (IRequest)null);
            var tileSources = new ITileSource[]
            {
                tileSource1,
                tileSource2
            };

            var mocks   = new MockRepository();
            var factory = mocks.Stub <ITileSourceFactory>();

            factory.Stub(f => f.GetWmtsTileSources(targetMapData.SourceCapabilitiesUrl)).Return(tileSources);
            mocks.ReplayAll();

            using (new UseCustomSettingsHelper(testSettingsHelper))
                using (new UseCustomTileSourceFactoryConfig(factory))
                {
                    // Call
                    using (WmtsLayerConfiguration configuration = WmtsLayerConfiguration.CreateInitializedConfiguration(targetMapData.SourceCapabilitiesUrl,
                                                                                                                        targetMapData.SelectedCapabilityIdentifier,
                                                                                                                        targetMapData.PreferredFormat))
                    {
                        // Assert
                        Assert.IsTrue(configuration.Initialized);
                        Assert.IsTrue(configuration.TileFetcher.IsReady());
                        Assert.AreSame(tileSource2.Schema, configuration.TileSchema);
                    }
                }

            mocks.VerifyAll();
        }
        public void Constructor_WithConfiguredWmtsMapDataConfiguration_PropertiesHaveExpectedAttributesValues()
        {
            // Setup
            WmtsMapData defaultPdokMapData = WmtsMapDataTestHelper.CreateDefaultPdokMapData();
            var         backgroundData     = new BackgroundData(new WmtsBackgroundDataConfiguration(defaultPdokMapData.IsConfigured,
                                                                                                    defaultPdokMapData.SourceCapabilitiesUrl,
                                                                                                    defaultPdokMapData.SelectedCapabilityIdentifier,
                                                                                                    defaultPdokMapData.PreferredFormat))
            {
                Name         = defaultPdokMapData.Name,
                Transparency = defaultPdokMapData.Transparency,
                IsVisible    = defaultPdokMapData.IsVisible
            };

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

            // Assert
            PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties);

            Assert.AreEqual(6, dynamicProperties.Count);

            PropertyDescriptor nameProperty = dynamicProperties[requiredNamePropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty,
                                                                            "Algemeen",
                                                                            "Omschrijving",
                                                                            "Omschrijving van de achtergrond kaartlaag.",
                                                                            true);

            PropertyDescriptor transparencyPropertyIndex = dynamicProperties[requiredTransparencyPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(transparencyPropertyIndex,
                                                                            "Algemeen",
                                                                            "Transparantie",
                                                                            "Transparantie waarmee de achtergrond kaartlaag wordt weergegeven.");

            PropertyDescriptor visibilityProperty = dynamicProperties[requiredVisibilityPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(visibilityProperty,
                                                                            "Algemeen",
                                                                            "Weergeven",
                                                                            "Geeft aan of de geselecteerde achtergrond kaartlaag in alle kaarten van dit traject wordt weergegeven.");

            const string       wmtsCategory = "WMTS";
            PropertyDescriptor urlProperty  = dynamicProperties[wmtsUrlPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(urlProperty,
                                                                            wmtsCategory,
                                                                            "URL",
                                                                            "Volledige URL naar de Web Map Tile Service (WMTS) die als achtergrond kaartlaag gebruikt wordt.",
                                                                            true);

            PropertyDescriptor selectedCapabilityProperty = dynamicProperties[wmtsSelectedCapabilityPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(selectedCapabilityProperty,
                                                                            wmtsCategory,
                                                                            "Kaartlaag",
                                                                            "De naam van de geselecteerde kaartlaag.",
                                                                            true);

            PropertyDescriptor preferredFormatProperty = dynamicProperties[wmtsPreferredFormatPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(preferredFormatProperty,
                                                                            wmtsCategory,
                                                                            "Formaat",
                                                                            "Het type afbeelding die door de geselecteerde kaartlaag aangeleverd wordt.",
                                                                            true);
        }