public async Task GetChampionShouldThrowArgumentNullExceptionIfGivenInvalidId() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase("championTest"); var db = new ApplicationDbContext(options.Options); int invalidChampionId = -100; var service = new ChampionsService(db); await Assert.ThrowsAsync <ArgumentNullException>(async() => await service.GetChampion(invalidChampionId)); }
public async Task GetChampionShouldReturnTheChampionWithTheGivenId() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase("championTest"); var db = new ApplicationDbContext(options.Options); int expectedChampionId = 33; string expectedChampionName = "Gangplank"; var service = new ChampionsService(db); var result = await service.GetChampion(expectedChampionId); Assert.NotNull(result); Assert.Equal(expectedChampionId, result.ChampionId); Assert.Equal(expectedChampionName, result.ChampionName); }