public void CheckRecursivePaths() { var a = ConceptCreationHelper.CreateConcept(); var b = ConceptCreationHelper.CreateConcept(); var c = ConceptCreationHelper.CreateConcept(); var statementsValid1 = new IStatement[] { new TestPath(a, a), }; var statementsValid2 = new IStatement[] { new TestPath(a, b), new TestPath(b, a), }; var statementsValid3 = new IStatement[] { new TestPath(a, b), new TestPath(b, c), new TestPath(c, a), }; var statementsInvalid = new IStatement[] { new TestPath(a, b), new TestPath(b, b), }; var statementsValid4 = new IStatement[] { new TestPath(a, b), new TestPath(b, c), new TestPath(c, a), }; foreach (var statements in new[] { statementsValid1, statementsValid2, statementsValid3, statementsValid4 }) { Assert.IsTrue(statements.FindPath <IConcept>(typeof(TestPath), a, a).Any()); } Assert.IsFalse(statementsInvalid.FindPath <IConcept>(typeof(TestPath), a, a).Any()); }
public void CheckPathFinding() { var parent1 = ConceptCreationHelper.CreateConcept(); var topMedium1 = ConceptCreationHelper.CreateConcept(); var bottomMedium1 = ConceptCreationHelper.CreateConcept(); var child1 = ConceptCreationHelper.CreateConcept(); var parent2 = ConceptCreationHelper.CreateConcept(); var topMedium2 = ConceptCreationHelper.CreateConcept(); var bottomMedium2 = ConceptCreationHelper.CreateConcept(); var child2 = ConceptCreationHelper.CreateConcept(); var parentNoConnection = ConceptCreationHelper.CreateConcept(); var childNoConnection = ConceptCreationHelper.CreateConcept(); var parent2Path = ConceptCreationHelper.CreateConcept(); var medium2Path1 = ConceptCreationHelper.CreateConcept(); var medium2Path2 = ConceptCreationHelper.CreateConcept(); var child2Path = ConceptCreationHelper.CreateConcept(); var statements = new IStatement[] { new TestPath(parent1, topMedium1), new TestPath(topMedium1, bottomMedium1), new TestPath(bottomMedium1, child1), new TestPath(parent2, topMedium2), new TestPath(topMedium2, bottomMedium2), new TestPath(bottomMedium2, child2), new IsStatement(null, parentNoConnection, childNoConnection), new TestPath(parent2Path, medium2Path1), new TestPath(parent2Path, medium2Path2), new TestPath(medium2Path1, child2Path), new TestPath(medium2Path2, child2Path), }; // valid direct paths Assert.IsTrue(statements.FindPath <IConcept>(typeof(TestPath), parent1, child1).Any()); Assert.IsTrue(statements.FindPath <IConcept>(typeof(TestPath), parent2, child2).Any()); // invalid direct paths Assert.IsFalse(statements.FindPath <IConcept>(typeof(TestPath), parent1, child2).Any()); Assert.IsFalse(statements.FindPath <IConcept>(typeof(TestPath), parent2, child1).Any()); // invalid reverted paths Assert.IsFalse(statements.FindPath <IConcept>(typeof(TestPath), child1, parent1).Any()); Assert.IsFalse(statements.FindPath <IConcept>(typeof(TestPath), child2, parent2).Any()); Assert.IsFalse(statements.FindPath <IConcept>(typeof(TestPath), child1, parent2).Any()); Assert.IsFalse(statements.FindPath <IConcept>(typeof(TestPath), child2, parent1).Any()); // other type path Assert.IsFalse(statements.FindPath <IConcept>(typeof(TestPath), parentNoConnection, childNoConnection).Any()); Assert.IsTrue(statements.FindPath <IConcept>(typeof(IsStatement), parentNoConnection, childNoConnection).Any()); // 2 paths Assert.IsTrue(statements.FindPath <IConcept>(typeof(TestPath), parent2Path, child2Path).Any()); Assert.IsFalse(statements.FindPath <IConcept>(typeof(TestPath), child2Path, parent2Path).Any()); }