示例#1
0
        public void Constructor_WithStyleAndMapTheme_ExpectedValues()
        {
            // Setup
            const string name  = "test data";
            var          style = new LineStyle
            {
                Color     = Color.Red,
                Width     = 5,
                DashStyle = LineDashStyle.Dash
            };

            var mapTheme = new MapTheme <LineCategoryTheme>("attribute", new[]
            {
                new LineCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion(),
                                      new LineStyle())
            });

            // Call
            var data = new MapLineData(name, style, mapTheme);

            // Assert
            Assert.AreEqual(name, data.Name);
            CollectionAssert.IsEmpty(data.Features);
            Assert.AreSame(style, data.Style);
            Assert.AreSame(mapTheme, data.Theme);
        }
示例#2
0
        public void Constructor_WithStyleAndMapTheme_ExpectedValues()
        {
            // Setup
            const string name  = "test data";
            var          style = new PolygonStyle
            {
                FillColor       = Color.Aqua,
                StrokeColor     = Color.DarkGoldenrod,
                StrokeThickness = 3
            };

            var mapTheme = new MapTheme <PolygonCategoryTheme>("attribute", new[]
            {
                new PolygonCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion(),
                                         new PolygonStyle())
            });

            // Call
            var data = new MapPolygonData(name, style, mapTheme);

            // Assert
            Assert.AreEqual(name, data.Name);
            CollectionAssert.IsEmpty(data.Features);
            Assert.AreSame(style, data.Style);
            Assert.AreSame(mapTheme, data.Theme);
        }
示例#3
0
  public void Init(Vector2 _sizeViewport, Level _level) {
    sizeViewport = _sizeViewport;
    level = _level;

    containerMap = new GameObject("Map").transform;
    containerMap.SetParent( transform );

    players = new List<Character>();
    Character c = new Character(10, 0, 49, 0, 0);
    c.name = "Fighter";
    c.actions.Add( new Action("attack") );

    c.health = c.maxHealth = 20;
    c.attack = 13;
    c.defense = 6;
    c.experience = 0;
    c.gold = 0;

    players.Add( c );

    theme = themePrefabs[0].GetComponent<MapTheme>();

    currentLevel = 0;
    NewLevel();
  }
示例#4
0
    public static void RegisterMap(string mapName, byte index, MapTheme mapTheme = MapTheme.Arena)
    {
        string code  = "00" + mapTheme.GetHashCode().ToString() + index.ToString();
        byte   bCode = byte.Parse(code);

        stringMapMapping.Add(mapName, bCode);
    }
示例#5
0
        public void Constructor_WithStyleAndMapTheme_ExpectedValues()
        {
            // Setup
            const string name  = "test data";
            Color        color = Color.Aqua;
            var          style = new PointStyle
            {
                Color           = color,
                Size            = 3,
                Symbol          = PointSymbol.Circle,
                StrokeColor     = color,
                StrokeThickness = 1
            };

            var mapTheme = new MapTheme <PointCategoryTheme>("attribute", new[]
            {
                new PointCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion(),
                                       new PointStyle())
            });

            // Call
            var data = new MapPointData(name, style, mapTheme);

            // Assert
            Assert.AreEqual(name, data.Name);
            CollectionAssert.IsEmpty(data.Features);
            Assert.AreSame(style, data.Style);
            Assert.AreSame(mapTheme, data.Theme);
        }
示例#6
0
        public void CreateFailureMechanismSectionAssemblyGroupMapTheme_ReturnsMapTheme()
        {
            // Call
            MapTheme <LineCategoryTheme> mapTheme = MapThemeFactory.CreateFailureMechanismSectionAssemblyGroupMapTheme();

            // Assert
            MapThemeTestHelper.AssertFailureMechanismSectionAssemblyGroupMapTheme(mapTheme);
        }
