static internal AlbumDescriptor FromDiscogs(dynamic found, bool NeedCovers, IOAuthManager iOAuthManager, HttpContext mycontext, CancellationToken ict)
        {
            AlbumDescriptor res = NeedCovers ? new AlbumDescriptor() : new LoadingAlbumDescriptor();

            List<dynamic> Images = found.images as List<dynamic>;
            bool hasimages = (Images != null) && (Images.Count > 0);

            if (NeedCovers && !hasimages)
                return null;

            res.Artist = MusicCollection.Implementation.Artist.AuthorName((found.artists as List<dynamic>).Select(o => o.name as string).ToList());
            res.Year = found.year;

            if (found.genres.Count > 0)
                res.Genre = found.genres[0];

            res.Name = found.title;
            res.RawTrackDescriptors = (found.tracklist as List<dynamic>).Select((o, i) => new TrackDescriptor(res, o.title, i + 1, o.duration, o.position)).ToList();
            res.TracksNumber = (uint)res.TrackDescriptors.Count;
            if (hasimages && (iOAuthManager != null))
            {

                Func<dynamic, int, AImage> GetImages = (o, i) =>
                {
                    Thread.Sleep(1000);
                    var request = InternetProvider.InternetHelper.CreateAuthentified((string)o.uri, mycontext.UserAgent, iOAuthManager);
                    return new AImage(BufferFactory.GetBufferProviderFromHttpRequest(request), i);
                };

                if (NeedCovers)
                    res.RawImages = Images.Select(GetImages).CancelableToList(ict);
                else
                    (res as LoadingAlbumDescriptor).LoadAction = () => Images.Select(GetImages).ToList();
            }

            return res;
        }
        public void Test()
        {
            //arrange
            FoundDo fdo = new FoundDo() {title="cacadanslaboue", year = 2000 };
            fdo.artists.Add(new FoundArtist() { name = "Esse cara sou eu" });
            fdo.tracklist.Add(new FoundTrack() { title = "Esse cara sou eu 1",duration="" });
            fdo.tracklist.Add(new FoundTrack() { title = "Esse cara sou eu 2" });
            fdo.images.Add(new FoundDoImage() { uri ="dans la lune"});
            fdo.genres.Add("Blues");

            IHttpWebRequest web = Substitute.For<IHttpWebRequest>();
            NameValueCollection nvc = new NameValueCollection();
            web.Headers.Returns(nvc);
            _FakeInternetProvider.CreateHttpRequest("dans la lune").Returns(web);

            IHttpWebResponse resp = Substitute.For<IHttpWebResponse>();
            Stream myimage = new MemoryStream();
            resp.GetResponseStream().Returns(myimage);

            web.GetResponse().Returns(resp);

            _FakeIOAuthManager.GenerateAuthzHeader("dans la lune", "GET").Returns("25");

            HttpContext hc = new HttpContext("ua", "r");

            CancellationToken ict = new CancellationTokenSource().Token;

            //act
            AlbumDescriptor res = AlbumDescriptor.FromDiscogs(fdo, true, _FakeIOAuthManager, hc, ict);

            //assert
            res.Should().NotBeNull();
            res.Images.Count.Should().Be(1);

            web.UserAgent.Should().Be("ua");
            web.Headers["Authorization"].Should().Be("25");
            web.PreAuthenticate.Should().BeTrue();

            res.Artist.Should().Be("Esse cara sou eu");
            res.Genre.Should().Be("Blues");
            res.Year.Should().Be(2000);
            res.Name.Should().Be("cacadanslaboue");
            res.TrackDescriptors.Count.Should().Be(2);

        }