Exemplo n.º 1
0
 public void RemoveAllData()
 {
     removing          = true;
     Data              = null;
     BackgroundMapData = null;
     removing          = false;
 }
Exemplo n.º 2
0
        public void GivenBackgroundData_WhenBackgroundDataChangedToOtherTypeAndNotified_ThenNewInstanceSetOnBackgroundMapData(
            BackgroundData originalBackgroundData,
            BackgroundData newBackgroundData)
        {
            // Given
            var mocks    = new MockRepository();
            var observer = mocks.StrictMock <IObserver>();

            mocks.ReplayAll();

            using (new UseCustomSettingsHelper(testSettingsHelper))
                using (new UseCustomTileSourceFactoryConfig(new TestTileSourceFactory(BackgroundDataConverter.ConvertFrom(originalBackgroundData))))
                {
                    var riskeerMapControl = new RiskeerMapControl();
                    var mapDataCollection = new MapDataCollection("Collection");

                    riskeerMapControl.SetAllData(mapDataCollection, originalBackgroundData);
                    riskeerMapControl.MapControl.BackgroundMapData.Attach(observer);

                    ImageBasedMapData oldMapData = riskeerMapControl.MapControl.BackgroundMapData;

                    // When
                    originalBackgroundData.Name          = newBackgroundData.Name;
                    originalBackgroundData.IsVisible     = newBackgroundData.IsVisible;
                    originalBackgroundData.Transparency  = newBackgroundData.Transparency;
                    originalBackgroundData.Configuration = newBackgroundData.Configuration;
                    originalBackgroundData.NotifyObservers();

                    // Then
                    Assert.IsNotNull(riskeerMapControl.MapControl.BackgroundMapData);
                    Assert.AreNotSame(oldMapData, riskeerMapControl.MapControl.BackgroundMapData);
                    Assert.AreNotEqual(oldMapData.GetType(), riskeerMapControl.MapControl.BackgroundMapData.GetType());
                    mocks.VerifyAll(); // Expect no observers notified
                }
        }
Exemplo n.º 3
0
        public void GivenConfiguredWellKnownBackgroundData_WhenTileSourceChangedAndNotified_ThenBackgroundMapDataUpdatedAndNotified()
        {
            // Given
            var mocks    = new MockRepository();
            var observer = mocks.StrictMock <IObserver>();

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

            var            mapData           = new WellKnownTileSourceMapData(WellKnownTileSource.BingAerial);
            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 WellKnownBackgroundDataConfiguration(RiskeerWellKnownTileSource.BingRoads);
                    backgroundData.NotifyObservers();

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

                    var newWellKnownMapData = (WellKnownTileSourceMapData)riskeerMapControl.MapControl.BackgroundMapData;
                    Assert.AreEqual(WellKnownTileSource.BingRoads, newWellKnownMapData.TileSource);
                    mocks.VerifyAll();
                }
        }
Exemplo n.º 4
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();
                }
        }
Exemplo n.º 5
0
        private void UpdateBackgroundMapData()
        {
            ImageBasedMapData newData = BackgroundDataConverter.ConvertFrom(backgroundData);

            if (backgroundData.Configuration is WmtsBackgroundDataConfiguration)
            {
                if (newData.IsConfigured)
                {
                    var newWmtsData = (WmtsMapData)newData;
                    ((WmtsMapData)mapControl.BackgroundMapData).Configure(newWmtsData.SourceCapabilitiesUrl,
                                                                          newWmtsData.SelectedCapabilityIdentifier,
                                                                          newWmtsData.PreferredFormat);
                }
                else
                {
                    ((WmtsMapData)mapControl.BackgroundMapData).RemoveConfiguration();
                }
            }
            else if (backgroundData.Configuration is WellKnownBackgroundDataConfiguration)
            {
                ((WellKnownTileSourceMapData)mapControl.BackgroundMapData).SetTileSource(((WellKnownTileSourceMapData)newData).TileSource);
            }

            mapControl.BackgroundMapData.IsVisible    = newData.IsVisible;
            mapControl.BackgroundMapData.Name         = newData.Name;
            mapControl.BackgroundMapData.Transparency = newData.Transparency;
        }
