Ejemplo n.º 1
0
        public void CommonPluralNounConstructorTest()
        {
            var text   = "clowns";
            var target = new CommonPluralNoun(text);

            Check.That(target.Text).IsEqualTo(text);
        }
Ejemplo n.º 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";
        }
Ejemplo n.º 3
0
        public void BindSubjectTest()
        {
            var     target  = CreateVerbPhraseHelp();
            IEntity subject = new CommonPluralNoun("cats");

            target.BindSubject(subject);
            Check.That(target.HasSubject(e => e == subject)).IsTrue();
        }
Ejemplo n.º 4
0
        public void JoinedRightTest()
        {
            IEnumerable <Word> composedWords = new[] { new Conjunction("and") };
            var      target   = new ConjunctionPhrase(composedWords);
            ILexical expected = new CommonPluralNoun("pies");
            ILexical actual;

            target.JoinedRight = expected;
            actual             = target.JoinedRight;
            Check.That(actual).IsEqualTo(expected);
        }
Ejemplo n.º 5
0
        public void QuantifiedByTest()
        {
            var         text     = "clowns";
            var         target   = new CommonPluralNoun(text);
            IQuantifier expected = new Quantifier("all");
            IQuantifier actual;

            target.QuantifiedBy = expected;
            actual = target.QuantifiedBy;
            Check.That(actual).IsEqualTo(expected);
        }
Ejemplo n.º 6
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();
        }
Ejemplo n.º 7
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();
        }
Ejemplo n.º 8
0
        public void HasIndirectObjectTest()
        {
            var     target = CreateVerbPhraseHelp();
            IEntity entity = new CommonPluralNoun("cats");

            target.BindIndirectObject(entity);

            var  expected = true;
            bool actual;

            actual = target.HasIndirectObject(predicate);
            Check.That(actual).IsEqualTo(expected);

            bool predicate(IEntity e) => e.Text == "cats";
        }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
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);
        }
Ejemplo n.º 11
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);
        }