public void Test_LetsGoHaking_NotNullStreamResponse_ResponseK0_MultipleReasons() { //arrange StringBuilder sb = new StringBuilder(); sb.AppendLine("210 ok."); sb.AppendLine("rock d009fb1f The Beatles / White Album"); sb.AppendLine("rock d239fb1f The Beatles / White Albumss"); sb.AppendLine("rock d639fb1f The Beatles / White Albumss"); sb.AppendLine("rock d839fb1f The Beatles / White Albumss"); IInternetProvider wrb = Substitute.For<IInternetProvider>(); IHttpWebRequest first = IHttpWebRequestOKBuilder(sb.ToString()); IHttpWebRequest second = IHttpWebRequestOKBuilder("titi"); IHttpWebRequest third = IHttpWebRequestOKBuilder((Stream)null); IHttpWebRequest fourth = IHttpWebRequestOKBuilder("500 ko"); IHttpWebRequest finth = IHttpWebRequestOKBuilder("590 ko"); wrb.CreateHttpRequest(Arg.Any<string>()).Returns(first, second, third, fourth, finth); InternetProvider.InternetHelper = wrb; FreedbFinder fdb = new FreedbFinder(new ManualSettings().WebUserSettings); Fake cdif = new Fake(_Track_frame_offsets, _Disc_length, _ID); IWebQuery iwq = new WebQueryFactory(null).FromCDInfo(cdif); iwq.NeedCoverArt = false; fdb.MonitorEvents(); //act List<Match<AlbumDescriptor>> reses = fdb.Search(iwq, new CancellationToken()).ToList(); //assert Assert.That(reses.Count, Is.EqualTo(0)); fdb.ShouldRaise("OnInternetError"); fdb.Dispose(); }
public void Test_LetsGoHaking_NotNullStreamResponse() { //arrange IInternetProvider wrb = Substitute.For<IInternetProvider>(); IHttpWebRequest wr = Substitute.For<IHttpWebRequest>(); wr.Headers.Returns(new System.Collections.Specialized.NameValueCollection()); wr.GetRequestStream().Returns(new MemoryStream()); IHttpWebResponse wres = Substitute.For<IHttpWebResponse>(); wres.StatusCode.Returns(HttpStatusCode.OK); wres.GetResponseStream().Returns(new MemoryStream()); wr.GetResponse().Returns(wres); wrb.CreateHttpRequest(Arg.Any<string>()).Returns(wr); InternetProvider.InternetHelper = wrb; FreedbFinder fdb = new FreedbFinder(new ManualSettings().WebUserSettings); Fake cdif = new Fake(_Track_frame_offsets, _Disc_length, _ID); IWebQuery iwq = new WebQueryFactory(null).FromCDInfo(cdif); iwq.NeedCoverArt = false; fdb.MonitorEvents(); //act List<Match<AlbumDescriptor>> reses = fdb.Search(iwq, new CancellationToken()).ToList(); //assert Assert.That(reses.Count, Is.EqualTo(0)); fdb.ShouldRaise("OnInternetError").WithSender(fdb); fdb.Dispose(); }
public void Test_LetsGoHaking_NotNullStreamResponse_Sever500() { //arrange SetUpMyFakeAnswer("500 ko"); FreedbFinder fdb = new FreedbFinder(new ManualSettings().WebUserSettings); Fake cdif = new Fake(_Track_frame_offsets, _Disc_length, _ID); IWebQuery iwq = new WebQueryFactory(null).FromCDInfo(cdif); iwq.NeedCoverArt = false; fdb.MonitorEvents(); //act List<Match<AlbumDescriptor>> reses = fdb.Search(iwq, new CancellationToken()).ToList(); //assert Assert.That(reses.Count, Is.EqualTo(0)); fdb.Dispose(); }
public void Test() { FreedbFinder fdb = new FreedbFinder(new ManualSettings().WebUserSettings); Fake cdif = new Fake(_Track_frame_offsets, _Disc_length, _ID); IWebQuery iwq = new WebQueryFactory(null).FromCDInfo(cdif); iwq.NeedCoverArt = false; List<Match<AlbumDescriptor>> reses = fdb.Search(iwq, new CancellationToken()).ToList(); Assert.That(reses.Count, Is.EqualTo(1)); this.AssertAlbumDescriptor(reses[0].FindItem, AlbumsOld[1][0], AlbumDescriptorCompareMode.AlbumandTrackMD); fdb.Dispose(); }