Example #1
0
        public void PastTenseVerbConstructorTest()
        {
            var text   = "had";
            var target = new PastTenseVerb(text);

            Check.That(target.Text).IsEqualTo(text);
        }
Example #2
0
        public void OnTest2()
        {
            IVerbal          relator    = new PastTenseVerb("walked");
            ActionsRelatedOn?relatorSet = new ActionsRelatedOn(new[] { relator });
            var actual = RelationshipInferenceExtensions.On(relatorSet, relator);

            Check.That(actual).IsTrue();
        }
Example #3
0
        public void OnTest1()
        {
            ActionsRelatedOn?relatorSet = null;
            IVerbal          relator    = new PastTenseVerb("walked");
            var actual = RelationshipInferenceExtensions.On(relatorSet, relator);

            Check.That(actual).IsFalse();
        }
Example #4
0
        public void BindIndirectObjectTest()
        {
            var     text           = "gave";
            Verb    target         = new PastTenseVerb(text);
            IEntity indirectObject = new PersonalPronoun("him");

            target.BindIndirectObject(indirectObject);

            Check.That(target.IndirectObjects).Contains(indirectObject).And.HasSize(1);
        }
Example #5
0
        public void OnLeftSideTest()
        {
            var      target   = new ParticlePhrase(new Particle("away"));
            ILexical expected = new PastTenseVerb("gave");
            ILexical actual;

            target.ToTheLeftOf = expected;
            actual             = target.ToTheLeftOf;
            Check.That(actual).IsEqualTo(expected);
        }
Example #6
0
        public void IndirectObjectOfTest()
        {
            var     target   = new CommonSingularNoun("dog");
            IVerbal expected = new PastTenseVerb("gave");

            target.BindAsIndirectObjectOf(expected);
            var actual = target.IndirectObjectOf;

            Check.That(actual).IsEqualTo(expected);
        }
Example #7
0
        public void BindDirectObjectTest()
        {
            var     text         = "gave";
            Verb    target       = new PastTenseVerb(text);
            IEntity directObject = new NounPhrase(new Determiner("a"), new CommonSingularNoun("cake"));

            target.BindDirectObject(directObject);

            Check.That(target.DirectObjects).Contains(directObject).And.HasSize(1);
        }
Example #8
0
        public void ToTheRightOfTest()
        {
            var      text     = "into";
            var      target   = new Preposition(text);
            ILexical expected = new PastTenseVerb("gazed");
            ILexical actual;

            target.ToTheRightOf = expected;
            actual = target.ToTheRightOf;
            Check.That(actual).IsEqualTo(expected);
        }
Example #9
0
        public void IndirectObjectOfTest()
        {
            var text   = "him";
            var target = new PersonalPronoun(text);
            var verbal = new PastTenseVerb("frightened");

            target.BindAsIndirectObjectOf(verbal);
            var actual = target.IndirectObjectOf;

            Check.That(actual).IsEqualTo(verbal);
        }
Example #10
0
        public void DirectObjectOfTest()
        {
            var     text     = "him";
            var     target   = new PersonalPronoun(text);
            IVerbal expected = new PastTenseVerb("frightened");

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

            Check.That(actual.Match((IVerbal x) => x.Text)).IsEqualTo(expected.Text);
        }
Example #11
0
        public void SubjectOfTest()
        {
            var     text     = "him";
            var     target   = new PersonalPronoun(text);
            IVerbal expected = new PastTenseVerb("frightened");

            target.BindAsSubjectOf(expected);
            var actual = target.SubjectOf;

            Check.That(actual).IsEqualTo(expected);
        }
Example #12
0
        public void ToTheLeftOfTest()
        {
            var      text     = "about";
            var      target   = new Particle(text);
            ILexical expected = new PastTenseVerb("walked");
            ILexical actual;

            target.ToTheLeftOf = expected;
            actual             = target.ToTheLeftOf;
            Check.That(actual).IsEqualTo(expected);
        }
Example #13
0
        public void BindObjectTest()
        {
            var      text   = "about";
            var      target = new Particle(text);
            ILexical prepositionalObject = new NounPhrase(new Determiner("the"), new CommonPluralNoun("grounds"));

            target.BindObject(prepositionalObject);
            Check.That(prepositionalObject).IsEqualTo(target.BoundObject);
            IVerbal verbal = new PastTenseVerb("walked");

            verbal.AttachObjectViaPreposition(target);
            Check.That(prepositionalObject).IsEqualTo(verbal.ObjectOfThePreposition);
        }
Example #14
0
        public void SetRelationshipLookupTest1()
        {
            IEntity entity1 = new ProperSingularNoun("John");
            IVerbal verb    = new PastTenseVerb("walked");
            IEntity entity2 = new NounPhrase(new Determiner("the"), new CommonSingularNoun("store"));

            verb.BindSubject(entity1);
            verb.BindDirectObject(entity2);
            IEnumerable <IVerbal> domain = new[] { verb };
            IRelationshipLookup <IEntity, IVerbal> relationshipLookup = CreateRelationshipLookup(domain);

            // Without calling RelationShipInferenceExtensions.SetRelationshipLookup(entity1, relationshipLookup) beforehand
            Check.ThatCode(() => entity1.IsRelatedTo(entity2)).Throws <InvalidOperationException>();
        }
Example #15
0
        public void ModifiersTest()
        {
            var  text   = "attacked";
            Verb target = new PastTenseVerb(text);
            IEnumerable <IAdverbial> actual;

            actual = target.AdverbialModifiers;
            Check.That(actual).IsEmpty();
            IAdverbial modifier = new Adverb("swiftly");

            target.ModifyWith(modifier);
            actual = target.AdverbialModifiers;
            Check.That(actual).Contains(modifier);
            Check.That(modifier.Modifies).Equals(target);
        }
Example #16
0
        public void SetRelationshipLookupTest4()
        {
            IEntity entity1 = new ProperSingularNoun("John");
            IVerbal verb    = new PastTenseVerb("walked");
            IEntity entity2 = new NounPhrase(new Determiner("the"), new CommonSingularNoun("store"));

            verb.BindSubject(entity1);
            verb.BindDirectObject(entity2); IEnumerable <IVerbal> domain = new[] { verb };
            IRelationshipLookup <IEntity, IVerbal> relationshipLookup    = CreateRelationshipLookup(domain);

            RelationshipInferenceExtensions.SetRelationshipLookup(entity1, relationshipLookup);
            ActionsRelatedOn?actual;

            actual = entity1.IsRelatedTo(new NounPhrase(new Determiner("the"), new CommonSingularNoun("store")));
            Check.That(actual).IsNull();// After calling RelationShipInferenceExtensions.SetRelationshipLookup(entity1, relationshipLookup);
        }
Example #17
0
        public void HasSubjectTest()
        {
            var  text   = "hired";
            Verb target = new PastTenseVerb(text);

            Check.That(target.HasSubject()).IsFalse();
            target.BindSubject(new PersonalPronoun("him"));
            Func <IEntity, bool> predicate = s => s.Text == "her";
            var  expected = false;
            bool actual;

            actual = target.HasSubject(predicate);
            Check.That(actual).Equals(expected);
            target.BindSubject(new PersonalPronoun("her"));
            expected = true;
            actual   = target.HasSubject(predicate);
            Check.That(actual).Equals(expected);
        }