예제 #1
0
#pragma warning disable xUnit1013
        public new void Dispose()
        {
            context.Stop();
            context.WaitForStopped();
            context.Poll();
            base.Dispose();
        }
예제 #2
0
        public void WaitForStopped()
        {
            MOCK_ContextWaitForStopped((IntPtr context, long duration) =>
            {
                Assert.Equal(pointer, context);
                Assert.Equal(1000000L, duration);
                return((int)Yogi.ErrorCode.Ok);
            });

            Assert.True(context.WaitForStopped(Yogi.Duration.FromMilliseconds(1)));
        }
예제 #3
0
        public void SendBroadcast()
        {
            var branchA = new Yogi.Branch(context,
                                          "{\"name\":\"a\", \"_transceive_byte_limit\": 5}");
            var branchB = new Yogi.Branch(context, "{\"name\":\"b\"}");

            RunContextUntilBranchesAreConnected(context, branchA, branchB);
            context.RunInBackground();

            // Receive a broadcast to verify that it has actually been sent
            bool broadcastReceived = false;

            branchB.ReceiveBroadcastAsync(Yogi.EncodingType.Json, (res, _, payload) =>
            {
                Assert.Equal(Yogi.ErrorCode.Ok, res.ErrorCode);
                Assert.Equal(bigJsonView, payload);
                broadcastReceived = true;
            });

            GC.Collect();

            // Blocking
            for (int i = 0; i < 3; ++i)
            {
                Assert.True(branchA.SendBroadcast(bigJsonView, true));
            }

            // Non-blocking
            while (branchA.SendBroadcast(bigJsonView, false))
            {
                ;
            }

            context.Stop();
            context.WaitForStopped();

            // Verify that a broadcast has actually been sent
            while (!broadcastReceived)
            {
                context.RunOne();
            }

            GC.KeepAlive(branchA);
            GC.KeepAlive(branchB);
        }