Exemplo n.º 1
0
 public ProjectController(ProjectService service, AccountService srv, TaskService taskService, SubTaskService subTaskService, CommentService commentService)
 {
     this.projectService = service;
     this.accountService = srv;
     this.taskService    = taskService;
     this.subTaskService = subTaskService;
     this.commentService = commentService;
 }
Exemplo n.º 2
0
 public TaskController(TaskService tService, SubTaskService stService, ProjectService projectService, AccountService accountService, CommentService commentService)
 {
     this.taskService    = tService;
     this.subTaskService = stService;
     this.projectService = projectService;
     this.accountService = accountService;
     this.commentService = commentService;
 }
Exemplo n.º 3
0
        public void GivenGetById_WhenNotFoundId_ThenReturnNull()
        {
            Mock <ISubTaskRepository> mockSubTaskRepository = new Mock <ISubTaskRepository>();

            mockSubTaskRepository.Setup(method => method.FindBy(It.IsAny <int>())).Returns((int id) => GetSubTasks().FirstOrDefault(st => st.Id == id));

            Mock <IMainTaskRepository> mockMainTaskRepository = new Mock <IMainTaskRepository>();

            var subTaskService = new SubTaskService(mockMainTaskRepository.Object, mockSubTaskRepository.Object, false);

            var subTasks = subTaskService.GetBy(0);

            Assert.IsNull(subTasks);
        }
Exemplo n.º 4
0
        public void GivenDeleteSubTaskByMainTaskId_WhenSuccess_ThenReturnTrue()
        {
            Mock <ISubTaskRepository> mockSubTaskRepository = new Mock <ISubTaskRepository>();

            mockSubTaskRepository.Setup(st => st.DeleteByMainTaskId(It.IsAny <int>())).Returns(1);

            Mock <IMainTaskRepository> mockMainTaskRepository = new Mock <IMainTaskRepository>();

            var subTaskService = new SubTaskService(mockMainTaskRepository.Object, mockSubTaskRepository.Object, false);

            var subtaskInput = GetSubTasks().FirstOrDefault();
            var subTasks     = subTaskService.DeleteByMainTaskId(subtaskInput.MainTaskId);

            Assert.IsTrue(subTasks);
        }
Exemplo n.º 5
0
        public void GivenHaveSubTaskInDatabase_WhenGetAll_ThenReturnNotNullAndCountMoreThanZero()
        {
            var expected = 0;
            Mock <ISubTaskRepository> mockSubTaskRepository = new Mock <ISubTaskRepository>();

            mockSubTaskRepository.Setup(method => method.GetAll()).Returns(GetSubTasks());

            Mock <IMainTaskRepository> mockMainTaskRepository = new Mock <IMainTaskRepository>();

            var subTaskService = new SubTaskService(mockMainTaskRepository.Object, mockSubTaskRepository.Object, false);

            var subTasks = subTaskService.GetAll();

            Assert.NotNull(subTasks);
            Assert.Less(expected, subTasks.Count());
        }
Exemplo n.º 6
0
        public void GivenGetByMainTaskId_WhenNotFoundId_ThenReturnNotNullAndCountEqualZero()
        {
            var expected = 0;
            Mock <ISubTaskRepository> mockSubTaskRepository = new Mock <ISubTaskRepository>();

            mockSubTaskRepository.Setup(method => method.FindByMainProjectId(It.IsAny <int>())).Returns((int id) => GetSubTasks().Where(st => st.MainTaskId == id));

            Mock <IMainTaskRepository> mockMainTaskRepository = new Mock <IMainTaskRepository>();

            var subTaskService = new SubTaskService(mockMainTaskRepository.Object, mockSubTaskRepository.Object, false);

            var subTasks = subTaskService.GetByMainTaskId(0);

            Assert.NotNull(subTasks);
            Assert.AreEqual(expected, subTasks.Count());
        }
