public async Task GetAllParentTaskTest() { var parentTasks = new List <ParentTask> { new ParentTask { ParentTaskDescription = "Task0", Parent_ID = 1, Parent_Task = 1, } }; var parentTaskMsgs = new List <ParentTaskMsg> { new ParentTaskMsg { Parent_ID = 1, ParentTask_ID = 1, Parent_Task_Description = "Task0" } }; var mockMapper = new Mock <IMapper>(); mockMapper.Setup(map => map.Map <List <ParentTaskMsg> >(It.IsAny <List <ParentTask> >())) .Returns(parentTaskMsgs); var mockTaskRepo = new Mock <ITaskRepo>(); mockTaskRepo.Setup(repo => repo.GetAllParentTasks()).Returns(Task.FromResult(parentTasks)); var taskService = new TasksService(mockMapper.Object, mockTaskRepo.Object, logger); var result = await taskService.GetAllParentTask(); Assert.Single(result); }