Exemplo n.º 1
0
 public void TestAttributeDashSelector()
 {
     SelectorParser parser = new SelectorParser();
     var selector = parser.Parse("[hreflang|=en]");
     Assert.AreEqual(
         new SelectorsGroup(
             new[] {
                 new Selector(
                     new SimpleSelectorSequence(
                         new UniversalSelector(),
                         new[] {
                             new AttributeDashFilter("hreflang", "en")}))}),
         selector);
 }
Exemplo n.º 2
0
 public void TestAttributeExactMatcFilter()
 {
     SelectorParser parser = new SelectorParser();
     var selector = parser.Parse("[name=username]");
     Assert.AreEqual(
         new SelectorsGroup(
             new[] {
                 new Selector(
                     new SimpleSelectorSequence(
                         new UniversalSelector(),
                         new[] {
                             new AttributeExactFilter("name", "username")}))}),
         selector);
 }
Exemplo n.º 3
0
 public void TestAttributeIncludesSelector()
 {
     SelectorParser parser = new SelectorParser();
     var selector = parser.Parse("[rel~=copyright]");
     Assert.AreEqual(
         new SelectorsGroup(
             new[] {
                 new Selector(
                     new SimpleSelectorSequence(
                         new UniversalSelector(),
                         new[] {
                             new AttributeIncludesFilter("rel", "copyright")}))}),
         selector);
 }
Exemplo n.º 4
0
 public void TestAdjacentSiblingCombinator()
 {
     SelectorParser parser = new SelectorParser();
     var selector = parser.Parse("div + a");
     Assert.AreEqual(
         new SelectorsGroup(
             new[] {
                 new Selector(
                     new[] {
                         new SimpleSelectorSequence(
                            new TypeSelector("div"), new IFilter[0]),
                        new SimpleSelectorSequence(
                            new TypeSelector("a"), new IFilter[0])},
                     new[] {
                         new AdjacentSiblingCombinator()
                     })}),
         selector);
 }
Exemplo n.º 5
0
 public void TestMultipleCombinators()
 {
     SelectorParser parser = new SelectorParser();
     var selector = parser.Parse("div > table tr > td");
     Assert.AreEqual(
         new SelectorsGroup(
             new[] {
                 new Selector(
                     new[] {
                         new SimpleSelectorSequence(
                            new TypeSelector("div"), new IFilter[0]),
                        new SimpleSelectorSequence(
                            new TypeSelector("table"), new IFilter[0]),
                         new SimpleSelectorSequence(
                            new TypeSelector("tr"), new IFilter[0]),
                        new SimpleSelectorSequence(
                            new TypeSelector("td"), new IFilter[0])},
                     new Combinator[] {
                         new ChildCombinator(),
                         new DescendantCombinator(),
                         new ChildCombinator()
                     })}),
         selector);
 }
Exemplo n.º 6
0
 public void TestCssPseudoOnlyOfTypeSelector()
 {
     SelectorParser parser = new SelectorParser();
     var selector = parser.Parse(":only-of-type");
     Assert.AreEqual(
         new SelectorsGroup(
             new[] {
                 new Selector(
                     new SimpleSelectorSequence(
                         new UniversalSelector(),
                         new[] {
                             new OnlyOfTypeFilter()}))}),
         selector);
 }
Exemplo n.º 7
0
 public void TestCssPseudoLastChildSelector()
 {
     SelectorParser parser = new SelectorParser();
     var selector = parser.Parse(":last-child");
     Assert.AreEqual(
         new SelectorsGroup(
             new[] {
                 new Selector(
                     new SimpleSelectorSequence(
                         new UniversalSelector(),
                         new[] {
                             new LastChildFilter()}))}),
         selector);
 }
Exemplo n.º 8
0
 public void TestUniversalSelector()
 {
     SelectorParser parser = new SelectorParser();
     var selector = parser.Parse("*");
     Assert.AreEqual(
         new SelectorsGroup(
             new[] {
                 new Selector(
                     new SimpleSelectorSequence(
                         new UniversalSelector(),
                         new IFilter[0]) )}),
         selector);
 }
Exemplo n.º 9
0
 public void TestMultipleSelectors()
 {
     SelectorParser parser = new SelectorParser();
     var selector = parser.Parse("a,div");
     Assert.AreEqual(
         new SelectorsGroup(
             new[] {
                 new Selector(
                     new SimpleSelectorSequence(
                         new TypeSelector("a"), new IFilter[0])),
                 new Selector(
                     new SimpleSelectorSequence(
                         new TypeSelector("div"), new IFilter[0]))}),
         selector);
 }
Exemplo n.º 10
0
 public void TestCssNegationUniversalFilter()
 {
     SelectorParser parser = new SelectorParser();
        var selector = parser.Parse(":not(*)");
        Assert.AreEqual(
        new SelectorsGroup(
            new[] {
                 new Selector(
                     new SimpleSelectorSequence(
                         new UniversalSelector(),
                         new[] {
                             new NegationTypeFilter(
                                 new UniversalSelector())}))}),
        selector);
 }
