コード例 #1
0
        public void Constructor_WithStyleAndMapTheme_ExpectedValues()
        {
            // Setup
            const string name  = "test data";
            Color        color = Color.Aqua;
            var          style = new PointStyle
            {
                Color           = color,
                Size            = 3,
                Symbol          = PointSymbol.Circle,
                StrokeColor     = color,
                StrokeThickness = 1
            };

            var mapTheme = new MapTheme <PointCategoryTheme>("attribute", new[]
            {
                new PointCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion(),
                                       new PointStyle())
            });

            // Call
            var data = new MapPointData(name, style, mapTheme);

            // Assert
            Assert.AreEqual(name, data.Name);
            CollectionAssert.IsEmpty(data.Features);
            Assert.AreSame(style, data.Style);
            Assert.AreSame(mapTheme, data.Theme);
        }
コード例 #2
0
        public void Constructor_WithStyleAndMapTheme_ExpectedValues()
        {
            // Setup
            const string name  = "test data";
            var          style = new LineStyle
            {
                Color     = Color.Red,
                Width     = 5,
                DashStyle = LineDashStyle.Dash
            };

            var mapTheme = new MapTheme <LineCategoryTheme>("attribute", new[]
            {
                new LineCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion(),
                                      new LineStyle())
            });

            // Call
            var data = new MapLineData(name, style, mapTheme);

            // Assert
            Assert.AreEqual(name, data.Name);
            CollectionAssert.IsEmpty(data.Features);
            Assert.AreSame(style, data.Style);
            Assert.AreSame(mapTheme, data.Theme);
        }
コード例 #3
0
        public void Constructor_WithMapTheme_ReturnCorrectPropertyValues()
        {
            // Setup
            const string attributeName = "Attribute";
            var          categoryTheme = new LineCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion(), new LineStyle());
            var          mapLineData   = new MapLineData("Test",
                                                         new LineStyle(),
                                                         new MapTheme <LineCategoryTheme>(attributeName, new[]
            {
                categoryTheme
            }));

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

            // Assert
            Assert.AreEqual("Categorie", properties.StyleType);

            Assert.AreEqual(mapLineData.ShowLabels, properties.ShowLabels);
            Assert.IsEmpty(properties.SelectedMetaDataAttribute.MetaDataAttribute);
            Assert.AreEqual(mapLineData.MetaData, properties.GetAvailableMetaDataAttributes());

            Assert.AreEqual(1, properties.CategoryThemes.Length);
            LineCategoryThemeProperties pointCategoryThemeProperties = properties.CategoryThemes.First();

            Assert.AreSame(categoryTheme, pointCategoryThemeProperties.Data);
            ValueCriterionTestHelper.AssertValueCriterionFormatExpression(attributeName,
                                                                          categoryTheme.Criterion,
                                                                          pointCategoryThemeProperties.Criterion);
        }
コード例 #4
0
        public void Constructor_WithStyleAndMapTheme_ExpectedValues()
        {
            // Setup
            const string name  = "test data";
            var          style = new PolygonStyle
            {
                FillColor       = Color.Aqua,
                StrokeColor     = Color.DarkGoldenrod,
                StrokeThickness = 3
            };

            var mapTheme = new MapTheme <PolygonCategoryTheme>("attribute", new[]
            {
                new PolygonCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion(),
                                         new PolygonStyle())
            });

            // Call
            var data = new MapPolygonData(name, style, mapTheme);

            // Assert
            Assert.AreEqual(name, data.Name);
            CollectionAssert.IsEmpty(data.Features);
            Assert.AreSame(style, data.Style);
            Assert.AreSame(mapTheme, data.Theme);
        }
コード例 #5
0
 private static MapTheme <LineCategoryTheme> CreateMapTheme()
 {
     return(new MapTheme <LineCategoryTheme>("Attribute", new[]
     {
         new LineCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion(), new LineStyle())
     }));
 }
