Exemplo n.º 1
0
 public void NonEmptyTest3()
 {
     DependencyGraph t = new DependencyGraph();
     t.AddDependency("a", "b");
     t.AddDependency("a", "c");
     t.AddDependency("d", "c");
     Assert.IsFalse(t.HasDependees("a"));
     Assert.IsTrue(t.HasDependees("b"));
     Assert.IsTrue(t.HasDependents("a"));
     Assert.IsTrue(t.HasDependees("c"));
 }
Exemplo n.º 2
0
 public void EmptyTest2()
 {
     DependencyGraph t = new DependencyGraph();
     Assert.IsFalse(t.HasDependees("a"));
 }
Exemplo n.º 3
0
 public void NonEmptyTest18()
 {
     DependencyGraph t = new DependencyGraph();
     t.AddDependency("x", "b");
     t.AddDependency("a", "z");
     t.ReplaceDependents("b", new HashSet<string>());
     t.AddDependency("y", "b");
     t.ReplaceDependents("a", new HashSet<string>() { "c" });
     t.AddDependency("w", "d");
     t.ReplaceDependees("b", new HashSet<string>() { "a", "c" });
     t.ReplaceDependees("d", new HashSet<string>() { "b" });
     Assert.IsTrue(t.HasDependents("a"));
     Assert.IsFalse(t.HasDependees("a"));
     Assert.IsTrue(t.HasDependents("b"));
     Assert.IsTrue(t.HasDependees("b"));
 }
Exemplo n.º 4
0
 public void NonEmptyTest13()
 {
     DependencyGraph t = new DependencyGraph();
     t.AddDependency("x", "y");
     t.AddDependency("a", "b");
     t.AddDependency("a", "c");
     t.AddDependency("a", "d");
     t.AddDependency("c", "b");
     t.RemoveDependency("a", "d");
     t.AddDependency("e", "b");
     t.AddDependency("b", "d");
     t.RemoveDependency("e", "b");
     t.RemoveDependency("x", "y");
     Assert.IsTrue(t.HasDependents("a"));
     Assert.IsFalse(t.HasDependees("a"));
     Assert.IsTrue(t.HasDependents("b"));
     Assert.IsTrue(t.HasDependees("b"));
 }
Exemplo n.º 5
0
 public void EmptyTest8()
 {
     DependencyGraph t = new DependencyGraph();
     t.AddDependency("x", "y");
     Assert.IsTrue(t.HasDependees("y"));
     Assert.IsTrue(t.HasDependents("x"));
     t.RemoveDependency("x", "y");
     Assert.IsFalse(t.HasDependees("y"));
     Assert.IsFalse(t.HasDependents("x"));
 }
Exemplo n.º 6
0
        public void MyTest11()
        {
            DependencyGraph t = new DependencyGraph();
            t.AddDependency("b", "b");
            t.ReplaceDependents("b", new HashSet<string>() { "c" });
            Assert.IsTrue(t.HasDependees("c"));

        }
Exemplo n.º 7
0
        public void MyTest()
        {
            DependencyGraph t = new DependencyGraph();
            t.AddDependency("a", "b");
            t.AddDependency("a", "c");
            t.AddDependency("b", "d");
            t.AddDependency("d", "d");
            Assert.IsTrue(t.GetDependents("a").ToHashSet().SetEquals(new HashSet<string>() { "b", "c" }));
            Assert.IsTrue(t.GetDependents("b").ToHashSet().SetEquals(new HashSet<string>() { "d" }));
            Assert.IsTrue(t.GetDependents("c").ToHashSet().SetEquals(new HashSet<string>() { }));
            Assert.IsTrue(t.GetDependents("d").ToHashSet().SetEquals(new HashSet<string>() { "d" }));
            Assert.IsTrue(t.GetDependees("a").ToHashSet().SetEquals(new HashSet<string>() {  }));
            Assert.IsTrue(t.GetDependees("b").ToHashSet().SetEquals(new HashSet<string>() { "a" }));
            Assert.AreEqual(1, t["b"]);
            Assert.IsTrue(t.GetDependees("c").ToHashSet().SetEquals(new HashSet<string>() { "a" }));
            Assert.IsTrue(t.GetDependees("d").ToHashSet().SetEquals(new HashSet<string>() { "b","d" }));
            Assert.AreEqual(2, t["d"]);
            Assert.AreEqual(0, t["h"]);
            Assert.AreEqual(0, t["a"]);
            Assert.IsFalse(t.HasDependees("a"));
            Assert.IsFalse(t.HasDependees("f"));
            Assert.IsFalse(t.HasDependents("c"));
            Assert.IsTrue(t.HasDependents("a"));
            Assert.IsFalse(t.HasDependents("h"));
            Assert.IsTrue(t.HasDependents("d"));
            Assert.IsTrue(t.HasDependees("b"));
            Assert.IsTrue(t.HasDependees("c")); 
            Assert.IsTrue(t.HasDependees("d"));
            Assert.AreEqual(4, t.Size);


            
            t.RemoveDependency("a", "b");
            Assert.IsTrue(t.GetDependents("a").ToHashSet().SetEquals(new HashSet<string>() { "c" }));
            Assert.IsTrue(t.GetDependees("b").ToHashSet().SetEquals(new HashSet<string>() {  }));

            t.AddDependency("a", "b");
            t.AddDependency("a", "b");
            t.ReplaceDependents("a", new HashSet<string>() { "x", "y", "x", "y" ,"z"});
            Assert.IsTrue(t.GetDependents("a").ToHashSet().SetEquals(new HashSet<string>() { "x", "y","z"}));
            Assert.AreEqual(5, t.Size);


            t.ReplaceDependees("b", new HashSet<string>() { "x", "y", "x", "y" });
            Assert.IsTrue(t.GetDependees("b").ToHashSet().SetEquals(new HashSet<string>() { "x", "y" }));
            Assert.AreEqual(7, t.Size);
            Assert.AreEqual(2, t["b"]);
           

            //Assert.AreEqual(4, t.Size);
        }