public async Task ValidateAsync_BoardExist() { // Arrange var boardContainer = new Mock <IBoardContainer>(); var board = new Board(); var boardDataAccess = new Mock <IBoardDataAccess>(); boardDataAccess.Setup(x => x.GetByAsync(boardContainer.Object)).ReturnsAsync(board); var boardGetService = new BoardGetService(boardDataAccess.Object); // Act var action = new Func <Task>(() => boardGetService.ValidateAsync(boardContainer.Object)); // Assert await action.Should().NotThrowAsync <Exception>(); }
public async Task ValidateAsync_BoardNotExist() { // Arrange var fixture = new Fixture(); var id = fixture.Create <int>(); var boardContainer = new Mock <IBoardContainer>(); boardContainer.Setup(x => x.BoardId).Returns(id); var board = new Board(); var boardDataAccess = new Mock <IBoardDataAccess>(); boardDataAccess.Setup(x => x.GetByAsync(boardContainer.Object)) .ReturnsAsync((Board)null); var boardGetService = new BoardGetService(boardDataAccess.Object); // Act var action = new Func <Task>(() => boardGetService.ValidateAsync(boardContainer.Object)); // Assert await action.Should().ThrowAsync <InvalidOperationException>($"Board not found by id {id}"); }