Exemplo n.º 6
0
        public void HasSameConfiguration_LayerInitializedSameMapDataType_ReturnFalse(ImageBasedMapData mapData1, ImageBasedMapData mapData2)
        {
            // Setup
            var            mocks         = new MockRepository();
            var            tileFetcher   = mocks.Stub <ITileFetcher>();
            IConfiguration configuration = CreateStubConfiguration(mocks, tileFetcher);

            mocks.ReplayAll();

            using (var layerStatus = new MapControlBackgroundLayerStatus())
            {
                using (var layer = new BruTileLayer(configuration))
                {
                    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();
        }
Exemplo n.º 7
0
        protected override bool OnHasSameConfiguration(ImageBasedMapData mapData)
        {
            var wellKnownTileSourceMapData = mapData as WellKnownTileSourceMapData;

            return(wellKnownTileSourceMapData != null &&
                   Equals(wellKnownTileSourceMapData.TileSource, wellKnownTileSource));
        }
Exemplo n.º 8
0
        protected override bool OnHasSameConfiguration(ImageBasedMapData mapData)
        {
            var wmtsDataSource = mapData as WmtsMapData;

            return(wmtsDataSource != null &&
                   Equals(wmtsDataSource.SourceCapabilitiesUrl, sourceCapabilitiesUrl) &&
                   Equals(wmtsDataSource.SelectedCapabilityIdentifier, selectedCapabilityId) &&
                   Equals(wmtsDataSource.PreferredFormat, preferredFormat));
        }
Exemplo n.º 9
0
        /// <summary>
        /// Indicates if a <see cref="ImageBasedMapData"/> corresponds with the <see cref="BackgroundLayer"/>.
        /// </summary>
        /// <param name="mapData">The map data.</param>
        /// <returns>Returns <c>true</c> if <paramref name="mapData"/> corresponds with
        /// <see cref="BackgroundLayer"/>, <c>false</c> otherwise.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="mapData"/> is <c>null</c>.</exception>
        public bool HasSameConfiguration(ImageBasedMapData mapData)
        {
            if (mapData == null)
            {
                throw new ArgumentNullException(nameof(mapData));
            }

            return(OnHasSameConfiguration(mapData));
        }
Exemplo n.º 10
0
        public void ConvertFrom_BackgroundData_ReturnWmtsMapData(WmtsMapData mapData)
        {
            // Setup
            BackgroundData backgroundData = BackgroundDataConverter.ConvertTo(mapData);

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

            // Assert
            MapDataTestHelper.AssertImageBasedMapData(backgroundData, convertedMapData);
        }
Exemplo n.º 11
0
        public void ConvertFrom_BackgroundData_ReturnWellKnownMapData()
        {
            // Setup
            var            random = new Random(21);
            var            wellKnownTileSource = random.NextEnumValue <WellKnownTileSource>();
            BackgroundData backgroundData      = BackgroundDataConverter.ConvertTo(new WellKnownTileSourceMapData(wellKnownTileSource));

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

            // Assert
            MapDataTestHelper.AssertImageBasedMapData(backgroundData, convertedMapData);
        }
Exemplo n.º 12
0
        private static void AssertAreEqual(WellKnownTileSourceMapData expected, ImageBasedMapData actual)
        {
            if (expected == null)
            {
                Assert.IsNull(actual);
                return;
            }

            var actualWellKnownTileSourceMapData = (WellKnownTileSourceMapData)actual;

            Assert.AreEqual(expected.Name, actualWellKnownTileSourceMapData.Name);
            Assert.AreEqual(expected.TileSource, actualWellKnownTileSourceMapData.TileSource);
        }
Exemplo n.º 13
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);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Marks that a (new) background layer has successfully been initialized.
        /// </summary>
        /// <param name="backgroundLayer">The constructed layer.</param>
        /// <param name="dataSource">The data used to construct <paramref name="backgroundLayer"/>.</param>
        /// <exception cref="ArgumentNullException">Thrown when any of the input parameters is <c>null</c>.</exception>
        public void LayerInitializationSuccessful(BruTileLayer backgroundLayer, ImageBasedMapData dataSource)
        {
            if (backgroundLayer == null)
            {
                throw new ArgumentNullException(nameof(backgroundLayer));
            }

            if (dataSource == null)
            {
                throw new ArgumentNullException(nameof(dataSource));
            }

            OnLayerInitializationSuccessful(backgroundLayer, dataSource);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Converts <see cref="BackgroundData"/> to <see cref="ImageBasedMapData"/>.
        /// </summary>
        /// <param name="backgroundData">The <see cref="BackgroundData"/> to convert.</param>
        /// <returns>The converted <see cref="ImageBasedMapData"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="backgroundData"/>
        /// is <c>null</c>.</exception>
        /// <exception cref="InvalidEnumArgumentException">Thrown when
        /// <see cref="WellKnownBackgroundDataConfiguration.WellKnownTileSource"/> contains an
        /// invalid value for <see cref="WellKnownTileSource"/>.</exception>
        /// <exception cref="NotSupportedException">Thrown when <see cref="BackgroundData.Configuration"/>
        /// doesn't is of a type that can be converted.</exception>
        public static ImageBasedMapData ConvertFrom(BackgroundData backgroundData)
        {
            if (backgroundData == null)
            {
                throw new ArgumentNullException(nameof(backgroundData));
            }

            ImageBasedMapData mapData = CreateMapData(backgroundData);

            mapData.IsVisible    = backgroundData.IsVisible;
            mapData.Transparency = backgroundData.Transparency;

            return(mapData);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Creates a new <see cref="BruTileLayer"/> based on the <paramref name="backgroundMapData"/>.
        /// </summary>
        /// <param name="backgroundMapData">The <see cref="ImageBasedMapData"/> to create a
        /// <see cref="BruTileLayer"/> for.</param>
        /// <returns>A new <see cref="BruTileLayer"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="backgroundMapData"/>
        /// is <c>null</c>.</exception>
        /// <exception cref="NotSupportedException">Thrown when a configuration can't
        /// be created for the type of <paramref name="backgroundMapData"/>.</exception>
        /// <exception cref="ConfigurationInitializationException">Thrown when the configuration
        /// can't connect with the tile service or creating the file cache failed.</exception>
        public static BruTileLayer Create(ImageBasedMapData backgroundMapData)
        {
            if (backgroundMapData == null)
            {
                throw new ArgumentNullException(nameof(backgroundMapData));
            }

            IConfiguration configuration = BrutileConfigurationFactory.CreateInitializedConfiguration(backgroundMapData);

            return(new BruTileLayer(configuration)
            {
                IsVisible = backgroundMapData.IsVisible,
                Transparency = Convert.ToSingle(backgroundMapData.Transparency)
            });
        }
        /// <summary>
        /// Creates a new instance of <see cref="BackgroundMapDataSelectionDialog"/>.
        /// </summary>
        /// <param name="dialogParent">The parent of the dialog.</param>
        /// <param name="mapData">The active map data or <c>null</c> if none is active.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="dialogParent"/> is <c>null</c>.</exception>
        public BackgroundMapDataSelectionDialog(IWin32Window dialogParent, ImageBasedMapData mapData)
            : base(dialogParent, RiskeerCommonFormsResources.SelectionDialogIcon, 500, 350)
        {
            mapDatas = new HashSet <BackgroundMapDataSelectionControl>
            {
                new WellKnownMapDataControl(mapData as WellKnownTileSourceMapData),
                new WmtsLocationControl(mapData as WmtsMapData, new BruTileWmtsCapabilityFactory())
            };

            InitializeComponent();
            InitializeButtons();

            BackgroundMapDataSelectionControl controlToSelect = GetBackgroundMapDataControlToSelect(mapData);

            PreSelectComboBox(controlToSelect);
        }
Exemplo n.º 18
0
        /// <summary>
        /// Initializes a new instance of <see cref="TestTileSourceFactory"/> for a given
        /// <see cref="ImageBasedMapData"/>.
        /// </summary>
        /// <param name="backgroundMapData">The map data to work for.</param>
        /// <remarks>If <paramref name="backgroundMapData"/> isn't initialized at construction
        /// time, then <see cref="GetWmtsTileSources"/> returns no tile sources.</remarks>
        public TestTileSourceFactory(ImageBasedMapData backgroundMapData)
        {
            var wellKnownMapData = backgroundMapData as WellKnownTileSourceMapData;

            if (wellKnownMapData != null)
            {
                SetWellKnownTileSource(wellKnownMapData);
            }

            var wmtsMapData = backgroundMapData as WmtsMapData;

            if (wmtsMapData != null && wmtsMapData.IsConfigured)
            {
                SetWmtsTileSource(wmtsMapData);
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// Converts <see cref="ImageBasedMapData"/> to <see cref="BackgroundData"/>.
        /// </summary>
        /// <param name="mapData">The <see cref="ImageBasedMapData"/> to convert.</param>
        /// <returns>The converted <see cref="BackgroundData"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="mapData"/>
        /// is <c>null</c>.</exception>
        /// <exception cref="NotSupportedException">Thrown when the <see cref="ImageBasedMapData"/>
        /// is not supported for conversion.</exception>
        public static BackgroundData ConvertTo(ImageBasedMapData mapData)
        {
            if (mapData == null)
            {
                throw new ArgumentNullException(nameof(mapData));
            }

            var backgroundData = new BackgroundData(CreateBackgroundDataConfiguration(mapData))
            {
                Name         = mapData.Name,
                IsVisible    = mapData.IsVisible,
                Transparency = mapData.Transparency
            };

            return(backgroundData);
        }
Exemplo n.º 20
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);
                    }
        }
        /// <summary>
        /// Creates a new instance of <see cref="BackgroundLayerStatus"/> corresponding to
        /// the type of <paramref name="mapData"/>.
        /// </summary>
        /// <param name="mapData">The type of <see cref="ImageBasedMapData"/> to create a
        /// <see cref="BackgroundLayerStatus"/> for.</param>
        /// <returns>A new instance of <see cref="BackgroundLayerStatus"/>.</returns>
        /// <exception cref="ArgumentNullException ">Thrown when <paramref name="mapData"/>
        /// is <c>null</c>.</exception>
        /// <exception cref="NotSupportedException">Thrown when the type of <see cref="ImageBasedMapData"/>
        /// is not supported.</exception>
        internal static BackgroundLayerStatus CreateBackgroundLayerStatus(ImageBasedMapData mapData)
        {
            if (mapData == null)
            {
                throw new ArgumentNullException(nameof(mapData));
            }

            if (mapData is WmtsMapData)
            {
                return(new WmtsBackgroundLayerStatus());
            }

            if (mapData is WellKnownTileSourceMapData)
            {
                return(new WellKnownBackgroundLayerStatus());
            }

            throw new NotSupportedException("Unsupported type of mapData");
        }
Exemplo n.º 22
0
        public void ClearConfiguration_HasLayer_ConfigurationCleared(ImageBasedMapData mapData)
        {
            // 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 MapControlBackgroundLayerStatus())
                {
                    layerStatus.LayerInitializationSuccessful(layer, mapData);

                    // Call
                    layerStatus.ClearConfiguration();

                    // Assert
                    Assert.IsFalse(layerStatus.PreviousBackgroundLayerCreationFailed);
                    Assert.IsFalse(layerStatus.HasSameConfiguration(mapData));
                }
        }
Exemplo n.º 23
0
        /// <summary>
        /// Creates a new initialized <see cref="IConfiguration"/>.
        /// </summary>
        /// <param name="mapData">The <see cref="ImageBasedMapData"/> to create an
        /// <see cref="IConfiguration"/> for.</param>
        /// <returns>A new initialized configuration.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="mapData"/>
        /// is <c>null</c>.</exception>
        /// <exception cref="NotSupportedException">Thrown when a configuration can't
        /// be created for the type of <paramref name="mapData"/>.</exception>
        /// <exception cref="ConfigurationInitializationException">Thrown when the configuration
        /// can't connect with the tile service or creating the file cache failed.</exception>
        public static IConfiguration CreateInitializedConfiguration(ImageBasedMapData mapData)
        {
            if (mapData == null)
            {
                throw new ArgumentNullException(nameof(mapData));
            }

            var wmtsBackgroundMapData      = mapData as WmtsMapData;
            var wellKnownBackgroundMapData = mapData as WellKnownTileSourceMapData;

            if (wmtsBackgroundMapData != null)
            {
                return(CreateInitializedConfiguration(wmtsBackgroundMapData));
            }

            if (wellKnownBackgroundMapData != null)
            {
                return(CreateInitializedConfiguration(wellKnownBackgroundMapData));
            }

            throw new NotSupportedException($"Cannot create a configuration for type {mapData.GetType()}.");
        }
Exemplo n.º 24
0
        /// <summary>
        /// Asserts whether the <see cref="ImageBasedMapData"/> contains the data that is representative for the <paramref name="backgroundData"/>.
        /// </summary>
        /// <param name="backgroundData">The <see cref="BackgroundData"/> that contains the original data.</param>
        /// <param name="imageBasedMapData">The <see cref="ImageBasedMapData"/> that needs to be asserted.</param>
        /// <exception cref="AssertionException">Thrown when:
        /// <list type="bullet">
        /// <item><paramref name="imageBasedMapData"/> is not of the expected type;</item>
        /// <item>one of the properties of <paramref name="imageBasedMapData"/> is not equal to <paramref name="backgroundData"/>.</item>
        /// </list>
        /// </exception>
        public static void AssertImageBasedMapData(BackgroundData backgroundData, ImageBasedMapData imageBasedMapData)
        {
            Assert.AreEqual(backgroundData.Name, imageBasedMapData.Name);
            Assert.AreEqual(backgroundData.IsVisible, imageBasedMapData.IsVisible);
            Assert.AreEqual(backgroundData.Transparency, imageBasedMapData.Transparency);

            var wmtsBackgroundDataConfiguration = backgroundData.Configuration as WmtsBackgroundDataConfiguration;

            if (wmtsBackgroundDataConfiguration != null)
            {
                Assert.IsInstanceOf <WmtsMapData>(imageBasedMapData);

                var wmtsMapData = (WmtsMapData)imageBasedMapData;
                Assert.AreEqual(wmtsBackgroundDataConfiguration.PreferredFormat, wmtsMapData.PreferredFormat);
                Assert.AreEqual(wmtsBackgroundDataConfiguration.SelectedCapabilityIdentifier, wmtsMapData.SelectedCapabilityIdentifier);
                Assert.AreEqual(wmtsBackgroundDataConfiguration.SourceCapabilitiesUrl, wmtsMapData.SourceCapabilitiesUrl);
                Assert.AreEqual(wmtsBackgroundDataConfiguration.IsConfigured, wmtsMapData.IsConfigured);

                return;
            }

            var wellKnownBackgroundDataConfiguration = backgroundData.Configuration as WellKnownBackgroundDataConfiguration;

            if (wellKnownBackgroundDataConfiguration != null)
            {
                Assert.IsInstanceOf <WellKnownTileSourceMapData>(imageBasedMapData);

                var wellKnownTileSourceMapData = (WellKnownTileSourceMapData)imageBasedMapData;
                Assert.AreEqual(wellKnownBackgroundDataConfiguration.WellKnownTileSource, (RiskeerWellKnownTileSource)wellKnownTileSourceMapData.TileSource);
                Assert.IsTrue(wellKnownTileSourceMapData.IsConfigured);

                return;
            }

            Assert.Fail("Unsupported background configuration.");
        }
Exemplo n.º 25
0
        public void SelectedMapData_DifferentRowSelected_UpdatesSelectedMapData()
        {
            // Setup
            var selectedWellKnownTileSourceMapData = new WellKnownTileSourceMapData(WellKnownTileSource.BingAerial);
            var selectionChanged = 0;

            using (var form = new Form())
                using (var control = new WellKnownMapDataControl(selectedWellKnownTileSourceMapData))
                {
                    form.Controls.Add(control);
                    var dataGridViewControl = (DataGridViewControl) new ControlTester("dataGridViewControl", form).TheObject;
                    dataGridViewControl.CurrentRowChanged += (sender, args) => selectionChanged++;
                    DataGridViewRow row = dataGridViewControl.GetRowFromIndex(2);

                    dataGridViewControl.SetCurrentCell(row.Cells[0]);

                    // Call
                    ImageBasedMapData actualImageBasedMapData = control.SelectedMapData;

                    // Assert
                    AssertAreEqual(row.DataBoundItem as WellKnownTileSourceMapData, actualImageBasedMapData);
                    Assert.AreEqual(1, selectionChanged);
                }
        }
Exemplo n.º 26
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();
                }
        }
