private TvDbEpisodeData SetUpTvDbEpisodeData(int id, int tvDbEpisodeIndex, int tvDbSeasonIndex) { var episodeData = TvDbTestData.Episode(id, tvDbEpisodeIndex, tvDbSeasonIndex); _embyData.GetParentId(MediaItemTypes.Series, _sources.TvDb).Returns(id); _tvDbSourceData.Data.Returns(episodeData); return(episodeData); }
public async Task MapAniDbEpisodeAsync_NoGroupMapping_UsesDefaultSeasonMapper() { var expected = TvDbTestData.Episode(3); this.defaultSeasonEpisodeMapper.MapEpisodeAsync(3, this.seriesMapping).Returns(expected); var episodeMapper = new EpisodeMapper(this.defaultSeasonEpisodeMapper, this.groupMappingEpisodeMapper); var episodeData = await episodeMapper .MapAniDbEpisodeAsync(3, this.seriesMapping, Option <EpisodeGroupMapping> .None) .ToOption(); episodeData.ValueUnsafe().Should().Be(expected); }
public async Task MapEpisodeAsync_AbsoluteDefaultTvDbSeason_MapsOnAbsoluteEpisodeIndex() { this.seriesMapping.Ids.Returns(new SeriesIds(12, 33, Option <int> .None, Option <int> .None)); this.seriesMapping.DefaultTvDbSeason.Returns(new AbsoluteTvDbSeason()); var tvDbEpisodeData = TvDbTestData.Episode(3); this.tvDbClient.GetEpisodeAsync(33, 10).Returns(tvDbEpisodeData); var defaultSeasonEpisodeMapper = new DefaultSeasonEpisodeMapper(this.tvDbClient, this.logManager); var result = await defaultSeasonEpisodeMapper.MapEpisodeAsync(10, this.seriesMapping); await this.tvDbClient.Received(1).GetEpisodeAsync(33, 10); result.ValueUnsafe().Should().Be(tvDbEpisodeData); }
public async Task LoadFrom_NoMatchingEpisode_Fails() { this.embyItemData.Identifier.Returns(new ItemIdentifier(4, 1, "Name")); this.tvDbClient.GetEpisodesAsync(22) .Returns(new[] { TvDbTestData.Episode(1, 1, 1, name: "NonMatch1"), TvDbTestData.Episode(1, 4, 2, name: "NonMatch2") }.ToList()); var loader = new TvDbEpisodeFromEmbyData(this.sources, this.tvDbClient, this.titleNormaliser); var result = await loader.LoadFrom(this.embyItemData); result.IsLeft.Should().BeTrue(); result.IfLeft(f => f.Reason.Should().Be("Failed to find TvDb episode")); }
public async Task MapAniDbEpisodeAsync_GroupMappingWithTvDbSeriesId_UsesGroupMappingEpisodeMapper() { this.seriesMapping = new SeriesMapping(new SeriesIds(123, 523, Option <int> .None, Option <int> .None), new AbsoluteTvDbSeason(), 2, new List <EpisodeGroupMapping>(), new List <SpecialEpisodePosition>()); var episodeGroupMapping = new EpisodeGroupMapping(1, 1, 3, 1, 1, new List <EpisodeMapping>()); var expected = TvDbTestData.Episode(3); this.groupMappingEpisodeMapper.MapAniDbEpisodeAsync(3, episodeGroupMapping, 523).Returns(expected); var episodeMapper = new EpisodeMapper(this.defaultSeasonEpisodeMapper, this.groupMappingEpisodeMapper); var episodeData = await episodeMapper.MapAniDbEpisodeAsync(3, this.seriesMapping, episodeGroupMapping).ToOption(); episodeData.ValueUnsafe().Should().Be(expected); }
public async Task MapEpisodeAsync_DefaultTvDbSeason_MapsOnSeasonAndEpisodeIndex() { _seriesMapping.Ids.Returns(new SeriesIds(12, 33, Option <int> .None, Option <int> .None)); _seriesMapping.DefaultTvDbSeason.Returns(new TvDbSeason(54)); _seriesMapping.DefaultTvDbEpisodeIndexOffset.Returns(7); var tvDbEpisodeData = TvDbTestData.Episode(3); _tvDbClient.GetEpisodeAsync(33, 54, 17).Returns(tvDbEpisodeData); var defaultSeasonEpisodeMapper = new DefaultSeasonEpisodeMapper(_tvDbClient, _logManager); var result = await defaultSeasonEpisodeMapper.MapEpisodeAsync(10, _seriesMapping); await _tvDbClient.Received(1).GetEpisodeAsync(33, 54, 17); result.ValueUnsafe().Should().Be(tvDbEpisodeData); }
public async Task LoadFrom_MatchOnTitle_CreatesSourceData() { var expected = TvDbTestData.Episode(1, 6, 1, name: "Match"); this.embyItemData.Identifier.Returns(new ItemIdentifier(4, 2, "Match")); this.tvDbClient.GetEpisodesAsync(22) .Returns(new[] { TvDbTestData.Episode(1, 1, 1, name: "NonMatch"), expected }.ToList()); var loader = new TvDbEpisodeFromEmbyData(this.sources, this.tvDbClient, this.titleNormaliser); var result = await loader.LoadFrom(this.embyItemData); result.IsRight.Should().BeTrue(); result.IfRight(sd => sd.Data.Should().Be(expected)); result.IfRight(sd => sd.Source.Should().Be(this.sources.TvDb)); result.IfRight(sd => sd.Identifier.Should().BeEquivalentTo(new ItemIdentifier(6, 1, "Match"))); }
public async Task LoadFrom_MatchOnEpisodeAndDefaultSeasonIndex_CreatesSourceData() { var expected = TvDbTestData.Episode(1, 4, 1, name: "Match"); _embyItemData.Identifier.Returns(new ItemIdentifier(4, Option <int> .None, "Name")); _tvDbClient.GetEpisodesAsync(22) .Returns(new[] { TvDbTestData.Episode(1, 1, 2, name: "NonMatch"), expected }.ToList()); var loader = new TvDbEpisodeFromEmbyData(_sources, _tvDbClient, _titleNormaliser); var result = await loader.LoadFrom(_embyItemData); result.IsRight.Should().BeTrue(); result.IfRight(sd => sd.Data.Should().Be(expected)); result.IfRight(sd => sd.Source.Should().Be(_sources.TvDb)); result.IfRight(sd => sd.Identifier.Should().BeEquivalentTo(new ItemIdentifier(4, 1, "Match"))); }
private TvDbEpisodeData CreateTvDbEpisodeData(int episodeIndex, int season = 1, string name = "TvDbEpisodeName") { return(TvDbTestData.Episode(3, episodeIndex, season, name: name)); }