Пример #1
0
        public async Task GetAllRolesInSeason_GivenSeasonWithSingleAnimeWithSingleRole_ShouldReturnSingle()
        {
            // Given
            var animeId    = Guid.NewGuid();
            var dbContext  = InMemoryDbProvider.GetDbContext();
            var repository = new SeasonRoleRepository(dbContext);

            var role = new AnimeRoleBuilder()
                       .WithAnime(x => x.WithId(animeId))
                       .WithLanguage(x => x.WithLanguageId(LanguageId.Japanese))
                       .WithRoleType(x => x.WithId(AnimeRoleTypeId.Main))
                       .Build();

            await dbContext.AddAsync(role);

            await dbContext.SaveChangesAsync();

            // When
            var result = await repository.GetAllRolesInSeason(new List <Guid> {
                animeId
            }, false);

            // Then
            result.Should().ContainSingle();
        }
Пример #2
0
        public async Task GetAllRolesInSeason_GivenSeasonWithSingleAnimeWithMultipleRolesAndMainRolesOnly_ShouldReturnPartial()
        {
            // Given
            var animeId    = Guid.NewGuid();
            var dbContext  = InMemoryDbProvider.GetDbContext();
            var repository = new SeasonRoleRepository(dbContext);

            var japanese       = new LanguageBuilder().WithLanguageId(LanguageId.Japanese).Build();
            var anime          = new AnimeBuilder().WithId(animeId).Build();
            var mainRole       = new AnimeRoleTypeBuilder().WithId(AnimeRoleTypeId.Main).Build();
            var supportingRole = new AnimeRoleTypeBuilder().WithId(AnimeRoleTypeId.Supporting).Build();

            anime.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(anime);

            await dbContext.SaveChangesAsync();

            // When
            var result = await repository.GetAllRolesInSeason(new List <Guid> {
                animeId
            }, true);

            // Then
            result.Should().HaveCount(2);
        }
Пример #3
0
        public async Task GetAllRolesInSeason_GivenSeasonWithSingleAnimeWithMultipleRoles_ShouldReturnMultiple()
        {
            // Given
            var animeId    = Guid.NewGuid();
            var dbContext  = InMemoryDbProvider.GetDbContext();
            var repository = new SeasonRoleRepository(dbContext);

            var japanese = new LanguageBuilder().WithLanguageId(LanguageId.Japanese).Build();
            var anime    = new AnimeBuilder().WithId(animeId).Build();

            anime.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(anime);

            await dbContext.SaveChangesAsync();

            // When
            var result = await repository.GetAllRolesInSeason(new List <Guid> {
                animeId
            }, false);

            // Then
            result.Should().HaveCount(5);
        }
Пример #4
0
        public async Task GetAllRolesInSeason_GivenNoRoles_ShouldReturnEmpty()
        {
            // Given
            var dbContext  = InMemoryDbProvider.GetDbContext();
            var repository = new SeasonRoleRepository(dbContext);

            // When
            var result = await repository.GetAllRolesInSeason(new List <Guid> {
                Guid.NewGuid()
            }, false);

            // Then
            result.Should().BeEmpty();
        }
Пример #5
0
        public async Task GetAllRolesInSeason_GivenNoRolesInSeason_ShouldReturnEmpty()
        {
            // Given
            var animeId    = Guid.NewGuid();
            var dbContext  = InMemoryDbProvider.GetDbContext();
            var repository = new SeasonRoleRepository(dbContext);

            var anime = new AnimeRoleBuilder()
                        .WithAnime(x => x.WithId(Guid.NewGuid()))
                        .WithLanguage(x => x.WithLanguageId(LanguageId.Japanese))
                        .Build();

            await dbContext.AddAsync(anime);

            await dbContext.SaveChangesAsync();

            // When
            var result = await repository.GetAllRolesInSeason(new List <Guid> {
                animeId
            }, false);

            // Then
            result.Should().BeEmpty();
        }