Пример #1
0
        public void ReturnOwnSignsOnlyIfNoRecursion()
        {
            // arrange
            var language        = Language.Default;
            var semanticNetwork = new TestSemanticNetwork(language);

            var ownSign = ConceptCreationHelper.CreateConcept();

            ownSign.WithAttribute(IsSignAttribute.Value);
            semanticNetwork.SemanticNetwork.Concepts.Add(ownSign);

            var ownSignStatement = semanticNetwork.SemanticNetwork.DeclareThat(semanticNetwork.Vehicle_Motorcycle).HasSign(ownSign);

            var questionOwnSign       = new HasSignsQuestion(semanticNetwork.Base_Vehicle, false);
            var questionInheritedSign = new HasSignsQuestion(semanticNetwork.Vehicle_Motorcycle, false);

            // act
            var answerOwnSign       = questionOwnSign.Ask(semanticNetwork.SemanticNetwork.Context);
            var answerInheritedSign = questionInheritedSign.Ask(semanticNetwork.SemanticNetwork.Context);

            // assert
            Assert.IsFalse(answerOwnSign.IsEmpty);
            Assert.IsTrue(((BooleanAnswer)answerOwnSign).Result);
            Assert.AreEqual(2, answerOwnSign.Explanation.Statements.Count);

            Assert.IsFalse(answerInheritedSign.IsEmpty);
            Assert.IsTrue(((BooleanAnswer)answerInheritedSign).Result);
            Assert.AreSame(ownSignStatement, answerInheritedSign.Explanation.Statements.Single());
        }
Пример #2
0
        public void TestBuildingIfHasSigns()
        {
            // arrange
            var language        = Language.Default;
            var semanticNetwork = new TestSemanticNetwork(language);

            // act
            var questionRegular = new HasSignsQuestion(semanticNetwork.Vehicle_Car, true);
            var answerRegular   = (BooleanAnswer)questionRegular.Ask(semanticNetwork.SemanticNetwork.Context);

            var answerBuilder = (BooleanAnswer)semanticNetwork.SemanticNetwork.Ask().IfHasSigns(semanticNetwork.Vehicle_Car);

            // assert
            Assert.AreEqual(answerRegular.Result, answerBuilder.Result);
            Assert.IsTrue(answerRegular.Explanation.Statements.SequenceEqual(answerBuilder.Explanation.Statements));
        }
Пример #3
0
        public void ReturnEmptyAnswerIfThereAreParentSignsButNotRecursive()
        {
            // arrange
            var language        = Language.Default;
            var semanticNetwork = new TestSemanticNetwork(language);

            var question = new HasSignsQuestion(semanticNetwork.Vehicle_Motorcycle, false);

            // act
            var answer = question.Ask(semanticNetwork.SemanticNetwork.Context);

            // assert
            Assert.IsFalse(answer.IsEmpty);
            Assert.IsFalse(((BooleanAnswer)answer).Result);
            Assert.AreEqual(0, answer.Explanation.Statements.Count);
        }
Пример #4
0
        public void ReturnEmptyAnswerIfNoSigns()
        {
            // arrange
            var language        = Language.Default;
            var semanticNetwork = new TestSemanticNetwork(language).SemanticNetwork;

            var questionWithoutRecursion = new HasSignsQuestion(LogicalValues.True, false);

            // act
            var answerWithoutRecursion = questionWithoutRecursion.Ask(semanticNetwork.Context);
            var answerWithRecursion    = semanticNetwork.Ask().IfHasSigns(LogicalValues.True);

            // assert
            Assert.IsFalse(answerWithoutRecursion.IsEmpty);
            Assert.IsFalse(((BooleanAnswer)answerWithoutRecursion).Result);
            Assert.AreEqual(0, answerWithoutRecursion.Explanation.Statements.Count);

            Assert.IsFalse(answerWithRecursion.IsEmpty);
            Assert.IsFalse(((BooleanAnswer)answerWithRecursion).Result);
            Assert.AreEqual(0, answerWithRecursion.Explanation.Statements.Count);
        }