public void ContextMenuStrip_VisibleFeatureBasedMapDataWithFeaturesInMapDataCollection_ZoomToAllItemEnabled()
        {
            // Setup
            var featureBasedMapData = new TestFeatureBasedMapData
            {
                IsVisible = true,
                Features  = new[]
                {
                    new MapFeature(Enumerable.Empty <MapGeometry>())
                }
            };

            var mapDataCollection = new MapDataCollection("test data");

            mapDataCollection.Add(featureBasedMapData);

            using (var treeViewControl = new TreeViewControl())
            {
                var builder = new CustomItemsOnlyContextMenuBuilder();
                contextMenuBuilderProvider.Expect(cmbp => cmbp.Get(null, null)).IgnoreArguments().Return(builder);
                mocks.ReplayAll();

                // Call
                using (ContextMenuStrip contextMenu = info.ContextMenuStrip(GetContext(mapDataCollection), null, treeViewControl))
                {
                    // Assert
                    TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuZoomToAllIndex,
                                                                  "&Zoom naar alles",
                                                                  "Zet het zoomniveau van de kaart dusdanig dat alle zichtbare kaartlagen in deze map met kaartlagen precies in het beeld passen.",
                                                                  Resources.ZoomToAllIcon);
                }
            }
        }
        public void ContextMenuStrip_VisibleFeatureBasedMapDataWithoutFeaturesInMapDataCollection_ZoomToAllItemDisabled()
        {
            // Setup
            var featureBasedMapData = new TestFeatureBasedMapData
            {
                IsVisible = true
            };
            var mapDataCollection = new MapDataCollection("test data");

            mapDataCollection.Add(featureBasedMapData);

            using (var treeViewControl = new TreeViewControl())
            {
                var builder = new CustomItemsOnlyContextMenuBuilder();
                contextMenuBuilderProvider.Expect(cmbp => cmbp.Get(null, null)).IgnoreArguments().Return(builder);
                mocks.ReplayAll();

                // Call
                using (ContextMenuStrip contextMenu = info.ContextMenuStrip(GetContext(mapDataCollection), null, treeViewControl))
                {
                    // Assert
                    TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuZoomToAllIndex,
                                                                  "&Zoom naar alles",
                                                                  "Om het zoomniveau aan te passen moet minstens één van de zichtbare kaartlagen in deze map met kaartlagen elementen bevatten.",
                                                                  Resources.ZoomToAllIcon,
                                                                  false);
                }
            }
        }
        public void OnNodeChecked_WithContextAndStateMixed_SetMapDataVisibilityAndNotifyObservers()
        {
            // Setup
            var observer1 = mocks.StrictMock <IObserver>();
            var observer2 = mocks.StrictMock <IObserver>();

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

            var featureBasedMapData1 = new TestFeatureBasedMapData();
            var featureBasedMapData2 = new TestFeatureBasedMapData
            {
                IsVisible = false
            };
            var mapDataCollection = new MapDataCollection("test");

            mapDataCollection.Add(featureBasedMapData1);
            mapDataCollection.Add(featureBasedMapData2);

            MapDataCollectionContext context = GetContext(mapDataCollection);

            featureBasedMapData1.Attach(observer1);
            featureBasedMapData2.Attach(observer2);

            // Call
            info.OnNodeChecked(context, null);

            // Assert
            Assert.IsTrue(context.WrappedData.IsVisible);
            Assert.IsTrue(featureBasedMapData1.IsVisible);
            Assert.IsTrue(featureBasedMapData2.IsVisible);
            mocks.VerifyAll();
        }
        public void ConvertLayerFeatures_LayerWithoutCoordinateSystem_CreatePointFeatureInMapDataCoordinateSystem()
        {
            // Setup
            var testConverter = new TestFeatureBasedMapDataConverter();
            var mapLayer      = new TestFeatureLayer
            {
                Projection = null
            };
            var mapData = new TestFeatureBasedMapData("test")
            {
                Features = new[]
                {
                    new MapFeature(Enumerable.Empty <MapGeometry>()) // TestFeatureBasedMapDataConverter will generate a Point feature at (1.1, 2.2)
                }
            };

            // Call
            testConverter.ConvertLayerFeatures(mapData, mapLayer);

            // Assert
            Assert.AreEqual(1, mapLayer.FeatureSet.Features.Count);
            Assert.AreEqual(1.1, mapLayer.FeatureSet.Features[0].Geometry.Coordinates[0].X);
            Assert.AreEqual(2.2, mapLayer.FeatureSet.Features[0].Geometry.Coordinates[0].Y);
            Assert.AreEqual(MapDataConstants.FeatureBasedMapDataCoordinateSystem, mapLayer.Projection);
        }
        public void GetNestedCollectionVisibilityStates_MapDataCollectionWithChildren_ReturnsDictionary()
        {
            // Setup
            var mapDataCollection = new MapDataCollection("test");
            var mapData1          = new TestFeatureBasedMapData();
            var mapData2          = new TestFeatureBasedMapData
            {
                IsVisible = false
            };
            var mapData3 = new TestFeatureBasedMapData
            {
                IsVisible = false
            };
            var nestedCollection = new MapDataCollection("nested");

            nestedCollection.Add(mapData3);

            mapDataCollection.Add(mapData1);
            mapDataCollection.Add(mapData2);
            mapDataCollection.Add(nestedCollection);

            // Call
            Dictionary <MapDataCollection, MapDataCollectionVisibility> states = MapDataCollectionHelper.GetNestedCollectionVisibilityStates(mapDataCollection);

            // Assert
            var expectedDictionary = new Dictionary <MapDataCollection, MapDataCollectionVisibility>
            {
                {
                    nestedCollection, MapDataCollectionVisibility.NotVisible
                }
            };

            CollectionAssert.AreEqual(expectedDictionary, states);
        }
        public void ConvertLayerFeatures_LayerInDifferentSystemAsMapData_CreatedPointIsReprojected()
        {
            // Setup
            var            testConverter    = new TestFeatureBasedMapDataConverter();
            ProjectionInfo coordinateSystem = KnownCoordinateSystems.Geographic.World.WGS1984;
            var            mapLayer         = new TestFeatureLayer
            {
                Projection = coordinateSystem
            };
            var mapData = new TestFeatureBasedMapData("test")
            {
                Features = new[]
                {
                    new MapFeature(Enumerable.Empty <MapGeometry>()) // TestFeatureBasedMapDataConverter will generate a Point feature at (1.1, 2.2)
                }
            };

            // Call
            testConverter.ConvertLayerFeatures(mapData, mapLayer);

            // Assert
            Assert.AreEqual(1, mapLayer.FeatureSet.Features.Count);
            Assert.AreEqual(3.3135717854013329, mapLayer.FeatureSet.Features[0].Geometry.Coordinates[0].X);
            Assert.AreEqual(47.974786294874853, mapLayer.FeatureSet.Features[0].Geometry.Coordinates[0].Y);
            Assert.AreEqual(coordinateSystem, mapLayer.Projection);
        }
        public void ContextMenuStrip_NoMapControlAndEnabledZoomToAllContextMenuItemClicked_DoesNotThrow()
        {
            // Setup
            var mapData = new TestFeatureBasedMapData("A")
            {
                IsVisible = true,
                Features  = new[]
                {
                    new MapFeature(Enumerable.Empty <MapGeometry>())
                }
            };

            var builder = new CustomItemsOnlyContextMenuBuilder();

            contextMenuBuilderProvider.Expect(p => p.Get(null, null)).IgnoreArguments().Return(builder);
            mocks.ReplayAll();

            using (ContextMenuStrip contextMenu = info.ContextMenuStrip(GetContext(mapData), null, null))
            {
                // Call
                TestDelegate call = () => contextMenu.Items[mapDataContextMenuZoomToAllIndex].PerformClick();

                // Assert
                Assert.DoesNotThrow(call);
            }
        }
        public void OnNodeChecked_WithContext_SetMapDataVisibilityAndNotifyObservers(bool initialVisibleState)
        {
            // Setup
            var collectionObserver = mocks.StrictMock <IObserver>();

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

            var featureBasedMapData = new TestFeatureBasedMapData();
            var mapDataCollection   = new MapDataCollection("test");

            mapDataCollection.Add(featureBasedMapData);

            MapDataCollectionContext context = GetContext(mapDataCollection);

            context.WrappedData.IsVisible = initialVisibleState;

            context.WrappedData.Attach(collectionObserver);

            // Call
            info.OnNodeChecked(context, null);

            // Assert
            Assert.AreEqual(!initialVisibleState, context.WrappedData.IsVisible);
            Assert.AreEqual(!initialVisibleState, featureBasedMapData.IsVisible);
            mocks.VerifyAll();
        }
        public void ContextMenuStrip_VisibleMapDataWithoutFeatures_ZoomToAllItemDisabled()
        {
            // Setup
            var builder = new CustomItemsOnlyContextMenuBuilder();

            contextMenuBuilderProvider.Expect(p => p.Get(null, null)).IgnoreArguments().Return(builder);

            mocks.ReplayAll();

            var mapData = new TestFeatureBasedMapData
            {
                IsVisible = true
            };

            // Call
            using (ContextMenuStrip contextMenu = info.ContextMenuStrip(GetContext(mapData), null, null))
            {
                // Assert
                TestHelper.AssertContextMenuStripContainsItem(contextMenu, mapDataContextMenuZoomToAllIndex,
                                                              "&Zoom naar alles",
                                                              "Om het zoomniveau aan te passen moet de kaartlaag elementen bevatten.",
                                                              Resources.ZoomToAllIcon,
                                                              false);
            }
        }
        public void SetProperties_IndividualProperties_UpdateDataAndNotifyObservers()
        {
            // Setup
            const int numberOfChangedProperties = 2;
            var       mocks    = new MockRepository();
            var       observer = mocks.StrictMock <IObserver>();

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

            var mapData = new TestFeatureBasedMapData
            {
                ShowLabels = true
            };

            mapData.Attach(observer);

            var properties = new TestFeatureBasedMapDataProperties(mapData, Enumerable.Empty <MapDataCollection>());

            // Call
            properties.ShowLabels = false;
            properties.SelectedMetaDataAttribute = new SelectableMetaDataAttribute("ID");

            // Assert
            Assert.IsFalse(mapData.ShowLabels);
            Assert.AreEqual("ID", mapData.SelectedMetaDataAttribute);
            mocks.VerifyAll();
        }
        public void ContextMenuStrip_Always_CallsBuilder()
        {
            // Setup
            var mapData = new TestFeatureBasedMapData();
            FeatureBasedMapDataContext context = GetContext(mapData);
            var builder = mocks.StrictMock <IContextMenuBuilder>();

            using (mocks.Ordered())
            {
                builder.Expect(mb => mb.AddCustomItem(Arg <StrictContextMenuItem> .Is.NotNull)).Return(builder);
                builder.Expect(mb => mb.AddSeparator()).Return(builder);
                builder.Expect(mb => mb.AddDeleteItem()).Return(builder);
                builder.Expect(mb => mb.AddSeparator()).Return(builder);
                builder.Expect(mb => mb.AddPropertiesItem()).Return(builder);
                builder.Expect(mb => mb.Build()).Return(null);
            }

            contextMenuBuilderProvider.Expect(p => p.Get(context, null)).Return(builder);

            mocks.ReplayAll();

            // Call
            info.ContextMenuStrip(context, null, null);

            // Assert
            // Assert expectancies are called in TearDown()
        }
        public void ContextMenuStrip_VisibleMapDataWithFeatures_ZoomToAllItemEnabled()
        {
            // Setup
            var builder = new CustomItemsOnlyContextMenuBuilder();

            contextMenuBuilderProvider.Expect(p => p.Get(null, null)).IgnoreArguments().Return(builder);

            mocks.ReplayAll();

            var mapData = new TestFeatureBasedMapData
            {
                IsVisible = true,
                Features  = new[]
                {
                    new MapFeature(Enumerable.Empty <MapGeometry>())
                }
            };

            // Call
            using (ContextMenuStrip contextMenu = info.ContextMenuStrip(GetContext(mapData), null, null))
            {
                // Assert
                TestHelper.AssertContextMenuStripContainsItem(contextMenu, mapDataContextMenuZoomToAllIndex,
                                                              "&Zoom naar alles",
                                                              "Zet het zoomniveau van de kaart dusdanig dat deze kaartlaag precies in het beeld past.",
                                                              Resources.ZoomToAllIcon);
            }
        }
        public void OnNodeChecked_WithContext_NotifyObserversOfParentMapDataCollections()
        {
            // Setup
            var collectionObserver = mocks.StrictMock <IObserver>();

            collectionObserver.Expect(o => o.UpdateObserver());
            var parentCollectionObserver = mocks.StrictMock <IObserver>();

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

            var featureBasedMapData     = new TestFeatureBasedMapData();
            var nestedMapDataCollection = new MapDataCollection("nested");

            nestedMapDataCollection.Add(featureBasedMapData);
            var mapDataCollection = new MapDataCollection("test");

            mapDataCollection.Add(nestedMapDataCollection);

            MapDataCollectionContext   rootCollectionContext      = GetContext(mapDataCollection);
            MapDataCollectionContext   nestedCollectionContext    = GetContext(nestedMapDataCollection, rootCollectionContext);
            FeatureBasedMapDataContext featureBasedMapDataContext = GetContext(featureBasedMapData, nestedCollectionContext);

            nestedMapDataCollection.Attach(collectionObserver);
            mapDataCollection.Attach(parentCollectionObserver);

            // Call
            info.OnNodeChecked(featureBasedMapDataContext, null);

            // Assert
            mocks.VerifyAll();
        }
        public void DynamicReadOnlyValidator_MapHasMetaData_ReturnsExpectedValuesForRelevantProperties(bool hasMetaData)
        {
            // Setup
            var feature = new MapFeature(Enumerable.Empty <MapGeometry>());

            if (hasMetaData)
            {
                feature.MetaData["key"] = "value";
            }

            var mapData = new TestFeatureBasedMapData
            {
                Features = new[]
                {
                    feature
                }
            };

            var properties = new TestFeatureBasedMapDataProperties(mapData, Enumerable.Empty <MapDataCollection>());

            // Call
            bool isShowLabelReadOnly = properties.DynamicReadonlyValidator(
                nameof(TestFeatureBasedMapDataProperties.ShowLabels));
            bool isSelectedMetaDataReadOnly = properties.DynamicReadonlyValidator(
                nameof(TestFeatureBasedMapDataProperties.SelectedMetaDataAttribute));

            // Assert
            Assert.AreNotEqual(hasMetaData, isShowLabelReadOnly);
            Assert.AreNotEqual(hasMetaData, isSelectedMetaDataReadOnly);
        }
