public void CanParse()
        {
            // ARRANGE
            var provider = new StylesheetProvider(TestHelper.TestBaseMapcssFile, TestHelper.GetFileSystemService());

            // ACT & ASSERT
            var stylesheet = provider.Get();

            Assert.AreEqual(9, stylesheet.Count);

            var testStyle1 = MapCssHelper.GetStyles(stylesheet)[1];

            Assert.AreEqual(2, testStyle1.Selectors.Count);
            Assert.AreEqual(7, testStyle1.Declarations.Count);

            var testSelector1 = testStyle1.Selectors.First();

            Assert.AreEqual("man_made", testSelector1.Tag);
            Assert.AreEqual("tower", testSelector1.Value);
            Assert.AreEqual("=", testSelector1.Operation);

            var testSelector2 = testStyle1.Selectors.Last();

            Assert.AreEqual("building", testSelector2.Tag);
            Assert.AreEqual("OP_EXIST", testSelector2.Operation);

            var lastStyle = MapCssHelper.GetStyles(stylesheet)[7];

            Assert.AreEqual(2, lastStyle.Selectors.Count);
            Assert.AreEqual(1, lastStyle.Declarations.Count);
        }
示例#2
0
        public void CanUseSimpleEvaluate(string path, bool canUseExprTree)
        {
            // ARRANGE
            var model = new Area
            {
                Id   = 1,
                Tags = new Dictionary <string, string>()
                {
                    { "building:levels", "5" }
                }.ToTags()
            };

            var stylesheet      = MapCssHelper.GetStylesheetFromFile(path, canUseExprTree);
            var evalDeclaration = MapCssHelper.GetStyles(stylesheet)[3].Declarations.First();

            // ACT
            var evalResult = evalDeclaration.Value.Evaluator.Walk <float>(model);

            // ASSERT
            Assert.AreEqual(15, evalResult);
        }