Exemplo n.º 1
0
            public void AppliesPropertyMappingsForIdentifierOnlySourceData()
            {
                var identifierOnlySourceData = new IdentifierOnlySourceData(_sources.AniDb, 33, new ItemIdentifier(33, 1, "Name"));

                MediaItem = Substitute.For <IMediaItem>();
                MediaItem.GetAllSourceData().Returns(new ISourceData[] { identifierOnlySourceData });

                MediaItemType.CreateMetadataFoundResult(PluginConfiguration, MediaItem, new ConsoleLogManager());

                PropertyMappings.Received(1)
                .Apply(Arg.Is <IEnumerable <object> >(e => e.Contains(identifierOnlySourceData)), Arg.Any <MetadataResult <Series> >(),
                       Arg.Any <Action <string> >());
            }
        public void SeasonMappings_MapsAllFields()
        {
            var source = new IdentifierOnlySourceData(TestSources.TvDbSource, 1, new ItemIdentifier(1, Option <int> .None, "Season 1"), MediaItemTypes.Season);

            var target = new MetadataResult <Season>
            {
                Item = new Season()
            };

            var tvDbSourceMappingConfiguration = new TvDbSourceMappingConfiguration();

            tvDbSourceMappingConfiguration.GetSeasonMappings(3, true, TitleType.Localized, "en")
            .Count(m => m.CanApply(source, target))
            .Should()
            .Be(1);

            tvDbSourceMappingConfiguration.GetSeasonMappings(3, true, TitleType.Localized, "en")
            .Iter(m => m.Apply(source, target));

            target.Item.Name.Should().Be("Season 1");
        }
Exemplo n.º 3
0
        private Task <Either <ProcessFailedResult, int> > MapSeriesDataAsync(int tvDbSeriesId, IdentifierOnlySourceData identifierData, ProcessResultContext resultContext)
        {
            var seriesMapping = this.mappingList.GetSeriesMappingsFromTvDb(tvDbSeriesId, resultContext)
                                .BindAsync(sm => sm.Where(m => m.DefaultTvDbSeason.Exists(s => s.Index == identifierData.Identifier.Index))
                                           .Match(
                                               () => resultContext.Failed(
                                                   $"No series mapping between TvDb series Id '{tvDbSeriesId}', season '{identifierData.Identifier.Index}'' and AniDb series"),
                                               Prelude.Right <ProcessFailedResult, ISeriesMapping>,
                                               (head, tail) =>
                                               resultContext.Failed(
                                                   $"Multiple series mappings found between TvDb series Id '{tvDbSeriesId}', season '{identifierData.Identifier.Index}'' and AniDb series")));

            return(seriesMapping.MapAsync(sm => sm.Ids.AniDbSeriesId));
        }