Esempio n. 1
0
        public void VerifyDirectoryGetsSearchedForAllImageFormats_VerifyFoundImagesGetLoaded()
        {
            var directory = new Mock <IDirectory>();

            directory.Setup(d => d.GetFiles("Homer Simpson", It.IsAny <string>(), It.IsAny <SearchOption>()))
            .Returns <string, string, SearchOption>((path, searchPattern, searchOption) => new[]
            {
                searchPattern
            });

            var imageLoader = new Mock <IImageLoader>();

            imageLoader.Setup(i => i.Load(It.IsAny <string>())).Returns(new Bitmap(1, 1));

            var imageProvider = new ImageProvider(directory.Object, imageLoader.Object);

            var images = imageProvider.GetImages("Homer Simpson");

            var imageFormats = new List <string>
            {
                "*.jpg",
                "*.jpeg",
                "*.png",
                "*.bmp"
            };

            foreach (string imageFormat in imageFormats)
            {
                directory.Verify(x => x.GetFiles("Homer Simpson", imageFormat, SearchOption.TopDirectoryOnly), Times.Once);
                imageLoader.Verify(i => i.Load(imageFormat), Times.Once);
            }

            Assert.AreEqual(4, images.Count());
        }
        public async Task <IEnumerable <RemoteImageInfo> > GetImages(int[] siteNum, string[] sceneID, BaseItem item, CancellationToken cancellationToken)
        {
            var result = new List <RemoteImageInfo>();

            if (sceneID == null)
            {
                return(result);
            }

            var provider = new ImageProvider();
            var info     = new Movie();

            info.ProviderIds[Plugin.Instance.Name] = string.Join("#", sceneID);

#if __EMBY__
            result = (await provider.GetImages(info, new LibraryOptions(), cancellationToken).ConfigureAwait(false)).ToList();
#else
            result = (await provider.GetImages(info, cancellationToken).ConfigureAwait(false)).ToList();
#endif

            return(result);
        }