コード例 #1
0
        public async Task DoWork()
        {
            var retriever = new ImageRetrieverService(limit: _imgPerPage);
            var results   = await retriever.RetrieveImages(Link);

            Images = results.ToObservableCollection();
        }
コード例 #2
0
        public void RetrieveImages_UnknownSite_ReturnsEmptyList()
        {
            var testUrl = "https://www.google.com";
            var service = new ImageRetrieverService();
            List <OnlineImageResult> results = service.RetrieveImages(testUrl).Result;

            Assert.AreEqual(0, results.Count);
        }
コード例 #3
0
        public void RetrieveImages_KnownSiteDifferentLimit_ReturnsCorrectInfo()
        {
            var testUrl = "https://www.instagram.com/aimyon36/";
            var service = new ImageRetrieverService(limit: 3);
            List <OnlineImageResult> results = service.RetrieveImages(testUrl).Result;

            Assert.AreEqual(3, results.Count);
            OnlineImageResult third = results[2];

            StringAssert.Contains(third.Link, "jpg");
        }
コード例 #4
0
        public void RetrieveImages_KnownSiteDefaultLimit_ReturnsCorrectInfo()
        {
            var testUrl = "https://www.instagram.com/aimyon36/";
            var service = new ImageRetrieverService();
            List <OnlineImageResult> results = service.RetrieveImages(testUrl).Result;

            Assert.AreEqual(2, results.Count);
            OnlineImageResult first = results[0];

            StringAssert.Contains(first.Link, "jpg");
        }
コード例 #5
0
        /// Populate indexed search results in queue with images found from their link
        private async Task FetchPreviewImages()
        {
            while (_fetchImageQueue.Count > 0)
            {
                var currRes = _fetchImageQueue.Dequeue();
                var result  = _results[currRes];
                var images  = await _iretriever.RetrieveImages(result.Link);

                if (images != null && images.Count > 0)
                {
                    result.Images = images;
                }
                _results[currRes] = result;
            }
        }