Ejemplo n.º 1
0
        public void Property_LtEq()
        {
            var selector = new SelectorSyntaxParser().Parse("[Name <= 123]");

            selector.Should().BeOfType <ComplexSelectorList>();
            selector.ToSelectorString().Should().Be(new ComplexSelectorList(new ComplexSelector(new PropertyLessThanEqualMatchSelector("Name", 123))).ToSelectorString());
        }
Ejemplo n.º 2
0
        public void UniversalTypeSelector()
        {
            var selector = new SelectorSyntaxParser().Parse("*");

            selector.Should().BeOfType <ComplexSelectorList>();
            selector.ToSelectorString().Should().Be(new ComplexSelectorList(new ComplexSelector(new UniversalTypeSelector())).ToSelectorString());
        }
Ejemplo n.º 3
0
        public void PseudoClass_Lambda()
        {
            var selector = new SelectorSyntaxParser().Parse(":lambda");

            selector.Should().BeOfType <ComplexSelectorList>();
            selector.ToSelectorString().Should().Be(new ComplexSelectorList(new ComplexSelector(new LambdaPseudoClassSelector())).ToSelectorString());
        }
Ejemplo n.º 4
0
        public void TypeSelector_SyntaxKind()
        {
            var selector = new SelectorSyntaxParser().Parse("ClassDeclaration");

            selector.Should().BeOfType <ComplexSelectorList>();
            selector.ToSelectorString().Should().Be(new ComplexSelectorList(new ComplexSelector(new TypeSelector(SyntaxKind.ClassDeclaration))).ToSelectorString());
        }
Ejemplo n.º 5
0
        public void PseudoClass_Interface()
        {
            var selector = new SelectorSyntaxParser().Parse(":interface");

            selector.Should().BeOfType <ComplexSelectorList>();
            selector.ToSelectorString().Should().Be(new ComplexSelectorList(new ComplexSelector(new InterfacePseudoClassSelector())).ToSelectorString());
        }
Ejemplo n.º 6
0
        public void PseudoClass_Method()
        {
            var selector = new SelectorSyntaxParser().Parse(":method");

            selector.Should().BeOfType <ComplexSelectorList>();
            selector.ToSelectorString().Should().Be(new ComplexSelectorList(new ComplexSelector(new MethodPseudoClassSelector())).ToSelectorString());
        }
Ejemplo n.º 7
0
        public void Property_ItemContainsMatchSelector()
        {
            var selector = new SelectorSyntaxParser().Parse("[Name ~= 'A']");

            selector.Should().BeOfType <ComplexSelectorList>();
            selector.ToSelectorString().Should().Be(new ComplexSelectorList(new ComplexSelector(new PropertyItemContainsMatchSelector("Name", "A"))).ToSelectorString());
        }
Ejemplo n.º 8
0
        public void Property_Exact()
        {
            var selector = new SelectorSyntaxParser().Parse("[Name=A]");

            selector.Should().BeOfType <ComplexSelectorList>();
            selector.ToSelectorString().Should().Be(new ComplexSelectorList(new ComplexSelector(new PropertyExactMatchSelector("Name", "A"))).ToSelectorString());
        }
Ejemplo n.º 9
0
        public void Property_NameOnly()
        {
            var selector = new SelectorSyntaxParser().Parse("[Name]");

            selector.Should().BeOfType <ComplexSelectorList>();
            selector.ToSelectorString().Should().Be(new ComplexSelectorList(new ComplexSelector(new PropertyNameSelector("Name"))).ToSelectorString());
        }
Ejemplo n.º 10
0
        public void Property_Gt()
        {
            var selector = new SelectorSyntaxParser().Parse("[Name > 123]");

            selector.Should().BeOfType <ComplexSelectorList>();
            selector.ToSelectorString().Should().Be(new ComplexSelectorList(new ComplexSelector(new PropertyGreaterThanMatchSelector("Name", 123))).ToSelectorString());
        }
