Exemple #1
0
        public void ReturnEmptyAnswerIfThereAreParentSignsButNotRecursive()
        {
            // arrange
            var language        = Language.Default;
            var semanticNetwork = new TestSemanticNetwork(language);

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

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

            // assert
            Assert.IsTrue(answer.IsEmpty);
            Assert.AreEqual(0, answer.Explanation.Statements.Count);
        }
Exemple #2
0
        public void TestBuildingWhichSignsHas()
        {
            // arrange
            var language        = Language.Default;
            var semanticNetwork = new TestSemanticNetwork(language);

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

            var answerBuilder = (ConceptsAnswer)semanticNetwork.SemanticNetwork.Ask().WhichSignsHas(semanticNetwork.Vehicle_Car);

            // assert
            Assert.IsTrue(answerRegular.Result.SequenceEqual(answerBuilder.Result));
            Assert.IsTrue(answerRegular.Explanation.Statements.SequenceEqual(answerBuilder.Explanation.Statements));
        }
Exemple #3
0
        public void ReturnParentOnlySignsIfRecursive()
        {
            // arrange
            var language        = Language.Default;
            var semanticNetwork = new TestSemanticNetwork(language);

            var question = new EnumerateSignsQuestion(semanticNetwork.Vehicle_Motorcycle, true);

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

            // assert
            Assert.IsFalse(answer.IsEmpty);
            Assert.AreEqual(2, answer.Result.Count);
            Assert.AreEqual(1, answer.Explanation.Statements.OfType <IsStatement>().Count());
            Assert.AreEqual(2, answer.Explanation.Statements.OfType <HasSignStatement>().Count());
        }
Exemple #4
0
        public void ReturnEmptyAnswerIfNoSigns()
        {
            // arrange
            var language        = Language.Default;
            var semanticNetwork = new TestSemanticNetwork(language).SemanticNetwork;

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

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

            // assert
            Assert.IsTrue(answerWithoutRecursion.IsEmpty);
            Assert.AreEqual(0, answerWithoutRecursion.Explanation.Statements.Count);

            Assert.IsTrue(answerWithRecursion.IsEmpty);
            Assert.AreEqual(0, answerWithRecursion.Explanation.Statements.Count);
        }
Exemple #5
0
        public void ReturnOwnSignsOnly()
        {
            // 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(ownSign).IsSignOf(semanticNetwork.Vehicle_Motorcycle);

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

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

            // assert
            Assert.IsFalse(answer.IsEmpty);
            Assert.AreSame(ownSign, answer.Result.Single());
            Assert.AreSame(ownSignStatement, answer.Explanation.Statements.Single());
        }