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);
        }
        public IObserver <Task> GetRequiredObserverByTask(Task task)
        {
            IObserver <Task> observerTask;

            try
            {
                observerTask = observers.First <IObserver <Task> >(
                    observer => Object.ReferenceEquals(((TaskObserver)observer).ObservableTask, task));
            }catch (System.InvalidOperationException)
            {
                logger.Debug(string.Format("Task {0} was not registered", task.Id));
                observerTask = TaskObserver.Create(task, logger);
                ((TaskObserver)observerTask).Subscribe(this);
            }
            return(observerTask);
        }
Exemple #4
0
        public void SubscribeTest()
        {
            List <Task> tasks = new List <Task>();
            Task        task  = Task.Run(() => { });

            tasks.Add(task);
            TasksProvider provider = TasksProvider.Create(new List <Task>(), GetLogger());

            provider.AddTask(task);
            TaskObserver observer = TaskObserver.Create(task, GetLogger());

            observer.OnNext(task);
            IDisposable unsubscriber = provider.Subscribe(observer);

            Assert.IsTrue(provider.Subscribe(observer) is IDisposable);
        }
        private void AddTask(Task task)
        {
            TaskObserver observableTask = TaskObserver.Create(task, logger);

            observableTask.Subscribe(tasksProvider);
        }
 public void TasksObserverCreateTest()
 {
     Assert.IsTrue(TaskObserver.Create(Task.Run(() => { }), GetLogger()) is IObserver <Task>);
 }