public void DynamicVisibleValidationMethod_MapPolygonDataWithMapTheme_ReturnsExpectedValuesForRelevantProperties(bool hasMapTheme) { // Setup MapPolygonData mapPolygonData = hasMapTheme ? new MapPolygonData("Test", new PolygonStyle(), CreateMapTheme()) : new MapPolygonData("Test"); var properties = new MapPolygonDataProperties(mapPolygonData, Enumerable.Empty <MapDataCollection>()); // Call bool isCategoryThemesVisible = properties.DynamicVisibleValidationMethod( nameof(MapPolygonDataProperties.CategoryThemes)); bool isFillColorVisible = properties.DynamicVisibleValidationMethod( nameof(MapPolygonDataProperties.FillColor)); bool isStrokeColorVisible = properties.DynamicVisibleValidationMethod( nameof(MapPolygonDataProperties.StrokeColor)); bool isStrokeThicknessVisible = properties.DynamicVisibleValidationMethod( nameof(MapPolygonDataProperties.StrokeThickness)); // Assert Assert.AreEqual(hasMapTheme, isCategoryThemesVisible); Assert.AreNotEqual(hasMapTheme, isFillColorVisible); Assert.AreNotEqual(hasMapTheme, isStrokeColorVisible); Assert.AreNotEqual(hasMapTheme, isStrokeThicknessVisible); }
public void DynamicReadOnlyValidator_MapHasMetaData_ReturnsExpectedValuesForRelevantProperties(bool hasMetaData) { // Setup var feature = new MapFeature(Enumerable.Empty <MapGeometry>()); if (hasMetaData) { feature.MetaData["key"] = "value"; } var mapData = new MapPolygonData("Test") { Features = new[] { feature } }; var properties = new MapPolygonDataProperties(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); }
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(); }
public void Constructor_WithMapTheme_ReturnCorrectPropertyValues() { // Setup const string attributeName = "Attribute"; var categoryTheme = new PolygonCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion(), new PolygonStyle()); var mapPolygonData = new MapPolygonData("Test", new PolygonStyle(), new MapTheme <PolygonCategoryTheme>(attributeName, new[] { categoryTheme })); // Call var properties = new MapPolygonDataProperties(mapPolygonData, Enumerable.Empty <MapDataCollection>()); // Assert Assert.AreEqual("Categorie", properties.StyleType); Assert.AreEqual(mapPolygonData.ShowLabels, properties.ShowLabels); Assert.IsEmpty(properties.SelectedMetaDataAttribute.MetaDataAttribute); Assert.AreEqual(mapPolygonData.MetaData, properties.GetAvailableMetaDataAttributes()); Assert.AreEqual(1, properties.CategoryThemes.Length); PolygonCategoryThemeProperties pointCategoryThemeProperties = properties.CategoryThemes.First(); Assert.AreSame(categoryTheme, pointCategoryThemeProperties.Data); ValueCriterionTestHelper.AssertValueCriterionFormatExpression(attributeName, categoryTheme.Criterion, pointCategoryThemeProperties.Criterion); }
public void Constructor_WithoutMapTheme_ReturnCorrectPropertyValues() { // Setup Color fillColor = Color.Aqua; Color strokeColor = Color.Bisque; const int strokeThickness = 4; var mapPolygonData = new MapPolygonData("Test", new PolygonStyle { FillColor = fillColor, StrokeColor = strokeColor, StrokeThickness = strokeThickness }); // Call var properties = new MapPolygonDataProperties(mapPolygonData, Enumerable.Empty <MapDataCollection>()); // Assert Assert.AreEqual("Enkel symbool", properties.StyleType); Assert.AreEqual(mapPolygonData.ShowLabels, properties.ShowLabels); Assert.IsEmpty(properties.SelectedMetaDataAttribute.MetaDataAttribute); Assert.AreEqual(mapPolygonData.MetaData, properties.GetAvailableMetaDataAttributes()); Assert.AreEqual(fillColor, properties.FillColor); Assert.AreEqual(strokeColor, properties.StrokeColor); Assert.AreEqual(strokeThickness, properties.StrokeThickness); CollectionAssert.IsEmpty(properties.CategoryThemes); }
public void Constructor_MapPolygonDataWithMapTheme_PropertiesHaveExpectedAttributesValues() { // Setup var mapPolygonData = new MapPolygonData("Test", new PolygonStyle(), CreateMapTheme()) { Features = new[] { new MapFeature(Enumerable.Empty <MapGeometry>()) }, ShowLabels = true }; // Call var properties = new MapPolygonDataProperties(mapPolygonData, 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); }
public void DynamicVisibleValidationMethod_ShowLabels_ReturnsExpectedValuesForRelevantProperties(bool showLabels) { // Setup var mapPolygonData = new MapPolygonData("Test") { ShowLabels = showLabels }; var properties = new MapPolygonDataProperties(mapPolygonData, Enumerable.Empty <MapDataCollection>()); // Call bool isSelectedMetaDataAttributeVisible = properties.DynamicVisibleValidationMethod( nameof(MapPolygonDataProperties.SelectedMetaDataAttribute)); // Assert Assert.AreEqual(showLabels, isSelectedMetaDataAttributeVisible); }
public void Constructor_MapPolygonDataWithoutMapTheme_PropertiesHaveExpectedAttributesValues() { // Setup var mapPolygonData = new MapPolygonData("Test") { Features = new[] { new MapFeature(Enumerable.Empty <MapGeometry>()) }, ShowLabels = true }; // Call var properties = new MapPolygonDataProperties(mapPolygonData, Enumerable.Empty <MapDataCollection>()); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); Assert.AreEqual(9, dynamicProperties.Count); const string styleCategory = "Stijl"; PropertyDescriptor colorProperty = dynamicProperties[fillColorPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(colorProperty, styleCategory, "Kleur", "De kleur van de vlakken waarmee deze kaartlaag wordt weergegeven."); PropertyDescriptor strokeColorProperty = dynamicProperties[strokeColorPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(strokeColorProperty, styleCategory, "Lijnkleur", "De kleur van de lijn van de vlakken waarmee deze kaartlaag wordt weergegeven."); PropertyDescriptor styleProperty = dynamicProperties[strokeThicknessPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(styleProperty, styleCategory, "Lijndikte", "De dikte van de lijn van de vlakken waarmee deze kaartlaag wordt weergegeven."); }
public void DynamicVisibleValidationMethod_AnyOtherProperty_ReturnsTrue() { // Setup var mapPolygonData = new MapPolygonData("Test", new PolygonStyle(), CreateMapTheme()) { Features = new[] { new MapFeature(Enumerable.Empty <MapGeometry>()) }, ShowLabels = true }; var properties = new MapPolygonDataProperties(mapPolygonData, Enumerable.Empty <MapDataCollection>()); // Call bool isOtherPropertyVisible = properties.DynamicVisibleValidationMethod(string.Empty); // Assert Assert.IsFalse(isOtherPropertyVisible); }
public void Constructor_ExpectedValues() { // Setup var data = new MapPolygonData("test"); // Call var properties = new MapPolygonDataProperties(data, Enumerable.Empty <MapDataCollection>()); // Assert Assert.IsInstanceOf <FeatureBasedMapDataProperties <MapPolygonData> >(properties); Assert.AreSame(data, properties.Data); Assert.AreEqual("Polygonen", properties.Type); TestHelper.AssertTypeConverter <MapPolygonDataProperties, ColorTypeConverter>( nameof(MapPolygonDataProperties.FillColor)); TestHelper.AssertTypeConverter <MapPolygonDataProperties, ColorTypeConverter>( nameof(MapPolygonDataProperties.StrokeColor)); TestHelper.AssertTypeConverter <MapPolygonDataProperties, ExpandableArrayConverter>( nameof(MapPolygonDataProperties.CategoryThemes)); }
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(); }