private TvDbSeriesData SetUpTvDbSeriesData(int id) { var seriesData = TvDbTestData.Series(id); _embyData.GetParentId(MediaItemTypes.Series, _sources.TvDb).Returns(id); _sources.TvDb.GetSeriesData(_embyData, Arg.Any <ProcessResultContext>()).Returns(seriesData); return(seriesData); }
public async Task GetSeriesData_ReturnsSeries() { var embyItemData = EmbyItemData("Name", 56); var seriesData = TvDbTestData.Series(56, "Name"); _tvDbClient.GetSeriesAsync(56).Returns(Option <TvDbSeriesData> .Some(seriesData)); var result = await _tvDbSource.GetSeriesData(embyItemData, TestProcessResultContext.Instance); result.IsRight.Should().BeTrue(); result.IfRight(r => r.Should().BeSameAs(seriesData)); }
public async Task LoadFrom_CreatesSourceData() { var tvDbSeriesData = TvDbTestData.Series(22, "SeriesName"); _tvDbClient.FindSeriesAsync("SeriesName").Returns(tvDbSeriesData); var loader = new TvDbSeriesFromEmbyData(_tvDbClient, _sources); var result = await loader.LoadFrom(_embyItemData); result.IsRight.Should().BeTrue(); result.IfRight(sd => sd.Data.Should().Be(tvDbSeriesData)); result.IfRight(sd => sd.Source.Should().Be(_sources.TvDb)); result.IfRight(sd => sd.Identifier.Should().BeEquivalentTo(new ItemIdentifier(2, Option <int> .None, "SeriesName"))); }
public async Task LoadFrom_MapsToTvDbSeries() { this.CreateAniDbSeries(342, "SeriesName"); this.SetUpSeriesMapping(342, 66); var tvDbSeriesData = TvDbTestData.Series(66); this.sources.TvDb.GetSeriesData(66, Arg.Any <ProcessResultContext>()) .Returns(tvDbSeriesData); var loader = new TvDbSeriesFromAniDb(this.sources, this.mappingList); var result = await loader.LoadFrom(this.mediaItem, this.aniDbSourceData); result.IsRight.Should().BeTrue(); result.IfRight(sd => sd.Data.Should().Be(tvDbSeriesData)); result.IfRight(sd => sd.Source.Should().Be(this.sources.TvDb)); result.IfRight(sd => sd.Id.ValueUnsafe().Should().Be(66)); result.IfRight(sd => sd.Identifier.Should().BeEquivalentTo(new ItemIdentifier(Option <int> .None, Option <int> .None, string.Empty))); }
public void Setup() { this.tvDbSource = Substitute.For <ITvDbSource>(); this.tvDbSource.Name.Returns(SourceNames.TvDb); this.sources = Substitute.For <ISources>(); this.sources.TvDb.Returns(this.tvDbSource); var embyItemData = Substitute.For <IEmbyItemData>(); embyItemData.Identifier.Returns(new ItemIdentifier(67, 1, "Name")); embyItemData.Language.Returns("en"); this.mediaItem = Substitute.For <IMediaItem>(); this.mediaItem.EmbyData.Returns(embyItemData); this.tvDbSeriesData = TvDbTestData.Series(3, "Title"); this.tvDbSource.GetSeriesData(this.mediaItem.EmbyData, Arg.Any <ProcessResultContext>()) .Returns(this.tvDbSeriesData); }