示例#7
0
 public MapData(float timeOfDay, MapType mapType, MapLocation mapLocation, MapTheme mapTheme, MapWeather mapWeather)
 {
     this.timeOfDay   = timeOfDay;
     this.mapType     = mapType;
     this.mapLocation = mapLocation;
     this.mapTheme    = mapTheme;
     this.mapWeather  = mapWeather;
 }
示例#8
0
 public MapData()
 {
     timeOfDay   = 0f;
     mapType     = MapType.None;
     mapLocation = MapLocation.None;
     mapTheme    = MapTheme.None;
     mapWeather  = MapWeather.None;
 }
示例#9
0
 public MapData(MapData mapData)
 {
     timeOfDay   = mapData.timeOfDay;
     mapType     = mapData.mapType;
     mapLocation = mapData.mapLocation;
     mapTheme    = mapData.mapTheme;
     mapWeather  = mapData.mapWeather;
 }
        public void GivenLayerWithConvertedProperties_WhenConvertingLayerFeatures_ThenOnlyDefaultCategoryAdded()
        {
            // Given
            var mocks           = new MockRepository();
            var defaultCategory = mocks.Stub <IPointCategory>();
            var categoryOne     = mocks.Stub <IPointCategory>();
            var categoryTwo     = mocks.Stub <IPointCategory>();

            mocks.ReplayAll();

            const string metadataAttributeName = "Meta";
            var          theme = new MapTheme <TestCategoryTheme>(metadataAttributeName, new[]
            {
                new TestCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion())
            });
            var mapData = new TestFeatureBasedMapData("test data", theme)
            {
                Features = new[]
                {
                    new MapFeature(Enumerable.Empty <MapGeometry>())
                    {
                        MetaData =
                        {
                            {
                                metadataAttributeName, new object()
                            }
                        }
                    }
                }
            };

            var scheme = new PointScheme();

            scheme.Categories.Clear();
            scheme.Categories.Add(categoryOne);
            scheme.Categories.Add(categoryTwo);

            var mapLayer = new TestFeatureLayer
            {
                Symbology = scheme
            };

            var testConverter = new TestFeatureBasedMapDataConverter
            {
                CreatedDefaultCategory = defaultCategory
            };

            // Precondition
            Assert.AreEqual(2, mapLayer.Symbology.Categories.Count);

            // When
            mapData.Features = Enumerable.Empty <MapFeature>();
            testConverter.ConvertLayerFeatures(mapData, mapLayer);

            // Then
            Assert.AreSame(defaultCategory, mapLayer.Symbology.Categories.Single());
        }
示例#11
0
        /// <summary>
        /// Creates a new instance of <see cref="MapPolygonData"/>.
        /// </summary>
        /// <param name="name">The name of the <see cref="MapLineData"/>.</param>
        /// <param name="style">The default style of the data that is not categorized by the categories
        /// defined in <paramref name="mapTheme"/>.</param>
        /// <param name="mapTheme">The map theme belong to the data.</param>
        /// <exception cref="ArgumentException">Thrown when <paramref name="name"/> is
        /// <c>null</c> or only whitespace.</exception>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="style"/>
        /// is <c>null</c>.</exception>
        public MapPolygonData(string name, PolygonStyle style, MapTheme <PolygonCategoryTheme> mapTheme) : base(name, mapTheme)
        {
            if (style == null)
            {
                throw new ArgumentNullException(nameof(style));
            }

            Style = style;
        }
示例#12
0
        /// <summary>
        /// Creates a new instance of <see cref="MapLineData"/>.
        /// </summary>
        /// <param name="name">The name of the <see cref="MapLineData"/>.</param>
        /// <param name="style">The default style of the data that is not categorized by the categories
        /// defined in <paramref name="mapTheme"/>.</param>
        /// <param name="mapTheme">The map theme belong to the data.</param>
        /// <exception cref="ArgumentException">Thrown when <paramref name="name"/> is
        /// <c>null</c> or only whitespace.</exception>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="style"/>
        /// is <c>null</c>.</exception>
        public MapLineData(string name, LineStyle style, MapTheme <LineCategoryTheme> mapTheme) : base(name, mapTheme)
        {
            if (style == null)
            {
                throw new ArgumentNullException(nameof(style));
            }

            Style = style;
        }
