Example #1
0
        public void DynamicVisibleValidationMethod_MapLineDataWithMapTheme_ReturnsExpectedValuesForRelevantProperties(bool hasMapTheme)
        {
            // Setup
            MapLineData mapLineData = hasMapTheme
                                          ? new MapLineData("Test", new LineStyle(), CreateMapTheme())
                                          : new MapLineData("Test");

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

            // Call
            bool isCategoryThemesVisible = properties.DynamicVisibleValidationMethod(
                nameof(MapLineDataProperties.CategoryThemes));
            bool isLineColorStyleVisible = properties.DynamicVisibleValidationMethod(
                nameof(MapLineDataProperties.Color));
            bool isLineWidthVisible = properties.DynamicVisibleValidationMethod(
                nameof(MapLineDataProperties.Color));
            bool isLineDashStyleVisible = properties.DynamicVisibleValidationMethod(
                nameof(MapLineDataProperties.Color));

            // Assert
            Assert.AreEqual(hasMapTheme, isCategoryThemesVisible);
            Assert.AreNotEqual(hasMapTheme, isLineColorStyleVisible);
            Assert.AreNotEqual(hasMapTheme, isLineWidthVisible);
            Assert.AreNotEqual(hasMapTheme, isLineDashStyleVisible);
        }
Example #2
0
        public void DynamicReadOnlyValidator_MapHasMetaData_ReturnsExpectedValuesForRelevantProperties(bool hasMetaData)
        {
            // Setup
            var feature = new MapFeature(Enumerable.Empty <MapGeometry>());

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

            var mapData = new MapLineData("Test")
            {
                Features = new[]
                {
                    feature
                }
            };

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

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

            // Assert
            Assert.AreNotEqual(hasMetaData, isShowLabelReadOnly);
            Assert.AreNotEqual(hasMetaData, isSelectedMetaDataReadOnly);
        }
Example #3
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();
        }
Example #4
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);
        }
Example #5
0
        public void Constructor_WithoutMapTheme_ReturnCorrectPropertyValues()
        {
            // Setup
            Color               color     = Color.Aqua;
            const int           width     = 4;
            const LineDashStyle dashStyle = LineDashStyle.DashDot;

            var mapLineData = new MapLineData("Test", new LineStyle
            {
                Color     = color,
                Width     = width,
                DashStyle = dashStyle
            });

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

            // Assert
            Assert.AreEqual("Enkel symbool", properties.StyleType);

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

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

            CollectionAssert.IsEmpty(properties.CategoryThemes);
        }
Example #6
0
        public void Constructor_MapLineDataWithMapTheme_PropertiesHaveExpectedAttributesValues()
        {
            // Setup
            var mapLineData = new MapLineData("Test", new LineStyle(), CreateMapTheme())
            {
                ShowLabels = true
            };

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

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

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

            PropertyDescriptor categoryThemesProperty = dynamicProperties[categoryThemesPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(categoryThemesProperty,
                                                                            styleCategory,
                                                                            "Categorieën",
                                                                            string.Empty,
                                                                            true);
        }
Example #7
0
        public void DynamicVisibleValidationMethod_ShowLabels_ReturnsExpectedValuesForRelevantProperties(bool showLabels)
        {
            // Setup
            var mapLineData = new MapLineData("Test")
            {
                ShowLabels = showLabels
            };

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

            // Call
            bool isSelectedMetaDataAttributeVisible = properties.DynamicVisibleValidationMethod(
                nameof(MapLineDataProperties.SelectedMetaDataAttribute));

            // Assert
            Assert.AreEqual(showLabels, isSelectedMetaDataAttributeVisible);
        }
Example #8
0
        public void DynamicVisibleValidationMethod_AnyOtherProperty_ReturnsTrue()
        {
            // Setup
            var mapLineData = new MapLineData("Test", new LineStyle(), CreateMapTheme())
            {
                Features = new[]
                {
                    new MapFeature(Enumerable.Empty <MapGeometry>())
                },
                ShowLabels = true
            };

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

            // Call
            bool isOtherPropertyVisible = properties.DynamicVisibleValidationMethod(string.Empty);

            // Assert
            Assert.IsFalse(isOtherPropertyVisible);
        }
Example #9
0
        public void Constructor_ExpectedValues()
        {
            // Setup
            var data = new MapLineData("test");

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

            // Assert
            Assert.IsInstanceOf <FeatureBasedMapDataProperties <MapLineData> >(properties);
            Assert.AreSame(data, properties.Data);
            Assert.AreEqual("Lijnen", properties.Type);

            TestHelper.AssertTypeConverter <MapLineDataProperties, ColorTypeConverter>(
                nameof(MapLineDataProperties.Color));
            TestHelper.AssertTypeConverter <MapLineDataProperties, EnumTypeConverter>(
                nameof(MapLineDataProperties.DashStyle));

            TestHelper.AssertTypeConverter <MapLineDataProperties, ExpandableArrayConverter>(
                nameof(MapLineDataProperties.CategoryThemes));
        }
Example #10
0
        public void Constructor_MapLineDataWithoutMapTheme_PropertiesHaveExpectedAttributesValues()
        {
            // Setup
            var mapLineData = new MapLineData("Test")
            {
                ShowLabels = true
            };

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

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

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

            PropertyDescriptor colorProperty = dynamicProperties[colorPropertyIndex];

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

            PropertyDescriptor widthProperty = dynamicProperties[widthPropertyIndex];

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

            PropertyDescriptor styleProperty = dynamicProperties[stylePropertyIndex];

            Assert.IsInstanceOf <EnumTypeConverter>(styleProperty.Converter);
            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(styleProperty,
                                                                            styleCategory,
                                                                            "Lijnstijl",
                                                                            "De stijl van de lijnen waarmee deze kaartlaag wordt weergegeven.");
        }
Example #11
0
        public void SetProperties_IndividualProperties_UpdateDataAndNotifyObservers()
        {
            // Setup
            const int numberOfChangedProperties = 3;
            var       mocks    = new MockRepository();
            var       observer = mocks.StrictMock <IObserver>();

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

            var mapLineData = new MapLineData("Test", new LineStyle
            {
                Color     = Color.AliceBlue,
                Width     = 3,
                DashStyle = LineDashStyle.Solid
            });

            mapLineData.Attach(observer);

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

            Color               newColor     = Color.Blue;
            const int           newWidth     = 6;
            const LineDashStyle newDashStyle = LineDashStyle.DashDot;

            // Call
            properties.Color     = newColor;
            properties.Width     = newWidth;
            properties.DashStyle = newDashStyle;

            // Assert
            Assert.AreEqual(newColor, mapLineData.Style.Color);
            Assert.AreEqual(newWidth, mapLineData.Style.Width);
            Assert.AreEqual(newDashStyle, mapLineData.Style.DashStyle);
            mocks.VerifyAll();
        }