Ejemplo n.º 1
0
        public Task <Either <ProcessFailedResult, ISourceData> > LoadFrom(IEmbyItemData embyItemData)
        {
            var resultContext = new ProcessResultContext(nameof(TvDbSeriesFromEmbyData), embyItemData.Identifier.Name,
                                                         embyItemData.ItemType);

            return(_tvDbClient.FindSeriesAsync(embyItemData.Identifier.Name)
                   .ToEitherAsync(resultContext.Failed("Failed to find series in TvDb"))
                   .MapAsync(s => CreateSourceData(s, embyItemData)));
        }
        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")));
        }