示例#13
0
        public static MapData Generate()
        {
            float       timeOfDay   = Random.Range(0f, 1f);
            MapType     mapType     = (MapType)Random.Range(0, (int)MapType.Number);
            MapLocation mapLocation = (MapLocation)Random.Range(0, (int)MapLocation.Number);
            MapTheme    mapTheme    = (MapTheme)Random.Range(0, (int)MapTheme.Number);
            MapWeather  mapWeather  = (MapWeather)Random.Range(0, (int)MapWeather.Number);

            MapData mapData = new MapData(timeOfDay, mapType, mapLocation, mapTheme, mapWeather);

            return(mapData);
        }
        public void ConvertLayerProperties_MapPointDataWithThemeAndMetaDataNameNotInFeatures_OnlyAddsDefaultCategory()
        {
            // Setup
            const string metadataAttribute = "Meta";
            var          random            = new Random(21);
            var          theme             = new MapTheme <PointCategoryTheme>("Other Meta", new[]
            {
                new PointCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion(),
                                       new PointStyle
                {
                    Color           = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                    Size            = random.Next(1, 48),
                    Symbol          = random.NextEnum <PointSymbol>(),
                    StrokeColor     = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                    StrokeThickness = random.Next(1, 48)
                })
            });

            var pointStyle = new PointStyle
            {
                Color           = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                Size            = random.Next(1, 48),
                Symbol          = random.NextEnum <PointSymbol>(),
                StrokeColor     = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                StrokeThickness = random.Next(1, 48)
            };
            var mapPointData = new MapPointData("test", pointStyle, theme)
            {
                Features = new[]
                {
                    CreateMapFeatureWithMetaData(metadataAttribute)
                }
            };

            var mapPointLayer = new MapPointLayer();

            var converter = new MapPointDataConverter();

            // Call
            converter.ConvertLayerProperties(mapPointData, mapPointLayer);

            // Assert
            PointSymbolizer expectedSymbolizer = CreateExpectedSymbolizer(pointStyle);

            IPointScheme appliedScheme = mapPointLayer.Symbology;

            Assert.AreEqual(1, appliedScheme.Categories.Count);

            IPointCategory baseCategory = appliedScheme.Categories[0];

            AssertAreEqual(expectedSymbolizer, baseCategory.Symbolizer);
            Assert.IsNull(baseCategory.FilterExpression);
        }
        public void ConvertLayerProperties_MapDataWithMapThemeAndVaryingValueCriteria_SetsCorrectFilterExpression(ValueCriterionOperator criterionOperator,
                                                                                                                  string expressionFormat)
        {
            // Setup
            const string metadataAttributeName = "Meta";
            const string value = "test value";

            var valueCriterion = new ValueCriterion(criterionOperator,
                                                    value);
            var theme = new MapTheme <TestCategoryTheme>(metadataAttributeName, new[]
            {
                new TestCategoryTheme(valueCriterion)
            });

            var mapData = new TestFeatureBasedMapData("test data", theme)
            {
                Features = new[]
                {
                    new MapFeature(Enumerable.Empty <MapGeometry>())
                    {
                        MetaData =
                        {
                            {
                                metadataAttributeName, new object()
                            }
                        }
                    }
                }
            };

            var featureScheme   = new PointScheme();
            var defaultCategory = new PointCategory();
            var category        = new PointCategory();
            var testConverter   = new TestFeatureBasedMapDataConverter
            {
                CreatedFeatureScheme         = featureScheme,
                CreatedDefaultCategory       = defaultCategory,
                CreatedCategoryThemeCategory = category
            };

            var mapLayer = new TestFeatureLayer();

            // Call
            testConverter.ConvertLayerProperties(mapData, mapLayer);

            // Assert
            Assert.IsNull(defaultCategory.FilterExpression);
            string expectedFilterExpression = string.Format(expressionFormat, value);

            Assert.AreEqual(expectedFilterExpression, category.FilterExpression);
        }
        public void ConvertLayerProperties_MapDataWithMapThemeAndExistingMetaData_SetsExpectedSymbology()
        {
            // Setup
            const string metadataAttributeName = "metaData";
            var          theme = new MapTheme <TestCategoryTheme>(metadataAttributeName, new[]
            {
                new TestCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion())
            });
            var mapData = new TestFeatureBasedMapData("test data", theme)
            {
                Features = new[]
                {
                    new MapFeature(Enumerable.Empty <MapGeometry>())
                    {
                        MetaData =
                        {
                            {
                                metadataAttributeName, new object()
                            }
                        }
                    }
                }
            };

            var scheme          = new PointScheme();
            var defaultCategory = new PointCategory();
            var categoryTheme   = new PointCategory();
            var testConverter   = new TestFeatureBasedMapDataConverter
            {
                CreatedFeatureScheme         = scheme,
                CreatedDefaultCategory       = defaultCategory,
                CreatedCategoryThemeCategory = categoryTheme
            };

            var mapLayer = new TestFeatureLayer();

            // Call
            testConverter.ConvertLayerProperties(mapData, mapLayer);

            // Assert
            IPointScheme symbology = mapLayer.Symbology;

            Assert.AreSame(scheme, symbology);
            CollectionAssert.AreEqual(new[]
            {
                defaultCategory,
                categoryTheme
            }, symbology.Categories);
        }
