public void AsyncJobThrowsExceptionOnNullCallback() { SteamClient client = new SteamClient(); AsyncJob <Callback> asyncJob = new AsyncJob <Callback>(client, 123); Assert.Throws <ArgumentNullException>(() => asyncJob.AddResult(null)); }
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); }
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); }
public void AsyncJobThrowsExceptionOnNullCallback() { SteamClient client = new SteamClient(); AsyncJob<Callback> asyncJob = new AsyncJob<Callback>( client, 123 ); Assert.Throws<ArgumentNullException>( () => asyncJob.AddResult( null ) ); }