public async Task TaskService_FindAsync_InputInvalid_Should_ReturnNull()
        {
            var mockUnitOfWork     = new Mock <IUnitOfWork>();
            var mockTaskRepository = new MockTaskRepository().MockFindByIdAsyncInvalid();

            var taskService = new TaskService(mockTaskRepository.Object, mockUnitOfWork.Object);

            var results = await taskService.FindAsync(1);

            Assert.IsNull(results);
            mockTaskRepository.VerifyFindByIdAsync(Times.Once());
        }
        public async Task TaskService_FindAsync_Should_ReturnTask()
        {
            var mockUnitOfWork     = new Mock <IUnitOfWork>();
            var mockTaskRepository = new MockTaskRepository().MockFindByIdAsync(Task.FromResult(Generics.Task));

            var taskService = new TaskService(mockTaskRepository.Object, mockUnitOfWork.Object);

            var results = await taskService.FindAsync(1);

            Assert.IsNotNull(results);
            mockTaskRepository.VerifyFindByIdAsync(Times.Once());
        }
        public async Task TaskService_SaveAsync_Should_ReturnTask()
        {
            var mockUnitOfWork     = new Mock <IUnitOfWork>();
            var mockTaskRepository = new MockTaskRepository().MockAddAsync(Task.FromResult(Generics.Task));

            var taskService = new TaskService(mockTaskRepository.Object, mockUnitOfWork.Object);

            var results = await taskService.SaveAsync(Generics.Task);

            Assert.IsNotNull(results);
            Assert.IsTrue(results.Success);
            Assert.IsInstanceOfType(results.Task, typeof(Domain.Models.Task));
            mockTaskRepository.VerifyAddAsync(Times.Once());
        }
        public async Task TaskService_SaveAsync_InputInvalid_Should_ReturnBadResponse()
        {
            var mockUnitOfWork     = new Mock <IUnitOfWork>();
            var mockTaskRepository = new MockTaskRepository().MockAddAsyncInvalid();

            var taskService = new TaskService(mockTaskRepository.Object, mockUnitOfWork.Object);

            var results = await taskService.SaveAsync(Generics.Task);

            Assert.IsNotNull(results);
            Assert.IsNull(results.Task);
            Assert.IsFalse(results.Success);
            Assert.IsTrue(results.Message.Contains("An error occurred when saving this task:"));
            mockTaskRepository.VerifyAddAsync(Times.Once());
        }
        public async Task TaskService_ListAsync_Should_ReturnEmptyList()
        {
            var tasks = new List <Domain.Models.Task> {
            };

            var mockUnitOfWork     = new Mock <IUnitOfWork>();
            var mockTaskRepository = new MockTaskRepository().MockListAsync(tasks);

            var taskService = new TaskService(mockTaskRepository.Object, mockUnitOfWork.Object);

            var results = await taskService.ListAsync();

            Assert.IsNotNull(results);
            Assert.IsTrue(results.Count() == 0);
            mockTaskRepository.VerifyListAsync(Times.Once());
        }
        public async Task TaskService_DeleteAsync_Should_DeleteFromRepository()
        {
            var mockUnitOfWork     = new Mock <IUnitOfWork>();
            var mockTaskRepository = new MockTaskRepository()
                                     .MockFindByIdAsync(Task.FromResult(Generics.Task))
                                     .MockRemove();

            var taskService = new TaskService(mockTaskRepository.Object, mockUnitOfWork.Object);

            var results = await taskService.DeleteAsync(1);

            Assert.IsNotNull(results);
            Assert.IsTrue(results.Success);
            Assert.IsInstanceOfType(results.Task, typeof(Domain.Models.Task));
            mockTaskRepository.VerifyFindByIdAsync(Times.Once());
            mockTaskRepository.VerifyRemove(Times.Once());
        }
        public async Task TaskService_DeleteAsync_InputInvalid_Should_DeleteFromRepository()
        {
            var mockUnitOfWork     = new Mock <IUnitOfWork>();
            var mockTaskRepository = new MockTaskRepository()
                                     .MockFindByIdAsync(Task.FromResult(Generics.Task))
                                     .MockRemoveInvalid();

            var taskService = new TaskService(mockTaskRepository.Object, mockUnitOfWork.Object);

            var results = await taskService.DeleteAsync(1);

            Assert.IsNotNull(results);
            Assert.IsNull(results.Task);
            Assert.IsFalse(results.Success);
            Assert.IsTrue(results.Message.Contains("An error occurred when deleting the task:"));
            mockTaskRepository.VerifyFindByIdAsync(Times.Once());
            mockTaskRepository.VerifyRemove(Times.Once());
        }
        public async Task TaskService_DeleteAsync_InputNotFound_Should_DeleteFromRepository()
        {
            var mockUnitOfWork     = new Mock <IUnitOfWork>();
            var mockTaskRepository = new MockTaskRepository()
                                     .MockFindByIdAsyncInvalid()
                                     .MockRemove();

            var taskService = new TaskService(mockTaskRepository.Object, mockUnitOfWork.Object);

            var results = await taskService.DeleteAsync(1);

            Assert.IsNotNull(results);
            Assert.IsNull(results.Task);
            Assert.IsFalse(results.Success);
            Assert.IsTrue(results.Message == Generics.TaskResponseNotFound);
            mockTaskRepository.VerifyFindByIdAsync(Times.Once());
            mockTaskRepository.VerifyRemove(Times.Never());
        }