当前位置: 首页>>代码示例>>C#>>正文


C# DependencyGraph.AddDependency方法代码示例

本文整理汇总了C#中SpreadsheetUtilities.DependencyGraph.AddDependency方法的典型用法代码示例。如果您正苦于以下问题:C# DependencyGraph.AddDependency方法的具体用法?C# DependencyGraph.AddDependency怎么用?C# DependencyGraph.AddDependency使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SpreadsheetUtilities.DependencyGraph的用法示例。


在下文中一共展示了DependencyGraph.AddDependency方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddTest2Test

 public void AddTest2Test()
 {
     DependencyGraph t = new DependencyGraph();
     t.AddDependency("A3", "A2");
     t.AddDependency("A1", "A2");
     Assert.AreEqual(2, t.Size);
 }
开发者ID:Buck417,项目名称:Second-Half-CS-3500,代码行数:7,代码来源:SpreadsheetUtilitiesTest.cs

示例2: AddTest1Test

 public void AddTest1Test()
 {
     DependencyGraph t = new DependencyGraph();
     t.AddDependency("A1", "A2");
     t.AddDependency("A1", "A3");
     t.RemoveDependency("A1", "A2");
     Assert.AreEqual(1, t.Size);
     t.AddDependency("A1", "A4");
     Assert.AreEqual(2, t.Size);
     HashSet<string> test = new HashSet<string>();
     test.Add("A3");
     test.Add("A4");
     Assert.AreEqual(true, test.SetEquals(t.GetDependents("A1")));
 }
开发者ID:Buck417,项目名称:Second-Half-CS-3500,代码行数:14,代码来源:SpreadsheetUtilitiesTest.cs

示例3: EmptyTest11

 public void EmptyTest11()
 {
     DependencyGraph t = new DependencyGraph();
     t.AddDependency("x", "y");
     Assert.AreEqual(t.Size, 1);
     t.RemoveDependency("x", "y");
     t.RemoveDependency("x", "y");
 }
开发者ID:Leyalic,项目名称:PS6_2015,代码行数:8,代码来源:GradingTests.cs

示例4: EmptyTest10

 public void EmptyTest10()
 {
     DependencyGraph t = new DependencyGraph();
     t.AddDependency("x", "y");
     Assert.AreEqual(1, t["y"]);
     t.RemoveDependency("x", "y");
     Assert.AreEqual(0, t["y"]);
 }
开发者ID:Leyalic,项目名称:PS6_2015,代码行数:8,代码来源:GradingTests.cs

示例5: PrivateDataTest

 public void PrivateDataTest()
 {
     try
     {
         DependencyGraph dg = new DependencyGraph();
         dg.AddDependency("a", "b");
         dg.AddDependency("a", "c");
         ICollection<string> temp = (ICollection<string>)dg.GetDependents("a");
         temp.Add("d");
         Assert.IsTrue(new HashSet<string> { "b", "c", "d" }.SetEquals(temp));
         Assert.IsTrue(new HashSet<string> { "b", "c" }.SetEquals(dg.GetDependents("a")));
     }
     catch (Exception e)
     {
         if (!(e is NotSupportedException || e is InvalidCastException))
             Assert.Fail();
     }
 }
开发者ID:Buck417,项目名称:Second-Half-CS-3500,代码行数:18,代码来源:SpreadsheetUtilitiesTest.cs

示例6: EmptyTest12

 public void EmptyTest12()
 {
     DependencyGraph t = new DependencyGraph();
     t.AddDependency("x", "y");
     Assert.AreEqual(t.Size, 1);
     t.RemoveDependency("x", "y");
     t.ReplaceDependents("x", new HashSet<string>());
     t.ReplaceDependees("y", new HashSet<string>());
 }
开发者ID:Leyalic,项目名称:PS6_2015,代码行数:9,代码来源:GradingTests.cs

示例7: NonEmptyTest9

        public void NonEmptyTest9()
        {
            DependencyGraph t = new DependencyGraph();
            t.AddDependency("a", "b");
            t.AddDependency("a", "c");
            t.AddDependency("a", "b");
            t.AddDependency("c", "b");
            t.AddDependency("b", "d");
            t.AddDependency("c", "b");

            IEnumerator<string> e = t.GetDependees("a").GetEnumerator();
            Assert.IsFalse(e.MoveNext());

            e = t.GetDependees("b").GetEnumerator();
            Assert.IsTrue(e.MoveNext());
            String s1 = e.Current;
            Assert.IsTrue(e.MoveNext());
            String s2 = e.Current;
            Assert.IsFalse(e.MoveNext());
            Assert.IsTrue(((s1 == "a") && (s2 == "c")) || ((s1 == "c") && (s2 == "a")));

            e = t.GetDependees("c").GetEnumerator();
            Assert.IsTrue(e.MoveNext());
            Assert.AreEqual("a", e.Current);
            Assert.IsFalse(e.MoveNext());

            e = t.GetDependees("d").GetEnumerator();
            Assert.IsTrue(e.MoveNext());
            Assert.AreEqual("b", e.Current);
            Assert.IsFalse(e.MoveNext());
        }
开发者ID:Leyalic,项目名称:PS6_2015,代码行数:31,代码来源:GradingTests.cs

