Пример #1
0
        public void HasDependents3()
        {
            DependencyGraph dg = new DependencyGraph();

            dg.AddDependency("a", "b");
            dg.AddDependency("a", "c");
            dg.RemoveDependency("a", "c");
            Assert.IsTrue(dg.HasDependents("a"));
            dg.RemoveDependency("a", "b");
            Assert.IsFalse(dg.HasDependents("a"));
        }
Пример #2
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"));
            }
Пример #3
0
        public void HasDependentAndDependee()
        {
            DependencyGraph g = new DependencyGraph();

            g.AddDependency("a", "b");
            g.AddDependency("a", "b");
            Assert.AreEqual(1, g.Size);
            Assert.IsTrue(g.HasDependents("a"));
            Assert.IsTrue(g.HasDependees("b"));
            Assert.IsFalse(g.HasDependees("a"));
            Assert.IsFalse(g.HasDependents("b"));
        }
Пример #4
0
        public void Copy3()
        {
            var d1 = new DependencyGraph();
            var d2 = new DependencyGraph(d1);

            d1.AddDependency("a", "b");
            d2.AddDependency("c", "d");
            Assert.IsTrue(d1.HasDependents("a"));
            Assert.IsFalse(d1.HasDependents("c"));
            Assert.IsFalse(d2.HasDependents("a"));
            Assert.IsTrue(d2.HasDependents("c"));
        }
Пример #5
0
            public void NonEmptyTest3()
            {
                DependencyGraph t = new DependencyGraph();

                t.AddDependency("a", "b");
                t.AddDependency("a", "c");
                t.AddDependency("c", "b");
                t.AddDependency("b", "d");
                Assert.IsTrue(t.HasDependents("a"));
                Assert.IsFalse(t.HasDependees("a"));
                Assert.IsTrue(t.HasDependents("b"));
                Assert.IsTrue(t.HasDependees("b"));
            }
Пример #6
0
        public void NewConstructorTest2()
        {
            DependencyGraph g1 = new DependencyGraph();

            g1.AddDependency("A1", "B1");
            g1.AddDependency("A2", "B2");
            g1.AddDependency("A2", "B1");
            g1.AddDependency("B2", "A1");
            Assert.AreEqual(4, g1.Size);

            DependencyGraph g2 = new DependencyGraph(g1);

            Assert.AreEqual(4, g2.Size);
            g2.RemoveDependency("A1", "B1");

            Assert.AreEqual(3, g2.Size);
            Assert.AreEqual(4, g1.Size);

            Assert.IsTrue(g1.HasDependents("A1"));
            Assert.IsFalse(g2.HasDependents("A1"));

            g1.AddDependency("A3", "B3");
            Assert.AreEqual(5, g1.Size);
            Assert.AreEqual(3, g2.Size);

            g2.AddDependency("A4", "B4");
            Assert.AreEqual(5, g1.Size);
            Assert.AreEqual(4, g2.Size);

            Assert.AreEqual("(A1, B1) (A2, B2) (A2, B1) (B2, A1) (A3, B3)", g1.ToString());
            Assert.AreEqual("(B2, A1) (A2, B2) (A2, B1) (A4, B4)", g2.ToString());
        }
Пример #7
0
        public void HasDependents0()
        {
            DependencyGraph dg = new DependencyGraph();
            string          a  = null;

            Assert.IsFalse(dg.HasDependents(a));
        }
Пример #8
0
            public void EmptyTest2()
            {
                DependencyGraph t = new DependencyGraph();

                Assert.IsFalse(t.HasDependees("x"));
                Assert.IsFalse(t.HasDependents("x"));
            }
Пример #9
0
        public void EmptyGraphTests()
        {
            DependencyGraph g = new DependencyGraph();

            Assert.AreEqual(g.Size, 0);
            Assert.IsFalse(g.HasDependents("a"));
            Assert.IsFalse(g.HasDependees("b"));
        }
Пример #10
0
        public void AddTest3()
        {
            DependencyGraph dg = new DependencyGraph();

            dg.AddDependency("a", "b");
            dg.AddDependency("a", "c");
            dg.AddDependency("a", "c");
            dg.AddDependency("d", "c");
            dg.AddDependency("g", "c");

            Assert.AreEqual(true, dg.HasDependents("a"));
            Assert.AreEqual(true, dg.HasDependees("b"));
            Assert.AreEqual(false, dg.HasDependents("b"));
            Assert.AreEqual(true, dg.HasDependees("c"));
            Assert.AreEqual(true, dg.HasDependents("d"));
            Assert.AreEqual(false, dg.HasDependents("c"));
            Assert.AreEqual(4, dg.Size);
        }
Пример #11
0
        public void RemoveDependency()
        {
            DependencyGraph g = new DependencyGraph();

            g.AddDependency("Dependent", "Dependee");
            g.RemoveDependency("Dependent", "Dependee");
            Assert.IsFalse(g.HasDependents("Dependent"));
            Assert.IsFalse(g.HasDependees("Dependee"));
            Assert.AreEqual(0, g.Size);
        }
Пример #12
0
        public void RemoveDependencyOnEmpty()
        {
            DependencyGraph g = new DependencyGraph();

            g.RemoveDependency("Dependee", "Dependent");
            Assert.IsFalse(g.HasDependees("Dependee"));
            Assert.IsFalse(g.HasDependents("Dependent"));
            Assert.AreEqual(0, g.Size);
            Console.WriteLine(g.ToString());
        }
