Exemple #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();
        }
        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();
        }
Exemple #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 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();
        }