示例8: NonEmptyTest7

 public void NonEmptyTest7()
 {
     DependencyGraph t = new DependencyGraph();
     t.AddDependency("a", "b");
     t.AddDependency("a", "c");
     t.AddDependency("a", "b");
     t.AddDependency("c", "b");
     t.AddDependency("b", "d");
     t.AddDependency("c", "b");
     Assert.AreEqual(2, t["b"]);
 }
开发者ID:Leyalic,项目名称:PS6_2015,代码行数:11,代码来源:GradingTests.cs

示例9: nonEmptyCirclesAToB

 public void nonEmptyCirclesAToB()
 {
     DependencyGraph t = new DependencyGraph();
     t.AddDependency("a", "b");
     t.AddDependency("b", "a");
     Assert.AreEqual(2, t.Size);
 }
开发者ID:Leyalic,项目名称:PS6_2015,代码行数:7,代码来源:DevelopementTests.cs

示例10: NonEmptyTest6

 public void NonEmptyTest6()
 {
     DependencyGraph t = new DependencyGraph();
     t.AddDependency("a", "b");
     t.AddDependency("a", "c");
     t.AddDependency("d", "c");
     t.RemoveDependency("a", "b");
     Assert.AreEqual(2, t.Size);
 }
开发者ID:jimibue,项目名称:cs3505,代码行数:9,代码来源:DevelopmentTests.cs

示例11: StressTest15

        public void StressTest15()
        {
            // Dependency graph
            DependencyGraph t = new DependencyGraph();

            // A bunch of strings to use
            const int SIZE = 100;
            string[] letters = new string[SIZE];
            for (int i = 0; i < SIZE; i++)
            {
                letters[i] = ("" + (char)('a' + i));
            }

            // The correct answers
            HashSet<string>[] dents = new HashSet<string>[SIZE];
            HashSet<string>[] dees = new HashSet<string>[SIZE];
            for (int i = 0; i < SIZE; i++)
            {
                dents[i] = new HashSet<string>();
                dees[i] = new HashSet<string>();
            }

            // Add a bunch of dependencies
            for (int i = 0; i < SIZE; i++)
            {
                for (int j = i + 1; j < SIZE; j++)
                {
                    t.AddDependency(letters[i], letters[j]);
                    dents[i].Add(letters[j]);
                    dees[j].Add(letters[i]);
                }
            }

            // Remove a bunch of dependencies
            for (int i = 0; i < SIZE; i++)
            {
                for (int j = i + 2; j < SIZE; j += 2)
                {
                    t.RemoveDependency(letters[i], letters[j]);
                    dents[i].Remove(letters[j]);
                    dees[j].Remove(letters[i]);
                }
            }

            // Replace a bunch of dependees
            for (int i = 0; i < SIZE; i += 4)
            {
                HashSet<string> newDees = new HashSet<String>();
                for (int j = 0; j < SIZE; j += 7)
                {
                    newDees.Add(letters[j]);
                }
                t.ReplaceDependees(letters[i], newDees);

                foreach (string s in dees[i])
                {
                    dents[s[0] - 'a'].Remove(letters[i]);
                }

                foreach (string s in newDees)
                {
                    dents[s[0] - 'a'].Add(letters[i]);
                }

                dees[i] = newDees;
            }

            // Make sure everything is right
            for (int i = 0; i < SIZE; i++)
            {
                Assert.IsTrue(dents[i].SetEquals(new HashSet<string>(t.GetDependents(letters[i]))));
                Assert.IsTrue(dees[i].SetEquals(new HashSet<string>(t.GetDependees(letters[i]))));
            }
        }
开发者ID:jimibue,项目名称:cs3505,代码行数:74,代码来源:DevelopmentTests.cs

示例12: NonEmptyTest2

 public void NonEmptyTest2()
 {
     DependencyGraph t = new DependencyGraph();
     t.AddDependency("a", "b");
     t.AddDependency("a", "b");
     Assert.AreEqual(1, t.Size);
 }
开发者ID:jimibue,项目名称:cs3505,代码行数:7,代码来源:DevelopmentTests.cs

示例13: NonEmptyReplacingDependents

 public void NonEmptyReplacingDependents()
 {
     DependencyGraph t = new DependencyGraph();
     t.AddDependency("a", "b");
     t.AddDependency("a", "c");
     t.AddDependency("d", "c");
     t.ReplaceDependents("a", new HashSet<string>() { "x", "y", "z" });
     HashSet<String> aPends = new HashSet<string>(t.GetDependents("a"));
     Assert.IsTrue(aPends.SetEquals(new HashSet<string>() { "x", "y", "z" }));
 }
开发者ID:Leyalic,项目名称:PS6_2015,代码行数:10,代码来源:DevelopementTests.cs

示例14: NonEmptyTest11

 public void NonEmptyTest11()
 {
     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.AreEqual(4, t.Size);
 }
开发者ID:Leyalic,项目名称:PS6_2015,代码行数:15,代码来源:GradingTests.cs

示例15: NonEmptyTest13

 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"));
 }
开发者ID:Leyalic,项目名称:PS6_2015,代码行数:18,代码来源:GradingTests.cs


注:本文中的SpreadsheetUtilities.DependencyGraph.AddDependency方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。