コード例 #1
0
ファイル: TimerTest.cs プロジェクト: yohummus/yogi-framework
        public void StartSyncError()
        {
            Yogi.Timer.HandlerFnDelegate fn = (Yogi.Result result) =>
            {
            };

            MOCK_TimerStartAsync((IntPtr timer, long duration, TimerStartAsyncFnDelegate fn_, IntPtr userarg) =>
            {
                return((int)Yogi.ErrorCode.Unknown);
            });

            Assert.ThrowsAny <Yogi.FailureException>(() =>
            {
                timer.StartAsync(Yogi.Duration.FromNanoseconds(1234), fn);
            });
        }
コード例 #2
0
ファイル: TimerTest.cs プロジェクト: yohummus/yogi-framework
        public void StartAsyncCallbackCancel()
        {
            bool called = false;

            Yogi.Timer.HandlerFnDelegate fn = (Yogi.Result result) =>
            {
                Assert.IsType <Yogi.Failure>(result);
                Assert.Equal(Yogi.ErrorCode.Canceled, result.ErrorCode);
                called = true;
            };

            MOCK_TimerStartAsync((IntPtr timer, long duration, TimerStartAsyncFnDelegate fn_, IntPtr userarg) =>
            {
                Assert.NotNull(fn_);
                fn_((int)Yogi.ErrorCode.Canceled, userarg);
                return((int)Yogi.ErrorCode.Ok);
            });

            timer.StartAsync(Yogi.Duration.FromNanoseconds(1234), fn);
            Assert.True(called);
        }