public int AddTask(ServiceTask task)
        {
            task.Id = GetNewId();
            taskList.Add(task);

            return task.Id;
        }
 public int AddTask(ServiceTask task)
 {
     task.Id = GetNewId();
     AddToCache(task);
     SynchronizeCacheAndLocal();
     return task.Id;
 }
        public void should_add_task_to_repo()
        {
            var task = new ServiceTask { DueDate = DateTime.Now, Name = "task1" };

            var result = repo.AddTask(task);

            result.Should().Be(1);
        }
        public void should_return_task_if_task_exists()
        {
            var spec = new ListByDateServiceSpecification {Date = DateTime.Today};
            var task = new ServiceTask{DueDate = DateTime.Today};

            var result = spec.IsSatisfied(task);

            result.Should().BeTrue();
        }
        public void should_return_true_if_equal_tasks()
        {
            var task = new ServiceTask {Id = 2};
            var spec = new ListSingleServiceSpecification {Id = 2};

            var result = spec.IsSatisfied(task);

            result.Should().BeTrue();
        }
        public void should_return_task_with_given_id()
        {
            const int id = 5;
            var serviceTask = new ServiceTask { Id = id };
            repo.GetTasks(Arg.Any<ListSingleServiceSpecification>()).Returns(new List<ServiceTask> { serviceTask });

            var selectTaskById = extractor.SelectTaskById(id);

            selectTaskById.Id.Should().Be(id);
        }
Exemple #7
0
        public void should_clear_task_date()
        {
            const int id = 5;
            var task = new ServiceTask { DueDate = DateTime.Today };
            extractor.SelectTaskById(id).Returns(task);

            todoList.ClearDate(5);
            repo.Received().UpdateChanges();
        }
Exemple #8
0
        public void should_return_task_id_on_add_task()
        {
            var args = new ServiceTask();
            var addTaskArgs = new AddTaskArgs();
            mapper.ConvertArgsToTask(addTaskArgs).Returns(args);

            repo.AddTask(args).Returns(1);
            var result = todoList.AddTask(addTaskArgs);
            result.Should().Be(1);
        }
 private void AddToCache(ServiceTask serviceTask)
 {
     cacheStorage.Add(serviceTask);
 }
Exemple #10
0
 public ClientTask ConvertToClient(ServiceTask task)
 {
     return Mapper.DynamicMap<ServiceTask, ClientTask>(task);
 }
        public void should_update_storage()
        {
            storage.AddTask(new ServiceTask { DueDate = DateTime.Today, Name = "Misha" });
            var task = new ServiceTask { Id = 1, DueDate = DateTime.Today, IsCompleted = false, Name = "Sasha" };

            storage.UpdateChanges();

            saver.ReceivedWithAnyArgs().SaveToFile("bla-bla");
        }
 public bool IsSatisfied(ServiceTask task)
 {
     return Date == task.DueDate;
 }
Exemple #13
0
        public void should_set_date_to_task()
        {
            const int id = 5;
            var task = new ServiceTask { DueDate = DateTime.Today, IsCompleted = false };
            extractor.SelectTaskById(id).Returns(task);

            todoList.SetTaskDate(5, DateTime.Today);
            repo.Received().UpdateChanges();
        }
 public bool IsSatisfied(ServiceTask task)
 {
     return true;
 }
Exemple #15
0
        public void should_get_task_from_repository()
        {
            var spec = new ListAllServiceSpecification();
            var serviceTask = new ServiceTask {Id = 3};
            var serviceTasks = new List<ServiceTask>{serviceTask};
            var expectedTask = new ClientTask{Id =3 };
            var clientTasks = new List<ClientTask> { expectedTask };
            repo.GetTasks(spec).Returns(serviceTasks);
            mapper.ConvertToClient(serviceTask).Returns(expectedTask);

            var resultList = todoList.GetTasks(spec);

            resultList.Should().BeEquivalentTo(clientTasks);
        }
 public bool IsSatisfied(ServiceTask task)
 {
     return Id == task.Id;
 }
Exemple #17
0
        public void should_throw_exception_on_clear_date_for_completed_task()
        {
            const int id = 5;
            var task = new ServiceTask { Id = id, IsCompleted = true };
            extractor.SelectTaskById(id).Returns(task);

            Action act = () => todoList.ClearDate(id);

            act.ShouldThrow<CouldNotSetDateException>().WithMessage("Could not clear due date for completed task.");
        }
Exemple #18
0
        public void should_throw_exception_on_set_date_to_completed_task()
        {
            const int id = 5;
            var dueDate = DateTime.Today;
            var task = new ServiceTask { Id = id, DueDate = dueDate, IsCompleted = true };
            extractor.SelectTaskById(id).Returns(task);

            Action action = () => todoList.SetTaskDate(id, dueDate);

            action.ShouldThrow<CouldNotSetDateException>().WithMessage("Could not set due date to completed task.");
        }