public async Task OnCompleted_NotCompletedTest()
        {
            TaskObserver observer = TaskObserver.Create(Task.Run(() => {  }), GetLogger());

            observer.OnCompleted();
            bool completedTransition = await observer.TaskStatusCompletedTransition;

            Assert.IsFalse(completedTransition);
        }
        public async Task OnCompleted_CompletedTest()
        {
            Task         taskToObserve = Task.Run(() => { Task.Delay(2000).Wait(); });
            TaskObserver observer      = TaskObserver.Create(taskToObserve, GetLogger());

            observer.OnNext(taskToObserve);
            observer.OnCompleted();
            bool completedTransition = await observer.TaskStatusCompletedTransition;

            Assert.IsTrue(completedTransition);
        }
Example #3
0
        public async Task <bool> ObserversCompletation()
        {
            List <Task> potentiallyFinishedTasks = new List <Task>();

            foreach (IObserver <Task> observer in observers)
            {
                TaskObserver taskObserver = (TaskObserver)observer;
                await taskObserver.TaskStatusCompletedTransition;
                potentiallyFinishedTasks.Add(taskObserver.ObservableTask);
                taskObserver.OnCompleted();
            }
            foreach (Task task in potentiallyFinishedTasks)
            {
                OnTaskFinished(task);
            }
            return(true);
        }