Пример #13
0
        public void ReplaceMethodsOnEmpty()
        {
            DependencyGraph g = new DependencyGraph();

            g.AddDependency("Dependee", "Dependent");

            List <string> stringList = new List <string>();

            for (int i = 1; i < 11; i++)
            {
                stringList.Add(i + "");
            }

            Assert.IsFalse(g.HasDependees("Dependee"));
            g.ReplaceDependees("Dependee", stringList);
            Assert.IsTrue(g.HasDependees("Dependee"));

            Assert.IsFalse(g.HasDependents("Dependent"));
            g.ReplaceDependents("Dependent", stringList);
            Assert.IsTrue(g.HasDependents("Dependent"));
            Console.WriteLine(g.ToString());
        }
Пример #14
0
        public void ReplaceDependeesOnEmpty()
        {
            List <string> stringList = new List <string>();

            for (int i = 0; i < 10; i++)
            {
                stringList.Add(i + "a");
            }
            DependencyGraph g = new DependencyGraph();

            g.ReplaceDependees("Dependent", stringList);
            Assert.IsFalse(g.HasDependents("0a"));
            Assert.AreEqual(0, g.Size);
        }
Пример #15
0
        public void ReplaceDependees()
        {
            List <string> stringList = new List <string>();

            for (int i = 0; i < 10; i++)
            {
                stringList.Add(i + "a");
            }
            DependencyGraph g = new DependencyGraph();

            g.AddDependency("Dependee", "Dependent");
            g.AddDependency("A", "B");
            stringList.Add("B");
            g.ReplaceDependees("Dependent", stringList);
            Assert.IsTrue(g.HasDependees("Dependent"));
            Assert.IsFalse(g.HasDependents("Dependee"));
            Assert.AreEqual(12, g.Size);
        }
Пример #16
0
        public void NullHas()
        {
            DependencyGraph g = new DependencyGraph();

            g.AddDependency("A", "B");
            // Has Dependees / Dependents
            try {
                g.AddDependency("A1", "B1");
                g.HasDependees(null);
                Assert.Fail();
            } catch (ArgumentNullException) {
            }

            try {
                g.AddDependency("A1", "B1");
                g.HasDependents(null);
                Assert.Fail();
            } catch (ArgumentNullException) {
            }
        }
Пример #17
0
        public void PassingNullTests()
        {
            DependencyGraph g = new DependencyGraph();

            g.AddDependency("A", "B");
            List <string> stringList = new List <string>();

            stringList.Add("1a");
            stringList.Add(null);

            try {
                g.AddDependency("A", null);
                Assert.Fail();
            } catch (Exception) {
            }

            try {
                g.AddDependency(null, "B");
                Assert.Fail();
            } catch (Exception) {
            }

            try {
                g.AddDependency(null, null);
                Assert.Fail();
            } catch (Exception) {
            }

            try {
                g.GetDependees(null);
                Assert.Fail();
            } catch (Exception) {
            }

            try {
                g.GetDependents(null);
                Assert.Fail();
            } catch (Exception) {
            }

            try {
                g.HasDependees(null);
                Assert.Fail();
            } catch (Exception) {
            }

            try {
                g.HasDependents(null);
                Assert.Fail();
            } catch (Exception) {
            }

            try {
                g.RemoveDependency("A", null);
                Assert.Fail();
            } catch (Exception) {
            }

            try {
                g.RemoveDependency(null, "B");
                Assert.Fail();
            } catch (Exception) {
            }

            try {
                g.ReplaceDependees(null, stringList);
                Assert.Fail();
            } catch (Exception) {
            }

            try {
                stringList = null;
                g.ReplaceDependees("A", stringList);
                Assert.Fail();
            } catch (Exception) {
            }

            try {
                g.ReplaceDependents(null, stringList);
                Assert.Fail();
            } catch (Exception) {
            }

            try {
                stringList = null;
                g.ReplaceDependents("A", stringList);
                Assert.Fail();
            } catch (Exception) {
            }
        }
Пример #18
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"));
 }
Пример #19
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"));
 }
Пример #20
0
        public void TestHasDependeesNull()
        {
            DependencyGraph dg = new DependencyGraph();

            dg.HasDependents(null);
        }
Пример #21
0
        public void SimpleTest3()
        {
            DependencyGraph dg = new DependencyGraph();

            Assert.AreEqual(false, dg.HasDependents("m"));
        }
Пример #22
0
 public void Copy3()
 {
     var d1 = new DependencyGraph();
     var d2 = new DependencyGraph(d1);
     d1.AddDependency("a", "b");
     d2.AddDependency("c", "d");
     Assert.IsTrue(d1.HasDependents("a"));
     Assert.IsFalse(d1.HasDependents("c"));
     Assert.IsFalse(d2.HasDependents("a"));
     Assert.IsTrue(d2.HasDependents("c"));
 }
Пример #23
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"));
 }
Пример #24
0
        public void HasDependents1()
        {
            DependencyGraph dg = new DependencyGraph();

            Assert.IsFalse(dg.HasDependents("a"));
        }
Пример #25
0
 public void EmptyTest2()
 {
     DependencyGraph t = new DependencyGraph();
     Assert.IsFalse(t.HasDependees("x"));
     Assert.IsFalse(t.HasDependents("x"));
 }