public void CanUseCanvas(string path, bool canUseExprTree) { // ARRANGE var stylesheet = MapCssHelper.GetStylesheetFromFile(path, canUseExprTree); var canvas = new Canvas(TestHelper.GetObjectPool()); // ACT var rule = stylesheet.GetModelRule(canvas, MapConsts.MaxZoomLevel); var material = rule.Evaluate <string>("material"); // ASSERT Assert.AreEqual("Terrain", material); }
public void CanGetMissing(string path, bool canUseExprTree) { // ARRANGE var stylesheet = MapCssHelper.GetStylesheetFromFile(path, canUseExprTree); var area = new Area { Id = 1, Points = new List <GeoCoordinate>(), Tags = new Dictionary <string, string>() { { "building", "residential" }, }.ToTags() }; // ACT var rule = stylesheet.GetModelRule(area, MapConsts.MaxZoomLevel); // ASSERT Assert.AreEqual(0, rule.GetLevels()); }
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); }
public void CanGetColorByName(string path, bool canUseExprTree) { // ARRANGE var stylesheet = MapCssHelper.GetStylesheetFromFile(path, canUseExprTree); var buildingWithColorName = new Area { Id = 1, Points = new List <GeoCoordinate>(), Tags = new Dictionary <string, string>() { { "building", "yes" }, }.ToTags() }; // ACT var rule = stylesheet.GetModelRule(buildingWithColorName, MapConsts.MaxZoomLevel); // ASSERT Assert.AreEqual(ColorUtils.FromName("salmon"), GetOriginalColorTypeObject(rule.GetFillUnityColor())); }
public void CanMergeDeclarations(string path, bool canUseExprTree) { // ARRANGE var stylesheet = MapCssHelper.GetStylesheetFromFile(path, canUseExprTree); var area = new Area { Id = 1, Points = new List <GeoCoordinate>() { new GeoCoordinate(52.5212186, 13.4096926), new GeoCoordinate(52.5210184, 13.4097473), new GeoCoordinate(52.5209891, 13.4097538), new GeoCoordinate(52.5209766, 13.4098037) }, Tags = new Dictionary <string, string>() { { "building", "residential" }, { "building:shape", "sphere" }, { "min_height", "100" }, { "building:levels", "5" }, }.ToTags() }; // ACT var rule = stylesheet.GetModelRule(area, MapConsts.MaxZoomLevel); // ASSERT Assert.IsTrue(rule.IsApplicable, "Unable to get declarations!"); Assert.AreEqual("sphere", rule.Evaluate <string>("builder"), "Unable to merge declarations!"); Assert.AreEqual(100, rule.Evaluate <float>("min_height"), "Unable to eval min_height from tag!"); Assert.AreEqual(new Color32(250, 128, 114, 255), rule.GetFillUnityColor(), "Unable to merge declarations!"); Assert.AreEqual("solid", rule.Evaluate <string>("behaviour"), "First rule isn't applied!"); Assert.AreEqual("Concrete_Patterned", rule.Evaluate <string>("material"), "First rule isn't applied!"); Assert.AreEqual(15, rule.Evaluate <float>("height"), "Unable to eval height from building:levels!"); }