示例#1
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);
        }
示例#2
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>();
        }
示例#3
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);
        }