コード例 #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);
 }
コード例 #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);
 }
コード例 #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);
 }
コード例 #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);
 }
コード例 #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);
 }
コード例 #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);
 }
コード例 #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);
 }
コード例 #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);
 }
コード例 #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);
 }
コード例 #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);
 }
コード例 #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);
 }
コード例 #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);
 }
コード例 #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);
 }
コード例 #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);
 }
コード例 #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);
 }
コード例 #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);
 }
コード例 #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);
 }
コード例 #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);
 }
コード例 #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);
 }
コード例 #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);
 }
コード例 #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);
 }
コード例 #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);
 }