예제 #1
0
        public void RelativeAllTest_AddFrame_CurrentUpdated()
        {
            Context target;
            var     obj = CreateTarget(out target);

            var expr = new ExpressionIs(new KnowledgeRelation {
                Subject = "Lawyer", Relation = "Occupation of", Target = obj.ToString()
            });
            var actual = target.Evaluate(expr);

            Assert.AreEqual(EvaluationResult.True, actual);
        }
예제 #2
0
        public void VariableNotEqual()
        {
            // Arrange
            var variableA = new Variable("a", false, Types.GetTypeShim(typeof(string), true));
            var ifParser  = CreateParser <EqualParser>("a != null", variableA);

            // Act
            var result = (NotEqual)ifParser.Parse();

            // Assert
            Assert.That(result, ExpressionIs.EqualTo(new NotEqual(variableA, Constant.Null)));
        }
예제 #3
0
        public void RelativeAllTest_All_NotSure()
        {
            Context target;
            var     obj = CreateTarget(out target);

            var expr = new ExpressionIs(new KnowledgeRelation
            {
                Subject  = "Undercut",
                Relation = "Hair style of",
                Target   = obj.ToString()
            });
            var rel    = new RelativeAll(expr);
            var actual = target.Evaluate(rel);

            Assert.AreEqual(EvaluationResult.NotSure, actual);
        }
예제 #4
0
        public void RelativeAllTest_All_False()
        {
            Context target;
            var     obj = CreateTarget(out target);

            var expr = new ExpressionIs(new KnowledgeRelation
            {
                Subject  = "Lawyer",
                Relation = "Occupation of",
                Target   = obj.ToString()
            });
            var rel    = new RelativeAll(expr);
            var actual = target.Evaluate(rel);

            Assert.AreEqual(EvaluationResult.False, actual);
        }
예제 #5
0
        public void RelativeBeforeTest_RightNotSure_NotSure()
        {
            Context target;
            var     obj = CreateTarget(out target);

            var expr1 = new ExpressionIs(new KnowledgeRelation {
                Subject = "Undercut", Relation = "Hair style of", Target = obj.ToString()
            });
            var expr2 = new ExpressionIs(new KnowledgeRelation {
                Subject = "Lawyer", Relation = "Occupation of", Target = obj.ToString()
            });
            var relative = new RelativeBefore(expr2, expr1);
            var actual   = target.Evaluate(relative);

            Assert.AreEqual(EvaluationResult.NotSure, actual);
        }
예제 #6
0
        public void RelativeBeforeTest_True()
        {
            Context target;
            var     obj = CreateTarget(out target);

            var expr1 = new ExpressionIs(new KnowledgeRelation {
                Subject = "Student", Relation = "Occupation of", Target = obj.ToString()
            });
            var expr2 = new ExpressionIs(new KnowledgeRelation {
                Subject = "Lawyer", Relation = "Occupation of", Target = obj.ToString()
            });
            var relative = new RelativeBefore(expr1, expr2);
            var actual   = target.Evaluate(relative);

            Assert.AreEqual(EvaluationResult.True, actual);
        }