public void GivenMapPointDataPropertiesWithMapTheme_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 mapPointData = new MapPointData("Test",
                                                new PointStyle(),
                                                new MapTheme <PointCategoryTheme>("Attribute", new[]
            {
                new PointCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion(), new PointStyle())
            }));

            mapPointData.Attach(observer);

            var properties = new MapPointDataProperties(mapPointData, Enumerable.Empty <MapDataCollection>());

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

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

            // Then
            mocks.VerifyAll();
        }
        public void SetProperties_IndividualProperties_UpdateDataAndNotifyObservers()
        {
            // Setup
            const int numberOfChangedProperties = 5;
            var       mocks    = new MockRepository();
            var       observer = mocks.StrictMock <IObserver>();

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

            Color color        = Color.AliceBlue;
            var   mapPointData = new MapPointData("Test", new PointStyle
            {
                Color           = color,
                Size            = 3,
                Symbol          = PointSymbol.Circle,
                StrokeColor     = color,
                StrokeThickness = 1
            });

            mapPointData.Attach(observer);

            var properties = new MapPointDataProperties(mapPointData, Enumerable.Empty <MapDataCollection>());

            Color             newColor           = Color.Blue;
            Color             newStrokeColor     = Color.Aquamarine;
            const int         newSize            = 6;
            const PointSymbol newSymbol          = PointSymbol.Diamond;
            const int         newStrokeThickness = 4;

            // Call
            properties.Color           = newColor;
            properties.Size            = newSize;
            properties.Symbol          = newSymbol;
            properties.StrokeColor     = newStrokeColor;
            properties.StrokeThickness = newStrokeThickness;

            // Assert
            Assert.AreEqual(newColor, mapPointData.Style.Color);
            Assert.AreEqual(newSize, mapPointData.Style.Size);
            Assert.AreEqual(newSymbol, mapPointData.Style.Symbol);
            Assert.AreEqual(newStrokeColor, mapPointData.Style.StrokeColor);
            Assert.AreEqual(newStrokeThickness, mapPointData.Style.StrokeThickness);
            mocks.VerifyAll();
        }
Пример #3
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();
        }