示例#1
0
        public void GivenMapPolygonDataPropertiesWithMapTheme_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 mapPolygonData = new MapPolygonData("Test",
                                                    new PolygonStyle(),
                                                    new MapTheme <PolygonCategoryTheme>("Attribute", new[]
            {
                new PolygonCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion(), new PolygonStyle())
            }));

            mapPolygonData.Attach(observer);

            var properties = new MapPolygonDataProperties(mapPolygonData, Enumerable.Empty <MapDataCollection>());

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

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

            // Then
            mocks.VerifyAll();
        }
示例#2
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 MapPolygonData("Name");

            mapData.Attach(observer);

            var categoryTheme = new PolygonCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion(),
                                                         new PolygonStyle());

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

            Color fillColor       = Color.FromKnownColor(random.NextEnumValue <KnownColor>());
            Color strokeColor     = Color.FromKnownColor(random.NextEnumValue <KnownColor>());
            int   strokeThickness = random.Next(1, 48);

            // Call
            properties.FillColor       = fillColor;
            properties.StrokeColor     = strokeColor;
            properties.StrokeThickness = strokeThickness;

            // Assert
            PolygonStyle actualStyle = categoryTheme.Style;

            Assert.AreEqual(fillColor, actualStyle.FillColor);
            Assert.AreEqual(strokeColor, actualStyle.StrokeColor);
            Assert.AreEqual(strokeThickness, actualStyle.StrokeThickness);

            mocks.VerifyAll();
        }
示例#3
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 mapPolygonData = new MapPolygonData("Test", new PolygonStyle
            {
                FillColor       = Color.AliceBlue,
                StrokeColor     = Color.Blue,
                StrokeThickness = 3
            });

            mapPolygonData.Attach(observer);

            var properties = new MapPolygonDataProperties(mapPolygonData, Enumerable.Empty <MapDataCollection>());

            Color     newFillColor       = Color.Blue;
            Color     newStrokeColor     = Color.Red;
            const int newStrokeThickness = 6;

            // Call
            properties.FillColor       = newFillColor;
            properties.StrokeColor     = newStrokeColor;
            properties.StrokeThickness = newStrokeThickness;

            // Assert
            Assert.AreEqual(newFillColor, mapPolygonData.Style.FillColor);
            Assert.AreEqual(newStrokeColor, mapPolygonData.Style.StrokeColor);
            Assert.AreEqual(newStrokeThickness, mapPolygonData.Style.StrokeThickness);
            mocks.VerifyAll();
        }