Exemplo n.º 7
0
        public void GivenActiveToEnable_WhenSuccess_ThenReturnTrue()
        {
            Mock <ISubTaskRepository> mockSubTaskRepository = new Mock <ISubTaskRepository>();

            mockSubTaskRepository.Setup(st => st.Active(It.IsAny <int>(), It.IsAny <bool>())).Returns(1);

            Mock <IMainTaskRepository> mockMainTaskRepository = new Mock <IMainTaskRepository>();

            var subTaskService = new SubTaskService(mockMainTaskRepository.Object, mockSubTaskRepository.Object, false);

            var subtaskInput = GetSubTasks().FirstOrDefault(st => !st.Active);

            subtaskInput.Active = true;
            var subTasks = subTaskService.Active(subtaskInput.Id, subtaskInput.Active);

            Assert.IsTrue(subTasks);
        }
Exemplo n.º 8
0
        public void GivenDeleteSubTask_WhenSuccess_ThenReturnTrue()
        {
            Mock <ISubTaskRepository> mockSubTaskRepository = new Mock <ISubTaskRepository>();

            mockSubTaskRepository.Setup(st => st.Delete(It.IsAny <SubTask>())).Returns(1);

            Mock <IMainTaskRepository> mockMainTaskRepository = new Mock <IMainTaskRepository>();

            mockMainTaskRepository.Setup(method => method.FindBy(It.IsAny <int>())).Returns((int id) => GetMainTasks().FirstOrDefault(mt => mt.Id == id));

            var subTaskService = new SubTaskService(mockMainTaskRepository.Object, mockSubTaskRepository.Object, false);

            var subtaskInput = GetSubTasks().FirstOrDefault();
            var subTasks     = subTaskService.Delete(subtaskInput);

            Assert.IsTrue(subTasks);
        }
Exemplo n.º 9
0
        public void GivenAddNewSubTask_WhenNotFoundMainTaskId_ThenReturnFalse()
        {
            Mock <ISubTaskRepository> mockSubTaskRepository = new Mock <ISubTaskRepository>();

            Mock <IMainTaskRepository> mockMainTaskRepository = new Mock <IMainTaskRepository>();

            mockMainTaskRepository.Setup(method => method.FindBy(It.IsAny <int>())).Returns((int id) => GetMainTasks().FirstOrDefault(mt => mt.Id == id));

            var subTaskService = new SubTaskService(mockMainTaskRepository.Object, mockSubTaskRepository.Object, false);

            var subtaskInput = GetSubTasks().FirstOrDefault();

            subtaskInput.Id = 0;
            var subTasks = subTaskService.Add(subtaskInput);

            Assert.IsFalse(subTasks);
        }
Exemplo n.º 10
0
        public void GivenGetById_WhenFoundId_ThenReturnSubTaskDetail()
        {
            Mock <ISubTaskRepository> mockSubTaskRepository = new Mock <ISubTaskRepository>();

            mockSubTaskRepository.Setup(method => method.FindBy(It.IsAny <int>())).Returns((int id) => GetSubTasks().FirstOrDefault(st => st.Id == id));

            Mock <IMainTaskRepository> mockMainTaskRepository = new Mock <IMainTaskRepository>();

            var subTaskService = new SubTaskService(mockMainTaskRepository.Object, mockSubTaskRepository.Object, false);

            var subTaskInput = GetSubTasks().FirstOrDefault();
            var subTasks     = subTaskService.GetBy(subTaskInput.Id);

            Assert.NotNull(subTasks);
            Assert.AreEqual(subTasks.Id, subTaskInput.Id);
            Assert.AreEqual(subTasks.Detail, subTaskInput.Detail);
            Assert.AreEqual(subTasks.MainTaskId, subTaskInput.MainTaskId);
            Assert.AreEqual(subTasks.Active, subTaskInput.Active);
        }
 public SubTaskController()
 {
     _service = new SubTaskService();
 }