예제 #1
0
 public void TestNoCycleInDirectedGraph()
 {
     using (var env = new TestEnvironment())
     {
         env.CreateRepo("A", new Dictionary <string, DepsData>
         {
             { "full-build", new DepsData(null, new List <Dep> {
                     new Dep("B"), new Dep("C")
                 }) }
         });
         env.CreateRepo("B", new Dictionary <string, DepsData>
         {
             { "full-build", new DepsData(null, new List <Dep> {
                     new Dep("D")
                 }) }
         });
         env.CreateRepo("C", new Dictionary <string, DepsData>
         {
             { "full-build", new DepsData(null, new List <Dep> {
                     new Dep("D")
                 }) }
         });
         env.CreateRepo("D", new Dictionary <string, DepsData>
         {
             { "full-build", new DepsData(null, new List <Dep>()) }
         });
         Helper.SetWorkspace(env.RemoteWorkspace);
         var cycle = CycleDetector.TryFindCycle("A");
         Assert.IsNull(cycle);
     }
 }
예제 #2
0
 public void TestCycleWithTwoWays()
 {
     using (var env = new TestEnvironment())
     {
         env.CreateRepo("A", new Dictionary <string, DepsData>
         {
             { "full-build", new DepsData(null, new List <Dep> {
                     new Dep("B"), new Dep("C")
                 }) }
         });
         env.CreateRepo("C", new Dictionary <string, DepsData>
         {
             { "full-build", new DepsData(null, new List <Dep> {
                     new Dep("D")
                 }) }
         });
         env.CreateRepo("D", new Dictionary <string, DepsData>
         {
             { "full-build", new DepsData(null, new List <Dep> {
                     new Dep("C")
                 }) }
         });
         Helper.SetWorkspace(env.RemoteWorkspace);
         var cycle = CycleDetector.TryFindCycle("A");
         Assert.AreEqual(new[] { "A/full-build", "C/full-build", "D/full-build", "C/full-build" }, cycle.ToArray());
     }
 }
예제 #3
0
 public void TestFindAnyCycleFromManyCycles()
 {
     using (var env = new TestEnvironment())
     {
         env.CreateRepo("A", new Dictionary <string, DepsContent>
         {
             { "full-build", new DepsContent(null, new List <Dep> {
                     new Dep("B"), new Dep("C")
                 }) }
         });
         env.CreateRepo("B", new Dictionary <string, DepsContent>
         {
             { "full-build", new DepsContent(null, new List <Dep> {
                     new Dep("D")
                 }) }
         });
         env.CreateRepo("C", new Dictionary <string, DepsContent>
         {
             { "full-build", new DepsContent(null, new List <Dep> {
                     new Dep("D")
                 }) }
         });
         env.CreateRepo("D", new Dictionary <string, DepsContent>
         {
             { "full-build", new DepsContent(null, new List <Dep> {
                     new Dep("A")
                 }) }
         });
         Helper.SetWorkspace(env.RemoteWorkspace);
         var cycle = CycleDetector.TryFindCycle("A");
         Assert.IsNotNull(cycle);
     }
 }
예제 #4
0
 public void TestSimpleCycle()
 {
     using (var env = new TestEnvironment())
     {
         env.CreateRepo("A", new Dictionary <string, DepsContent>
         {
             { "full-build", new DepsContent(null, new List <Dep> {
                     new Dep("B")
                 }) }
         });
         env.CreateRepo("B", new Dictionary <string, DepsContent>
         {
             { "full-build", new DepsContent(null, new List <Dep> {
                     new Dep("A")
                 }) }
         });
         Helper.SetWorkspace(env.RemoteWorkspace);
         var cycle = CycleDetector.TryFindCycle("A");
         Assert.AreEqual(new[] { "A/full-build", "B/full-build", "A/full-build" }, cycle.ToArray());
     }
 }
예제 #5
0
 public void TestNoCycleIfDifferentConfigs()
 {
     using (var env = new TestEnvironment())
     {
         env.CreateRepo("A", new Dictionary <string, DepsData>
         {
             { "full-build", new DepsData(null, new List <Dep> {
                     new Dep("B")
                 }) },
             { "client", new DepsData(null, new List <Dep>()) }
         });
         env.CreateRepo("B", new Dictionary <string, DepsData>
         {
             { "full-build", new DepsData(null, new List <Dep> {
                     new Dep("A", null, "client")
                 }) }
         });
         Helper.SetWorkspace(env.RemoteWorkspace);
         var cycle = CycleDetector.TryFindCycle("A/full-build");
         Assert.IsNull(cycle);
     }
 }
예제 #6
0
 public void TestCycleWithDefaultConfig()
 {
     using (var env = new TestEnvironment())
     {
         env.CreateRepo("A", new Dictionary <string, DepsData>
         {
             { "full-build", new DepsData(null, new List <Dep> {
                     new Dep("B")
                 }) },
             { "client *default", new DepsData(null, new List <Dep> {
                     new Dep("B")
                 }) }
         });
         env.CreateRepo("B", new Dictionary <string, DepsData>
         {
             { "full-build", new DepsData(null, new List <Dep> {
                     new Dep("A", null, "full-build")
                 }) }
         });
         Helper.SetWorkspace(env.RemoteWorkspace);
         var cycle = CycleDetector.TryFindCycle("A");
         Assert.AreEqual(new[] { "A/client", "B/full-build", "A/full-build", "B/full-build" }, cycle);
     }
 }