Exemplo n.º 11
0
 public void TestCssNegationPseudoFilter()
 {
     SelectorParser parser = new SelectorParser();
        var selector = parser.Parse(":not(:nth-child(2))");
        Assert.AreEqual(
        new SelectorsGroup(
            new[] {
                 new Selector(
                     new SimpleSelectorSequence(
                         new UniversalSelector(),
                         new[] {
                             new NegationFilter(
                                 new NthChildFilter(
                                     new NumericExpression(0, 2)))}))}),
        selector);
 }
Exemplo n.º 12
0
 public void TestCssNegationClassFilter()
 {
     SelectorParser parser = new SelectorParser();
        var selector = parser.Parse(":not(.class)");
        Assert.AreEqual(
        new SelectorsGroup(
            new[] {
                 new Selector(
                     new SimpleSelectorSequence(
                         new UniversalSelector(),
                         new[] {
                             new NegationFilter(
                                 new ClassFilter("class"))}))}),
        selector);
 }
Exemplo n.º 13
0
 public void TestCssNegationAttributeFilter()
 {
     SelectorParser parser = new SelectorParser();
        var selector = parser.Parse(":not([align=right])");
        Assert.AreEqual(
        new SelectorsGroup(
            new[] {
                 new Selector(
                     new SimpleSelectorSequence(
                         new UniversalSelector(),
                         new[] {
                             new NegationFilter(
                                 new AttributeExactFilter("align", "right"))}))}),
        selector);
 }
Exemplo n.º 14
0
 public void TestCssLangFilter()
 {
     SelectorParser parser = new SelectorParser();
     var selector = parser.Parse(":lang(en)");
     Assert.AreEqual(
         new SelectorsGroup(
             new[] {
                 new Selector(
                     new SimpleSelectorSequence(
                         new UniversalSelector(),
                         new[] {
                             new LangFilter("en")}))}),
         selector);
 }
Exemplo n.º 15
0
 public void TestCssExpressionNumericNPlusNumeric()
 {
     SelectorParser parser = new SelectorParser();
     var selector = parser.Parse(":nth-child(2n+1)");
     Assert.AreEqual(
         new SelectorsGroup(
             new[] {
                 new Selector(
                     new SimpleSelectorSequence(
                         new UniversalSelector(),
                         new[] {
                             new NthChildFilter(
                                 new NumericExpression(2, 1))}))}),
         selector);
 }
Exemplo n.º 16
0
 public void TestCssNthOfTypeFilter()
 {
     SelectorParser parser = new SelectorParser();
     var selector = parser.Parse(":nth-of-type(n)");
     Assert.AreEqual(
         new SelectorsGroup(
             new[] {
                 new Selector(
                     new SimpleSelectorSequence(
                         new UniversalSelector(),
                         new[] {
                             new NthOfTypeFilter(
                                 new NumericExpression(1, 0))}))}),
         selector);
 }
Exemplo n.º 17
0
 public void TestMultipleFilters()
 {
     SelectorParser parser = new SelectorParser();
     var selector = parser.Parse(".class.selected");
     Assert.AreEqual(
         new SelectorsGroup(
             new[] {
                 new Selector(
                     new SimpleSelectorSequence(
                         new UniversalSelector(),
                         new[] {
                             new ClassFilter("class"),
                             new ClassFilter("selected")}))}),
         selector);
 }
Exemplo n.º 18
0
 public void TestCssPseudoDisabledSelector()
 {
     SelectorParser parser = new SelectorParser();
     var selector = parser.Parse(":disabled");
     Assert.AreEqual(
         new SelectorsGroup(
             new[] {
                 new Selector(
                     new SimpleSelectorSequence(
                         new UniversalSelector(),
                         new[] {
                             new DisabledFilter()}))}),
         selector);
 }
Exemplo n.º 19
0
 public void TestPseudoRootSelector()
 {
     SelectorParser parser = new SelectorParser();
     var selector = parser.Parse(":root");
     Assert.AreEqual(
         new SelectorsGroup(
             new[] {
                 new Selector(
                     new SimpleSelectorSequence(
                         new UniversalSelector(),
                         new[] {
                             new RootFilter()}))}),
         selector);
 }
Exemplo n.º 20
0
 public void TestCssPseudoEmptySelector()
 {
     SelectorParser parser = new SelectorParser();
     var selector = parser.Parse(":empty");
     Assert.AreEqual(
         new SelectorsGroup(
             new[] {
                 new Selector(
                     new SimpleSelectorSequence(
                         new UniversalSelector(),
                         new[] {
                             new EmptyFilter()}))}),
         selector);
 }
Exemplo n.º 21
0
 public void TestAttributePrefixFilter()
 {
     SelectorParser parser = new SelectorParser();
     var selector = parser.Parse("[href^=http]");
     Assert.AreEqual(
         new SelectorsGroup(
             new[] {
                 new Selector(
                     new SimpleSelectorSequence(
                         new UniversalSelector(),
                         new[] {
                             new AttributePrefixFilter("href", "http")}))}),
         selector);
 }
Exemplo n.º 22
0
 public void TestAttributeSubstringMatcFilter()
 {
     SelectorParser parser = new SelectorParser();
     var selector = parser.Parse("[href*=www]");
     Assert.AreEqual(
         new SelectorsGroup(
             new[] {
                 new Selector(
                     new SimpleSelectorSequence(
                         new UniversalSelector(),
                         new[] {
                             new AttributeSubstringFilter("href", "www")}))}),
         selector);
 }