public async Task AddTVShows(IEnumerable <TVShowDTO> tvShows) { foreach (var tvShow in tvShows) { await tvShowRepository.AddTVShows(tvShow); foreach (var item in tvShow.Cast) { await tvShowRepository.AddCasts(item); TVShowCastMemberDTO relation = new TVShowCastMemberDTO(tvShow.Id, item.Id); await tvShowRepository.AddRelation(relation); } } }
public void AddRelation_Succesfully() { Task.Run(async() => { CastMemberDTO mockCasMember_5 = new CastMemberDTO(5, "mockMember_5", "12-07-1989"); TVShowDTO mockTvShow_5 = new TVShowDTO(5, "mockTvShow_4", new List <CastMemberDTO> { mockCasMember_5 }); TVShowCastMemberDTO relation = new TVShowCastMemberDTO(mockTvShow_5.Id, mockCasMember_5.Id); await repo.AddTVShows(mockTvShow_5); await repo.AddCasts(mockCasMember_5); await repo.AddRelation(relation); var tvShows = await repo.GetTVShows(); var castId = tvShows.Where(x => x.Id == mockCasMember_5.Id).First().Id; Assert.AreEqual(mockTvShow_5.Id, castId); }).GetAwaiter().GetResult(); }