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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }