예제 #1
0
        public void DirectObjectsTest()
        {
            var target = new BaseVerb("slay");
            IEnumerable <IEntity> actual = target.DirectObjects;

            Check.That(target.DirectObjects).IsEqualTo(actual);
        }
예제 #2
0
        public void HasSubjectOrObjectTest()
        {
            var     text   = "attack";
            Verb    target = new BaseVerb(text);
            IEntity entity = new CommonPluralNoun("monkeys");
            var     rand   = new Random().Next(-1, 2);

            switch (rand)
            {
            case -1:
                target.BindSubject(entity);
                break;

            case 0:
                target.BindDirectObject(entity);
                break;

            case 1:
                target.BindDirectObject(entity);
                break;

            default:
                Check.That(false).IsTrue();
                break;
            }
            var  expected = true;
            bool actual;

            actual = target.HasSubjectOrObject(predicate);
            Check.That(actual).Equals(expected);

            bool predicate(IEntity e) => e.Text == "monkeys";
        }
예제 #3
0
        public void ModifiesTest()
        {
            var quickly = new Adverb("quickly");
            IAdverbialModifiable ran = new BaseVerb("ran");

            quickly.Modifies = ran;
            Check.That(quickly.Modifies).IsEqualTo(ran);
        }
예제 #4
0
        public void GetSynonymsOfVerbIsReflexive()
        {
            Verb walk        = new BaseVerb("walk");
            Verb perambulate = new BaseVerb("perambulate");

            Check.That(walk.GetSynonyms()).Contains("perambulate");
            Check.That(perambulate.GetSynonyms()).Contains("walk");
        }
예제 #5
0
        public void BindDirectObjectTest()
        {
            var     target       = new BaseVerb("slay");
            IEntity directObject = new PersonalPronoun("them");

            target.BindDirectObject(directObject);
            Check.That(target.DirectObjects).Contains(directObject);
        }
예제 #6
0
        public void IsClassifierTest()
        {
            var  text   = "is";
            Verb target = new BaseVerb(text);
            bool isClassifier;

            isClassifier = target.IsClassifier;
            Check.That(isClassifier).IsTrue();
        }
예제 #7
0
        public void TextTest()
        {
            Word   target   = new BaseVerb("run");
            var    expected = "run";
            string actual;

            actual = target.Text;
            Check.That(actual).IsEqualTo(expected);
        }
예제 #8
0
        public void DirectObjectOfTest()
        {
            var     target   = new NounPhrase(new ProperPluralNoun("Americans"), new Conjunction("and"), new ProperPluralNoun("Canadians"));
            IVerbal expected = new BaseVerb("insult");

            target.BindAsDirectObjectOf(expected);
            var actual = target.DirectObjectOf;

            Check.That(actual).IsEqualTo(expected);
        }
예제 #9
0
        public void BindSubjectTest()
        {
            var     text    = "gave";
            Verb    target  = new BaseVerb(text);
            IEntity subject = new PersonalPronoun("he");

            target.BindSubject(subject);

            Check.That(target.Subjects).Contains(subject).And.HasSize(1);
        }
예제 #10
0
        public void ModifyWithTest()
        {
            var        text   = "insulate";
            Verb       target = new BaseVerb(text);
            IAdverbial adv    = new Adverb("sufficiently");

            target.ModifyWith(adv);

            Check.That(target.AdverbialModifiers).Contains(adv).And.HasSize(1);
        }
예제 #11
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());
        }
예제 #12
0
        public void SelectManyTest1()
        {
            var      expectedWord = new BaseVerb("walk");
            ILexical target       = new Clause(new VerbPhrase(expectedWord, new Adverb("briskly")));
            var      result       = from phrase in target.Match()
                                    .Case((Clause c) => c.Phrases.OfVerbPhrase().First())
                                    from word in phrase.Words
                                    select word;

            Assert.Equal(expectedWord, result.First());
        }
예제 #13
0
        public void ModifiesTest()
        {
            var text   = "can";
            var target = new ModalAuxilary(text);
            IModalityModifiable expected = new BaseVerb("do");
            IModalityModifiable actual;

            target.Modifies = expected;
            actual          = target.Modifies;
            Check.That(actual).IsEqualTo(expected);
        }
예제 #14
0
        public void AttachObjectViaPrepositionTest()
        {
            var            text              = "insulate";
            Verb           target            = new BaseVerb(text);
            var            prepositionObject = new NounPhrase(new PersonalPronoun("them"));
            IPrepositional prep              = new Preposition("for");

            prep.BindObject(prepositionObject);
            target.AttachObjectViaPreposition(prep);
            Check.That(target.ObjectOfThePreposition).Equals(prepositionObject);
        }
예제 #15
0
        public void ModalityTest()
        {
            var           text     = "insulate";
            Verb          target   = new BaseVerb(text);
            var           expected = new ModalAuxilary("can");
            ModalAuxilary actual;

            target.Modality = expected;
            actual          = target.Modality;
            Check.That(actual).Equals(expected);
        }
예제 #16
0
        public void VerbConstructorTest()
        {
            var  text   = "insulate";
            Verb target = new BaseVerb(text);

            Check.That(target.Text).Equals(text);
            Check.That(target.Subjects).IsEmpty();
            Check.That(target.DirectObjects).IsEmpty();
            Check.That(target.IndirectObjects).IsEmpty();
            Check.That(target.Modality).IsNull();
            Check.That(target.IsPossessive).IsFalse();
        }
예제 #17
0
        public void SelectManyTest7()
        {
            var      word       = new BaseVerb("walk");
            var      verbPhrase = new VerbPhrase(word, new Adverb("briskly"));
            var      expected   = new { Character = 'w', Word = word, Phrase = verbPhrase };
            ILexical target     = new Clause(verbPhrase);
            var      result     = from phrase in target.Match()
                                  .Case((Clause c) => c.Phrases.OfVerbPhrase().First())
                                  from w in phrase.Words.OfVerb()
                                  select new { Character = w.Text.First(), word = w, Phrase = phrase };

            Assert.Equal(expected.Phrase, result.First().Phrase);
        }
예제 #18
0
        public void SubjectOfTest()
        {
            var target = new AggregateEntity(
                new NounPhrase(new CommonPluralNoun("cats")),
                new NounPhrase(new CommonPluralNoun("dogs"))
                );
            IVerbal expected = new BaseVerb("eat");
            IVerbal actual;

            target.BindAsSubjectOf(expected);
            actual = target.SubjectOf;
            Check.That(actual).IsEqualTo(expected);
        }
예제 #19
0
        public void IsRelatedToOnTest2()
        {
            IEntity performer = new CommonPluralNoun("dogs");
            IEntity receiver  = new CommonPluralNoun("cats");
            IVerbal relator   = new BaseVerb("chase");

            relator.BindSubject(performer);
            relator.BindDirectObject(receiver);
            performer.SetRelationshipLookup(new RelationshipLookup <IEntity, IVerbal>(new[] { relator }, Equals, Equals, Equals));
            var actual = RelationshipInferenceExtensions.IsRelatedTo(receiver, performer).On(relator);

            Check.That(actual).IsTrue();
        }
예제 #20
0
        public void AggregateDirectObjectTest()
        {
            var              text   = "attack";
            Verb             target = new BaseVerb(text);
            IAggregateEntity actual;

            actual = target.AggregateDirectObject;
            Check.That(actual).IsEmpty();
            IEntity directObject = new CommonPluralNoun("monkeys");

            target.BindDirectObject(directObject);
            actual = target.AggregateDirectObject;
            Check.That(new[] { directObject }.Except(actual)).IsEmpty();
        }
예제 #21
0
        public void AggregateDirectObjectTest()
        {
            var target = new BaseVerb("slay");
            IAggregateEntity aggregateObject = new AggregateEntity(
                new NounPhrase(new ProperSingularNoun("John"), new ProperSingularNoun("Smith")),
                new NounPhrase(new PossessivePronoun("his"), new CommonPluralNoun("cats"))
                );

            target.BindDirectObject(aggregateObject);

            var actual = target.AggregateDirectObject;

            Check.That(actual).ContainsExactly(aggregateObject).And.Not.IsNull().And.Not.IsEmpty();
        }
예제 #22
0
        public void SubjectsTest()
        {
            var  text   = "attack";
            Verb target = new BaseVerb(text);
            IEnumerable <IEntity> actual;

            actual = target.Subjects;
            Check.That(actual).IsEmpty();
            IEntity subject = new CommonPluralNoun("chimpanzees");

            target.BindSubject(subject);
            actual = target.Subjects;
            Check.That(actual).Contains(subject);
            Check.That(target.AggregateSubject).Contains(subject);
        }
예제 #23
0
        public void DirectObjectsTest()
        {
            var  text   = "attack";
            Verb target = new BaseVerb(text);
            IEnumerable <IEntity> actual;

            actual = target.IndirectObjects;
            Check.That(actual).IsEmpty();
            IEntity directObject = new CommonPluralNoun("monkeys");

            target.BindDirectObject(directObject);
            actual = target.DirectObjects;
            Check.That(actual).Contains(directObject);
            Check.That(target.AggregateDirectObject).Contains(directObject);
        }
예제 #24
0
        public void IsRelatedToTest()
        {
            IEntity performer = new CommonPluralNoun("dogs");
            IEntity receiver  = new CommonPluralNoun("cats");
            IVerbal relator   = new BaseVerb("chase");

            relator.BindSubject(performer);
            relator.BindDirectObject(receiver);
            performer.SetRelationshipLookup(new RelationshipLookup <IEntity, IVerbal>(new[] { relator }, Equals, Equals, Equals));
            ActionsRelatedOn?expected = new ActionsRelatedOn(new[] { relator });
            ActionsRelatedOn?actual;

            actual = RelationshipInferenceExtensions.IsRelatedTo(performer, receiver);
            Check.That(actual).IsEqualTo(expected);
        }
예제 #25
0
        internal virtual IModalityModifiable CreateIModalityModifiable()
        {
            IModalityModifiable target = new BaseVerb("laugh");

            return(target);
        }
예제 #26
0
        internal virtual IInderectObjectTaker CreateIInderectObjectTaker()
        {
            IInderectObjectTaker target = new BaseVerb("walk");

            return(target);
        }
예제 #27
0
        public void GetSynonymsOfVerbIncludesOwnText()
        {
            Verb heal = new BaseVerb("heal");

            Check.That(heal.GetSynonyms().Contains(heal.Text, StringComparer.OrdinalIgnoreCase)).IsTrue();
        }