public void should_prefer_quality_over_the_number_of_peers() { var remoteEpisode1 = GivenRemoteEpisode(new List <Episode> { GivenEpisode(1) }, new QualityModel(Quality.Bluray1080p)); var remoteEpisode2 = GivenRemoteEpisode(new List <Episode> { GivenEpisode(1) }, new QualityModel(Quality.SDTV)); var torrentInfo1 = new TorrentInfo(); torrentInfo1.PublishDate = DateTime.Now; torrentInfo1.DownloadProtocol = DownloadProtocol.Torrent; torrentInfo1.Seeders = 100; torrentInfo1.Peers = 10; torrentInfo1.Size = 200.Megabytes(); var torrentInfo2 = torrentInfo1.JsonClone(); torrentInfo2.Seeders = 1100; torrentInfo2.Peers = 10; torrentInfo1.Size = 250.Megabytes(); remoteEpisode1.Release = torrentInfo1; remoteEpisode2.Release = torrentInfo2; var decisions = new List <DownloadDecision>(); decisions.Add(new DownloadDecision(remoteEpisode1)); decisions.Add(new DownloadDecision(remoteEpisode2)); var qualifiedReports = Subject.PrioritizeDecisions(decisions); ((TorrentInfo)qualifiedReports.First().RemoteEpisode.Release).Should().Be(torrentInfo1); }
public void should_prefer_first_release_if_peers_and_size_are_too_similar() { var remoteMovie1 = GivenRemoteMovie(new QualityModel(Quality.HDTV720p)); var remoteMovie2 = GivenRemoteMovie(new QualityModel(Quality.HDTV720p)); var torrentInfo1 = new TorrentInfo(); torrentInfo1.PublishDate = DateTime.Now; torrentInfo1.DownloadProtocol = DownloadProtocol.Torrent; torrentInfo1.Seeders = 1000; torrentInfo1.Peers = 10; torrentInfo1.Size = 200.Megabytes(); var torrentInfo2 = torrentInfo1.JsonClone(); torrentInfo2.Seeders = 1100; torrentInfo2.Peers = 10; torrentInfo1.Size = 250.Megabytes(); remoteMovie1.Release = torrentInfo1; remoteMovie1.Release.Title = "A Movie 1998"; remoteMovie2.Release = torrentInfo2; remoteMovie2.Release.Title = "A Movie 1998"; var decisions = new List <DownloadDecision>(); decisions.Add(new DownloadDecision(remoteMovie1)); decisions.Add(new DownloadDecision(remoteMovie2)); var qualifiedReports = Subject.PrioritizeDecisionsForMovies(decisions); ((TorrentInfo)qualifiedReports.First().RemoteMovie.Release).Should().Be(torrentInfo1); }
public void should_prefer_releases_with_more_peers_no_seeds() { var remoteEpisode1 = GivenRemoteEpisode(new List <Episode> { GivenEpisode(1) }, new QualityModel(Quality.HDTV720p)); var remoteEpisode2 = GivenRemoteEpisode(new List <Episode> { GivenEpisode(1) }, new QualityModel(Quality.HDTV720p)); var torrentInfo1 = new TorrentInfo(); torrentInfo1.PublishDate = DateTime.Now; torrentInfo1.Size = 0; torrentInfo1.DownloadProtocol = DownloadProtocol.Torrent; torrentInfo1.Seeders = 0; torrentInfo1.Peers = 10; var torrentInfo2 = torrentInfo1.JsonClone(); torrentInfo2.Seeders = 0; torrentInfo2.Peers = 100; remoteEpisode1.Release = torrentInfo1; remoteEpisode2.Release = torrentInfo2; var decisions = new List <DownloadDecision>(); decisions.Add(new DownloadDecision(remoteEpisode1)); decisions.Add(new DownloadDecision(remoteEpisode2)); var qualifiedReports = Subject.PrioritizeDecisions(decisions); ((TorrentInfo)qualifiedReports.First().RemoteEpisode.Release).Peers.Should().Be(torrentInfo2.Peers); }
public void should_prefer_releases_with_more_peers_given_equal_number_of_seeds() { var remoteMovie1 = GivenRemoteMovie(new QualityModel(Quality.HDTV720p)); var remoteMovie2 = GivenRemoteMovie(new QualityModel(Quality.HDTV720p)); var torrentInfo1 = new TorrentInfo(); torrentInfo1.PublishDate = DateTime.Now; torrentInfo1.Size = 0; torrentInfo1.DownloadProtocol = DownloadProtocol.Torrent; torrentInfo1.Seeders = 10; torrentInfo1.Peers = 10; var torrentInfo2 = torrentInfo1.JsonClone(); torrentInfo2.Peers = 100; remoteMovie1.Release = torrentInfo1; remoteMovie1.Release.Title = "A Movie 1998"; remoteMovie2.Release = torrentInfo2; remoteMovie2.Release.Title = "A Movie 1998"; var decisions = new List <DownloadDecision>(); decisions.Add(new DownloadDecision(remoteMovie1)); decisions.Add(new DownloadDecision(remoteMovie2)); var qualifiedReports = Subject.PrioritizeDecisionsForMovies(decisions); ((TorrentInfo)qualifiedReports.First().RemoteMovie.Release).Peers.Should().Be(torrentInfo2.Peers); }
public void should_prefer_first_release_if_peers_and_size_are_too_similar() { var remoteAlbum1 = GivenRemoteAlbum(new List <Album> { GivenAlbum(1) }, new QualityModel(Quality.MP3_256)); var remoteAlbum2 = GivenRemoteAlbum(new List <Album> { GivenAlbum(1) }, new QualityModel(Quality.MP3_256)); var torrentInfo1 = new TorrentInfo(); torrentInfo1.PublishDate = DateTime.Now; torrentInfo1.DownloadProtocol = DownloadProtocol.Torrent; torrentInfo1.Seeders = 1000; torrentInfo1.Peers = 10; torrentInfo1.Size = 200.Megabytes(); var torrentInfo2 = torrentInfo1.JsonClone(); torrentInfo2.Seeders = 1100; torrentInfo2.Peers = 10; torrentInfo1.Size = 250.Megabytes(); remoteAlbum1.Release = torrentInfo1; remoteAlbum2.Release = torrentInfo2; var decisions = new List <DownloadDecision>(); decisions.Add(new DownloadDecision(remoteAlbum1)); decisions.Add(new DownloadDecision(remoteAlbum2)); var qualifiedReports = Subject.PrioritizeDecisions(decisions); ((TorrentInfo)qualifiedReports.First().RemoteAlbum.Release).Should().Be(torrentInfo1); }
public void should_prefer_releases_with_more_peers_given_equal_number_of_seeds() { var remoteAlbum1 = GivenRemoteAlbum(new List <Album> { GivenAlbum(1) }, new QualityModel(Quality.MP3_256)); var remoteAlbum2 = GivenRemoteAlbum(new List <Album> { GivenAlbum(1) }, new QualityModel(Quality.MP3_256)); var torrentInfo1 = new TorrentInfo(); torrentInfo1.PublishDate = DateTime.Now; torrentInfo1.Size = 0; torrentInfo1.DownloadProtocol = DownloadProtocol.Torrent; torrentInfo1.Seeders = 10; torrentInfo1.Peers = 10; var torrentInfo2 = torrentInfo1.JsonClone(); torrentInfo2.Peers = 100; remoteAlbum1.Release = torrentInfo1; remoteAlbum2.Release = torrentInfo2; var decisions = new List <DownloadDecision>(); decisions.Add(new DownloadDecision(remoteAlbum1)); decisions.Add(new DownloadDecision(remoteAlbum2)); var qualifiedReports = Subject.PrioritizeDecisions(decisions); ((TorrentInfo)qualifiedReports.First().RemoteAlbum.Release).Peers.Should().Be(torrentInfo2.Peers); }
public void should_prefer_quality_over_the_number_of_peers() { var remoteBook1 = GivenRemoteAlbum(new List <Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320)); var remoteBook2 = GivenRemoteAlbum(new List <Book> { GivenAlbum(1) }, new QualityModel(Quality.AZW3)); var torrentInfo1 = new TorrentInfo(); torrentInfo1.PublishDate = DateTime.Now; torrentInfo1.DownloadProtocol = DownloadProtocol.Torrent; torrentInfo1.Seeders = 100; torrentInfo1.Peers = 10; torrentInfo1.Size = 200.Megabytes(); var torrentInfo2 = torrentInfo1.JsonClone(); torrentInfo2.Seeders = 1100; torrentInfo2.Peers = 10; torrentInfo1.Size = 250.Megabytes(); remoteBook1.Release = torrentInfo1; remoteBook2.Release = torrentInfo2; var decisions = new List <DownloadDecision>(); decisions.Add(new DownloadDecision(remoteBook1)); decisions.Add(new DownloadDecision(remoteBook2)); var qualifiedReports = Subject.PrioritizeDecisions(decisions); ((TorrentInfo)qualifiedReports.First().RemoteBook.Release).Should().Be(torrentInfo1); }
public void should_prefer_releases_with_more_seeders() { var remoteBook1 = GivenRemoteBook(new List <Book> { GivenBook(1) }, new QualityModel(Quality.MP3_320)); var remoteBook2 = GivenRemoteBook(new List <Book> { GivenBook(1) }, new QualityModel(Quality.MP3_320)); var torrentInfo1 = new TorrentInfo(); torrentInfo1.PublishDate = DateTime.Now; torrentInfo1.Size = 0; torrentInfo1.DownloadProtocol = DownloadProtocol.Torrent; torrentInfo1.Seeders = 10; var torrentInfo2 = torrentInfo1.JsonClone(); torrentInfo2.Seeders = 100; remoteBook1.Release = torrentInfo1; remoteBook2.Release = torrentInfo2; var decisions = new List <DownloadDecision>(); decisions.Add(new DownloadDecision(remoteBook1)); decisions.Add(new DownloadDecision(remoteBook2)); var qualifiedReports = Subject.PrioritizeDecisions(decisions); ((TorrentInfo)qualifiedReports.First().RemoteBook.Release).Seeders.Should().Be(torrentInfo2.Seeders); }