コード例 #6
0
        public void GivenMapLineDataPropertiesWithMapTheme_WhenCategoryThemePropertySet_ThenMapDataNotified()
        {
            // Given
            var random = new Random(21);

            var mocks    = new MockRepository();
            var observer = mocks.StrictMock <IObserver>();

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

            var mapLineData = new MapLineData("Test",
                                              new LineStyle(),
                                              new MapTheme <LineCategoryTheme>("Attribute", new[]
            {
                new LineCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion(), new LineStyle())
            }));

            mapLineData.Attach(observer);

            var properties = new MapLineDataProperties(mapLineData, Enumerable.Empty <MapDataCollection>());

            // When
            LineCategoryThemeProperties categoryThemeProperties = properties.CategoryThemes.First();

            categoryThemeProperties.Width = random.Next(1, 48);

            // Then
            mocks.VerifyAll();
        }
コード例 #7
0
        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());
        }
コード例 #8
0
        public void Constructor_StyleNull_ThrowsArgumentNullException()
        {
            // Call
            TestDelegate call = () => new PointCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion(), null);

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

            Assert.AreEqual("style", exception.ParamName);
        }
コード例 #9
0
ファイル: CategoryThemeTest.cs プロジェクト: Deltares/Riskeer
        public void Constructor_WithValidArguments_ExpectedValues()
        {
            // Setup
            ValueCriterion criterion = ValueCriterionTestFactory.CreateValueCriterion();

            // Call
            var category = new TestCategoryTheme(criterion);

            // Assert
            Assert.AreSame(criterion, category.Criterion);
        }
コード例 #10
0
        public void ConvertLayerProperties_MapPointDataWithThemeAndMetaDataNameNotInFeatures_OnlyAddsDefaultCategory()
        {
            // Setup
            const string metadataAttribute = "Meta";
            var          random            = new Random(21);
            var          theme             = new MapTheme <PointCategoryTheme>("Other Meta", new[]
            {
                new PointCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion(),
                                       new PointStyle
                {
                    Color           = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                    Size            = random.Next(1, 48),
                    Symbol          = random.NextEnum <PointSymbol>(),
                    StrokeColor     = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                    StrokeThickness = random.Next(1, 48)
                })
            });

            var pointStyle = new PointStyle
            {
                Color           = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                Size            = random.Next(1, 48),
                Symbol          = random.NextEnum <PointSymbol>(),
                StrokeColor     = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                StrokeThickness = random.Next(1, 48)
            };
            var mapPointData = new MapPointData("test", pointStyle, theme)
            {
                Features = new[]
                {
                    CreateMapFeatureWithMetaData(metadataAttribute)
                }
            };

            var mapPointLayer = new MapPointLayer();

            var converter = new MapPointDataConverter();

            // Call
            converter.ConvertLayerProperties(mapPointData, mapPointLayer);

            // Assert
            PointSymbolizer expectedSymbolizer = CreateExpectedSymbolizer(pointStyle);

            IPointScheme appliedScheme = mapPointLayer.Symbology;

            Assert.AreEqual(1, appliedScheme.Categories.Count);

            IPointCategory baseCategory = appliedScheme.Categories[0];

            AssertAreEqual(expectedSymbolizer, baseCategory.Symbolizer);
            Assert.IsNull(baseCategory.FilterExpression);
        }
コード例 #11
0
        public void ToString_Always_ReturnsEmptyString()
        {
            // Setup
            var theme      = new TestCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion());
            var properties = new TestCategoryThemeProperties(string.Empty, theme, new TestFeatureBasedMapData());

            // Call
            string toString = properties.ToString();

            // Assert
            Assert.IsEmpty(toString);
        }
コード例 #12
0
        public void Constructor_MapDataNull_ThrowsArgumentNullException()
        {
            // Setup
            var categoryTheme = new TestCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion());

            // Call
            TestDelegate call = () => new TestCategoryThemeProperties(string.Empty, categoryTheme, null);

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

            Assert.AreEqual("mapData", exception.ParamName);
        }
コード例 #13
0
        public void Constructor_ExpectedValues()
        {
            // Setup
            var theme = new TestCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion());

            // Call
            var properties = new TestCategoryThemeProperties(string.Empty, theme, new TestFeatureBasedMapData());

            // Assert
            Assert.AreSame(theme, properties.Data);
            Assert.IsInstanceOf <ObjectProperties <TestCategoryTheme> >(properties);
            TestHelper.AssertTypeConverter <CategoryThemeProperties <CategoryTheme>, ExpandableObjectConverter>();
        }
