public void ResultFromFinishedTask()
        {
            var fromResult = Task.FromResult(1);
            var completion = new NotifyTaskCompletion(fromResult);

            AssertCompletion.AreEqual(fromResult, completion);
        }
        public void ThrowTask()
        {
            var tcs        = new TaskCompletionSource <int>();
            var task       = tcs.Task;
            var completion = new NotifyTaskCompletion(task);

            tcs.SetException(new Exception());
            AssertCompletion.AreEqual(task, completion);
        }
        public void CancelTask()
        {
            var tcs        = new TaskCompletionSource <int>();
            var task       = tcs.Task;
            var completion = new NotifyTaskCompletion(task);

            tcs.SetCanceled();
            AssertCompletion.AreEqual(task, completion);
        }
        public void AwaitTask()
        {
            var tcs        = new TaskCompletionSource <int>();
            var task       = tcs.Task;
            var completion = new NotifyTaskCompletion(task);

            tcs.SetResult(1);
            AssertCompletion.AreEqual(task, completion);
        }
        public async Task AwaitTypedTask()
        {
            var tcs        = new TaskCompletionSource <int>();
            var task       = tcs.Task;
            var completion = new NotifyTaskCompletion <int>(task);

            tcs.SetResult(1);
            await completion.Task.ConfigureAwait(false);

            Assert.AreEqual(task.Result, completion.Completed.Result);
            AssertCompletion.AreEqual(task, completion);
        }