示例#17
0
 /// <summary>
 /// Asserts whether the <paramref name="theme"/> is configured for values
 /// of type <see cref="FailureMechanismSectionAssemblyGroup"/>.
 /// </summary>
 /// <param name="theme">The <see cref="MapTheme{T}"/> to assert.</param>
 /// <exception cref="AssertionException">Thrown when:
 /// <list type="bullet">
 /// <item><paramref name="theme"/> does not have the expected attribute name it categorizes its data on.</item>
 /// <item><paramref name="theme"/> does not have the expected number of criteria as themes.</item>
 /// <item><paramref name="theme"/> does not have the expected categorical criteria as themes.</item>
 /// </list></exception>
 public static void AssertFailureMechanismSectionAssemblyGroupMapTheme(MapTheme <LineCategoryTheme> theme)
 {
     Assert.AreEqual("Duidingsklasse", theme.AttributeName);
     Assert.AreEqual(11, theme.CategoryThemes.Count());
     AssertCategoryTheme("+III", Color.FromArgb(255, 34, 139, 34), theme.CategoryThemes.ElementAt(0));
     AssertCategoryTheme("+II", Color.FromArgb(255, 146, 208, 80), theme.CategoryThemes.ElementAt(1));
     AssertCategoryTheme("+I", Color.FromArgb(255, 198, 224, 180), theme.CategoryThemes.ElementAt(2));
     AssertCategoryTheme("0", Color.FromArgb(255, 255, 255, 0), theme.CategoryThemes.ElementAt(3));
     AssertCategoryTheme("-I", Color.FromArgb(255, 255, 165, 0), theme.CategoryThemes.ElementAt(4));
     AssertCategoryTheme("-II", Color.FromArgb(255, 255, 0, 0), theme.CategoryThemes.ElementAt(5));
     AssertCategoryTheme("-III", Color.FromArgb(255, 178, 34, 34), theme.CategoryThemes.ElementAt(6));
     AssertCategoryTheme("Do", Color.FromArgb(255, 255, 90, 172), theme.CategoryThemes.ElementAt(7));
     AssertCategoryTheme("NDo", Color.FromArgb(255, 192, 192, 192), theme.CategoryThemes.ElementAt(8));
     AssertCategoryTheme("NR", Color.FromArgb(255, 38, 245, 245), theme.CategoryThemes.ElementAt(9));
     AssertCategoryTheme(string.Empty, Color.FromArgb(0, 0, 0, 0), theme.CategoryThemes.ElementAt(10));
 }
