public async Task GetAllSeiyuuRolesAsync_GivenSeiyuuWithMultipleRolesAndMainRolesOnly_ShouldReturnPartial() { // Given var seiyuuId = Guid.NewGuid(); var dbContext = InMemoryDbProvider.GetDbContext(); var repository = new SeiyuuRoleRepository(dbContext); var japanese = new LanguageBuilder().WithLanguageId(LanguageId.Japanese).Build(); var seiyuu = new SeiyuuBuilder().WithId(seiyuuId).Build(); var mainRole = new AnimeRoleTypeBuilder().WithId(AnimeRoleTypeId.Main).Build(); var supportingRole = new AnimeRoleTypeBuilder().WithId(AnimeRoleTypeId.Supporting).Build(); seiyuu.Role = new List <AnimeRole> { new AnimeRoleBuilder().WithLanguage(japanese).WithRoleType(mainRole).Build(), new AnimeRoleBuilder().WithLanguage(japanese).WithRoleType(supportingRole).Build(), new AnimeRoleBuilder().WithLanguage(japanese).WithRoleType(supportingRole).Build(), new AnimeRoleBuilder().WithLanguage(japanese).WithRoleType(supportingRole).Build(), new AnimeRoleBuilder().WithLanguage(japanese).WithRoleType(mainRole).Build() }; await dbContext.AddAsync(seiyuu); await dbContext.SaveChangesAsync(); // When var result = await repository.GetAllSeiyuuRolesAsync(seiyuuId, true); // Then result.Should().HaveCount(2); }
public async Task GetAllSeiyuuRolesAsync_GivenMultipleRoles_ShouldReturnMultiple() { // Given var seiyuuId = Guid.NewGuid(); var dbContext = InMemoryDbProvider.GetDbContext(); var repository = new SeiyuuRoleRepository(dbContext); var japanese = new LanguageBuilder().WithLanguageId(LanguageId.Japanese).Build(); var seiyuu = new SeiyuuBuilder().WithId(seiyuuId).Build(); seiyuu.Role = new List <AnimeRole> { new AnimeRoleBuilder().WithLanguage(japanese).Build(), new AnimeRoleBuilder().WithLanguage(japanese).Build(), new AnimeRoleBuilder().WithLanguage(japanese).Build(), new AnimeRoleBuilder().WithLanguage(japanese).Build(), new AnimeRoleBuilder().WithLanguage(japanese).Build(), }; await dbContext.AddAsync(seiyuu); await dbContext.SaveChangesAsync(); // When var result = await repository.GetAllSeiyuuRolesAsync(seiyuuId, false); // Then result.Should().HaveCount(5); }
public async Task GetAllSeiyuuRolesAsync_GivenNoRoles_ShouldReturnEmpty() { // Given var dbContext = InMemoryDbProvider.GetDbContext(); var repository = new SeiyuuRoleRepository(dbContext); // When var result = await repository.GetAllSeiyuuRolesAsync(Guid.NewGuid(), false); // Then result.Should().BeEmpty(); }
private static UpdateSeiyuuHandler CreateHandler(SeiyuuMoeContext dbContext) { var animeRepository = new AnimeRepository(dbContext); var seiyuuRepository = new SeiyuuRepository(dbContext); var characterRepository = new CharacterRepository(dbContext); var seiyuuRoleRepository = new SeiyuuRoleRepository(dbContext); var animeRoleRepository = new AnimeRoleRepository(dbContext); var seasonRepository = new SeasonRepository(dbContext); var jikanUrl = ConfigurationReader.JikanUrl; var jikanClient = new Jikan(jikanUrl, true); var jikanService = new JikanService(jikanClient); return(new UpdateSeiyuuHandler(seiyuuRepository, animeRepository, characterRepository, seiyuuRoleRepository, animeRoleRepository, seasonRepository, jikanService)); }
public async Task GetAllSeiyuuRolesByMalIdAsync_GivenNoRolesForAnime_ShouldReturnEmpty() { // Given const int seiyuuMalId = 1; var dbContext = InMemoryDbProvider.GetDbContext(); var repository = new SeiyuuRoleRepository(dbContext); var seiyuu = new SeiyuuBuilder().WithMalId(2).Build(); await dbContext.AddAsync(seiyuu); await dbContext.SaveChangesAsync(); // When var result = await repository.GetAllSeiyuuRolesByMalIdAsync(seiyuuMalId, false); // Then result.Should().BeEmpty(); }
public async Task GetAllSeiyuuRolesAsync_GivenAnimeWithSingleRoleInLanguageOtherThanJapanese_ShouldReturnEmpty() { // Given var seiyuuId = Guid.NewGuid(); var dbContext = InMemoryDbProvider.GetDbContext(); var repository = new SeiyuuRoleRepository(dbContext); var role = new AnimeRoleBuilder() .WithSeiyuu(x => x.WithId(seiyuuId)) .WithLanguage(x => x.WithLanguageId(LanguageId.Korean)) .Build(); await dbContext.AddAsync(role); await dbContext.SaveChangesAsync(); // When var result = await repository.GetAllSeiyuuRolesAsync(seiyuuId, false); // Then result.Should().BeEmpty(); }
public async Task GetAllSeiyuuRolesByMalIdAsync_GivenAnimeWithSingleRole_ShouldReturnSingle() { // Given const int seiyuuMalId = 1; var dbContext = InMemoryDbProvider.GetDbContext(); var repository = new SeiyuuRoleRepository(dbContext); var role = new AnimeRoleBuilder() .WithSeiyuu( x => x.WithMalId(seiyuuMalId) ) .WithLanguage(x => x.WithLanguageId(LanguageId.Japanese)) .Build(); await dbContext.AddAsync(role); await dbContext.SaveChangesAsync(); // When var result = await repository.GetAllSeiyuuRolesByMalIdAsync(seiyuuMalId, false); // Then result.Should().ContainSingle(); }