Beispiel #1
0
        public async Task GetSeriesData_NoSeriesLoaded_ReturnsFailed()
        {
            var embyItemData = EmbyItemData("Name", 56);

            _aniDbClient.GetSeriesAsync(56).Returns(Option <AniDbSeriesData> .None);

            var result = await _aniDbSource.GetSeriesData(embyItemData, new ProcessResultContext("", "", null));

            result.IsLeft.Should().BeTrue();
            result.IfLeft(f => f.Reason.Should().Be("Failed to load parent series with AniDb Id '56'"));
        }
Beispiel #2
0
 private OptionAsync <AniDbEpisodeData> GetAniDbEpisodeAsync(int aniDbSeriesId, int seasonIndex,
                                                             int episodeIndex)
 {
     return(_aniDbClient.GetSeriesAsync(aniDbSeriesId)
            .BindAsync(aniDbSeries =>
                       aniDbSeries.Episodes.Find(e =>
                                                 e.EpisodeNumber.SeasonNumber == seasonIndex && e.EpisodeNumber.Number == episodeIndex)));
 }
Beispiel #3
0
 public Task <Either <ProcessFailedResult, AniDbSeriesData> > GetSeriesData(IEmbyItemData embyItemData,
                                                                            ProcessResultContext resultContext)
 {
     return(embyItemData.GetParentId(MediaItemTypes.Series, this)
            .ToEitherAsync(
                resultContext.Failed("No AniDb Id found on parent series"))
            .BindAsync(aniDbSeriesId => _aniDbClient.GetSeriesAsync(aniDbSeriesId)
                       .ToEitherAsync(
                           resultContext.Failed($"Failed to load parent series with AniDb Id '{aniDbSeriesId}'"))));
 }
        public void Setup()
        {
            _tvDbClient  = Substitute.For <ITvDbClient>();
            _aniDbClient = Substitute.For <IAniDbClient>();

            _tvDbEpisodeA  = TestData.TvDbTestData.Episode(12, 48, 2);
            _tvDbEpisodeB  = TestData.TvDbTestData.Episode(45, 7, 2);
            _aniDbEpisodeA = new AniDbEpisodeData
            {
                RawEpisodeNumber = new EpisodeNumberData
                {
                    RawNumber = "44",
                    RawType   = 1
                }
            };
            _aniDbEpisodeB = new AniDbEpisodeData
            {
                RawEpisodeNumber = new EpisodeNumberData
                {
                    RawNumber = "23",
                    RawType   = 1
                }
            };

            _tvDbClient.GetEpisodesAsync(123)
            .Returns(Option <List <TvDbEpisodeData> > .Some(new List <TvDbEpisodeData> {
                _tvDbEpisodeA, _tvDbEpisodeB
            }));
            _aniDbClient.GetSeriesAsync(77)
            .Returns(Option <AniDbSeriesData> .Some(new AniDbSeriesData
            {
                Episodes = new[] { _aniDbEpisodeA, _aniDbEpisodeB }
            }));

            _mapper = new GroupMappingEpisodeMapper(_tvDbClient, _aniDbClient, new ConsoleLogManager());
        }
 private Task <Option <AniDbSeriesData> > GetAniDbSeriesAsync(Series embySeries)
 {
     return(_aniDbClient.GetSeriesAsync(embySeries.ProviderIds.GetOrDefault(SourceNames.AniDb)));
 }