示例#18
0
        public void TypedConstructor_WithNameAndCategoryThemes_ExpectedValues()
        {
            // Setup
            const string name     = "name";
            var          mapTheme = new MapTheme <TestCategoryTheme>("test", new[]
            {
                new TestCategoryTheme()
            });

            // Call
            var data = new TypedTestFeatureBasedMapData(name, mapTheme);

            // Assert
            Assert.IsInstanceOf <FeatureBasedMapData>(data);
            Assert.AreEqual(name, data.Name);
            Assert.AreSame(mapTheme, data.Theme);
        }
示例#19
0
        public void Constructor_ValidArguments_SetsExpectedValues()
        {
            // Setup
            const string attributeName = "Arbitrary attribute";

            TestCategoryTheme[] mapCategories =
            {
                CreateCategoryTheme()
            };

            // Call
            var theme = new MapTheme <TestCategoryTheme>(attributeName, mapCategories);

            // Assert
            Assert.AreEqual(attributeName, theme.AttributeName);
            Assert.AreSame(mapCategories, theme.CategoryThemes);
        }
        public void ConvertLayerProperties_MapDataWithMapTheme_UsesCorrectInputsForConversion()
        {
            // Setup
            const string metadataAttributeName = "metaData";
            var          theme = new MapTheme <TestCategoryTheme>(metadataAttributeName, new[]
            {
                new TestCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion()),
                new TestCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion())
            });
            var mapData = new TestFeatureBasedMapData("test data", theme)
            {
                Features = new[]
                {
                    new MapFeature(Enumerable.Empty <MapGeometry>())
                    {
                        MetaData =
                        {
                            {
                                metadataAttributeName, new object()
                            }
                        }
                    }
                }
            };

            var testConverter = new TestFeatureBasedMapDataConverter
            {
                CreatedFeatureScheme         = new PointScheme(),
                CreatedDefaultCategory       = new PointCategory(),
                CreatedCategoryThemeCategory = new PointCategory()
            };

            var mapLayer = new TestFeatureLayer();

            // Call
            testConverter.ConvertLayerProperties(mapData, mapLayer);

            // Assert
            CollectionAssert.AreEqual(new[]
            {
                mapData
            }, testConverter.DefaultCategoryInputs);
            CollectionAssert.AreEqual(theme.CategoryThemes, testConverter.CategoryThemeInputs);
        }
示例#21
0
    void Awake()
    {
        if (GlobalVariables.Instance != null)//Else use the default or previous instance
        {
            GLOBALS = GlobalVariables.Instance;
        }
        mapSize                  = GLOBALS.mapSize;
        mapTheme                 = GLOBALS.mapTheme;
        platformRowNums          = new List <int>();
        zoneObjects              = new List <GameObject>();
        zonePrefabNum            = new List <int>();
        startingColliderPlatform = new List <int>();
        rand        = new System.Random();
        xZoneOffset = new Vector3(xZoneSize + 6, 0, 0);
        yZoneOffset = new Vector3(0, yZoneSize + 3, 0);

        switch (mapSize)
        {
        case MapSize.Large:
            numRows = largeZoneRows;
            numCols = largeZoneColumns;
            break;

        case MapSize.Medium:
            numRows = mediumZoneRows;
            numCols = mediumZoneColumns;
            break;

        case MapSize.Small:
            numRows = smallZoneRows;
            numCols = smallZoneColumns;
            break;

        default:
            Debug.LogError("Map size not Initalized yet!");
            break;
        }

        GenerateMap();
    }