Exemple #15
0
        public void MetaData_Always_ReturnAllUniqueAvailableMetaDataAttributesFromFeatures()
        {
            // Setup
            var feature1 = new MapFeature(Enumerable.Empty <MapGeometry>());

            feature1.MetaData["Attribute1"] = new object();
            var feature2 = new MapFeature(Enumerable.Empty <MapGeometry>());

            feature2.MetaData["Attribute1"] = new object();
            feature2.MetaData["Attribute2"] = new object();
            var feature3 = new MapFeature(Enumerable.Empty <MapGeometry>());

            feature3.MetaData["Attribute3"] = new object();

            var data = new TestFeatureBasedMapData("test data")
            {
                Features = new[]
                {
                    feature1,
                    feature2,
                    feature3
                }
            };

            // Call
            IEnumerable <string> metaData = data.MetaData;

            // Assert
            CollectionAssert.AreEqual(new[]
            {
                "Attribute1",
                "Attribute2",
                "Attribute3"
            }, metaData);
        }
Exemple #16
0
        public void Selection_Always_ReturnsDataContext()
        {
            // Setup
            var mapData           = new TestFeatureBasedMapData();
            var mapDataCollection = new MapDataCollection("collection");

            mapDataCollection.Add(mapData);

            using (var view = new MapLegendView(contextMenuBuilderProvider)
            {
                Data = mapDataCollection
            })
            {
                var treeViewControl = TypeUtils.GetField <TreeViewControl>(view, "treeViewControl");
                WindowsFormsTestHelper.Show(treeViewControl);
                treeViewControl.TrySelectNodeForData(view.Data);

                // Call
                var selection = (MapDataCollectionContext)view.Selection;

                // Assert
                Assert.AreSame(mapDataCollection, selection.WrappedData);
            }

            WindowsFormsTestHelper.CloseAll();
        }
        public void ContextMenuStrip_EnabledZoomToAllContextMenuItemClicked_DoZoomToVisibleData()
        {
            // Setup
            var mapData = new TestFeatureBasedMapData
            {
                IsVisible = true,
                Features  = new[]
                {
                    new MapFeature(Enumerable.Empty <MapGeometry>())
                }
            };

            var builder = new CustomItemsOnlyContextMenuBuilder();

            contextMenuBuilderProvider.Expect(p => p.Get(null, null)).IgnoreArguments().Return(builder);
            var mapControl = mocks.StrictMock <IMapControl>();

            mapControl.Expect(c => c.Data).Return(new MapDataCollection("name"));
            mapControl.Expect(c => c.ZoomToVisibleLayers(mapData));
            mocks.ReplayAll();

            mapLegendView.MapControl = mapControl;

            using (ContextMenuStrip contextMenu = info.ContextMenuStrip(GetContext(mapData), null, null))
            {
                // Call
                contextMenu.Items[mapDataContextMenuZoomToAllIndex].PerformClick();

                // Assert
                // Assert expectancies are called in TearDown()
            }
        }
        public void IsVisible_SetNewValue_UpdateDataAndNotifyObserversOfDataAndParents()
        {
            // Setup
            var mocks    = new MockRepository();
            var observer = mocks.StrictMock <IObserver>();

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

            var mapData = new TestFeatureBasedMapData();
            var parents = new[]
            {
                new MapDataCollection("test 1"),
                new MapDataCollection("test 2"),
                new MapDataCollection("test 3")
            };

            mapData.Attach(observer);
            parents.ForEachElementDo(parent => parent.Attach(observer));

            var properties = new TestFeatureBasedMapDataProperties(mapData, parents);

            // Call
            properties.IsVisible = false;

            // Assert
            Assert.IsFalse(properties.IsVisible);
            mocks.VerifyAll();
        }
        public void ConvertLayerFeatures_LayerWithDataInDifferentCoordinateSystem_CreatedPointIsNotReprojected()
        {
            // Setup
            var testConverter = new TestFeatureBasedMapDataConverter();
            var mapLayer      = new TestFeatureLayer
            {
                Projection = KnownCoordinateSystems.Geographic.World.WGS1984
            };
            var mapData = new TestFeatureBasedMapData("test")
            {
                Features = new[]
                {
                    new MapFeature(Enumerable.Empty <MapGeometry>()) // TestFeatureBasedMapDataConverter will generate a Point feature at (1.1, 2.2)
                }
            };

            testConverter.ConvertLayerFeatures(mapData, mapLayer);
            mapLayer.Projection = MapDataConstants.FeatureBasedMapDataCoordinateSystem;

            // Call
            testConverter.ConvertLayerFeatures(mapData, mapLayer);

            // Assert
            Assert.AreEqual(1, mapLayer.FeatureSet.Features.Count);
            Assert.AreEqual(1.1, mapLayer.FeatureSet.Features[0].Geometry.Coordinates[0].X);
            Assert.AreEqual(2.2, mapLayer.FeatureSet.Features[0].Geometry.Coordinates[0].Y);
            Assert.AreEqual(MapDataConstants.FeatureBasedMapDataCoordinateSystem, mapLayer.Projection);
        }
        public void SelectedMetaDataAttribute_ShowLabelsTrue_SelectedMetaDataAttributeShouldBeVisible(bool showLabels)
        {
            // Setup
            var feature = new MapFeature(Enumerable.Empty <MapGeometry>());

            feature.MetaData["key"] = "value";

            var mapData = new TestFeatureBasedMapData
            {
                Features = new[]
                {
                    feature
                },
                ShowLabels = showLabels
            };

            // Call
            var properties = new TestFeatureBasedMapDataProperties(mapData, Enumerable.Empty <MapDataCollection>());

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

            Assert.AreEqual(showLabels ? 6 : 5, dynamicProperties.Count);

            if (showLabels)
            {
                PropertyDescriptor selectedMetaDataAttributeProperty = dynamicProperties[selectedMetaDataAttributePropertyIndex];
                PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(selectedMetaDataAttributeProperty,
                                                                                "Labels",
                                                                                "Op basis van",
                                                                                "Toont de eigenschap op basis waarvan labels worden weergegeven op deze kaartlaag.");
            }
        }
        public void ConvertLayerProperties_MapDataWithoutMetaData_DefaultLabelLayerSetToLayer()
        {
            // Setup
            var testConverter = new TestFeatureBasedMapDataConverter();
            var mapData       = new TestFeatureBasedMapData("test data")
            {
                Features = new[]
                {
                    new MapFeature(Enumerable.Empty <MapGeometry>())
                },
                SelectedMetaDataAttribute = "Name"
            };
            var mapLayer = new TestFeatureLayer
            {
                DataSet =
                {
                    DataTable   =
                    {
                        Columns =
                        {
                            "1",
                            "2"
                        }
                    }
                }
            };

            // Call
            testConverter.ConvertLayerProperties(mapData, mapLayer);

            // Assert
            Assert.IsNotNull(mapLayer.LabelLayer);
            Assert.AreEqual("FID", mapLayer.LabelLayer.Symbology.Categories[0].Symbolizer.PriorityField);
            Assert.IsNull(mapLayer.LabelLayer.Symbology.Categories[0].Expression);
        }
        public void GivenLayerWithConvertedProperties_WhenConvertingLayerFeatures_ThenOnlyDefaultCategoryAdded()
        {
            // Given
            var mocks           = new MockRepository();
            var defaultCategory = mocks.Stub <IPointCategory>();
            var categoryOne     = mocks.Stub <IPointCategory>();
            var categoryTwo     = mocks.Stub <IPointCategory>();

            mocks.ReplayAll();

            const string metadataAttributeName = "Meta";
            var          theme = new MapTheme <TestCategoryTheme>(metadataAttributeName, new[]
            {
                new TestCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion())
            });
            var mapData = new TestFeatureBasedMapData("test data", theme)
            {
                Features = new[]
                {
                    new MapFeature(Enumerable.Empty <MapGeometry>())
                    {
                        MetaData =
                        {
                            {
                                metadataAttributeName, new object()
                            }
                        }
                    }
                }
            };

            var scheme = new PointScheme();

            scheme.Categories.Clear();
            scheme.Categories.Add(categoryOne);
            scheme.Categories.Add(categoryTwo);

            var mapLayer = new TestFeatureLayer
            {
                Symbology = scheme
            };

            var testConverter = new TestFeatureBasedMapDataConverter
            {
                CreatedDefaultCategory = defaultCategory
            };

            // Precondition
            Assert.AreEqual(2, mapLayer.Symbology.Categories.Count);

            // When
            mapData.Features = Enumerable.Empty <MapFeature>();
            testConverter.ConvertLayerFeatures(mapData, mapLayer);

            // Then
            Assert.AreSame(defaultCategory, mapLayer.Symbology.Categories.Single());
        }
