public async Task TestDeleteFilmAsync_GetInvalidId_ThrowFilmNotExistException() { // Arrange int filmId = 3; filmRepository.Setup(f => f.DeleteFilmAsync(filmId)) .ReturnsAsync(filmsList.FirstOrDefault(f => f.FilmId == filmId)); FilmService service = new FilmService(filmRepository.Object, ratingRepository.Object, mapper); // Act, Assert await Assert.ThrowsAsync <FilmNotExistException>(() => service.DeleteFilmAsync(filmId)); }
public async Task TestDeleteFilmAsync_GetValidId_ReturnDeletedFilmSuccessfully() { // Arrange int filmId = 2; filmRepository.Setup(f => f.DeleteFilmAsync(filmId)) .ReturnsAsync(filmsList.FirstOrDefault(f => f.FilmId == filmId)); FilmService service = new FilmService(filmRepository.Object, ratingRepository.Object, mapper); // Act var result = await service.DeleteFilmAsync(filmId); //Assert Assert.NotNull(result); Assert.Equal(3.7, result?.Rating); }