コード例 #14
0
        public void Constructor_AttributeNameNull_ThrowsArgumentNullException()
        {
            // Setup
            var categoryTheme = new TestCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion());

            // Call
            TestDelegate call = () => new TestCategoryThemeProperties(null, categoryTheme, new TestFeatureBasedMapData());

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

            Assert.AreEqual("attributeName", exception.ParamName);
        }
コード例 #15
0
        public void Constructor_WithValidArguments_PropertiesHaveExpectedAttributeValues()
        {
            // Setup
            var categoryTheme = new PointCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion(),
                                                       new PointStyle());

            // Call
            var properties = new PointCategoryThemeProperties(categoryTheme, string.Empty, new MapPointData("Name"));

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

            Assert.AreEqual(6, dynamicProperties.Count);
            const string styleCategory = "Stijl";

            PropertyDescriptor colorProperty = dynamicProperties[colorPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(colorProperty,
                                                                            styleCategory,
                                                                            "Kleur",
                                                                            "De kleur van de symbolen waarmee deze categorie wordt weergegeven.");

            PropertyDescriptor strokeColorProperty = dynamicProperties[strokeColorPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(strokeColorProperty,
                                                                            styleCategory,
                                                                            "Lijnkleur",
                                                                            "De kleur van de lijn van de symbolen waarmee deze categorie wordt weergegeven.");

            PropertyDescriptor strokeThicknessProperty = dynamicProperties[strokeThicknessPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(strokeThicknessProperty,
                                                                            styleCategory,
                                                                            "Lijndikte",
                                                                            "De dikte van de lijn van de symbolen waarmee deze categorie wordt weergegeven.");

            PropertyDescriptor sizeProperty = dynamicProperties[sizePropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(sizeProperty,
                                                                            styleCategory,
                                                                            "Grootte",
                                                                            "De grootte van de symbolen waarmee deze categorie wordt weergegeven.");

            PropertyDescriptor symbolProperty = dynamicProperties[symbolPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(symbolProperty,
                                                                            styleCategory,
                                                                            "Symbool",
                                                                            "Het symbool waarmee deze categorie wordt weergegeven.");
        }
コード例 #16
0
        public void Constructor_ExpectedValues()
        {
            // Setup
            ValueCriterion valueCriterion = ValueCriterionTestFactory.CreateValueCriterion();
            var            style          = new PointStyle();

            // Call
            var category = new PointCategoryTheme(valueCriterion, style);

            // Assert
            Assert.IsInstanceOf <CategoryTheme>(category);
            Assert.AreSame(valueCriterion, category.Criterion);
            Assert.AreSame(style, category.Style);
        }
コード例 #17
0
        public void ConvertLayerProperties_MapDataWithMapThemeAndExistingMetaData_SetsExpectedSymbology()
        {
            // Setup
            const string metadataAttributeName = "metaData";
            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();
            var defaultCategory = new PointCategory();
            var categoryTheme   = new PointCategory();
            var testConverter   = new TestFeatureBasedMapDataConverter
            {
                CreatedFeatureScheme         = scheme,
                CreatedDefaultCategory       = defaultCategory,
                CreatedCategoryThemeCategory = categoryTheme
            };

            var mapLayer = new TestFeatureLayer();

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

            // Assert
            IPointScheme symbology = mapLayer.Symbology;

            Assert.AreSame(scheme, symbology);
            CollectionAssert.AreEqual(new[]
            {
                defaultCategory,
                categoryTheme
            }, symbology.Categories);
        }
コード例 #18
0
        public void Constructor_StyleNullAndWithMapTheme_ThrowsArgumentNullException()
        {
            // Call
            TestDelegate call = () => new MapPointData("test data",
                                                       null,
                                                       new MapTheme <PointCategoryTheme>("attribute", new[]
            {
                new PointCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion(),
                                       new PointStyle())
            }));

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

            Assert.AreEqual("style", exception.ParamName);
        }
コード例 #19
0
        public void Constructor_ExpectedValues()
        {
            // Setup
            var categoryTheme = new PolygonCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion(),
                                                         new PolygonStyle());

            // Call
            var properties = new PolygonCategoryThemeProperties(categoryTheme, string.Empty, new MapPolygonData("Name"));

            // Assert
            Assert.IsInstanceOf <CategoryThemeProperties <PolygonCategoryTheme> >(properties);

            TestHelper.AssertTypeConverter <PolygonCategoryThemeProperties, ColorTypeConverter>(
                nameof(PolygonCategoryThemeProperties.FillColor));
            TestHelper.AssertTypeConverter <PolygonCategoryThemeProperties, ColorTypeConverter>(
                nameof(PolygonCategoryThemeProperties.StrokeColor));
        }
コード例 #20
0
        public void Constructor_ExpectedValues()
        {
            // Setup
            var categoryTheme = new LineCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion(),
                                                      new LineStyle());

            // Call
            var properties = new LineCategoryThemeProperties(categoryTheme, string.Empty, new MapLineData("Name"));

            // Assert
            Assert.IsInstanceOf <CategoryThemeProperties <LineCategoryTheme> >(properties);

            TestHelper.AssertTypeConverter <LineCategoryThemeProperties, ColorTypeConverter>(
                nameof(LineCategoryThemeProperties.Color));
            TestHelper.AssertTypeConverter <LineCategoryThemeProperties, EnumTypeConverter>(
                nameof(LineCategoryThemeProperties.DashStyle));
        }
コード例 #21
0
        public void SetProperties_IndividualProperties_UpdateDataAndNotifyObservers()
        {
            // Setup
            var random = new Random(21);

            var mocks    = new MockRepository();
            var observer = mocks.StrictMock <IObserver>();

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

            var mapData = new MapPointData("Name");

            mapData.Attach(observer);

            var categoryTheme = new PointCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion(),
                                                       new PointStyle());

            var properties = new PointCategoryThemeProperties(categoryTheme, string.Empty, mapData);

            Color color           = Color.FromKnownColor(random.NextEnumValue <KnownColor>());
            Color strokeColor     = Color.FromKnownColor(random.NextEnumValue <KnownColor>());
            int   strokeThickness = random.Next(1, 48);
            int   size            = random.Next(1, 48);
            var   symbol          = random.NextEnumValue <PointSymbol>();

            // Call
            properties.Color           = color;
            properties.StrokeColor     = strokeColor;
            properties.StrokeThickness = strokeThickness;
            properties.Size            = size;
            properties.Symbol          = symbol;

            // Assert
            PointStyle actualStyle = categoryTheme.Style;

            Assert.AreEqual(color, actualStyle.Color);
            Assert.AreEqual(strokeColor, actualStyle.StrokeColor);
            Assert.AreEqual(strokeThickness, actualStyle.StrokeThickness);
            Assert.AreEqual(size, actualStyle.Size);
            Assert.AreEqual(symbol, actualStyle.Symbol);

            mocks.VerifyAll();
        }
