public void Discogs2FinderTester_ProblemWithInternet()
        {
            //Arrange
            IWebUserSettings iwsb = Substitute.For<IWebUserSettings>();
            iwsb.DiscogsActivated.Returns(true);
            IInternetProvider wrb = Substitute.For<IInternetProvider>();
            IHttpWebRequest wr = Substitute.For<IHttpWebRequest>();
            wr.Headers.Returns(new System.Collections.Specialized.NameValueCollection());

            IHttpWebResponse wres = Substitute.For<IHttpWebResponse>();
            wres.StatusCode.Returns(HttpStatusCode.BadRequest);
            wr.GetResponse().Returns(wres);


            wrb.CreateHttpRequest(Arg.Any<string>()).Returns(wr);

            InternetProvider.InternetHelper = wrb;

            IWebQuery wq =  Substitute.For<IWebQuery>();
            wq.Type.Returns(QueryType.FromAlbumInfo);

            IAlbumDescriptor iad = Substitute.For<IAlbumDescriptor>();
            wq.AlbumDescriptor.Returns(iad);

            //Act
            CancellationToken ct = new CancellationToken(false);
            Discogs2Finder target = new Discogs2Finder(iwsb);
            target.MonitorEvents(); ;
            
            //Assert
            var res = target.Search(wq, ct);
            res.Should().NotBeNull();
            var listres = res.ToList();

            listres.Should().BeEmpty();

            target.ShouldRaise("OnInternetError").WithSender(target);
  
        }
        public void StringAlbumParserTester()
        {
            int i = 0;
            foreach(IFullAlbumDescriptor ifua in AlbumsOld[0])
            {
                Discogs2Finder dh = new Discogs2Finder(new StandardWebSettings());
                IWebQuery iwq = new WebQueryFactory(null).FromAlbumDescriptor(ifua);
                //iwq.NeedCoverArt = true;
                iwq.NeedCoverArt = false;
                var res = dh.Search(iwq, new CancellationToken ());
                if (i==0)
                {
                    res.Any().Should().BeTrue();
                }
                
                if (i == 1)
                {
                    List<Match<AlbumDescriptor>> reses = res.ToList();
                    Assert.That(reses.Count, Is.EqualTo(1));
                    Assert.That(reses[0].FindItem.Genre, Is.EqualTo("Jazz"));
                    Assert.That(reses[0].FindItem.Name, Is.EqualTo(ifua.Name));

                    //InternetFinder idf = new InternetFinder(Context.WebServicesManager);
                    //idf.Query = iwq;
                    //idf.Compute(true);

                    //List<WebMatch<IFullAlbumDescriptor>> ress = idf.Result.Found;
                    //Assert.That(ress.Count, Is.AtLeast(1));
                    //WebMatch<IFullAlbumDescriptor> discogs = ress.Where(o => o.WebProvider == "Discogs").FirstOrDefault();
                    //Assert.That(discogs, Is.Not.Null);
                    //AssertAlbumDescriptor(reses[0].FindItem, discogs.FindItem, AlbumDescriptorCompareMode.AlbumandTrackMD);
                }
                i++;
                dh.Dispose();
            }

 
        }
        public void Discogs2FinderTester_NoResult()
        {         
            //new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(myPage));

            //Arrange
            IWebUserSettings iwsb = Substitute.For<IWebUserSettings>();
            iwsb.DiscogsActivated.Returns(true);
            IInternetProvider wrb = Substitute.For<IInternetProvider>();
            
            IHttpWebRequest wrFirst = Substitute.For<IHttpWebRequest>();
            wrFirst.Headers.Returns(new System.Collections.Specialized.NameValueCollection());
            IHttpWebResponse wresok = Substitute.For<IHttpWebResponse>();
            wresok.StatusCode.Returns(HttpStatusCode.OK);
            wresok.GetResponseStream().Returns(new MemoryStream(Encoding.UTF8.GetBytes(_FakeEmptyAnswer)));
            wrFirst.GetResponse().Returns(wresok);

            IHttpWebRequest wrSecond = Substitute.For<IHttpWebRequest>();
            wrSecond.Headers.Returns(new System.Collections.Specialized.NameValueCollection());
            IHttpWebResponse wresko = Substitute.For<IHttpWebResponse>();
            wresko.StatusCode.Returns(HttpStatusCode.BadRequest);         
            wresko.GetResponseStream().Returns((Stream)null); 
            wrSecond.GetResponse().Returns(wresko);


            wrb.CreateHttpRequest(Arg.Any<string>()).Returns(wrFirst, wrSecond, wrSecond);

            InternetProvider.InternetHelper = wrb;

            IWebQuery wq = Substitute.For<IWebQuery>();
            wq.Type.Returns(QueryType.FromAlbumInfo);

            IAlbumDescriptor iad = Substitute.For<IAlbumDescriptor>();
            wq.AlbumDescriptor.Returns(iad);

            //Act
            CancellationToken ct = new CancellationToken(false);
            Discogs2Finder target = new Discogs2Finder(iwsb);
            target.MonitorEvents(); ;

            //Assert
            var res = target.Search(wq, ct);
            res.Should().NotBeNull();
            var listres = res.ToList();

            listres.Should().BeEmpty();

            target.ShouldNotRaise("OnInternetError");

        }