Пример #1
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();
        }
Пример #2
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);
        }
        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));
        }
        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);
        }
        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();
        }
        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.");
        }