/// <summary> /// Method to get all tasks for a given user /// </summary> /// <param name="userId">The user id to get the tasks from</param> /// <returns>The UITask model object</returns> public List <Models.UIToDoTask> GetAllTasksForUser(int userId) { IList <ToDoTasksDataLayer.Entities.ToDoTasks> tasks = new List <ToDoTasksDataLayer.Entities.ToDoTasks>(); ToDoTask toDoTask = new ToDoTask(this.resporitoryToDoTasks); tasks = toDoTask.GetAllTasksForUser(userId); List <Models.UIToDoTask> uiToDoTasks = new List <Models.UIToDoTask>(); // Can use auto mapper here! foreach (ToDoTasksDataLayer.Entities.ToDoTasks entityTask in tasks.ToList()) { Models.UIToDoTask uiToDoTask = new Models.UIToDoTask { ToDoTaskId = entityTask.ToDoTaskId, CheckedDone = entityTask.CheckedDone, LastUpdated = entityTask.LastUpdated, TaskDescription = entityTask.TaskDescription, TaskUserId = entityTask.TaskUserId }; uiToDoTasks.Add(uiToDoTask); } return(uiToDoTasks); }
public void GetAllTasksForForUsers_InCorrectParameters_ReturnsEmptyObject() { IRepository <ToDoTasks, int> iRepository = Substitute.For <IRepository <ToDoTasks, int> >(); List <ToDoTasks> taskUserExpected = new List <ToDoTasks>(); taskUserExpected.Add(new ToDoTasks { CheckedDone = false, LastUpdated = System.DateTime.Now, TaskDescription = "someDescription", TaskUserId = 1, ToDoTaskId = 1 }); iRepository.FindAll().Returns(taskUserExpected); ToDoTask toDoTasks = new ToDoTask(iRepository); List <ToDoTasks> taskUserActual = toDoTasks.GetAllTasksForUser(2); Assert.True(taskUserActual.Count == 0); }