コード例 #22
0
        public void ConvertLayerProperties_MapDataWithMapTheme_UsesCorrectInputsForConversion()
        {
            // Setup
            const string metadataAttributeName = "metaData";
            var          theme = new MapTheme <TestCategoryTheme>(metadataAttributeName, new[]
            {
                new TestCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion()),
                new TestCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion())
            });
            var mapData = new TestFeatureBasedMapData("test data", theme)
            {
                Features = new[]
                {
                    new MapFeature(Enumerable.Empty <MapGeometry>())
                    {
                        MetaData =
                        {
                            {
                                metadataAttributeName, new object()
                            }
                        }
                    }
                }
            };

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

            var mapLayer = new TestFeatureLayer();

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

            // Assert
            CollectionAssert.AreEqual(new[]
            {
                mapData
            }, testConverter.DefaultCategoryInputs);
            CollectionAssert.AreEqual(theme.CategoryThemes, testConverter.CategoryThemeInputs);
        }
コード例 #23
0
        public void Constructor_Always_ReturnExpectedPropertyValues()
        {
            // Setup
            const string   attributeName  = "AttributeName";
            ValueCriterion valueCriterion = ValueCriterionTestFactory.CreateValueCriterion();
            var            categoryTheme  = new PolygonCategoryTheme(valueCriterion, new PolygonStyle());

            var properties = new PolygonCategoryThemeProperties(categoryTheme, attributeName, new MapPolygonData("Name"));

            // Assert
            Assert.AreSame(categoryTheme, properties.Data);

            Assert.AreEqual(categoryTheme.Style.FillColor, properties.FillColor);
            Assert.AreEqual(categoryTheme.Style.StrokeColor, properties.StrokeColor);
            Assert.AreEqual(categoryTheme.Style.StrokeThickness, properties.StrokeThickness);

            ValueCriterionTestHelper.AssertValueCriterionFormatExpression(attributeName,
                                                                          valueCriterion,
                                                                          properties.Criterion);
        }
