|
| 1 | +using Jellyfin.Plugin.MetaShark.Api; |
| 2 | +using Jellyfin.Plugin.MetaShark.Core; |
| 3 | +using Jellyfin.Plugin.MetaShark.Model; |
| 4 | +using Jellyfin.Plugin.MetaShark.Providers; |
| 5 | +using MediaBrowser.Controller.Library; |
| 6 | +using MediaBrowser.Controller.Providers; |
| 7 | +using MediaBrowser.Model.Entities; |
| 8 | +using Microsoft.AspNetCore.Http; |
| 9 | +using Microsoft.Extensions.Logging; |
| 10 | +using Moq; |
| 11 | +using System; |
| 12 | +using System.Collections.Generic; |
| 13 | +using System.Linq; |
| 14 | +using System.Text; |
| 15 | +using System.Threading.Tasks; |
| 16 | + |
| 17 | +namespace Jellyfin.Plugin.MetaShark.Test |
| 18 | +{ |
| 19 | + [TestClass] |
| 20 | + public class SeriesImageProviderTest |
| 21 | + { |
| 22 | + |
| 23 | + ILoggerFactory loggerFactory = LoggerFactory.Create(builder => |
| 24 | + builder.AddSimpleConsole(options => |
| 25 | + { |
| 26 | + options.IncludeScopes = true; |
| 27 | + options.SingleLine = true; |
| 28 | + options.TimestampFormat = "hh:mm:ss "; |
| 29 | + })); |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | + [TestMethod] |
| 35 | + public void TestGetMovieImageFromTMDB() |
| 36 | + { |
| 37 | + var info = new MediaBrowser.Controller.Entities.Movies.Movie() |
| 38 | + { |
| 39 | + PreferredMetadataLanguage = "zh", |
| 40 | + ProviderIds = new Dictionary<string, string> { { MetadataProvider.Tmdb.ToString(), "67534" }, { Plugin.ProviderId, MetaSource.Tmdb } } |
| 41 | + }; |
| 42 | + var doubanApi = new DoubanApi(loggerFactory); |
| 43 | + var tmdbApi = new TmdbApi(loggerFactory); |
| 44 | + var omdbApi = new OmdbApi(loggerFactory); |
| 45 | + var httpClientFactory = new DefaultHttpClientFactory(); |
| 46 | + var libraryManagerStub = new Mock<ILibraryManager>(); |
| 47 | + var httpContextAccessorStub = new Mock<IHttpContextAccessor>(); |
| 48 | + |
| 49 | + Task.Run(async () => |
| 50 | + { |
| 51 | + var provider = new SeriesImageProvider(httpClientFactory, loggerFactory, libraryManagerStub.Object, httpContextAccessorStub.Object, doubanApi, tmdbApi, omdbApi); |
| 52 | + var result = await provider.GetImages(info, CancellationToken.None); |
| 53 | + Assert.IsNotNull(result); |
| 54 | + |
| 55 | + var str = result.ToJson(); |
| 56 | + Console.WriteLine(result.ToJson()); |
| 57 | + }).GetAwaiter().GetResult(); |
| 58 | + } |
| 59 | + } |
| 60 | +} |
0 commit comments