示例#1
0
        public void AsyncJobThrowsExceptionOnNullCallback()
        {
            SteamClient client = new SteamClient();

            AsyncJob <Callback> asyncJob = new AsyncJob <Callback>(client, 123);

            Assert.Throws <ArgumentNullException>(() => asyncJob.AddResult(null));
        }
示例#2
0
        public async Task AsyncJobContinuesAsynchronously()
        {
            SteamClient client = new SteamClient();

            var asyncJob  = new AsyncJob <Callback>(client, 123);
            var asyncTask = asyncJob.ToTask();

            var continuationThreadID = -1;
            var continuation         = asyncTask.ContinueWith(t =>
            {
                continuationThreadID = Thread.CurrentThread.ManagedThreadId;
            }, TaskContinuationOptions.ExecuteSynchronously);

            var completionThreadID = Thread.CurrentThread.ManagedThreadId;

            asyncJob.AddResult(new Callback {
                JobID = 123
            });

            await continuation;

            Assert.NotEqual(-1, continuationThreadID);
            Assert.NotEqual(completionThreadID, continuationThreadID);
        }
示例#3
0
        public void AsyncJobContinuesAsynchronously()
        {
            SteamClient client = new SteamClient();

            var asyncJob  = new AsyncJob <Callback>(client, 123);
            var asyncTask = asyncJob.ToTask();

            var continuationThreadID = -1;
            var continuation         = asyncTask.ContinueWith(t =>
            {
                continuationThreadID = Environment.CurrentManagedThreadId;
            }, TaskContinuationOptions.ExecuteSynchronously);

            var completionThreadID = Environment.CurrentManagedThreadId;

            asyncJob.AddResult(new Callback {
                JobID = 123
            });

            WaitForTaskWithoutRunningInline(continuation);

            Assert.NotEqual(-1, continuationThreadID);
            Assert.NotEqual(completionThreadID, continuationThreadID);
        }
示例#4
0
        public void AsyncJobThrowsExceptionOnNullCallback()
        {
            SteamClient client = new SteamClient();

            AsyncJob<Callback> asyncJob = new AsyncJob<Callback>( client, 123 );

            Assert.Throws<ArgumentNullException>( () => asyncJob.AddResult( null ) );
        }