Example #1
0
        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());
        }
Example #2
0
        private static WorkingGraph CreateSmallTestgraph()
        {
            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),
                graph.CreateDependency(b, c, null, "", 1),
                graph.CreateDependency(b, d, null, "", 1)
            });

            return(graph);
        }
Example #3
0
        private static WorkingGraph CreateGraphWithLongTail()
        {
            var          gc    = new GlobalContext();
            WorkingGraph graph = gc.CurrentGraph;
            ItemType     g2    = ItemType.Generic(2, ignoreCase: true);
            Item         a     = graph.CreateItem(g2, "a:");
            Item         b     = graph.CreateItem(g2, "b:0");
            Item         c     = graph.CreateItem(g2, "c:");
            Item         b1    = graph.CreateItem(g2, "b:1");
            Item         b2    = graph.CreateItem(g2, "b:2");
            Item         b3    = graph.CreateItem(g2, "b:3");
            Item         b4    = graph.CreateItem(g2, "b:4");
            Item         b5    = graph.CreateItem(g2, "b:5");

            graph.AddDependencies(new[] {
                graph.CreateDependency(a, b, null, "", 1), graph.CreateDependency(b, b, null, "", 1),
                graph.CreateDependency(b, c, null, "", 1), graph.CreateDependency(b, b1, null, "", 1),
                graph.CreateDependency(b1, b2, null, "", 1), graph.CreateDependency(b2, b3, null, "", 1),
                graph.CreateDependency(b3, b4, null, "", 1), graph.CreateDependency(b4, b5, null, "", 1),
            });
            return(graph);
        }