public async Task BoardService_DeleteAsync_Should_DeleteFromRepository() { var mockUnitOfWork = new Mock <IUnitOfWork>(); var mockBoardRepository = new MockBoardRepository() .MockFindAsync(Task.FromResult(Generics.Board)) .MockRemove(); var BoardService = new BoardService(mockBoardRepository.Object, mockUnitOfWork.Object); var results = await BoardService.DeleteAsync(1); Assert.IsNotNull(results); Assert.IsTrue(results.Success); Assert.IsInstanceOfType(results.Board, typeof(Domain.Models.Board)); mockBoardRepository.VerifyFindAsync(Times.Once()); mockBoardRepository.VerifyRemove(Times.Once()); }
public async Task BoardService_DeleteAsync_InputInvalid_Should_DeleteFromRepository() { var mockUnitOfWork = new Mock <IUnitOfWork>(); var mockBoardRepository = new MockBoardRepository() .MockFindAsync(Task.FromResult(Generics.Board)) .MockRemoveInvalid(); var BoardService = new BoardService(mockBoardRepository.Object, mockUnitOfWork.Object); var results = await BoardService.DeleteAsync(1); Assert.IsNotNull(results); Assert.IsNull(results.Board); Assert.IsFalse(results.Success); Assert.IsTrue(results.Message.Contains("An error occurred when deleting the board:")); mockBoardRepository.VerifyFindAsync(Times.Once()); mockBoardRepository.VerifyRemove(Times.Once()); }
public async Task BoardService_DeleteAsync_InputNotFound_Should_DeleteFromRepository() { var mockUnitOfWork = new Mock <IUnitOfWork>(); var mockBoardRepository = new MockBoardRepository() .MockFindAsyncInvalid() .MockRemove(); var BoardService = new BoardService(mockBoardRepository.Object, mockUnitOfWork.Object); var results = await BoardService.DeleteAsync(1); Assert.IsNotNull(results); Assert.IsNull(results.Board); Assert.IsFalse(results.Success); Assert.IsTrue(results.Message == Generics.BoardResponseNotFound); mockBoardRepository.VerifyFindAsync(Times.Once()); mockBoardRepository.VerifyRemove(Times.Never()); }