예제 #1
0
 public void RunOne()
 {
     Assert.Equal(0, context.RunOne(TimeSpan.FromMilliseconds(1)));
     context.Post(() => { });
     context.Post(() => { });
     Assert.Equal(1, context.RunOne(TimeSpan.FromMilliseconds(1)));
 }
예제 #2
0
        public void RunOne()
        {
            MOCK_ContextRunOne((IntPtr context, ref int count, long duration) =>
            {
                Assert.Equal(pointer, context);
                Assert.Equal(1000000L, duration);
                count = 1;
                return((int)Yogi.ErrorCode.Ok);
            });

            Assert.Equal(1, context.RunOne(Yogi.Duration.FromMilliseconds(1)));
        }
예제 #3
0
        public void Start()
        {
            Yogi.Timer timer = new Yogi.Timer(context);

            bool called = false;

            timer.StartAsync(Yogi.Duration.FromMilliseconds(1), (res) => {
                Assert.IsType <Yogi.Success>(res);
                Assert.Equal(Yogi.ErrorCode.Ok, res.ErrorCode);
                called = true;
            });

            GC.Collect();

            while (!called)
            {
                context.RunOne();
            }

            Assert.True(called);

            GC.KeepAlive(timer);
        }
예제 #4
0
        public void GetConnectedBranches()
        {
            var branch   = new Yogi.Branch(context, "{\"name\":\"My Branch\"}");
            var branch_a = new Yogi.Branch(context, "{\"name\":\"A\"}");
            var branch_b = new Yogi.Branch(context, "{\"name\":\"B\"}");

            while (!branch.GetConnectedBranches().ContainsKey(branch_a.Uuid) ||
                   !branch.GetConnectedBranches().ContainsKey(branch_b.Uuid))
            {
                context.RunOne();
            }
            var branches = branch.GetConnectedBranches();

            Assert.True(branches.ContainsKey(branch_a.Uuid));
            Assert.Equal(branches[branch_a.Uuid].Name, branch_a.Name);
            Assert.IsType <Yogi.RemoteBranchInfo>(branches[branch_a.Uuid]);

            Assert.True(branches.ContainsKey(branch_b.Uuid));
            Assert.Equal(branches[branch_b.Uuid].Name, branch_b.Name);
            Assert.IsType <Yogi.RemoteBranchInfo>(branches[branch_b.Uuid]);
        }