public void TestFindAllGraphs() { // All graphs in a->b-->b1->b2->b3->b4->b5 // / \\_ // +-+ \->c // are: WorkingGraph graph = CreateGraphWithLongTail(); var traverser = new TestTraverser(graph.VisibleDependencies, new PathRegex(":(.:)*")); traverser.Traverse(graph.VisibleDependencies.First().UsingItem); Assert.AreEqual(15, traverser.RecordedPaths.Count()); AssertRecordedDependenciesContainPath(traverser.RecordedPaths, "a:", "b:0"); AssertRecordedDependenciesContainPath(traverser.RecordedPaths, "a:", "b:0", "b:0"); AssertRecordedDependenciesContainPath(traverser.RecordedPaths, "a:", "b:0", "b:0", "b:0"); AssertRecordedDependenciesContainPath(traverser.RecordedPaths, "a:", "b:0", "b:0", "c:"); AssertRecordedDependenciesContainPath(traverser.RecordedPaths, "a:", "b:0", "b:0", "b:1"); AssertRecordedDependenciesContainPath(traverser.RecordedPaths, "a:", "b:0", "b:0", "b:1", "b:2"); AssertRecordedDependenciesContainPath(traverser.RecordedPaths, "a:", "b:0", "b:0", "b:1", "b:2", "b:3"); AssertRecordedDependenciesContainPath(traverser.RecordedPaths, "a:", "b:0", "b:0", "b:1", "b:2", "b:3", "b:4"); AssertRecordedDependenciesContainPath(traverser.RecordedPaths, "a:", "b:0", "b:0", "b:1", "b:2", "b:3", "b:4", "b:5"); AssertRecordedDependenciesContainPath(traverser.RecordedPaths, "a:", "b:0", "c:"); AssertRecordedDependenciesContainPath(traverser.RecordedPaths, "a:", "b:0", "b:1"); AssertRecordedDependenciesContainPath(traverser.RecordedPaths, "a:", "b:0", "b:1", "b:2"); AssertRecordedDependenciesContainPath(traverser.RecordedPaths, "a:", "b:0", "b:1", "b:2", "b:3"); AssertRecordedDependenciesContainPath(traverser.RecordedPaths, "a:", "b:0", "b:1", "b:2", "b:3", "b:4"); AssertRecordedDependenciesContainPath(traverser.RecordedPaths, "a:", "b:0", "b:1", "b:2", "b:3", "b:4", "b:5"); }
public void TestLoopIsNotEndless() { var gc = new GlobalContext(); WorkingGraph graph = gc.CurrentGraph; Item a = graph.CreateItem(ItemType.SIMPLE, "a"); Item b = graph.CreateItem(ItemType.SIMPLE, "b"); Item c = graph.CreateItem(ItemType.SIMPLE, "c"); Item d = graph.CreateItem(ItemType.SIMPLE, "d"); graph.AddDependencies(new[] { graph.CreateDependency(a, b, null, "", 1), // Loop on b & c; but we never reach d! graph.CreateDependency(b, c, null, "", 1), graph.CreateDependency(c, b, null, "", 1), // Loop on d so that it remains in graph graph.CreateDependency(d, d, null, "", 1) }); // We want to go from a to d - this will never succeed; but we must make sure that // there is no endless loop around b and c. var traverser = new TestTraverser(graph.VisibleDependencies, new PathRegex("a.(b.c.)*d")); traverser.Traverse(a); Assert.AreEqual(0, traverser.RecordedPaths.Count()); }
public void TestCreateSimpleDependencyCountingRegex() { WorkingGraph graph = CreateSmallTestgraph(); var traverser = new TestTraverser(graph.VisibleDependencies, new PathRegex("a.b(.#d)?")); traverser.Traverse(graph.VisibleDependencies.First().UsingItem); Assert.AreEqual(1, traverser.CountedObjects.Distinct().Count()); }
public void TestCreateSimpleRegex() { WorkingGraph graph = CreateSmallTestgraph(); var traverser = new TestTraverser(graph.VisibleDependencies, new PathRegex("a.b(.d)?")); traverser.Traverse(graph.VisibleDependencies.First().UsingItem); Assert.AreEqual(2, traverser.RecordedPaths.Count()); AssertRecordedDependenciesContainPath(traverser.RecordedPaths, "a", "b"); AssertRecordedDependenciesContainPath(traverser.RecordedPaths, "a", "b", "d"); }
public void TestComplexLoopIsFound() { // b-loop in Item-Graph matched by a.b.b.b.c is actually looped 3 times // Better test on a->b-->b->b->b->b... // / \\_ // +-+ \->c ... must loop, but also run along b list and not find an end there! WorkingGraph graph = CreateGraphWithLongTail(); var traverser = new TestTraverser(graph.VisibleDependencies, new PathRegex("a.b.b.b.c")); traverser.Traverse(graph.VisibleDependencies.First().UsingItem); Assert.AreEqual(1, traverser.RecordedPaths.Count()); AssertRecordedDependenciesContainPath(traverser.RecordedPaths, "a", "b:0", "b:0", "b:0", "c"); }
public void TestTraversal() { var traverser = new TestTraverser(); traverser.QueryFullTraversal(); }