示例#22
0
        public static SubjectBase ReadSubject(string xml, List<SubjectBase> floatSubjects, out MapTheme theme,out MapViewModel viewmodel)
        {
            XmlDocument NexusDocument = new XmlDocument();

            NexusDocument.LoadXml(xml);

            theme = MapTheme.Default;
            viewmodel = MapViewModel.ExpandRightSide;
            //Read Map Attributes
            foreach (XmlAttribute att in NexusDocument.DocumentElement.Attributes)
            {
                string name = att.Name;
                string value = att.Value;
                if(name=="Theme")
                {
                    theme = (MapTheme)Enum.Parse(typeof(MapTheme), value);
                }
                else if (name == "ViewModel")
                {
                    viewmodel = (MapViewModel)Enum.Parse(typeof(MapViewModel), value);
                }
            }
            //Read CenterSubject,FloatSubject
            SubjectBase centetSubject = null;
            foreach (XmlNode node in NexusDocument.DocumentElement.ChildNodes)
            {
                if(node.Name=="CenterSubject")
                {
                    centetSubject = ReadSubjectInfo(node);
                }
                else
                {
                    SubjectBase floatSubject = ReadSubjectInfo(node);
                    floatSubjects.Add(floatSubject);
                }
            }
            return centetSubject;
        }
示例#23
0
        private IFeatureScheme CreateCategoryScheme(TFeatureBasedMapData mapData)
        {
            IFeatureScheme scheme = CreateScheme();

            scheme.ClearCategories();
            scheme.AddCategory(CreateDefaultCategory(mapData));

            MapTheme <TCategoryTheme> mapTheme         = mapData.Theme;
            Dictionary <string, int>  attributeMapping = GetAttributeMapping(mapData);

            if (attributeMapping.ContainsKey(mapTheme.AttributeName))
            {
                int attributeIndex = attributeMapping[mapTheme.AttributeName];

                foreach (TCategoryTheme categoryTheme in mapTheme.CategoryThemes)
                {
                    IFeatureCategory category = CreateFeatureCategory(categoryTheme);
                    category.FilterExpression = CreateFilterExpression(attributeIndex, categoryTheme.Criterion);
                    scheme.AddCategory(category);
                }
            }

            return(scheme);
        }
示例#24
0
 private PolygonCategoryThemeProperties[] GetCategoryThemes(MapTheme <PolygonCategoryTheme> mapTheme)
 {
     return(mapTheme.CategoryThemes.Select(ct => new PolygonCategoryThemeProperties(ct, mapTheme.AttributeName, data)).ToArray());
 }
示例#25
0
 public static bool IsMapExisted(byte index, MapTheme theme)
 {
     return(stringMapMapping.ContainsValue(byte.Parse(theme.GetHashCode().ToString() + index.ToString())));
 }
示例#26
0
 public static MindDocTheme CreateTheme(MapTheme theme)
 {
     MindDocTheme mindDocTheme = null;
     switch (theme)
     {
         case MapTheme.Default:
             mindDocTheme = new MindDocThemeDefault();
             break;
         case MapTheme.Classics:
             mindDocTheme = new MindDocThemeClassics();
             break;
         case MapTheme.Bubble:
             mindDocTheme = new MindDocThemeBubble();
             break;
         case MapTheme.Lemo:
             mindDocTheme = new MindDocThemeLemo();
             break;
         case MapTheme.Black:
             mindDocTheme = new MindDocThemeBlack();
             break;
     }
     return mindDocTheme;
 }
示例#27
0
 public void SetMapTheme(MapTheme mapTheme)
 {
     this._theme = mapTheme;
 }
