Exemplo n.º 1
0
        public void DoubleSquareBracketIsAliasForAngleBracket()
        {
            var grammar = new BindingGrammar();
            var result  = grammar.Nodes(Source("this[[that]]"));

            Assert.That(result.Value.Count(), Is.EqualTo(1));
            var node = (BindingLiteral)result.Value[0];

            Assert.That(node.Text, Is.EqualTo("this<that>"));
        }
Exemplo n.º 2
0
        public void PrefixLetsYouWildcardAsTheLastCharacter()
        {
            var grammar = new BindingGrammar();
            var result  = grammar.Nodes(Source("Html.ActionLink(@caption.**, @**)"));

            Assert.That(result.Value.Count(), Is.EqualTo(5));

            Assert.That(((BindingLiteral)result.Value[0]).Text, Is.EqualTo("Html.ActionLink("));
            Assert.That(((BindingPrefixReference)result.Value[1]).Prefix, Is.EqualTo("caption."));
            Assert.That(((BindingLiteral)result.Value[2]).Text, Is.EqualTo("*, "));
            Assert.That(((BindingPrefixReference)result.Value[3]).Prefix ?? "", Is.EqualTo(""));
            Assert.That(((BindingLiteral)result.Value[4]).Text, Is.EqualTo("*)"));
        }
Exemplo n.º 3
0
        public void MixedResultsComeBackAtTheRightPlaces()
        {
            var grammar = new BindingGrammar();
            var result  = grammar.Nodes(Source("Html.ActionLink(@caption, @action)"));

            Assert.That(result.Value.Count(), Is.EqualTo(5));

            Assert.That(((BindingLiteral)result.Value[0]).Text, Is.EqualTo("Html.ActionLink("));
            Assert.That(((BindingNameReference)result.Value[1]).Name, Is.EqualTo("caption"));
            Assert.That(((BindingLiteral)result.Value[2]).Text, Is.EqualTo(", "));
            Assert.That(((BindingNameReference)result.Value[3]).Name, Is.EqualTo("action"));
            Assert.That(((BindingLiteral)result.Value[4]).Text, Is.EqualTo(")"));
        }
Exemplo n.º 4
0
        public void BothBracesMustBePresentToMatch()
        {
            var grammar = new BindingGrammar();
            var result  = grammar.Nodes(Source("a{{@*@hello*}}b"));

            Assert.That(result.Value.Count(), Is.EqualTo(4));
            var a      = (BindingLiteral)result.Value[0];
            var match1 = (BindingPrefixReference)result.Value[1];
            var match2 = (BindingPrefixReference)result.Value[2];
            var b      = (BindingLiteral)result.Value[3];

            Assert.That(a.Text, Is.EqualTo("a{{"));
            Assert.That(b.Text, Is.EqualTo("}}b"));
            Assert.That(match1.Prefix, Is.Null);
            Assert.That(match2.Prefix, Is.EqualTo("hello"));
            Assert.That(match1.AssumeDictionarySyntax, Is.False);
            Assert.That(match2.AssumeDictionarySyntax, Is.False);
        }
Exemplo n.º 5
0
        public void BracesMayAppearAroundStrings()
        {
            var grammar = new BindingGrammar();
            var result  = grammar.Nodes(Source("a{{'@*'}}{{\"@hello*\"}}b"));

            Assert.That(result.Value.Count(), Is.EqualTo(4));
            var a      = (BindingLiteral)result.Value[0];
            var match1 = (BindingPrefixReference)result.Value[1];
            var match2 = (BindingPrefixReference)result.Value[2];
            var b      = (BindingLiteral)result.Value[3];

            Assert.That(a.Text, Is.EqualTo("a"));
            Assert.That(b.Text, Is.EqualTo("b"));
            Assert.That(match1.Prefix, Is.Null);
            Assert.That(match2.Prefix, Is.EqualTo("hello"));
            Assert.That(match1.AssumeDictionarySyntax, Is.True);
            Assert.That(match2.AssumeDictionarySyntax, Is.True);
            Assert.That(match1.AssumeStringValue, Is.True);
            Assert.That(match2.AssumeStringValue, Is.True);
        }
Exemplo n.º 6
0
        public void CurleyBracesAroundWildcardIndicateDictionaryInitializingSyntax()
        {
            var grammar = new BindingGrammar();
            var result  = grammar.Nodes(Source("a{{@*}}{{@hello*}}b"));

            Assert.That(result.Value.Count(), Is.EqualTo(4));
            var a      = (BindingLiteral)result.Value[0];
            var match1 = (BindingPrefixReference)result.Value[1];
            var match2 = (BindingPrefixReference)result.Value[2];
            var b      = (BindingLiteral)result.Value[3];

            Assert.That(a.Text, Is.EqualTo("a"));
            Assert.That(b.Text, Is.EqualTo("b"));
            Assert.That(match1.Prefix, Is.Null);
            Assert.That(match2.Prefix, Is.EqualTo("hello"));
            Assert.That(match1.AssumeDictionarySyntax, Is.True);
            Assert.That(match2.AssumeDictionarySyntax, Is.True);
            Assert.That(match1.AssumeStringValue, Is.False);
            Assert.That(match2.AssumeStringValue, Is.False);
        }
Exemplo n.º 7
0
        public void OptionalQuotesMarkAssumeStringValueAsTrue()
        {
            var grammar = new BindingGrammar();
            var result  = grammar.Nodes(Source("@one'@two'\"@three\"@four.*'@five.*'\"@six.*\""));

            Assert.That(result.Value.Count(), Is.EqualTo(6));
            var one   = (BindingNameReference)result.Value[0];
            var two   = (BindingNameReference)result.Value[1];
            var three = (BindingNameReference)result.Value[2];
            var four  = (BindingPrefixReference)result.Value[3];
            var five  = (BindingPrefixReference)result.Value[4];
            var six   = (BindingPrefixReference)result.Value[5];

            Assert.That(one.AssumeStringValue, Is.False);
            Assert.That(two.AssumeStringValue, Is.True);
            Assert.That(three.AssumeStringValue, Is.True);
            Assert.That(four.AssumeStringValue, Is.False);
            Assert.That(five.AssumeStringValue, Is.True);
            Assert.That(six.AssumeStringValue, Is.True);
        }
Exemplo n.º 8
0
        public void ChildContentCanAppearWithOrWithoutQuotes()
        {
            var grammar = new BindingGrammar();
            var result  = grammar.Nodes(Source("achild::*b'child::*'c\"child::*\"d"));

            Assert.That(result.Value.Count(), Is.EqualTo(7));
            var a      = (BindingLiteral)result.Value[0];
            var child1 = (BindingChildReference)result.Value[1];
            var b      = (BindingLiteral)result.Value[2];
            var child2 = (BindingChildReference)result.Value[3];
            var c      = (BindingLiteral)result.Value[4];
            var child3 = (BindingChildReference)result.Value[5];
            var d      = (BindingLiteral)result.Value[6];

            Assert.That(a.Text, Is.EqualTo("a"));
            Assert.That(b.Text, Is.EqualTo("b"));
            Assert.That(c.Text, Is.EqualTo("c"));
            Assert.That(d.Text, Is.EqualTo("d"));
            Assert.That(child1, Is.Not.Null);
            Assert.That(child2, Is.Not.Null);
            Assert.That(child3, Is.Not.Null);
        }