Exemple #23
0
        public void Create_OtherData_ThrowsNotSupportedException()
        {
            // Setup
            var testData = new TestFeatureBasedMapData("test data");

            // Call
            TestDelegate test = () => FeatureBasedMapDataLayerFactory.Create(testData);

            // Assert
            Assert.Throws <NotSupportedException>(test);
        }
        public void Constructor_ExpectedValues()
        {
            // Setup
            var data = new TestFeatureBasedMapData();

            // Call
            var properties = new TestFeatureBasedMapDataProperties(data, Enumerable.Empty <MapDataCollection>());

            // Assert
            Assert.IsInstanceOf <ObjectProperties <TestFeatureBasedMapData> >(properties);
            Assert.IsInstanceOf <IHasMetaData>(properties);
            Assert.AreSame(data, properties.Data);
        }
Exemple #25
0
        public void FromFeatureBasedMapData_WithUnsupportedFeatureBasedMapData_ThrowsNotSupportedException()
        {
            // Setup
            var testData = new TestFeatureBasedMapData("test");

            // Call
            TestDelegate test = () => RemovableMapDataConverter.FromFeatureBasedMapData(testData);

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

            Assert.AreEqual("The given mapData was not convertible to IRemovable data.", exception.Message);
        }
Exemple #26
0
        public void Features_SetNullValue_ThrowsArgumentNullException()
        {
            // Setup
            var data = new TestFeatureBasedMapData("test data");

            // Call
            TestDelegate test = () => data.Features = null;

            // Assert
            const string expectedMessage = "The array of features cannot be null or contain null.";

            TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentNullException>(test, expectedMessage);
        }
        public void ConvertLayerProperties_MapDataWithMapThemeAndVaryingValueCriteria_SetsCorrectFilterExpression(ValueCriterionOperator criterionOperator,
                                                                                                                  string expressionFormat)
        {
            // Setup
            const string metadataAttributeName = "Meta";
            const string value = "test value";

            var valueCriterion = new ValueCriterion(criterionOperator,
                                                    value);
            var theme = new MapTheme <TestCategoryTheme>(metadataAttributeName, new[]
            {
                new TestCategoryTheme(valueCriterion)
            });

            var mapData = new TestFeatureBasedMapData("test data", theme)
            {
                Features = new[]
                {
                    new MapFeature(Enumerable.Empty <MapGeometry>())
                    {
                        MetaData =
                        {
                            {
                                metadataAttributeName, new object()
                            }
                        }
                    }
                }
            };

            var featureScheme   = new PointScheme();
            var defaultCategory = new PointCategory();
            var category        = new PointCategory();
            var testConverter   = new TestFeatureBasedMapDataConverter
            {
                CreatedFeatureScheme         = featureScheme,
                CreatedDefaultCategory       = defaultCategory,
                CreatedCategoryThemeCategory = category
            };

            var mapLayer = new TestFeatureLayer();

            // Call
            testConverter.ConvertLayerProperties(mapData, mapLayer);

            // Assert
            Assert.IsNull(defaultCategory.FilterExpression);
            string expectedFilterExpression = string.Format(expressionFormat, value);

            Assert.AreEqual(expectedFilterExpression, category.FilterExpression);
        }
        public void ConvertLayerProperties_MapData_NameSetToLayer()
        {
            // Setup
            const string name          = "<Some name>";
            var          testConverter = new TestFeatureBasedMapDataConverter();
            var          mapData       = new TestFeatureBasedMapData(name);
            var          mapLayer      = new TestFeatureLayer();

            // Call
            testConverter.ConvertLayerProperties(mapData, mapLayer);

            // Assert
            Assert.AreEqual(name, mapLayer.Name);
        }
        public void ConvertLayerProperties_MapDataWithMetaAndSelectedMetaDataAttributeInDataColumns_CustomLabelLayerSetToLayer()
        {
            // Setup
            var testConverter = new TestFeatureBasedMapDataConverter();
            var mapData       = new TestFeatureBasedMapData("test data")
            {
                Features = new[]
                {
                    new MapFeature(Enumerable.Empty <MapGeometry>())
                    {
                        MetaData =
                        {
                            {
                                "Id", 1.1
                            },
                            {
                                "Name", "Feature"
                            }
                        }
                    }
                },
                SelectedMetaDataAttribute = "Name"
            };
            var mapLayer = new TestFeatureLayer
            {
                DataSet =
                {
                    DataTable   =
                    {
                        Columns =
                        {
                            "1",
                            "2"
                        }
                    }
                }
            };

            // Call
            testConverter.ConvertLayerProperties(mapData, mapLayer);

            // Assert
            Assert.IsNotNull(mapLayer.LabelLayer);
            ILabelCategory labelCategory = mapLayer.LabelLayer.Symbology.Categories[0];

            Assert.AreEqual("FID", labelCategory.Symbolizer.PriorityField);
            Assert.AreEqual(ContentAlignment.MiddleRight, labelCategory.Symbolizer.Orientation);
            Assert.AreEqual(5, labelCategory.Symbolizer.OffsetX);
            Assert.AreEqual("[2]", labelCategory.Expression);
        }
        public void ConvertLayerProperties_TargetLayerNull_ThrowsArgumentNullException()
        {
            // Setup
            var testConverter = new TestFeatureBasedMapDataConverter();
            var mapData       = new TestFeatureBasedMapData("test data");

            // Call
            TestDelegate test = () => testConverter.ConvertLayerProperties(mapData, null);

            // Assert
            const string expectedMessage = "Null data cannot be used as conversion target.";

            TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentNullException>(test, expectedMessage);
        }