コード例 #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);
     }
 }