Exemple #1
0
        public async Task AsyncJobCancelsOnSetFailedTimeout()
        {
            SteamClient client = new SteamClient();

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

            asyncJob.SetFailed(dueToRemoteFailure: false);

            Assert.True(asyncTask.IsCompleted, "Async job should be completed on message timeout");
            Assert.True(asyncTask.IsCanceled, "Async job should be canceled on message timeout");
            Assert.False(asyncTask.IsFaulted, "Async job should not be faulted on message timeout");

            await Assert.ThrowsAsync(typeof(TaskCanceledException), async() => await asyncTask);
        }
Exemple #2
0
        public async void AsyncJobCancelsOnSetFailedTimeout()
        {
            SteamClient client = new SteamClient();

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

            asyncJob.SetFailed( dueToRemoteFailure: false );
            
            Assert.True( asyncTask.IsCompleted, "Async job should be completed on message timeout" );
            Assert.True( asyncTask.IsCanceled, "Async job should be canceled on message timeout" );
            Assert.False( asyncTask.IsFaulted, "Async job should not be faulted on message timeout" );

            await Assert.ThrowsAsync( typeof( TaskCanceledException ), async () => await asyncTask );
        }
Exemple #3
0
        public async Task AsyncJobThrowsFailureExceptionOnFailure()
        {
            SteamClient client = new SteamClient();

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

            asyncJob.SetFailed(dueToRemoteFailure: true);

            Assert.True(asyncTask.IsCompleted, "Async job should be completed after job failure");
            Assert.False(asyncTask.IsCanceled, "Async job should not be canceled after job failure");
            Assert.True(asyncTask.IsFaulted, "Async job should be faulted after job failure");

            await Assert.ThrowsAsync(typeof(AsyncJobFailedException), async() => await asyncTask);
        }
Exemple #4
0
        public async void AsyncJobThrowsFailureExceptionOnFailure()
        {
            SteamClient client = new SteamClient();

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

            asyncJob.SetFailed( dueToRemoteFailure: true );

            Assert.True( asyncTask.IsCompleted, "Async job should be completed after job failure" );
            Assert.False( asyncTask.IsCanceled, "Async job should not be canceled after job failure" );
            Assert.True( asyncTask.IsFaulted, "Async job should be faulted after job failure" );

            await Assert.ThrowsAsync( typeof( AsyncJobFailedException ), async () => await asyncTask );
        }