예제 #1
0
        public void WhereTest1()
        {
            ILexical target = new VerbPhrase(new BaseVerb("walk"), new Adverb("briskly"));
            var      result = from word in target.Match()
                              .Case((VerbPhrase v) => v.Words.OfVerb().First())
                              where word.Text == "run" // false
                              select word;

            Check.That(result).IsEmpty();
        }
예제 #2
0
        public void SelectTest1()
        {
            var      expectedWord = new BaseVerb("walk");
            ILexical target       = new VerbPhrase(expectedWord, new Adverb("briskly"));
            var      result       = from word in target.Match()
                                    .Case((VerbPhrase v) => v.Words.OfVerb().First())
                                    select word;

            Assert.Equal(expectedWord, result.Single());
        }
예제 #3
0
        public void MatchChangingMidwayToLessDerivedResultType1()
        {
            ILexical target = new VerbPhrase(new BaseVerb("walk"), new Adverb("briskly"));
            var      result = target.Match()
                              .Case((VerbPhrase v) => v.Words)
                              .Case((IVerbal v) => new[] { v }.OfType <ILexical>())
                              .Result();

            Check.That(result).IsNotNull().And.Contains(((Phrase)target).Words).Only().InThatOrder();
        }