public async Task GetByIdAsync_ThrowsException_WhenNotFound() { A.CallTo(() => _genresRepository.FindSingleAsync(A <Expression <Func <Genre, bool> > > ._)) .Returns((Genre)null); Func <Task> action = async() => await _genreServices.GetByIdAsync(Id); await action.Should().ThrowAsync <EntityNotFoundException <Genre> >() .WithMessage($"Entity Genre wasn't found. Id: {Id}"); }
async Task DeleteGenreAsync() { Console.Write("Enter Genre Id = "); int id = Convert.ToInt32(Console.ReadLine()); Genre g = await genreService.GetByIdAsync(id); if (await genreService.DeleteGenreAsync(id) > 0) { Console.WriteLine($"Genre Id: {id} Name: {g.Name} deleted"); } else { Console.WriteLine("Some error occurred"); } }