public async Task GetAsync_GivenMultipleExistingAnimeOneOfWhichWithId_ShouldReturnResult() { // Given var dbContext = InMemoryDbProvider.GetDbContext(); var repository = new CharacterRepository(dbContext); var character1 = new CharacterBuilder().WithMalId(1).Build(); var character2 = new CharacterBuilder().WithMalId(2).Build(); var character3 = new CharacterBuilder().WithMalId(3).Build(); var character4 = new CharacterBuilder().WithMalId(4).Build(); var character5 = new CharacterBuilder().WithMalId(5).Build(); await dbContext.AnimeCharacters.AddAsync(character1); await dbContext.AnimeCharacters.AddAsync(character2); await dbContext.AnimeCharacters.AddAsync(character3); await dbContext.AnimeCharacters.AddAsync(character4); await dbContext.AnimeCharacters.AddAsync(character5); await dbContext.SaveChangesAsync(); // When var result = await repository.GetAsync(3); // Then result.Should().NotBeNull(); result.MalId.Should().Be(3); }
public async Task GetAsync_GivenNoCharacter_ShouldReturnNull() { // Given var dbContext = InMemoryDbProvider.GetDbContext(); var repository = new CharacterRepository(dbContext); // When var result = await repository.GetAsync(1); // Then result.Should().BeNull(); }
public async Task GetAsync_GivenExistingCharacterWithId_ShouldReturnResult() { // Given var dbContext = InMemoryDbProvider.GetDbContext(); var repository = new CharacterRepository(dbContext); var character = new CharacterBuilder().WithMalId(1).Build(); await dbContext.AnimeCharacters.AddAsync(character); await dbContext.SaveChangesAsync(); // When var result = await repository.GetAsync(1); // Then result.Should().NotBeNull(); }