public void Can_parse_rule_to_ast() { var css = @" .header { BackgroundColor: Green; } "; var ast = CssParser.GetAst(css); ast.GetSelectorNode(0, 0, 0).Text.Should().Be(".header"); }
public void TestGetAst() { var doc = CssParser.GetAst(test1); var node = doc.Children.FirstOrDefault(x => x.Type == CssNodeType.StyleRule) ?.Children.FirstOrDefault(x => x.Type == CssNodeType.StyleDeclarationBlock) ?.Children.FirstOrDefault(x => x.Type == CssNodeType.StyleDeclaration) ?.Children.FirstOrDefault(x => x.Type == CssNodeType.Value && x.Text == "red") ; Assert.NotNull(node); }
public void Can_parse_nested_rule_to_ast() { var css = @" .header { BackgroundColor: Green; Label { BackgroundColor: Red; } } "; var ast = CssParser.GetAst(css); var headerRuleNode = ast.GetRootStyleRuleNode(0); var labelRuleNode = headerRuleNode .GetSubStyleRuleNode(0); labelRuleNode .GetSelectorNode(0, 0, 0).Text.Should().Be("Label"); }