Ejemplo n.º 11
0
        public void PseudoNot()
        {
            var selector = new SelectorSyntaxParser().Parse(":not([Name='Foo'])");
            var expected = new ComplexSelectorList(new ComplexSelector(
                                                       new NotPseudoClassSelector(new PropertyExactMatchSelector("Name", "Foo"))
                                                       ));

            selector.ToSelectorString().Should().Be(expected.ToSelectorString());
        }
Ejemplo n.º 12
0
        public void SubsequentSiblingCombinator()
        {
            var selector = new SelectorSyntaxParser().Parse("ClassDeclaration ~ MethodDeclaration");

            selector.Should().BeOfType <ComplexSelectorList>();
            selector.ToSelectorString().Should().Be(
                new ComplexSelectorList(
                    new ComplexSelector(new TypeSelector(SyntaxKind.ClassDeclaration), new SubsequentSiblingCombinator(), new TypeSelector(SyntaxKind.MethodDeclaration))
                    ).ToSelectorString());
        }
Ejemplo n.º 13
0
        public void ChildCombinatorOneCapture()
        {
            var selector = new SelectorSyntaxParser().Parse("ClassDeclaration > $MethodDeclaration");

            selector.Should().BeOfType <ComplexSelectorList>();
            selector.ToSelectorString().Should().Be(
                new ComplexSelectorList(
                    new ComplexSelector(new TypeSelector(SyntaxKind.ClassDeclaration), new ChildCombinator(), new CaptureSelector(new TypeSelector(SyntaxKind.MethodDeclaration)))
                    ).ToSelectorString());
        }
Ejemplo n.º 14
0
        public void PseudoIs()
        {
            var selector = new SelectorSyntaxParser().Parse(":is(PredefinedType, GenericName, :not([Name='Foo']))");
            var expected = new ComplexSelectorList(new ComplexSelector(
                                                       new IsPseudoClassSelector(
                                                           new TypeSelector(SyntaxKind.PredefinedType),
                                                           new TypeSelector(SyntaxKind.GenericName),
                                                           new NotPseudoClassSelector(new PropertyExactMatchSelector("Name", "Foo"))
                                                           )
                                                       ));

            selector.ToSelectorString().Should().Be(expected.ToSelectorString());
        }
Ejemplo n.º 15
0
        public void Complex_1()
        {
            var selector = new SelectorSyntaxParser().Parse(":class :method:not([Name='Foo'])  SwitchSection ObjectCreationExpression    > :is(PredefinedType, GenericName)[Name^='List'] ");
            var expected = new ComplexSelectorList(new ComplexSelector(
                                                       new CompoundSelector(new ClassPseudoClassSelector()),
                                                       new DescendantCombinator(),
                                                       new CompoundSelector(new MethodPseudoClassSelector(), new NotPseudoClassSelector(new PropertyExactMatchSelector("Name", "Foo"))),
                                                       new DescendantCombinator(),
                                                       new CompoundSelector(new TypeSelector(SyntaxKind.SwitchSection)),
                                                       new DescendantCombinator(),
                                                       new CompoundSelector(new TypeSelector(SyntaxKind.ObjectCreationExpression)),
                                                       new ChildCombinator(),
                                                       new CompoundSelector(
                                                           new IsPseudoClassSelector(
                                                               new TypeSelector(SyntaxKind.PredefinedType),
                                                               new TypeSelector(SyntaxKind.GenericName)
                                                               ),
                                                           new PropertyPrefixMatchSelector("Name", "List")
                                                           )
                                                       ));

            selector.ToSelectorString().Should().Be(expected.ToSelectorString());
        }
Ejemplo n.º 16
0
        public void IgnoreAroundWhitespaces()
        {
            var selector = new SelectorSyntaxParser().Parse("     ClassDeclaration         ");

            selector.ToSelectorString().Should().Be(new ComplexSelectorList(new ComplexSelector(new TypeSelector(SyntaxKind.ClassDeclaration))).ToSelectorString());
        }