Exemplo n.º 1
0
 public void DependencyGraphCircular()
 {
     var g = new PvcDependencyGraph();
     g.AddDependencies("A", new string[] { "B", "C" });
     g.AddDependency("B", "C");
     g.AddDependency("C", "B");
     Assert.Throws<PvcCircularDependencyException>(() =>
     {
         var paths = g.GetPaths("A");
     });
     try
     {
         var paths = g.GetPaths("A");
     }
     catch (PvcCircularDependencyException e)
     {
         Assert.Equal(e.CircularPath.Count, 4);
         Assert.Equal(e.CircularPath[0], "A");
         Assert.Equal(e.CircularPath[1], "B");
         Assert.Equal(e.CircularPath[2], "C");
         Assert.Equal(e.CircularPath[3], "B");
     }
 }
Exemplo n.º 2
0
        public void DependencyGraphSimpleChain()
        {
            var g = new PvcDependencyGraph();
            g.AddDependency("A", "B");
            g.AddDependency("B", "C");
            var paths = g.GetPaths("A");
            CheckPaths(g, paths);

            var pathstrings = paths.Select(p => string.Join(" ", p)).ToList();

            Assert.Equal(1, pathstrings.Count);
            Assert.Contains("C B A", pathstrings);
        }
Exemplo n.º 3
0
 public void DependencyGraphMultipleBranches()
 {
     var g = new PvcDependencyGraph();
     g.AddDependencies("A", new string[] { "B", "C" });
     g.AddDependency("B", "D");
     g.AddDependency("C", "E");
     g.AddDependency("E", "F");
     g.AddDependency("E", "G");
     var paths = g.GetPaths("A");
     CheckPaths(g, paths);
     Assert.Equal(12, paths.Count);
 }
Exemplo n.º 4
0
        public void DependencyGraphRemovesExtraNodes()
        {
            var g = new PvcDependencyGraph();
            g.AddDependency("A", "B");
            // These two aren't actually part of the graph for A.
            g.AddDependency("C", "D");
            // This depends on A, so shouldn't be included in the dependencies for A.
            g.AddDependency("Z", "A");

            var paths = g.GetPaths("A");
            CheckPaths(g, paths);

            Assert.Equal(1, paths.Count);
            Assert.Equal(2, paths[0].Count);
        }
Exemplo n.º 5
0
 public void DependencyGraphHugeBranchesWithMoreBranching()
 {
     var g = new PvcDependencyGraph();
     g.AddDependencies("A", new string[] { "B", "C", "D", "E", "F", "G", "H", "I" });
     g.AddDependency("F", "J");
     g.AddDependency("F", "K");
     var paths = g.GetPaths("A");
     CheckPaths(g, paths);
     Assert.Equal(1, paths.Count);
 }