Exemplo n.º 27
0
        public void ClearConfiguration_WithFailedLayerInitializationAndExpectingRecreation_ConfigurationClearedButKeepFailedFlagSet(ImageBasedMapData mapData)
        {
            // Setup
            using (var layerStatus = new MapControlBackgroundLayerStatus())
            {
                layerStatus.LayerInitializationFailed();

                // Call
                layerStatus.ClearConfiguration(true);

                // Assert
                Assert.IsTrue(layerStatus.PreviousBackgroundLayerCreationFailed);
                Assert.IsFalse(layerStatus.HasSameConfiguration(mapData));
            }
        }
Exemplo n.º 28
0
 protected override bool OnHasSameConfiguration(ImageBasedMapData mapData)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 29
0
 protected override void OnLayerInitializationSuccessful(BruTileLayer backgroundLayer, ImageBasedMapData dataSource)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 30
0
        public void CreateInitializedConfiguration_CannotCreateFileCache_ThrowConfigurationInitializationException(ImageBasedMapData mapData)
        {
            // Setup
            using (new UseCustomSettingsHelper(new TestSettingsHelper
            {
                ApplicationLocalUserSettingsDirectory = Path.Combine(TestHelper.GetScratchPadPath(), nameof(BrutileConfigurationFactoryTest))
            }))
                using (var disposeHelper = new DirectoryDisposeHelper(TestHelper.GetScratchPadPath(), nameof(BrutileConfigurationFactoryTest)))
                    using (new UseCustomTileSourceFactoryConfig(mapData))
                    {
                        disposeHelper.LockDirectory(FileSystemRights.Write);

                        // Call
                        TestDelegate test = () => BrutileConfigurationFactory.CreateInitializedConfiguration(mapData);

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