Exemplo n.º 1
0
        public ActionResult ListTasks()
        {
            List <TaskViewModel> tasks = new List <TaskViewModel>();

            foreach (var task in _taskLogic.GetTasks())
            {
                tasks.Add(_mapper.Map <TaskViewModel>(task));
            }
            return(View(tasks));
        }
 public IActionResult Get(bool activeOnly = false)
 {
     try
     {
         return(Ok(taskLogic.GetTasks(activeOnly)));
     }
     catch (Exception ex)
     {
         _logger.LogError(ex, "Error during GET All Tasks");
         return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
     }
 }
Exemplo n.º 3
0
 // GET: api/Tasks
 /// <summary>
 /// Get all Tasks
 /// </summary>
 /// <returns>List of all Tasks</returns>
 public IHttpActionResult Get()
 {
     try
     {
         return(Ok(taskLogic.GetTasks()));
     }
     catch (Exception ex)
     {
         _logger.LogError(ex, "Error during GET All Tasks");
         return(InternalServerError(ex));
     }
 }
        public void Test_For_Get_AllTasks()
        {
            // Arrange
            var testTasksList = new Models.DataModels.Task[]
            {
                new Models.DataModels.Task()
                {
                    TaskName = "TestTask1", Priority = 20, ProjectId = 100, TaskOwnerId = Guid.NewGuid(), StartDate = DateTime.Today, ParentTaskId = null
                },
                new Models.DataModels.Task()
                {
                    TaskName = "TestTask2", Priority = 20, ProjectId = 200, TaskOwnerId = Guid.NewGuid(), StartDate = DateTime.Today, ParentTaskId = 100
                },
                new Models.DataModels.Task()
                {
                    TaskName = "TestTask3", Priority = 20, ProjectId = 130, TaskOwnerId = Guid.NewGuid(), StartDate = DateTime.Today, ParentTaskId = null
                },
                new Models.DataModels.Task()
                {
                    TaskName = "TestTask4", Priority = 20, ProjectId = 400, TaskOwnerId = Guid.NewGuid(), StartDate = DateTime.Today, ParentTaskId = 140
                },
                new Models.DataModels.Task()
                {
                    TaskName = "TestTask5", Priority = 20, ProjectId = 160, TaskOwnerId = Guid.NewGuid(), StartDate = DateTime.Today, ParentTaskId = 100
                },
                new Models.DataModels.Task()
                {
                    TaskName = "TestTask6", Priority = 20, ProjectId = 140, TaskOwnerId = Guid.NewGuid(), StartDate = DateTime.Today, ParentTaskId = null
                },
            };

            mockTaskRepo.Setup(repo => repo.GetAll()).Returns(testTasksList);
            // Act
            var actualResult = tasksLogicTest.GetTasks();

            // Assert
            Assert.NotNull(actualResult);
            Assert.Equal(testTasksList.Count(), actualResult.Count());
        }