Пример #1
0
            Given_valid_responsibility_task_id_and_company_id_When_mark_responsibility_task_for_delete_Then_should_call_appropiate_methods
            ()
        {
            //Given
            var target = CreateController();

            var markTaskAsDeleteViewModel = new MarkResponsibilityTaskAsDeletedViewModel()
                                                {
                                                    CompanyId = companyId,
                                                    TaskId = taskId
                                                };

            //When
            target.MarkTaskAsDeleted(markTaskAsDeleteViewModel);

            //Then
            _taskService.Verify(x => x.MarkTaskAsDeleted(It.Is<MarkTaskAsDeletedRequest>(y => y.TaskId == taskId &&
                                                                                              y.CompanyId == companyId &&
                                                                                              y.UserId ==
                                                                                              target.CurrentUser.UserId)));
        }
Пример #2
0
            Given_invalid_responsibility_task_id_and_company_id_When_mark_responsibility_task_for_delete_Then_should_throw_correct_exception
            ()
        {
            //Given
            taskId = 0;
            companyId = 0;
            var target = CreateController();

            var markTaskAsDeleteViewModel = new MarkResponsibilityTaskAsDeletedViewModel()
                                                {
                                                    CompanyId = companyId,
                                                    TaskId = taskId
                                                };

            target.ModelState.AddModelError("", "");

            //When
            //Then
            Assert.Throws<ArgumentException>(() => target.MarkTaskAsDeleted(markTaskAsDeleteViewModel));
        }
Пример #3
0
            Given_valid_responsibility_task_id_and_company_id_When_mark_responsibility_task_for_delete_Then_should_return_correct_result
            ()
        {
            //Given
            var target = CreateController();
            var markTaskAsDeleteViewModel = new MarkResponsibilityTaskAsDeletedViewModel()
                                                {
                                                    CompanyId = companyId,
                                                    TaskId = taskId
                                                };

            //When
            var result = target.MarkTaskAsDeleted(markTaskAsDeleteViewModel);

            //Then
            dynamic data = result.Data;
            Assert.That(data.Success, Is.EqualTo(true));
        }
        public JsonResult MarkTaskAsDeleted(MarkResponsibilityTaskAsDeletedViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                throw new ArgumentException("Invalid Arguments To Mark Task As Deleted");
            }

            var request = new MarkTaskAsDeletedRequest()
            {
                TaskId = viewModel.TaskId,
                CompanyId = viewModel.CompanyId,
                UserId = CurrentUser.UserId
            };

            if (_taskService.HasCompletedTasks(request))
            {
                return Json(new MarkTaskForDeleteResultViewModel()
                {
                    Success = false,
                    Message = "This reoccurring task has previous tasks which have been completed, and can therefore not be deleted."
                });
            }

            _taskService.MarkTaskAsDeleted(request);

            return Json(new MarkTaskForDeleteResultViewModel()
            {
                Success = true
            });
        }