public async Task GetAllRolesInAnimeAsync_GivenAnimeWithSingleRoleInLanguageOtherThanJapanese_ShouldReturnEmpty() { // Given const int animeMalId = 1; var animeId = Guid.NewGuid(); var dbContext = InMemoryDbProvider.GetDbContext(); var repository = new AnimeRoleRepository(dbContext); var role = new AnimeRoleBuilder() .WithAnime( x => x.WithMalId(animeMalId).WithId(animeId) ) .WithLanguage(x => x.WithLanguageId(LanguageId.Korean)) .Build(); await dbContext.AddAsync(role); await dbContext.SaveChangesAsync(); // When var result = await repository.GetAllRolesInAnimeAsync(animeId); // Then result.Should().BeEmpty(); }
private static InsertSeiyuuHandler CreateHandler(SeiyuuMoeContext dbContext) { var scheduleConfiguration = ConfigurationReader.MalBgJobsScheduleConfiguration; var animeRepository = new AnimeRepository(dbContext); var seiyuuRepository = new SeiyuuRepository(dbContext); var characterRepository = new CharacterRepository(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); var s3Client = new S3Service(); return(new InsertSeiyuuHandler( scheduleConfiguration.InsertSeiyuuBatchSize, scheduleConfiguration.DelayBetweenCallsInSeconds, seiyuuRepository, seasonRepository, characterRepository, animeRepository, animeRoleRepository, jikanService, s3Client )); }
public async Task GetAllRolesInAnimeAsync_GivenNoRoles_ShouldReturnEmpty() { // Given var animeId = Guid.NewGuid(); var dbContext = InMemoryDbProvider.GetDbContext(); var repository = new AnimeRoleRepository(dbContext); // When var result = await repository.GetAllRolesInAnimeAsync(animeId); // Then result.Should().BeEmpty(); }
public async Task AddAsync_GivenAnime_ShouldAddAnime() { // Given var dbContext = InMemoryDbProvider.GetDbContext(); var repository = new AnimeRoleRepository(dbContext); const string expectedAnimeTitle = "expectedTitle"; const string expectedSeiyuuName = "expectedSeiyuuName"; const string expectedcharacterName = "expectedCharacterName"; const string expectedRoleTypeName = "Main"; var expectedLanguage = LanguageId.Japanese; var role = new AnimeRoleBuilder() .WithAnime(x => x.WithTitle(expectedAnimeTitle)) .WithSeiyuu(x => x.WithName(expectedSeiyuuName)) .WithCharacter(x => x.WithName(expectedcharacterName)) .WithRoleType(x => x.WithDescription(expectedRoleTypeName)) .WithLanguage(x => x.WithLanguageId(expectedLanguage)) .Build(); // When await repository.AddAsync(role); // Then var allroles = await dbContext.AnimeRoles.ToListAsync(); var newRole = await dbContext.AnimeRoles .Include(x => x.Anime) .Include(x => x.Character) .Include(x => x.Seiyuu) .Include(x => x.Language) .Include(x => x.RoleType) .FirstOrDefaultAsync(); using (new AssertionScope()) { allroles.Should().ContainSingle(); newRole.Should().NotBeNull(); newRole.Anime.Should().NotBeNull(); newRole.Anime.Title.Should().Be(expectedAnimeTitle); newRole.Character.Should().NotBeNull(); newRole.Character.Name.Should().Be(expectedcharacterName); newRole.Seiyuu.Should().NotBeNull(); newRole.Seiyuu.Name.Should().Be(expectedSeiyuuName); newRole.Language.Should().NotBeNull(); newRole.Language.Id.Should().Be(expectedLanguage); newRole.RoleType.Should().NotBeNull(); newRole.RoleType.Description.Should().Be(expectedRoleTypeName); } }
public async Task AddAsync_GivenEmptyRole_ShouldAddRole() { // Given var dbContext = InMemoryDbProvider.GetDbContext(); var repository = new AnimeRoleRepository(dbContext); // When await repository.AddAsync(new AnimeRoleBuilder().Build()); // Then var allRoles = await dbContext.AnimeRoles.ToListAsync(); allRoles.Should().ContainSingle(); }
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 GetAllRolesInAnimeAsync_GivenNoRolesForAnime_ShouldReturnEmpty() { // Given var animeId = Guid.NewGuid(); var dbContext = InMemoryDbProvider.GetDbContext(); var repository = new AnimeRoleRepository(dbContext); var anime = new AnimeBuilder().WithMalId(2).WithId(animeId).Build(); await dbContext.AddAsync(anime); await dbContext.SaveChangesAsync(); // When var result = await repository.GetAllRolesInAnimeAsync(animeId); // Then result.Should().BeEmpty(); }
private InsertSeiyuuHandler CreateHandler(SeiyuuMoeContext dbContext, JikanService jikanService, IS3Service s3Service, int insertSeiyuuBatchSize) { var animeRepository = new AnimeRepository(dbContext); var seiyuuRepository = new SeiyuuRepository(dbContext); var characterRepository = new CharacterRepository(dbContext); var animeRoleRepository = new AnimeRoleRepository(dbContext); var seasonRepository = new SeasonRepository(dbContext); return(new InsertSeiyuuHandler( insertSeiyuuBatchSize, 0, seiyuuRepository, seasonRepository, characterRepository, animeRepository, animeRoleRepository, jikanService, s3Service )); }
public async Task AddAsync_GivenExistingRoleWithSameValues_ShouldAdd() { // Given var dbContext = InMemoryDbProvider.GetDbContext(); var repository = new AnimeRoleRepository(dbContext); var role1 = new AnimeRoleBuilder() .Build(); var role2 = new AnimeRoleBuilder() .Build(); await repository.AddAsync(role1); // When Func <Task> func = repository.Awaiting(x => x.AddAsync(role2)); // Then func.Should().NotThrow <Exception>(); }
private CompareAnimeQueryHandler CreateHandler(SeiyuuMoeContext seiyuuMoeContext) { var animeRepository = new AnimeRoleRepository(seiyuuMoeContext); return(new CompareAnimeQueryHandler(animeRepository)); }