예제 #1
0
        public void ComplexCase()
        {
            var set   = new GraphSet <string>();
            var three = set.Add("3");
            var four  = three.AddChild("4");

            three.AddParent("2");
            var two = three.AddParent("Two");
            var one = two.AddParent("One");

            two.AddParent("Un");
            four.AddParent(one);
            var names = new List <string>();
            var task  = set.ToTask(x => { OnNames(names, x); });

            task.Wait();
            lock (_synchro)
            {
                Assert.Equal(6, names.Count);
                Assert.True(names.IndexOf("3") < names.IndexOf("4"));
                Assert.True(names.IndexOf("Two") < names.IndexOf("3"));
                Assert.True(names.IndexOf("2") < names.IndexOf("3"));
                Assert.True(names.IndexOf("One") < names.IndexOf("Two"));
                Assert.True(names.IndexOf("Un") < names.IndexOf("Two"));
            }
        }
예제 #2
0
        public void UseCase()
        {
            var set  = new GraphSet <int>();
            var node = set.Add(3);
            var two  = node.AddParent(2);

            two.AddParent(1);
            var task = set.ToTask(OnNode);

            task.Wait();
            Assert.Equal(1, _values[0]);
            Assert.Equal(2, _values[1]);
            Assert.Equal(3, _values[2]);
        }