示例#28
0
        public static string SaveSubject(SubjectBase centerSubject, List<SubjectBase> floatSubjects,MapTheme theme,MapViewModel viewmodel)
        {
            XmlDocument doc = new XmlDocument();
            XmlElement root = doc.CreateElement("JmMap");

            CreateObjectAttribute(doc, root, "Theme", theme.ToString());
            CreateObjectAttribute(doc, root, "ViewModel", viewmodel.ToString());

            SaveSubjectInfo(doc,root, centerSubject);
            foreach(SubjectBase floatSubject in floatSubjects)
            {
                SaveSubjectInfo(doc, root, floatSubject);
            }

            doc.AppendChild(root);
            string ss = doc.InnerXml;
            return ss;
        }
 public TestFeatureBasedMapData(string name, MapTheme <TestCategoryTheme> theme) : base(name, theme)
 {
 }
示例#30
0
 private bool ValidationCheck(string mapName, byte index = 0, MapTheme theme = MapTheme.Arena)
 {
     return(!GlobalMapInfoMgr.IsMapExisted(mapName) && !GlobalMapInfoMgr.IsMapExisted(index, theme));
 }
示例#31
0
        public void GivenMapLayerWithScheme_WhenConvertingLayerFeatures_ThenClearsAppliedSchemeAndAppliesDefaultCategory()
        {
            // Given
            var mocks       = new MockRepository();
            var categoryOne = mocks.Stub <ILineCategory>();
            var categoryTwo = mocks.Stub <ILineCategory>();

            mocks.ReplayAll();

            var mapLineLayer = new MapLineLayer
            {
                Symbology = new LineScheme
                {
                    Categories =
                    {
                        categoryOne,
                        categoryTwo
                    }
                }
            };

            var converter = new MapLineDataConverter();

            var random    = new Random(21);
            var lineStyle = new LineStyle
            {
                Color     = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                Width     = random.Next(1, 48),
                DashStyle = random.NextEnum <LineDashStyle>()
            };
            var theme = new MapTheme <LineCategoryTheme>("Meta", new[]
            {
                new LineCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion(),
                                      new LineStyle
                {
                    Color     = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                    Width     = random.Next(1, 48),
                    DashStyle = random.NextEnum <LineDashStyle>()
                })
            });

            var mapLineData = new MapLineData("test", lineStyle, theme)
            {
                Features = new[]
                {
                    CreateMapFeatureWithMetaData("Meta")
                }
            };

            // When
            converter.ConvertLayerFeatures(mapLineData, mapLineLayer);

            // Then
            LineCategoryCollection categoryCollection = mapLineLayer.Symbology.Categories;

            Assert.AreEqual(1, categoryCollection.Count);

            ILineSymbolizer expectedSymbolizer = CreateExpectedSymbolizer(lineStyle);

            AssertAreEqual(expectedSymbolizer, categoryCollection.Single().Symbolizer);

            mocks.VerifyAll();
        }
