Example #1
0
        public void CopyTreeCompletely()
        {
            var owner = new Mock <IIntervalOwner>();
            {
                owner.Setup(o => o.CurrentTicks)
                .Returns(10L);
            }

            var group   = new TimingGroup();
            var parents = new ITimerInterval[]
            {
                new TimerInterval(owner.Object, group, "a"),
                new TimerInterval(owner.Object, group, "b"),
                new TimerInterval(owner.Object, group, "c"),
            };

            var children = new[]
            {
                new ITimerInterval[]
                {
                    new TimerInterval(owner.Object, group, "aa"),
                    new TimerInterval(owner.Object, group, "ab"),
                    new TimerInterval(owner.Object, group, "ac"),
                },
                new ITimerInterval[]
                {
                    new TimerInterval(owner.Object, group, "ba"),
                    new TimerInterval(owner.Object, group, "bb"),
                    new TimerInterval(owner.Object, group, "bc"),
                },
                new ITimerInterval[]
                {
                    new TimerInterval(owner.Object, group, "ca"),
                    new TimerInterval(owner.Object, group, "cb"),
                    new TimerInterval(owner.Object, group, "cc"),
                },
            };

            var tree      = BuildTree(parents, children);
            var otherTree = new TimingTree(tree);

            Assert.That(otherTree.BaseIntervals(group), Is.EquivalentTo(parents));
            Assert.That(otherTree.ChildIntervals(parents[0]), Is.EquivalentTo(children[0]));
            Assert.That(otherTree.ChildIntervals(parents[1]), Is.EquivalentTo(children[1]));
            Assert.That(otherTree.ChildIntervals(parents[2]), Is.EquivalentTo(children[2]));

            CleanUpIntervals(parents, children);
        }
Example #2
0
        public void AddChildInterval()
        {
            var tree = new TimingTree();

            var owner = new Mock <IIntervalOwner>();
            {
                owner.Setup(o => o.CurrentTicks)
                .Returns(10L);
            }

            var group = new TimingGroup();

            using (var parent = new TimerInterval(owner.Object, group, "a"))
            {
                parent.Start();
                tree.AddBaseInterval(parent);
                using (var child = new TimerInterval(owner.Object, group, "b"))
                {
                    child.Start();
                    tree.AddChildInterval(parent, child);
                    Assert.That(tree.ChildIntervals(parent), Is.EquivalentTo(new ITimerInterval[] { child }));
                }
            }
        }