#pragma warning disable xUnit1013 public new void Dispose() { context.Stop(); context.WaitForStopped(); context.Poll(); base.Dispose(); }
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))); }
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); }