コード例 #24
0
        public void Constructor_Always_ReturnExpectedPropertyValues()
        {
            // Setup
            const string   attributeName  = "AttributeName";
            ValueCriterion valueCriterion = ValueCriterionTestFactory.CreateValueCriterion();
            var            categoryTheme  = new LineCategoryTheme(valueCriterion, new LineStyle());

            var properties = new LineCategoryThemeProperties(categoryTheme, attributeName, new MapLineData("Name"));

            // Assert
            Assert.AreSame(categoryTheme, properties.Data);

            Assert.AreEqual(categoryTheme.Style.Color, properties.Color);
            Assert.AreEqual(categoryTheme.Style.Width, properties.Width);
            Assert.AreEqual(categoryTheme.Style.DashStyle, properties.DashStyle);

            ValueCriterionTestHelper.AssertValueCriterionFormatExpression(attributeName,
                                                                          valueCriterion,
                                                                          properties.Criterion);
        }
コード例 #25
0
        public void Constructor_Always_PropertiesHaveExpectedAttributesValues()
        {
            // Setup
            var theme = new TestCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion());

            // Call
            var properties = new TestCategoryThemeProperties(string.Empty, theme, new TestFeatureBasedMapData());

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

            Assert.AreEqual(1, dynamicProperties.Count);

            const string       themeCategory     = "Stijl";
            PropertyDescriptor criterionProperty = dynamicProperties[criterionPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(criterionProperty,
                                                                            themeCategory,
                                                                            "Criterium",
                                                                            "Het criterium van deze categorie.",
                                                                            true);
        }
コード例 #26
0
        public void SetProperties_IndividualProperties_UpdateDataAndNotifyObservers()
        {
            // Setup
            var random = new Random(21);

            var mocks    = new MockRepository();
            var observer = mocks.StrictMock <IObserver>();

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

            var mapData = new MapLineData("Name");

            mapData.Attach(observer);

            var categoryTheme = new LineCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion(),
                                                      new LineStyle());

            var properties = new LineCategoryThemeProperties(categoryTheme, string.Empty, mapData);

            int   width     = random.Next(1, 48);
            Color color     = Color.FromKnownColor(random.NextEnumValue <KnownColor>());
            var   dashStyle = random.NextEnumValue <LineDashStyle>();

            // Call
            properties.Width     = width;
            properties.Color     = color;
            properties.DashStyle = dashStyle;

            // Assert
            LineStyle actualStyle = categoryTheme.Style;

            Assert.AreEqual(width, actualStyle.Width);
            Assert.AreEqual(color, actualStyle.Color);
            Assert.AreEqual(dashStyle, actualStyle.DashStyle);

            mocks.VerifyAll();
        }
