public void Cancel() { Yogi.Timer timer = new Yogi.Timer(context); Assert.False(timer.Cancel()); bool called = false; timer.StartAsync(Yogi.Duration.Infinity, (res) => { Assert.IsType <Yogi.Failure>(res); Assert.Equal(Yogi.ErrorCode.Canceled, res.ErrorCode); called = true; }); GC.Collect(); Assert.True(timer.Cancel()); GC.Collect(); while (!called) { context.RunOne(); } Assert.True(called); GC.KeepAlive(timer); }
public static Yogi.Timer CreateTimer() { MOCK_TimerCreate((ref IntPtr timer, IntPtr context) => { timer = pointer; return((int)Yogi.ErrorCode.Ok); }); return(new Yogi.Timer(CreateContext())); }
public void Create() { MOCK_TimerCreate((ref IntPtr timer, IntPtr context) => { Assert.Equal(context, pointer); timer = pointer; return((int)Yogi.ErrorCode.Ok); }); new Yogi.Timer(CreateContext()); }
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); }