Ejemplo n.º 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();
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 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();
        }