コード例 #27
0
        public void Constructor_WithValidArguments_PropertiesHaveExpectedAttributeValues()
        {
            // Setup
            var categoryTheme = new LineCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion(),
                                                      new LineStyle());

            // Call
            var properties = new LineCategoryThemeProperties(categoryTheme, string.Empty, new MapLineData("Name"));

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

            Assert.AreEqual(4, dynamicProperties.Count);
            const string styleCategory = "Stijl";

            PropertyDescriptor colorProperty = dynamicProperties[colorPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(colorProperty,
                                                                            styleCategory,
                                                                            "Kleur",
                                                                            "De kleur van de lijnen waarmee deze categorie wordt weergegeven.");

            PropertyDescriptor lineWidthProperty = dynamicProperties[lineWidthPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(lineWidthProperty,
                                                                            styleCategory,
                                                                            "Lijndikte",
                                                                            "De dikte van de lijnen waarmee deze categorie wordt weergegeven.");

            PropertyDescriptor lineStyleProperty = dynamicProperties[lineStylePropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(lineStyleProperty,
                                                                            styleCategory,
                                                                            "Lijnstijl",
                                                                            "De stijl van de lijnen waarmee deze categorie wordt weergegeven.");
        }
コード例 #28
0
        public void GivenMapLayerWithScheme_WhenConvertingLayerFeatures_ThenClearsAppliedSchemeAndAppliesDefaultCategory()
        {
            // Given
            const string metadataAttribute = "Meta";

            var mocks       = new MockRepository();
            var categoryOne = mocks.Stub <IPolygonCategory>();
            var categoryTwo = mocks.Stub <IPolygonCategory>();

            mocks.ReplayAll();

            var mapPolygonLayer = new MapPolygonLayer
            {
                Symbology = new PolygonScheme
                {
                    Categories =
                    {
                        categoryOne,
                        categoryTwo
                    }
                }
            };

            var converter = new MapPolygonDataConverter();

            var random       = new Random(21);
            var polygonStyle = new PolygonStyle
            {
                FillColor       = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                StrokeColor     = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                StrokeThickness = random.Next(1, 48)
            };
            var theme = new MapTheme <PolygonCategoryTheme>(metadataAttribute, new[]
            {
                new PolygonCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion(),
                                         new PolygonStyle
                {
                    FillColor       = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                    StrokeColor     = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                    StrokeThickness = random.Next(1, 48)
                })
            });
            var mapPolygonData = new MapPolygonData("test", polygonStyle, theme)
            {
                Features = new[]
                {
                    CreateMapFeatureWithMetaData(metadataAttribute)
                }
            };

            // When
            converter.ConvertLayerFeatures(mapPolygonData, mapPolygonLayer);

            // Then
            PolygonCategoryCollection categoryCollection = mapPolygonLayer.Symbology.Categories;

            Assert.AreEqual(1, categoryCollection.Count);

            PolygonSymbolizer expectedSymbolizer = CreateExpectedSymbolizer(polygonStyle);

            AssertAreEqual(expectedSymbolizer, categoryCollection.Single().Symbolizer);

            mocks.VerifyAll();
        }
コード例 #29
0
 public TestCategoryTheme() : base(ValueCriterionTestFactory.CreateValueCriterion())
 {
 }
コード例 #30
0
        public void GivenMapLayerWithScheme_WhenConvertingLayerFeatures_ThenClearsAppliedSchemeAndAppliesDefaultCategory()
        {
            // Given
            var mocks       = new MockRepository();
            var categoryOne = mocks.Stub <ILineCategory>();
            var categoryTwo = mocks.Stub <ILineCategory>();

            mocks.ReplayAll();

            var mapLineLayer = new MapLineLayer
            {
                Symbology = new LineScheme
                {
                    Categories =
                    {
                        categoryOne,
                        categoryTwo
                    }
                }
            };

            var converter = new MapLineDataConverter();

            var random    = new Random(21);
            var lineStyle = new LineStyle
            {
                Color     = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                Width     = random.Next(1, 48),
                DashStyle = random.NextEnum <LineDashStyle>()
            };
            var theme = new MapTheme <LineCategoryTheme>("Meta", new[]
            {
                new LineCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion(),
                                      new LineStyle
                {
                    Color     = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                    Width     = random.Next(1, 48),
                    DashStyle = random.NextEnum <LineDashStyle>()
                })
            });

            var mapLineData = new MapLineData("test", lineStyle, theme)
            {
                Features = new[]
                {
                    CreateMapFeatureWithMetaData("Meta")
                }
            };

            // When
            converter.ConvertLayerFeatures(mapLineData, mapLineLayer);

            // Then
            LineCategoryCollection categoryCollection = mapLineLayer.Symbology.Categories;

            Assert.AreEqual(1, categoryCollection.Count);

            ILineSymbolizer expectedSymbolizer = CreateExpectedSymbolizer(lineStyle);

            AssertAreEqual(expectedSymbolizer, categoryCollection.Single().Symbolizer);

            mocks.VerifyAll();
        }