Example #1
0
        public async Task TestAlreadyCompleted()
        {
            var mySyncImpl = new MySynchronousImplementation();

            (await mySyncImpl.GetValueAsync()).Output();

            await mySyncImpl.DoAsync();

            try
            {
                await mySyncImpl.NotImplementedAsync <NotImplementedException>();
            }
            catch (NotImplementedException e)
            {
                e.Output();
            }

            try
            {
                var cts = new CancellationTokenSource(TimeSpan.FromSeconds(2));
                cts.Cancel();
                (await mySyncImpl.GetValueCanceledAsync(cts.Token)).Output();
            }
            catch (TaskCanceledException e)
            {
                e.Output();
            }
        }
Example #2
0
        public async void TestWrapAsyncAsync()
        {
            var expected            = 8;
            IAsyncInterface <int> x = new MySynchronousImplementation(expected);
            var actual = await x.GetAsyncValue();

            Assert.Equal(expected, actual);
        }