示例#32
0
        public void ConvertLayerProperties_MapPolygonDataWithThemeAndMetaDataNameInFeatures_ConvertDataToMapPolygonLayer()
        {
            // Setup
            const string metadataAttribute = "Meta";
            var          random            = new Random(21);

            var unequalCriterion = new ValueCriterion(ValueCriterionOperator.UnequalValue,
                                                      "unequal value");
            var equalCriterion = new ValueCriterion(ValueCriterionOperator.EqualValue,
                                                    "equal value");
            var theme = new MapTheme <PolygonCategoryTheme>(metadataAttribute, new[]
            {
                new PolygonCategoryTheme(equalCriterion, new PolygonStyle
                {
                    FillColor       = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                    StrokeColor     = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                    StrokeThickness = random.Next(1, 48)
                }),
                new PolygonCategoryTheme(unequalCriterion, new PolygonStyle
                {
                    FillColor       = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                    StrokeColor     = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                    StrokeThickness = random.Next(1, 48)
                })
            });

            var polygonStyle = new PolygonStyle
            {
                FillColor       = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                StrokeColor     = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                StrokeThickness = random.Next(1, 48)
            };
            var mapPolygonData = new MapPolygonData("test", polygonStyle, theme)
            {
                Features = new[]
                {
                    CreateMapFeatureWithMetaData(metadataAttribute)
                }
            };

            var mapPolygonLayer = new MapPolygonLayer();

            var converter = new MapPolygonDataConverter();

            // Call
            converter.ConvertLayerProperties(mapPolygonData, mapPolygonLayer);

            // Assert
            PolygonSymbolizer expectedSymbolizer = CreateExpectedSymbolizer(polygonStyle);

            IPolygonScheme appliedScheme = mapPolygonLayer.Symbology;

            Assert.AreEqual(3, appliedScheme.Categories.Count);

            IPolygonCategory baseCategory = appliedScheme.Categories[0];

            AssertAreEqual(expectedSymbolizer, baseCategory.Symbolizer);
            Assert.IsNull(baseCategory.FilterExpression);

            IPolygonCategory equalSchemeCategory = appliedScheme.Categories[1];
            string           expectedFilter      = $"[1] = '{equalCriterion.Value}'";

            Assert.AreEqual(expectedFilter, equalSchemeCategory.FilterExpression);
            PolygonStyle expectedCategoryStyle = theme.CategoryThemes.ElementAt(0).Style;

            expectedSymbolizer = CreateExpectedSymbolizer(expectedCategoryStyle);
            AssertAreEqual(expectedSymbolizer, equalSchemeCategory.Symbolizer);

            IPolygonCategory unEqualSchemeCategory = appliedScheme.Categories[2];

            expectedFilter = $"NOT [1] = '{unequalCriterion.Value}'";
            Assert.AreEqual(expectedFilter, unEqualSchemeCategory.FilterExpression);
            expectedCategoryStyle = theme.CategoryThemes.ElementAt(1).Style;
            expectedSymbolizer    = CreateExpectedSymbolizer(expectedCategoryStyle);
            AssertAreEqual(expectedSymbolizer, unEqualSchemeCategory.Symbolizer);
        }
示例#33
0
        public void GivenMapLayerWithScheme_WhenConvertingLayerFeatures_ThenClearsAppliedSchemeAndAppliesDefaultCategory()
        {
            // Given
            const string metadataAttribute = "Meta";

            var mocks       = new MockRepository();
            var categoryOne = mocks.Stub <IPolygonCategory>();
            var categoryTwo = mocks.Stub <IPolygonCategory>();

            mocks.ReplayAll();

            var mapPolygonLayer = new MapPolygonLayer
            {
                Symbology = new PolygonScheme
                {
                    Categories =
                    {
                        categoryOne,
                        categoryTwo
                    }
                }
            };

            var converter = new MapPolygonDataConverter();

            var random       = new Random(21);
            var polygonStyle = new PolygonStyle
            {
                FillColor       = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                StrokeColor     = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                StrokeThickness = random.Next(1, 48)
            };
            var theme = new MapTheme <PolygonCategoryTheme>(metadataAttribute, new[]
            {
                new PolygonCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion(),
                                         new PolygonStyle
                {
                    FillColor       = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                    StrokeColor     = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                    StrokeThickness = random.Next(1, 48)
                })
            });
            var mapPolygonData = new MapPolygonData("test", polygonStyle, theme)
            {
                Features = new[]
                {
                    CreateMapFeatureWithMetaData(metadataAttribute)
                }
            };

            // When
            converter.ConvertLayerFeatures(mapPolygonData, mapPolygonLayer);

            // Then
            PolygonCategoryCollection categoryCollection = mapPolygonLayer.Symbology.Categories;

            Assert.AreEqual(1, categoryCollection.Count);

            PolygonSymbolizer expectedSymbolizer = CreateExpectedSymbolizer(polygonStyle);

            AssertAreEqual(expectedSymbolizer, categoryCollection.Single().Symbolizer);

            mocks.VerifyAll();
        }