mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-24 22:35:39 -04:00
Cleanup Conflicts in Sonarr/Lidarr Pulls
Co-Authored-By: Robin Dadswell <19610103+RobinDadswell@users.noreply.github.com>
This commit is contained in:
@@ -20,9 +20,9 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
public class AlreadyImportedSpecificationFixture : CoreTest<AlreadyImportedSpecification>
|
||||
{
|
||||
private const int FIRST_ALBUM_ID = 1;
|
||||
private const string TITLE = "Some.Artist-Some.Album-2018-320kbps-CD-Readarr";
|
||||
private const string TITLE = "Some.Author-Some.Book-2018-320kbps-CD-Readarr";
|
||||
|
||||
private Author _artist;
|
||||
private Author _author;
|
||||
private QualityModel _mp3;
|
||||
private QualityModel _flac;
|
||||
private RemoteBook _remoteBook;
|
||||
@@ -32,16 +32,16 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
var singleAlbumList = new List<Book>
|
||||
var singleBookList = new List<Book>
|
||||
{
|
||||
new Book
|
||||
{
|
||||
Id = FIRST_ALBUM_ID,
|
||||
Title = "Some Album"
|
||||
Title = "Some Book"
|
||||
}
|
||||
};
|
||||
|
||||
_artist = Builder<Author>.CreateNew()
|
||||
_author = Builder<Author>.CreateNew()
|
||||
.Build();
|
||||
|
||||
_firstFile = new BookFile { Quality = new QualityModel(Quality.FLAC, new Revision(version: 2)), DateAdded = DateTime.Now };
|
||||
@@ -51,9 +51,9 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
|
||||
_remoteBook = new RemoteBook
|
||||
{
|
||||
Author = _artist,
|
||||
Author = _author,
|
||||
ParsedBookInfo = new ParsedBookInfo { Quality = _mp3 },
|
||||
Books = singleAlbumList,
|
||||
Books = singleBookList,
|
||||
Release = Builder<ReleaseInfo>.CreateNew()
|
||||
.Build()
|
||||
};
|
||||
@@ -101,7 +101,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_accepted_if_album_does_not_have_a_file()
|
||||
public void should_be_accepted_if_book_does_not_have_a_file()
|
||||
{
|
||||
Mocker.GetMock<IMediaFileService>()
|
||||
.Setup(c => c.GetFilesByBook(It.IsAny<int>()))
|
||||
@@ -111,13 +111,13 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_accepted_if_album_does_not_have_grabbed_event()
|
||||
public void should_be_accepted_if_book_does_not_have_grabbed_event()
|
||||
{
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_accepted_if_album_does_not_have_imported_event()
|
||||
public void should_be_accepted_if_book_does_not_have_imported_event()
|
||||
{
|
||||
GivenHistoryItem(Guid.NewGuid().ToString().ToUpper(), TITLE, _mp3, HistoryEventType.Grabbed);
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
private static readonly int NoPreferredWordScore = 0;
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_current_album_is_less_than_cutoff()
|
||||
public void should_return_true_if_current_book_is_less_than_cutoff()
|
||||
{
|
||||
Subject.CutoffNotMet(
|
||||
new QualityProfile
|
||||
@@ -27,7 +27,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_current_album_is_equal_to_cutoff()
|
||||
public void should_return_false_if_current_book_is_equal_to_cutoff()
|
||||
{
|
||||
Subject.CutoffNotMet(
|
||||
new QualityProfile
|
||||
@@ -40,7 +40,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_current_album_is_greater_than_cutoff()
|
||||
public void should_return_false_if_current_book_is_greater_than_cutoff()
|
||||
{
|
||||
Subject.CutoffNotMet(
|
||||
new QualityProfile
|
||||
@@ -53,7 +53,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_when_new_album_is_proper_but_existing_is_not()
|
||||
public void should_return_true_when_new_book_is_proper_but_existing_is_not()
|
||||
{
|
||||
Subject.CutoffNotMet(
|
||||
new QualityProfile
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
var artist = Builder<Author>.CreateNew().With(s => s.Id = 1234).Build();
|
||||
var author = Builder<Author>.CreateNew().With(s => s.Id = 1234).Build();
|
||||
_remoteBook = new RemoteBook
|
||||
{
|
||||
ParsedBookInfo = new ParsedBookInfo
|
||||
@@ -30,12 +30,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
Books = Builder<Book>.CreateListOfSize(3)
|
||||
.All()
|
||||
.With(e => e.ReleaseDate = DateTime.UtcNow.AddDays(-8))
|
||||
.With(s => s.AuthorId = artist.Id)
|
||||
.With(s => s.AuthorId = author.Id)
|
||||
.BuildList(),
|
||||
Author = artist,
|
||||
Author = author,
|
||||
Release = new ReleaseInfo
|
||||
{
|
||||
Title = "Artist.Discography.1978.2005.FLAC-RlsGrp"
|
||||
Title = "Author.Discography.1978.2005.FLAC-RlsGrp"
|
||||
}
|
||||
};
|
||||
|
||||
@@ -52,20 +52,20 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_all_albums_have_released()
|
||||
public void should_return_true_if_all_books_have_released()
|
||||
{
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_one_album_has_not_released()
|
||||
public void should_return_false_if_one_book_has_not_released()
|
||||
{
|
||||
_remoteBook.Books.Last().ReleaseDate = DateTime.UtcNow.AddDays(+2);
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_an_album_does_not_have_an_release_date()
|
||||
public void should_return_false_if_an_book_does_not_have_an_release_date()
|
||||
{
|
||||
_remoteBook.Books.Last().ReleaseDate = null;
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeFalse();
|
||||
|
||||
@@ -147,7 +147,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_attempt_to_map_album_if_not_parsable()
|
||||
public void should_not_attempt_to_map_book_if_not_parsable()
|
||||
{
|
||||
GivenSpecifications(_pass1, _pass2, _pass3);
|
||||
_reports[0].Title = "Not parsable";
|
||||
@@ -159,11 +159,10 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
_pass1.Verify(c => c.IsSatisfiedBy(It.IsAny<RemoteBook>(), null), Times.Never());
|
||||
_pass2.Verify(c => c.IsSatisfiedBy(It.IsAny<RemoteBook>(), null), Times.Never());
|
||||
_pass3.Verify(c => c.IsSatisfiedBy(It.IsAny<RemoteBook>(), null), Times.Never());
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_attempt_to_map_album_if_artist_title_is_blank()
|
||||
public void should_not_attempt_to_map_book_if_author_title_is_blank()
|
||||
{
|
||||
GivenSpecifications(_pass1, _pass2, _pass3);
|
||||
_reports[0].Title = "2013 - Night Visions";
|
||||
@@ -185,20 +184,20 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
GivenSpecifications(_pass1, _pass2, _pass3);
|
||||
_reports[0].Title = "1937 - Snow White and the Seven Dwarves";
|
||||
|
||||
var artist = new Artist { Name = "Some Artist" };
|
||||
var albums = new List<Album> { new Album { Title = "Some Album" } };
|
||||
var author = new Author { Name = "Some Author" };
|
||||
var books = new List<Book> { new Book { Title = "Some Book" } };
|
||||
|
||||
Subject.GetSearchDecision(_reports, new AlbumSearchCriteria { Artist = artist, Albums = albums }).ToList();
|
||||
Subject.GetSearchDecision(_reports, new BookSearchCriteria { Author = author, Books = books }).ToList();
|
||||
|
||||
Mocker.GetMock<IParsingService>().Verify(c => c.Map(It.IsAny<ParsedAlbumInfo>(), It.IsAny<SearchCriteriaBase>()), Times.Never());
|
||||
Mocker.GetMock<IParsingService>().Verify(c => c.Map(It.IsAny<ParsedBookInfo>(), It.IsAny<SearchCriteriaBase>()), Times.Never());
|
||||
|
||||
_pass1.Verify(c => c.IsSatisfiedBy(It.IsAny<RemoteAlbum>(), null), Times.Never());
|
||||
_pass2.Verify(c => c.IsSatisfiedBy(It.IsAny<RemoteAlbum>(), null), Times.Never());
|
||||
_pass3.Verify(c => c.IsSatisfiedBy(It.IsAny<RemoteAlbum>(), null), Times.Never());
|
||||
_pass1.Verify(c => c.IsSatisfiedBy(It.IsAny<RemoteBook>(), null), Times.Never());
|
||||
_pass2.Verify(c => c.IsSatisfiedBy(It.IsAny<RemoteBook>(), null), Times.Never());
|
||||
_pass3.Verify(c => c.IsSatisfiedBy(It.IsAny<RemoteBook>(), null), Times.Never());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_attempt_to_make_decision_if_artist_is_unknown()
|
||||
public void should_not_attempt_to_make_decision_if_author_is_unknown()
|
||||
{
|
||||
GivenSpecifications(_pass1, _pass2, _pass3);
|
||||
|
||||
@@ -234,7 +233,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_unknown_artist_rejection_if_artist_is_unknown()
|
||||
public void should_return_unknown_author_rejection_if_author_is_unknown()
|
||||
{
|
||||
GivenSpecifications(_pass1, _pass2, _pass3);
|
||||
|
||||
@@ -246,22 +245,22 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_only_include_reports_for_requested_albums()
|
||||
public void should_only_include_reports_for_requested_books()
|
||||
{
|
||||
var artist = Builder<Author>.CreateNew().Build();
|
||||
var author = Builder<Author>.CreateNew().Build();
|
||||
|
||||
var albums = Builder<Book>.CreateListOfSize(2)
|
||||
var books = Builder<Book>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(v => v.AuthorId, artist.Id)
|
||||
.With(v => v.Author, new LazyLoaded<Author>(artist))
|
||||
.With(v => v.AuthorId, author.Id)
|
||||
.With(v => v.Author, new LazyLoaded<Author>(author))
|
||||
.BuildList();
|
||||
|
||||
var criteria = new AuthorSearchCriteria { Books = albums.Take(1).ToList() };
|
||||
var criteria = new AuthorSearchCriteria { Books = books.Take(1).ToList() };
|
||||
|
||||
var reports = albums.Select(v =>
|
||||
var reports = books.Select(v =>
|
||||
new ReleaseInfo()
|
||||
{
|
||||
Title = string.Format("{0}-{1}[FLAC][2017][DRONE]", artist.Name, v.Title)
|
||||
Title = string.Format("{0}-{1}[FLAC][2017][DRONE]", author.Name, v.Title)
|
||||
}).ToList();
|
||||
|
||||
Mocker.GetMock<IParsingService>()
|
||||
@@ -271,8 +270,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
DownloadAllowed = true,
|
||||
ParsedBookInfo = p,
|
||||
Author = artist,
|
||||
Books = albums.Where(v => v.Title == p.BookTitle).ToList()
|
||||
Author = author,
|
||||
Books = books.Where(v => v.Title == p.BookTitle).ToList()
|
||||
});
|
||||
|
||||
Mocker.SetConstant<IEnumerable<IDecisionEngineSpecification>>(new List<IDecisionEngineSpecification>
|
||||
@@ -288,7 +287,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_allow_download_if_artist_is_unknown()
|
||||
public void should_not_allow_download_if_author_is_unknown()
|
||||
{
|
||||
GivenSpecifications(_pass1, _pass2, _pass3);
|
||||
|
||||
@@ -302,7 +301,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_allow_download_if_no_albums_found()
|
||||
public void should_not_allow_download_if_no_books_found()
|
||||
{
|
||||
GivenSpecifications(_pass1, _pass2, _pass3);
|
||||
|
||||
|
||||
@@ -17,27 +17,27 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
[TestFixture]
|
||||
public class EarlyReleaseSpecificationFixture : TestBase<EarlyReleaseSpecification>
|
||||
{
|
||||
private Author _artist;
|
||||
private Book _album1;
|
||||
private Book _album2;
|
||||
private Author _author;
|
||||
private Book _book1;
|
||||
private Book _book2;
|
||||
private RemoteBook _remoteBook;
|
||||
private IndexerDefinition _indexerDefinition;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_artist = Builder<Author>.CreateNew().With(s => s.Id = 1).Build();
|
||||
_album1 = Builder<Book>.CreateNew().With(s => s.ReleaseDate = DateTime.Today).Build();
|
||||
_album2 = Builder<Book>.CreateNew().With(s => s.ReleaseDate = DateTime.Today).Build();
|
||||
_author = Builder<Author>.CreateNew().With(s => s.Id = 1).Build();
|
||||
_book1 = Builder<Book>.CreateNew().With(s => s.ReleaseDate = DateTime.Today).Build();
|
||||
_book2 = Builder<Book>.CreateNew().With(s => s.ReleaseDate = DateTime.Today).Build();
|
||||
|
||||
_remoteBook = new RemoteBook
|
||||
{
|
||||
Author = _artist,
|
||||
Books = new List<Book> { _album1 },
|
||||
Author = _author,
|
||||
Books = new List<Book> { _book1 },
|
||||
Release = new TorrentInfo
|
||||
{
|
||||
IndexerId = 1,
|
||||
Title = "Artist - Album [FLAC-RlsGrp]",
|
||||
Title = "Author - Book [FLAC-RlsGrp]",
|
||||
PublishDate = DateTime.Today
|
||||
}
|
||||
};
|
||||
@@ -66,9 +66,9 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_release_contains_multiple_albums()
|
||||
public void should_return_true_if_release_contains_multiple_books()
|
||||
{
|
||||
_remoteBook.Books.Add(_album2);
|
||||
_remoteBook.Books.Add(_book2);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
private RemoteBook _parseResultSingle;
|
||||
private QualityModel _upgradableQuality;
|
||||
private QualityModel _notupgradableQuality;
|
||||
private Author _fakeArtist;
|
||||
private Author _fakeAuthor;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
@@ -37,15 +37,15 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
Mocker.Resolve<UpgradableSpecification>();
|
||||
_upgradeHistory = Mocker.Resolve<HistorySpecification>();
|
||||
|
||||
var singleAlbumList = new List<Book> { new Book { Id = FIRST_ALBUM_ID } };
|
||||
var doubleAlbumList = new List<Book>
|
||||
var singleBookList = new List<Book> { new Book { Id = FIRST_ALBUM_ID } };
|
||||
var doubleBookList = new List<Book>
|
||||
{
|
||||
new Book { Id = FIRST_ALBUM_ID },
|
||||
new Book { Id = SECOND_ALBUM_ID },
|
||||
new Book { Id = 3 }
|
||||
};
|
||||
|
||||
_fakeArtist = Builder<Author>.CreateNew()
|
||||
_fakeAuthor = Builder<Author>.CreateNew()
|
||||
.With(c => c.QualityProfile = new QualityProfile
|
||||
{
|
||||
UpgradeAllowed = true,
|
||||
@@ -56,16 +56,16 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
|
||||
_parseResultMulti = new RemoteBook
|
||||
{
|
||||
Author = _fakeArtist,
|
||||
Author = _fakeAuthor,
|
||||
ParsedBookInfo = new ParsedBookInfo { Quality = new QualityModel(Quality.MP3_320, new Revision(version: 2)) },
|
||||
Books = doubleAlbumList
|
||||
Books = doubleBookList
|
||||
};
|
||||
|
||||
_parseResultSingle = new RemoteBook
|
||||
{
|
||||
Author = _fakeArtist,
|
||||
Author = _fakeAuthor,
|
||||
ParsedBookInfo = new ParsedBookInfo { Quality = new QualityModel(Quality.MP3_320, new Revision(version: 2)) },
|
||||
Books = singleAlbumList
|
||||
Books = singleBookList
|
||||
};
|
||||
|
||||
_upgradableQuality = new QualityModel(Quality.MP3_320, new Revision(version: 1));
|
||||
@@ -76,7 +76,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
.Returns(true);
|
||||
}
|
||||
|
||||
private void GivenMostRecentForAlbum(int bookId, string downloadId, QualityModel quality, DateTime date, HistoryEventType eventType)
|
||||
private void GivenMostRecentForBook(int bookId, string downloadId, QualityModel quality, DateTime date, HistoryEventType eventType)
|
||||
{
|
||||
Mocker.GetMock<IHistoryService>().Setup(s => s.MostRecentForBook(bookId))
|
||||
.Returns(new History.History { DownloadId = downloadId, Quality = quality, Date = date, EventType = eventType });
|
||||
@@ -105,7 +105,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
[Test]
|
||||
public void should_return_true_if_latest_history_item_is_not_grabbed()
|
||||
{
|
||||
GivenMostRecentForAlbum(FIRST_ALBUM_ID, string.Empty, _notupgradableQuality, DateTime.UtcNow, HistoryEventType.DownloadFailed);
|
||||
GivenMostRecentForBook(FIRST_ALBUM_ID, string.Empty, _notupgradableQuality, DateTime.UtcNow, HistoryEventType.DownloadFailed);
|
||||
_upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
@@ -118,57 +118,57 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
[Test]
|
||||
public void should_return_true_if_latest_history_item_is_older_than_twelve_hours()
|
||||
{
|
||||
GivenMostRecentForAlbum(FIRST_ALBUM_ID, string.Empty, _notupgradableQuality, DateTime.UtcNow.AddHours(-12).AddMilliseconds(-1), HistoryEventType.Grabbed);
|
||||
GivenMostRecentForBook(FIRST_ALBUM_ID, string.Empty, _notupgradableQuality, DateTime.UtcNow.AddHours(-12).AddMilliseconds(-1), HistoryEventType.Grabbed);
|
||||
_upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_upgradable_if_only_album_is_upgradable()
|
||||
public void should_be_upgradable_if_only_book_is_upgradable()
|
||||
{
|
||||
GivenMostRecentForAlbum(FIRST_ALBUM_ID, string.Empty, _upgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed);
|
||||
GivenMostRecentForBook(FIRST_ALBUM_ID, string.Empty, _upgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed);
|
||||
_upgradeHistory.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_upgradable_if_both_albums_are_upgradable()
|
||||
public void should_be_upgradable_if_both_books_are_upgradable()
|
||||
{
|
||||
GivenMostRecentForAlbum(FIRST_ALBUM_ID, string.Empty, _upgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed);
|
||||
GivenMostRecentForAlbum(SECOND_ALBUM_ID, string.Empty, _upgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed);
|
||||
GivenMostRecentForBook(FIRST_ALBUM_ID, string.Empty, _upgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed);
|
||||
GivenMostRecentForBook(SECOND_ALBUM_ID, string.Empty, _upgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed);
|
||||
_upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_be_upgradable_if_both_albums_are_not_upgradable()
|
||||
public void should_not_be_upgradable_if_both_books_are_not_upgradable()
|
||||
{
|
||||
GivenMostRecentForAlbum(FIRST_ALBUM_ID, string.Empty, _notupgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed);
|
||||
GivenMostRecentForAlbum(SECOND_ALBUM_ID, string.Empty, _notupgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed);
|
||||
GivenMostRecentForBook(FIRST_ALBUM_ID, string.Empty, _notupgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed);
|
||||
GivenMostRecentForBook(SECOND_ALBUM_ID, string.Empty, _notupgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed);
|
||||
_upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_not_upgradable_if_only_first_albums_is_upgradable()
|
||||
public void should_be_not_upgradable_if_only_first_books_is_upgradable()
|
||||
{
|
||||
GivenMostRecentForAlbum(FIRST_ALBUM_ID, string.Empty, _upgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed);
|
||||
GivenMostRecentForAlbum(FIRST_ALBUM_ID, string.Empty, _notupgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed);
|
||||
GivenMostRecentForBook(FIRST_ALBUM_ID, string.Empty, _upgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed);
|
||||
GivenMostRecentForBook(FIRST_ALBUM_ID, string.Empty, _notupgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed);
|
||||
_upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_not_upgradable_if_only_second_albums_is_upgradable()
|
||||
public void should_be_not_upgradable_if_only_second_books_is_upgradable()
|
||||
{
|
||||
GivenMostRecentForAlbum(FIRST_ALBUM_ID, string.Empty, _notupgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed);
|
||||
GivenMostRecentForAlbum(SECOND_ALBUM_ID, string.Empty, _upgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed);
|
||||
GivenMostRecentForBook(FIRST_ALBUM_ID, string.Empty, _notupgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed);
|
||||
GivenMostRecentForBook(SECOND_ALBUM_ID, string.Empty, _upgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed);
|
||||
_upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_be_upgradable_if_album_is_of_same_quality_as_existing()
|
||||
public void should_not_be_upgradable_if_book_is_of_same_quality_as_existing()
|
||||
{
|
||||
_fakeArtist.QualityProfile = new QualityProfile { Cutoff = Quality.MP3_320.Id, Items = Qualities.QualityFixture.GetDefaultQualities() };
|
||||
_fakeAuthor.QualityProfile = new QualityProfile { Cutoff = Quality.MP3_320.Id, Items = Qualities.QualityFixture.GetDefaultQualities() };
|
||||
_parseResultSingle.ParsedBookInfo.Quality = new QualityModel(Quality.MP3_320, new Revision(version: 1));
|
||||
_upgradableQuality = new QualityModel(Quality.MP3_320, new Revision(version: 1));
|
||||
|
||||
GivenMostRecentForAlbum(FIRST_ALBUM_ID, string.Empty, _upgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed);
|
||||
GivenMostRecentForBook(FIRST_ALBUM_ID, string.Empty, _upgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed);
|
||||
|
||||
_upgradeHistory.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
@@ -176,11 +176,11 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
[Test]
|
||||
public void should_not_be_upgradable_if_cutoff_already_met()
|
||||
{
|
||||
_fakeArtist.QualityProfile = new QualityProfile { Cutoff = Quality.MP3_320.Id, Items = Qualities.QualityFixture.GetDefaultQualities() };
|
||||
_fakeAuthor.QualityProfile = new QualityProfile { Cutoff = Quality.MP3_320.Id, Items = Qualities.QualityFixture.GetDefaultQualities() };
|
||||
_parseResultSingle.ParsedBookInfo.Quality = new QualityModel(Quality.MP3_320, new Revision(version: 1));
|
||||
_upgradableQuality = new QualityModel(Quality.MP3_320, new Revision(version: 1));
|
||||
|
||||
GivenMostRecentForAlbum(FIRST_ALBUM_ID, string.Empty, _upgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed);
|
||||
GivenMostRecentForBook(FIRST_ALBUM_ID, string.Empty, _upgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed);
|
||||
|
||||
_upgradeHistory.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
@@ -188,7 +188,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
[Test]
|
||||
public void should_return_false_if_latest_history_item_is_only_one_hour_old()
|
||||
{
|
||||
GivenMostRecentForAlbum(FIRST_ALBUM_ID, string.Empty, _notupgradableQuality, DateTime.UtcNow.AddHours(-1), HistoryEventType.Grabbed);
|
||||
GivenMostRecentForBook(FIRST_ALBUM_ID, string.Empty, _notupgradableQuality, DateTime.UtcNow.AddHours(-1), HistoryEventType.Grabbed);
|
||||
_upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
public void should_return_false_if_latest_history_has_a_download_id_and_cdh_is_disabled()
|
||||
{
|
||||
GivenCdhDisabled();
|
||||
GivenMostRecentForAlbum(FIRST_ALBUM_ID, "test", _upgradableQuality, DateTime.UtcNow.AddDays(-100), HistoryEventType.Grabbed);
|
||||
GivenMostRecentForBook(FIRST_ALBUM_ID, "test", _upgradableQuality, DateTime.UtcNow.AddDays(-100), HistoryEventType.Grabbed);
|
||||
_upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
@@ -204,20 +204,20 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
public void should_return_false_if_cutoff_already_met_and_cdh_is_disabled()
|
||||
{
|
||||
GivenCdhDisabled();
|
||||
_fakeArtist.QualityProfile = new QualityProfile { Cutoff = Quality.MP3_320.Id, Items = Qualities.QualityFixture.GetDefaultQualities() };
|
||||
_fakeAuthor.QualityProfile = new QualityProfile { Cutoff = Quality.MP3_320.Id, Items = Qualities.QualityFixture.GetDefaultQualities() };
|
||||
_parseResultSingle.ParsedBookInfo.Quality = new QualityModel(Quality.MP3_320, new Revision(version: 1));
|
||||
_upgradableQuality = new QualityModel(Quality.MP3_320, new Revision(version: 1));
|
||||
|
||||
GivenMostRecentForAlbum(FIRST_ALBUM_ID, "test", _upgradableQuality, DateTime.UtcNow.AddDays(-100), HistoryEventType.Grabbed);
|
||||
GivenMostRecentForBook(FIRST_ALBUM_ID, "test", _upgradableQuality, DateTime.UtcNow.AddDays(-100), HistoryEventType.Grabbed);
|
||||
|
||||
_upgradeHistory.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_only_album_is_not_upgradable_and_cdh_is_disabled()
|
||||
public void should_return_false_if_only_book_is_not_upgradable_and_cdh_is_disabled()
|
||||
{
|
||||
GivenCdhDisabled();
|
||||
GivenMostRecentForAlbum(FIRST_ALBUM_ID, "test", _notupgradableQuality, DateTime.UtcNow.AddDays(-100), HistoryEventType.Grabbed);
|
||||
GivenMostRecentForBook(FIRST_ALBUM_ID, "test", _notupgradableQuality, DateTime.UtcNow.AddDays(-100), HistoryEventType.Grabbed);
|
||||
_upgradeHistory.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,128 +12,128 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
[TestFixture]
|
||||
|
||||
public class MonitoredAlbumSpecificationFixture : CoreTest<MonitoredBookSpecification>
|
||||
public class MonitoredBookSpecificationFixture : CoreTest<MonitoredBookSpecification>
|
||||
{
|
||||
private MonitoredBookSpecification _monitoredAlbumSpecification;
|
||||
private MonitoredBookSpecification _monitoredBookSpecification;
|
||||
|
||||
private RemoteBook _parseResultMulti;
|
||||
private RemoteBook _parseResultSingle;
|
||||
private Author _fakeArtist;
|
||||
private Book _firstAlbum;
|
||||
private Book _secondAlbum;
|
||||
private Author _fakeAuthor;
|
||||
private Book _firstBook;
|
||||
private Book _secondBook;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_monitoredAlbumSpecification = Mocker.Resolve<MonitoredBookSpecification>();
|
||||
_monitoredBookSpecification = Mocker.Resolve<MonitoredBookSpecification>();
|
||||
|
||||
_fakeArtist = Builder<Author>.CreateNew()
|
||||
_fakeAuthor = Builder<Author>.CreateNew()
|
||||
.With(c => c.Monitored = true)
|
||||
.Build();
|
||||
|
||||
_firstAlbum = new Book { Monitored = true };
|
||||
_secondAlbum = new Book { Monitored = true };
|
||||
_firstBook = new Book { Monitored = true };
|
||||
_secondBook = new Book { Monitored = true };
|
||||
|
||||
var singleAlbumList = new List<Book> { _firstAlbum };
|
||||
var doubleAlbumList = new List<Book> { _firstAlbum, _secondAlbum };
|
||||
var singleBookList = new List<Book> { _firstBook };
|
||||
var doubleBookList = new List<Book> { _firstBook, _secondBook };
|
||||
|
||||
_parseResultMulti = new RemoteBook
|
||||
{
|
||||
Author = _fakeArtist,
|
||||
Books = doubleAlbumList
|
||||
Author = _fakeAuthor,
|
||||
Books = doubleBookList
|
||||
};
|
||||
|
||||
_parseResultSingle = new RemoteBook
|
||||
{
|
||||
Author = _fakeArtist,
|
||||
Books = singleAlbumList
|
||||
Author = _fakeAuthor,
|
||||
Books = singleBookList
|
||||
};
|
||||
}
|
||||
|
||||
private void WithFirstAlbumUnmonitored()
|
||||
private void WithFirstBookUnmonitored()
|
||||
{
|
||||
_firstAlbum.Monitored = false;
|
||||
_firstBook.Monitored = false;
|
||||
}
|
||||
|
||||
private void WithSecondAlbumUnmonitored()
|
||||
private void WithSecondBookUnmonitored()
|
||||
{
|
||||
_secondAlbum.Monitored = false;
|
||||
_secondBook.Monitored = false;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void setup_should_return_monitored_album_should_return_true()
|
||||
public void setup_should_return_monitored_book_should_return_true()
|
||||
{
|
||||
_monitoredAlbumSpecification.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeTrue();
|
||||
_monitoredAlbumSpecification.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeTrue();
|
||||
_monitoredBookSpecification.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeTrue();
|
||||
_monitoredBookSpecification.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void not_monitored_artist_should_be_skipped()
|
||||
public void not_monitored_author_should_be_skipped()
|
||||
{
|
||||
_fakeArtist.Monitored = false;
|
||||
_monitoredAlbumSpecification.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse();
|
||||
_fakeAuthor.Monitored = false;
|
||||
_monitoredBookSpecification.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void only_album_not_monitored_should_return_false()
|
||||
public void only_book_not_monitored_should_return_false()
|
||||
{
|
||||
WithFirstAlbumUnmonitored();
|
||||
_monitoredAlbumSpecification.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeFalse();
|
||||
WithFirstBookUnmonitored();
|
||||
_monitoredBookSpecification.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void both_albums_not_monitored_should_return_false()
|
||||
public void both_books_not_monitored_should_return_false()
|
||||
{
|
||||
WithFirstAlbumUnmonitored();
|
||||
WithSecondAlbumUnmonitored();
|
||||
_monitoredAlbumSpecification.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse();
|
||||
WithFirstBookUnmonitored();
|
||||
WithSecondBookUnmonitored();
|
||||
_monitoredBookSpecification.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void only_first_album_not_monitored_should_return_false()
|
||||
public void only_first_book_not_monitored_should_return_false()
|
||||
{
|
||||
WithFirstAlbumUnmonitored();
|
||||
_monitoredAlbumSpecification.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse();
|
||||
WithFirstBookUnmonitored();
|
||||
_monitoredBookSpecification.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void only_second_album_not_monitored_should_return_false()
|
||||
public void only_second_book_not_monitored_should_return_false()
|
||||
{
|
||||
WithSecondAlbumUnmonitored();
|
||||
_monitoredAlbumSpecification.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse();
|
||||
WithSecondBookUnmonitored();
|
||||
_monitoredBookSpecification.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_for_single_album_search()
|
||||
public void should_return_true_for_single_book_search()
|
||||
{
|
||||
_fakeArtist.Monitored = false;
|
||||
_monitoredAlbumSpecification.IsSatisfiedBy(_parseResultSingle, new BookSearchCriteria()).Accepted.Should().BeTrue();
|
||||
_fakeAuthor.Monitored = false;
|
||||
_monitoredBookSpecification.IsSatisfiedBy(_parseResultSingle, new BookSearchCriteria()).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_album_is_not_monitored_and_monitoredEpisodesOnly_flag_is_false()
|
||||
public void should_return_true_if_book_is_not_monitored_and_monitoredEpisodesOnly_flag_is_false()
|
||||
{
|
||||
WithFirstAlbumUnmonitored();
|
||||
_monitoredAlbumSpecification.IsSatisfiedBy(_parseResultSingle, new BookSearchCriteria { MonitoredBooksOnly = false }).Accepted.Should().BeTrue();
|
||||
WithFirstBookUnmonitored();
|
||||
_monitoredBookSpecification.IsSatisfiedBy(_parseResultSingle, new BookSearchCriteria { MonitoredBooksOnly = false }).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_album_is_not_monitored_and_monitoredEpisodesOnly_flag_is_true()
|
||||
public void should_return_false_if_book_is_not_monitored_and_monitoredEpisodesOnly_flag_is_true()
|
||||
{
|
||||
WithFirstAlbumUnmonitored();
|
||||
_monitoredAlbumSpecification.IsSatisfiedBy(_parseResultSingle, new BookSearchCriteria { MonitoredBooksOnly = true }).Accepted.Should().BeFalse();
|
||||
WithFirstBookUnmonitored();
|
||||
_monitoredBookSpecification.IsSatisfiedBy(_parseResultSingle, new BookSearchCriteria { MonitoredBooksOnly = true }).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_all_albums_are_not_monitored_for_discography_pack_release()
|
||||
public void should_return_false_if_all_books_are_not_monitored_for_discography_pack_release()
|
||||
{
|
||||
WithSecondAlbumUnmonitored();
|
||||
WithSecondBookUnmonitored();
|
||||
_parseResultMulti.ParsedBookInfo = new ParsedBookInfo()
|
||||
{
|
||||
Discography = true
|
||||
};
|
||||
|
||||
_monitoredAlbumSpecification.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse();
|
||||
_monitoredBookSpecification.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,21 +27,21 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
GivenPreferredDownloadProtocol(DownloadProtocol.Usenet);
|
||||
}
|
||||
|
||||
private Book GivenAlbum(int id)
|
||||
private Book GivenBook(int id)
|
||||
{
|
||||
return Builder<Book>.CreateNew()
|
||||
.With(e => e.Id = id)
|
||||
.Build();
|
||||
}
|
||||
|
||||
private RemoteBook GivenRemoteAlbum(List<Book> albums, QualityModel quality, int age = 0, long size = 0, DownloadProtocol downloadProtocol = DownloadProtocol.Usenet, int indexerPriority = 25)
|
||||
private RemoteBook GivenRemoteBook(List<Book> books, QualityModel quality, int age = 0, long size = 0, DownloadProtocol downloadProtocol = DownloadProtocol.Usenet, int indexerPriority = 25)
|
||||
{
|
||||
var remoteBook = new RemoteBook();
|
||||
remoteBook.ParsedBookInfo = new ParsedBookInfo();
|
||||
remoteBook.ParsedBookInfo.Quality = quality;
|
||||
|
||||
remoteBook.Books = new List<Book>();
|
||||
remoteBook.Books.AddRange(albums);
|
||||
remoteBook.Books.AddRange(books);
|
||||
|
||||
remoteBook.Release = new ReleaseInfo();
|
||||
remoteBook.Release.PublishDate = DateTime.Now.AddDays(-age);
|
||||
@@ -73,22 +73,22 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
[Test]
|
||||
public void should_put_reals_before_non_reals()
|
||||
{
|
||||
var remoteAlbum1 = GivenRemoteAlbum(new List<Album> { GivenAlbum(1) }, new QualityModel(Quality.MP3_256, new Revision(version: 1, real: 0)));
|
||||
var remoteAlbum2 = GivenRemoteAlbum(new List<Album> { GivenAlbum(1) }, new QualityModel(Quality.MP3_256, new Revision(version: 1, real: 1)));
|
||||
var remoteBook1 = GivenRemoteBook(new List<Book> { GivenBook(1) }, new QualityModel(Quality.MP3_320, new Revision(version: 1, real: 0)));
|
||||
var remoteBook2 = GivenRemoteBook(new List<Book> { GivenBook(1) }, new QualityModel(Quality.MP3_320, new Revision(version: 1, real: 1)));
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteAlbum1));
|
||||
decisions.Add(new DownloadDecision(remoteAlbum2));
|
||||
decisions.Add(new DownloadDecision(remoteBook1));
|
||||
decisions.Add(new DownloadDecision(remoteBook2));
|
||||
|
||||
var qualifiedReports = Subject.PrioritizeDecisions(decisions);
|
||||
qualifiedReports.First().RemoteAlbum.ParsedAlbumInfo.Quality.Revision.Real.Should().Be(1);
|
||||
qualifiedReports.First().RemoteBook.ParsedBookInfo.Quality.Revision.Real.Should().Be(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_put_propers_before_non_propers()
|
||||
{
|
||||
var remoteBook1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320, new Revision(version: 1)));
|
||||
var remoteBook2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320, new Revision(version: 2)));
|
||||
var remoteBook1 = GivenRemoteBook(new List<Book> { GivenBook(1) }, new QualityModel(Quality.MP3_320, new Revision(version: 1)));
|
||||
var remoteBook2 = GivenRemoteBook(new List<Book> { GivenBook(1) }, new QualityModel(Quality.MP3_320, new Revision(version: 2)));
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteBook1));
|
||||
@@ -101,8 +101,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
[Test]
|
||||
public void should_put_higher_quality_before_lower()
|
||||
{
|
||||
var remoteBook1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
var remoteBook2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
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 decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteBook1));
|
||||
@@ -115,10 +115,10 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
[Test]
|
||||
public void should_order_by_age_then_largest_rounded_to_200mb()
|
||||
{
|
||||
var remoteBookSd = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320), size: 100.Megabytes(), age: 1);
|
||||
var remoteBookHdSmallOld = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320), size: 1200.Megabytes(), age: 1000);
|
||||
var remoteBookSmallYoung = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320), size: 1250.Megabytes(), age: 10);
|
||||
var remoteBookHdLargeYoung = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320), size: 3000.Megabytes(), age: 1);
|
||||
var remoteBookSd = GivenRemoteBook(new List<Book> { GivenBook(1) }, new QualityModel(Quality.MP3_320), size: 100.Megabytes(), age: 1);
|
||||
var remoteBookHdSmallOld = GivenRemoteBook(new List<Book> { GivenBook(1) }, new QualityModel(Quality.MP3_320), size: 1200.Megabytes(), age: 1000);
|
||||
var remoteBookSmallYoung = GivenRemoteBook(new List<Book> { GivenBook(1) }, new QualityModel(Quality.MP3_320), size: 1250.Megabytes(), age: 10);
|
||||
var remoteBookHdLargeYoung = GivenRemoteBook(new List<Book> { GivenBook(1) }, new QualityModel(Quality.MP3_320), size: 3000.Megabytes(), age: 1);
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteBookSd));
|
||||
@@ -133,8 +133,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
[Test]
|
||||
public void should_order_by_youngest()
|
||||
{
|
||||
var remoteBook1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320), age: 10);
|
||||
var remoteBook2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320), age: 5);
|
||||
var remoteBook1 = GivenRemoteBook(new List<Book> { GivenBook(1) }, new QualityModel(Quality.MP3_320), age: 10);
|
||||
var remoteBook2 = GivenRemoteBook(new List<Book> { GivenBook(1) }, new QualityModel(Quality.MP3_320), age: 5);
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteBook1));
|
||||
@@ -145,10 +145,10 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_throw_if_no_albums_are_found()
|
||||
public void should_not_throw_if_no_books_are_found()
|
||||
{
|
||||
var remoteBook1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320), size: 500.Megabytes());
|
||||
var remoteBook2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320), size: 500.Megabytes());
|
||||
var remoteBook1 = GivenRemoteBook(new List<Book> { GivenBook(1) }, new QualityModel(Quality.MP3_320), size: 500.Megabytes());
|
||||
var remoteBook2 = GivenRemoteBook(new List<Book> { GivenBook(1) }, new QualityModel(Quality.MP3_320), size: 500.Megabytes());
|
||||
|
||||
remoteBook1.Books = new List<Book>();
|
||||
|
||||
@@ -164,8 +164,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
GivenPreferredDownloadProtocol(DownloadProtocol.Usenet);
|
||||
|
||||
var remoteBook1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320), downloadProtocol: DownloadProtocol.Torrent);
|
||||
var remoteBook2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320), downloadProtocol: DownloadProtocol.Usenet);
|
||||
var remoteBook1 = GivenRemoteBook(new List<Book> { GivenBook(1) }, new QualityModel(Quality.MP3_320), downloadProtocol: DownloadProtocol.Torrent);
|
||||
var remoteBook2 = GivenRemoteBook(new List<Book> { GivenBook(1) }, new QualityModel(Quality.MP3_320), downloadProtocol: DownloadProtocol.Usenet);
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteBook1));
|
||||
@@ -180,8 +180,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
GivenPreferredDownloadProtocol(DownloadProtocol.Torrent);
|
||||
|
||||
var remoteBook1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320), downloadProtocol: DownloadProtocol.Torrent);
|
||||
var remoteBook2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320), downloadProtocol: DownloadProtocol.Usenet);
|
||||
var remoteBook1 = GivenRemoteBook(new List<Book> { GivenBook(1) }, new QualityModel(Quality.MP3_320), downloadProtocol: DownloadProtocol.Torrent);
|
||||
var remoteBook2 = GivenRemoteBook(new List<Book> { GivenBook(1) }, new QualityModel(Quality.MP3_320), downloadProtocol: DownloadProtocol.Usenet);
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteBook1));
|
||||
@@ -192,10 +192,10 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_prefer_discography_pack_above_single_album()
|
||||
public void should_prefer_discography_pack_above_single_book()
|
||||
{
|
||||
var remoteBook1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1), GivenAlbum(2) }, new QualityModel(Quality.FLAC));
|
||||
var remoteBook2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.FLAC));
|
||||
var remoteBook1 = GivenRemoteBook(new List<Book> { GivenBook(1), GivenBook(2) }, new QualityModel(Quality.FLAC));
|
||||
var remoteBook2 = GivenRemoteBook(new List<Book> { GivenBook(1) }, new QualityModel(Quality.FLAC));
|
||||
|
||||
remoteBook1.ParsedBookInfo.Discography = true;
|
||||
|
||||
@@ -210,8 +210,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
[Test]
|
||||
public void should_prefer_quality_over_discography_pack()
|
||||
{
|
||||
var remoteBook1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1), GivenAlbum(2) }, new QualityModel(Quality.MP3_320));
|
||||
var remoteBook2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.FLAC));
|
||||
var remoteBook1 = GivenRemoteBook(new List<Book> { GivenBook(1), GivenBook(2) }, new QualityModel(Quality.MP3_320));
|
||||
var remoteBook2 = GivenRemoteBook(new List<Book> { GivenBook(1) }, new QualityModel(Quality.FLAC));
|
||||
|
||||
remoteBook1.ParsedBookInfo.Discography = true;
|
||||
|
||||
@@ -224,10 +224,10 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_prefer_single_album_over_multi_album()
|
||||
public void should_prefer_single_book_over_multi_book()
|
||||
{
|
||||
var remoteBook1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1), GivenAlbum(2) }, new QualityModel(Quality.MP3_320));
|
||||
var remoteBook2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
var remoteBook1 = GivenRemoteBook(new List<Book> { GivenBook(1), GivenBook(2) }, new QualityModel(Quality.MP3_320));
|
||||
var remoteBook2 = GivenRemoteBook(new List<Book> { GivenBook(1) }, new QualityModel(Quality.MP3_320));
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteBook1));
|
||||
@@ -240,8 +240,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
[Test]
|
||||
public void should_prefer_releases_with_more_seeders()
|
||||
{
|
||||
var remoteBook1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
var remoteBook2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
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;
|
||||
@@ -266,8 +266,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
[Test]
|
||||
public void should_prefer_releases_with_more_peers_given_equal_number_of_seeds()
|
||||
{
|
||||
var remoteBook1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
var remoteBook2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
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;
|
||||
@@ -293,8 +293,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
[Test]
|
||||
public void should_prefer_releases_with_more_peers_no_seeds()
|
||||
{
|
||||
var remoteBook1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
var remoteBook2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
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;
|
||||
@@ -321,8 +321,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
[Test]
|
||||
public void should_prefer_first_release_if_peers_and_size_are_too_similar()
|
||||
{
|
||||
var remoteBook1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
var remoteBook2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
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;
|
||||
@@ -350,8 +350,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
[Test]
|
||||
public void should_prefer_first_release_if_age_and_size_are_too_similar()
|
||||
{
|
||||
var remoteBook1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
var remoteBook2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
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));
|
||||
|
||||
remoteBook1.Release.PublishDate = DateTime.UtcNow.AddDays(-100);
|
||||
remoteBook1.Release.Size = 200.Megabytes();
|
||||
@@ -370,8 +370,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
[Test]
|
||||
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 remoteBook1 = GivenRemoteBook(new List<Book> { GivenBook(1) }, new QualityModel(Quality.MP3_320));
|
||||
var remoteBook2 = GivenRemoteBook(new List<Book> { GivenBook(1) }, new QualityModel(Quality.AZW3));
|
||||
|
||||
var torrentInfo1 = new TorrentInfo();
|
||||
torrentInfo1.PublishDate = DateTime.Now;
|
||||
@@ -399,8 +399,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
[Test]
|
||||
public void should_put_higher_quality_before_lower_always()
|
||||
{
|
||||
var remoteBook1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
var remoteBook2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
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 decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteBook1));
|
||||
@@ -413,8 +413,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
[Test]
|
||||
public void should_prefer_higher_score_over_lower_score()
|
||||
{
|
||||
var remoteBook1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.FLAC));
|
||||
var remoteBook2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.FLAC));
|
||||
var remoteBook1 = GivenRemoteBook(new List<Book> { GivenBook(1) }, new QualityModel(Quality.FLAC));
|
||||
var remoteBook2 = GivenRemoteBook(new List<Book> { GivenBook(1) }, new QualityModel(Quality.FLAC));
|
||||
|
||||
remoteBook1.PreferredWordScore = 10;
|
||||
remoteBook2.PreferredWordScore = 0;
|
||||
@@ -434,8 +434,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
.Setup(s => s.DownloadPropersAndRepacks)
|
||||
.Returns(ProperDownloadTypes.PreferAndUpgrade);
|
||||
|
||||
var remoteBook1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.FLAC, new Revision(1)));
|
||||
var remoteBook2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.FLAC, new Revision(2)));
|
||||
var remoteBook1 = GivenRemoteBook(new List<Book> { GivenBook(1) }, new QualityModel(Quality.FLAC, new Revision(1)));
|
||||
var remoteBook2 = GivenRemoteBook(new List<Book> { GivenBook(1) }, new QualityModel(Quality.FLAC, new Revision(2)));
|
||||
|
||||
remoteBook1.PreferredWordScore = 10;
|
||||
remoteBook2.PreferredWordScore = 0;
|
||||
@@ -455,8 +455,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
.Setup(s => s.DownloadPropersAndRepacks)
|
||||
.Returns(ProperDownloadTypes.DoNotUpgrade);
|
||||
|
||||
var remoteBook1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.FLAC, new Revision(1)));
|
||||
var remoteBook2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.FLAC, new Revision(2)));
|
||||
var remoteBook1 = GivenRemoteBook(new List<Book> { GivenBook(1) }, new QualityModel(Quality.FLAC, new Revision(1)));
|
||||
var remoteBook2 = GivenRemoteBook(new List<Book> { GivenBook(1) }, new QualityModel(Quality.FLAC, new Revision(2)));
|
||||
|
||||
remoteBook1.PreferredWordScore = 10;
|
||||
remoteBook2.PreferredWordScore = 0;
|
||||
@@ -476,8 +476,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
.Setup(s => s.DownloadPropersAndRepacks)
|
||||
.Returns(ProperDownloadTypes.DoNotPrefer);
|
||||
|
||||
var remoteBook1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.FLAC, new Revision(1)));
|
||||
var remoteBook2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.FLAC, new Revision(2)));
|
||||
var remoteBook1 = GivenRemoteBook(new List<Book> { GivenBook(1) }, new QualityModel(Quality.FLAC, new Revision(1)));
|
||||
var remoteBook2 = GivenRemoteBook(new List<Book> { GivenBook(1) }, new QualityModel(Quality.FLAC, new Revision(2)));
|
||||
|
||||
remoteBook1.PreferredWordScore = 10;
|
||||
remoteBook2.PreferredWordScore = 0;
|
||||
@@ -495,35 +495,35 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
[Test]
|
||||
public void sort_download_decisions_based_on_indexer_priority()
|
||||
{
|
||||
var remoteAlbum1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.AZW3, new Revision(1)), indexerPriority: 25);
|
||||
var remoteAlbum2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.AZW3, new Revision(1)), indexerPriority: 50);
|
||||
var remoteAlbum3 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.AZW3, new Revision(1)), indexerPriority: 1);
|
||||
var remoteBook1 = GivenRemoteBook(new List<Book> { GivenBook(1) }, new QualityModel(Quality.AZW3, new Revision(1)), indexerPriority: 25);
|
||||
var remoteBook2 = GivenRemoteBook(new List<Book> { GivenBook(1) }, new QualityModel(Quality.AZW3, new Revision(1)), indexerPriority: 50);
|
||||
var remoteBook3 = GivenRemoteBook(new List<Book> { GivenBook(1) }, new QualityModel(Quality.AZW3, new Revision(1)), indexerPriority: 1);
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.AddRange(new[] { new DownloadDecision(remoteAlbum1), new DownloadDecision(remoteAlbum2), new DownloadDecision(remoteAlbum3) });
|
||||
decisions.AddRange(new[] { new DownloadDecision(remoteBook1), new DownloadDecision(remoteBook2), new DownloadDecision(remoteBook3) });
|
||||
|
||||
var qualifiedReports = Subject.PrioritizeDecisions(decisions);
|
||||
qualifiedReports.First().RemoteBook.Should().Be(remoteAlbum3);
|
||||
qualifiedReports.Skip(1).First().RemoteBook.Should().Be(remoteAlbum1);
|
||||
qualifiedReports.Last().RemoteBook.Should().Be(remoteAlbum2);
|
||||
qualifiedReports.First().RemoteBook.Should().Be(remoteBook3);
|
||||
qualifiedReports.Skip(1).First().RemoteBook.Should().Be(remoteBook1);
|
||||
qualifiedReports.Last().RemoteBook.Should().Be(remoteBook2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ensure_download_decisions_indexer_priority_is_not_perfered_over_quality()
|
||||
{
|
||||
var remoteAlbum1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.EPUB, new Revision(1)), indexerPriority: 25);
|
||||
var remoteAlbum2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.AZW3, new Revision(1)), indexerPriority: 50);
|
||||
var remoteAlbum3 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.PDF, new Revision(1)), indexerPriority: 1);
|
||||
var remoteAlbum4 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.AZW3, new Revision(1)), indexerPriority: 25);
|
||||
var remoteBook1 = GivenRemoteBook(new List<Book> { GivenBook(1) }, new QualityModel(Quality.EPUB, new Revision(1)), indexerPriority: 25);
|
||||
var remoteBook2 = GivenRemoteBook(new List<Book> { GivenBook(1) }, new QualityModel(Quality.AZW3, new Revision(1)), indexerPriority: 50);
|
||||
var remoteBook3 = GivenRemoteBook(new List<Book> { GivenBook(1) }, new QualityModel(Quality.PDF, new Revision(1)), indexerPriority: 1);
|
||||
var remoteBook4 = GivenRemoteBook(new List<Book> { GivenBook(1) }, new QualityModel(Quality.AZW3, new Revision(1)), indexerPriority: 25);
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.AddRange(new[] { new DownloadDecision(remoteAlbum1), new DownloadDecision(remoteAlbum2), new DownloadDecision(remoteAlbum3), new DownloadDecision(remoteAlbum4) });
|
||||
decisions.AddRange(new[] { new DownloadDecision(remoteBook1), new DownloadDecision(remoteBook2), new DownloadDecision(remoteBook3), new DownloadDecision(remoteBook4) });
|
||||
|
||||
var qualifiedReports = Subject.PrioritizeDecisions(decisions);
|
||||
qualifiedReports.First().RemoteBook.Should().Be(remoteAlbum4);
|
||||
qualifiedReports.Skip(1).First().RemoteBook.Should().Be(remoteAlbum2);
|
||||
qualifiedReports.Skip(2).First().RemoteBook.Should().Be(remoteAlbum1);
|
||||
qualifiedReports.Last().RemoteBook.Should().Be(remoteAlbum3);
|
||||
qualifiedReports.First().RemoteBook.Should().Be(remoteBook4);
|
||||
qualifiedReports.Skip(1).First().RemoteBook.Should().Be(remoteBook2);
|
||||
qualifiedReports.Skip(2).First().RemoteBook.Should().Be(remoteBook1);
|
||||
qualifiedReports.Last().RemoteBook.Should().Be(remoteBook3);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -533,21 +533,22 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
.Setup(s => s.DownloadPropersAndRepacks)
|
||||
.Returns(ProperDownloadTypes.DoNotPrefer);
|
||||
|
||||
var remoteAlbum1 = GivenRemoteAlbum(new List<Album> { GivenAlbum(1) }, new QualityModel(Quality.FLAC, new Revision(1, 0)));
|
||||
var remoteAlbum2 = GivenRemoteAlbum(new List<Album> { GivenAlbum(1) }, new QualityModel(Quality.FLAC, new Revision(1, 1)));
|
||||
var remoteBook1 = GivenRemoteBook(new List<Book> { GivenBook(1) }, new QualityModel(Quality.FLAC, new Revision(1, 0)));
|
||||
var remoteBook2 = GivenRemoteBook(new List<Book> { GivenBook(1) }, new QualityModel(Quality.FLAC, new Revision(1, 1)));
|
||||
|
||||
remoteAlbum1.PreferredWordScore = 10;
|
||||
remoteAlbum2.PreferredWordScore = 0;
|
||||
remoteBook1.PreferredWordScore = 10;
|
||||
remoteBook2.PreferredWordScore = 0;
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteAlbum1));
|
||||
decisions.Add(new DownloadDecision(remoteAlbum2));
|
||||
decisions.Add(new DownloadDecision(remoteBook1));
|
||||
decisions.Add(new DownloadDecision(remoteBook2));
|
||||
|
||||
var qualifiedReports = Subject.PrioritizeDecisions(decisions);
|
||||
qualifiedReports.First().RemoteAlbum.ParsedAlbumInfo.Quality.Quality.Should().Be(Quality.FLAC);
|
||||
qualifiedReports.First().RemoteAlbum.ParsedAlbumInfo.Quality.Revision.Version.Should().Be(1);
|
||||
qualifiedReports.First().RemoteAlbum.ParsedAlbumInfo.Quality.Revision.Real.Should().Be(0);
|
||||
qualifiedReports.First().RemoteAlbum.PreferredWordScore.Should().Be(10);
|
||||
|
||||
qualifiedReports.First().RemoteBook.ParsedBookInfo.Quality.Quality.Should().Be(Quality.FLAC);
|
||||
qualifiedReports.First().RemoteBook.ParsedBookInfo.Quality.Revision.Version.Should().Be(1);
|
||||
qualifiedReports.First().RemoteBook.ParsedBookInfo.Quality.Revision.Real.Should().Be(0);
|
||||
qualifiedReports.First().RemoteBook.PreferredWordScore.Should().Be(10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -32,13 +32,13 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
var fakeArtist = Builder<Author>.CreateNew()
|
||||
var fakeAuthor = Builder<Author>.CreateNew()
|
||||
.With(c => c.QualityProfile = new QualityProfile { Cutoff = Quality.MP3_320.Id })
|
||||
.Build();
|
||||
|
||||
_remoteBook = new RemoteBook
|
||||
{
|
||||
Author = fakeArtist,
|
||||
Author = fakeAuthor,
|
||||
ParsedBookInfo = new ParsedBookInfo { Quality = new QualityModel(Quality.MP3_320, new Revision(version: 2)) },
|
||||
};
|
||||
}
|
||||
|
||||
@@ -17,12 +17,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
[TestFixture]
|
||||
public class QueueSpecificationFixture : CoreTest<QueueSpecification>
|
||||
{
|
||||
private Author _artist;
|
||||
private Book _album;
|
||||
private Author _author;
|
||||
private Book _book;
|
||||
private RemoteBook _remoteBook;
|
||||
|
||||
private Author _otherArtist;
|
||||
private Book _otherAlbum;
|
||||
private Author _otherAuthor;
|
||||
private Book _otherBook;
|
||||
|
||||
private ReleaseInfo _releaseInfo;
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
Mocker.Resolve<UpgradableSpecification>();
|
||||
|
||||
_artist = Builder<Author>.CreateNew()
|
||||
_author = Builder<Author>.CreateNew()
|
||||
.With(e => e.QualityProfile = new QualityProfile
|
||||
{
|
||||
UpgradeAllowed = true,
|
||||
@@ -39,16 +39,16 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
})
|
||||
.Build();
|
||||
|
||||
_album = Builder<Book>.CreateNew()
|
||||
.With(e => e.AuthorId = _artist.Id)
|
||||
_book = Builder<Book>.CreateNew()
|
||||
.With(e => e.AuthorId = _author.Id)
|
||||
.Build();
|
||||
|
||||
_otherArtist = Builder<Author>.CreateNew()
|
||||
_otherAuthor = Builder<Author>.CreateNew()
|
||||
.With(s => s.Id = 2)
|
||||
.Build();
|
||||
|
||||
_otherAlbum = Builder<Book>.CreateNew()
|
||||
.With(e => e.AuthorId = _otherArtist.Id)
|
||||
_otherBook = Builder<Book>.CreateNew()
|
||||
.With(e => e.AuthorId = _otherAuthor.Id)
|
||||
.With(e => e.Id = 2)
|
||||
.Build();
|
||||
|
||||
@@ -56,8 +56,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
.Build();
|
||||
|
||||
_remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(r => r.Author = _artist)
|
||||
.With(r => r.Books = new List<Book> { _album })
|
||||
.With(r => r.Author = _author)
|
||||
.With(r => r.Books = new List<Book> { _book })
|
||||
.With(r => r.ParsedBookInfo = new ParsedBookInfo { Quality = new QualityModel(Quality.MP3_320) })
|
||||
.With(r => r.PreferredWordScore = 0)
|
||||
.Build();
|
||||
@@ -91,11 +91,11 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_when_artist_doesnt_match()
|
||||
public void should_return_true_when_author_doesnt_match()
|
||||
{
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(r => r.Author = _otherArtist)
|
||||
.With(r => r.Books = new List<Book> { _album })
|
||||
.With(r => r.Author = _otherAuthor)
|
||||
.With(r => r.Books = new List<Book> { _book })
|
||||
.With(r => r.Release = _releaseInfo)
|
||||
.Build();
|
||||
|
||||
@@ -106,11 +106,11 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
[Test]
|
||||
public void should_return_false_if_everything_is_the_same()
|
||||
{
|
||||
_artist.QualityProfile.Value.Cutoff = Quality.FLAC.Id;
|
||||
_author.QualityProfile.Value.Cutoff = Quality.FLAC.Id;
|
||||
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(r => r.Author = _artist)
|
||||
.With(r => r.Books = new List<Book> { _album })
|
||||
.With(r => r.Author = _author)
|
||||
.With(r => r.Books = new List<Book> { _book })
|
||||
.With(r => r.ParsedBookInfo = new ParsedBookInfo
|
||||
{
|
||||
Quality = new QualityModel(Quality.MP3_320)
|
||||
@@ -126,11 +126,11 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
[Test]
|
||||
public void should_return_true_when_quality_in_queue_is_lower()
|
||||
{
|
||||
_artist.QualityProfile.Value.Cutoff = Quality.MP3_320.Id;
|
||||
_author.QualityProfile.Value.Cutoff = Quality.MP3_320.Id;
|
||||
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(r => r.Author = _artist)
|
||||
.With(r => r.Books = new List<Book> { _album })
|
||||
.With(r => r.Author = _author)
|
||||
.With(r => r.Books = new List<Book> { _book })
|
||||
.With(r => r.ParsedBookInfo = new ParsedBookInfo
|
||||
{
|
||||
Quality = new QualityModel(Quality.AZW3)
|
||||
@@ -143,11 +143,11 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_when_album_doesnt_match()
|
||||
public void should_return_true_when_book_doesnt_match()
|
||||
{
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(r => r.Author = _artist)
|
||||
.With(r => r.Books = new List<Book> { _otherAlbum })
|
||||
.With(r => r.Author = _author)
|
||||
.With(r => r.Books = new List<Book> { _otherBook })
|
||||
.With(r => r.ParsedBookInfo = new ParsedBookInfo
|
||||
{
|
||||
Quality = new QualityModel(Quality.MP3_320)
|
||||
@@ -165,8 +165,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
_remoteBook.PreferredWordScore = 1;
|
||||
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(r => r.Author = _artist)
|
||||
.With(r => r.Books = new List<Book> { _album })
|
||||
.With(r => r.Author = _author)
|
||||
.With(r => r.Books = new List<Book> { _book })
|
||||
.With(r => r.ParsedBookInfo = new ParsedBookInfo
|
||||
{
|
||||
Quality = new QualityModel(Quality.MP3_320)
|
||||
@@ -182,8 +182,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
public void should_return_false_when_qualities_are_the_same()
|
||||
{
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(r => r.Author = _artist)
|
||||
.With(r => r.Books = new List<Book> { _album })
|
||||
.With(r => r.Author = _author)
|
||||
.With(r => r.Books = new List<Book> { _book })
|
||||
.With(r => r.ParsedBookInfo = new ParsedBookInfo
|
||||
{
|
||||
Quality = new QualityModel(Quality.MP3_320)
|
||||
@@ -198,11 +198,11 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
[Test]
|
||||
public void should_return_false_when_quality_in_queue_is_better()
|
||||
{
|
||||
_artist.QualityProfile.Value.Cutoff = Quality.FLAC.Id;
|
||||
_author.QualityProfile.Value.Cutoff = Quality.FLAC.Id;
|
||||
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(r => r.Author = _artist)
|
||||
.With(r => r.Books = new List<Book> { _album })
|
||||
.With(r => r.Author = _author)
|
||||
.With(r => r.Books = new List<Book> { _book })
|
||||
.With(r => r.ParsedBookInfo = new ParsedBookInfo
|
||||
{
|
||||
Quality = new QualityModel(Quality.MP3_320)
|
||||
@@ -215,11 +215,11 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_matching_multi_album_is_in_queue()
|
||||
public void should_return_false_if_matching_multi_book_is_in_queue()
|
||||
{
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(r => r.Author = _artist)
|
||||
.With(r => r.Books = new List<Book> { _album, _otherAlbum })
|
||||
.With(r => r.Author = _author)
|
||||
.With(r => r.Books = new List<Book> { _book, _otherBook })
|
||||
.With(r => r.ParsedBookInfo = new ParsedBookInfo
|
||||
{
|
||||
Quality = new QualityModel(Quality.MP3_320)
|
||||
@@ -232,11 +232,11 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_multi_album_has_one_album_in_queue()
|
||||
public void should_return_false_if_multi_book_has_one_book_in_queue()
|
||||
{
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(r => r.Author = _artist)
|
||||
.With(r => r.Books = new List<Book> { _album })
|
||||
.With(r => r.Author = _author)
|
||||
.With(r => r.Books = new List<Book> { _book })
|
||||
.With(r => r.ParsedBookInfo = new ParsedBookInfo
|
||||
{
|
||||
Quality = new QualityModel(Quality.MP3_320)
|
||||
@@ -244,18 +244,18 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
.With(r => r.Release = _releaseInfo)
|
||||
.Build();
|
||||
|
||||
_remoteBook.Books.Add(_otherAlbum);
|
||||
_remoteBook.Books.Add(_otherBook);
|
||||
|
||||
GivenQueue(new List<RemoteBook> { remoteBook });
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_multi_part_album_is_already_in_queue()
|
||||
public void should_return_false_if_multi_part_book_is_already_in_queue()
|
||||
{
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(r => r.Author = _artist)
|
||||
.With(r => r.Books = new List<Book> { _album, _otherAlbum })
|
||||
.With(r => r.Author = _author)
|
||||
.With(r => r.Books = new List<Book> { _book, _otherBook })
|
||||
.With(r => r.ParsedBookInfo = new ParsedBookInfo
|
||||
{
|
||||
Quality = new QualityModel(Quality.MP3_320)
|
||||
@@ -263,30 +263,30 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
.With(r => r.Release = _releaseInfo)
|
||||
.Build();
|
||||
|
||||
_remoteBook.Books.Add(_otherAlbum);
|
||||
_remoteBook.Books.Add(_otherBook);
|
||||
|
||||
GivenQueue(new List<RemoteBook> { remoteBook });
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_multi_part_album_has_two_albums_in_queue()
|
||||
public void should_return_false_if_multi_part_book_has_two_books_in_queue()
|
||||
{
|
||||
var remoteBooks = Builder<RemoteBook>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(r => r.Author = _artist)
|
||||
.With(r => r.Author = _author)
|
||||
.With(r => r.ParsedBookInfo = new ParsedBookInfo
|
||||
{
|
||||
Quality = new QualityModel(Quality.MP3_320)
|
||||
})
|
||||
.With(r => r.Release = _releaseInfo)
|
||||
.TheFirst(1)
|
||||
.With(r => r.Books = new List<Book> { _album })
|
||||
.With(r => r.Books = new List<Book> { _book })
|
||||
.TheNext(1)
|
||||
.With(r => r.Books = new List<Book> { _otherAlbum })
|
||||
.With(r => r.Books = new List<Book> { _otherBook })
|
||||
.Build();
|
||||
|
||||
_remoteBook.Books.Add(_otherAlbum);
|
||||
_remoteBook.Books.Add(_otherBook);
|
||||
GivenQueue(remoteBooks);
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
@@ -294,12 +294,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
[Test]
|
||||
public void should_return_false_when_quality_is_better_and_upgrade_allowed_is_false_for_quality_profile()
|
||||
{
|
||||
_artist.QualityProfile.Value.Cutoff = Quality.FLAC.Id;
|
||||
_artist.QualityProfile.Value.UpgradeAllowed = false;
|
||||
_author.QualityProfile.Value.Cutoff = Quality.FLAC.Id;
|
||||
_author.QualityProfile.Value.UpgradeAllowed = false;
|
||||
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(r => r.Author = _artist)
|
||||
.With(r => r.Books = new List<Book> { _album })
|
||||
.With(r => r.Author = _author)
|
||||
.With(r => r.Books = new List<Book> { _book })
|
||||
.With(r => r.ParsedBookInfo = new ParsedBookInfo
|
||||
{
|
||||
Quality = new QualityModel(Quality.FLAC)
|
||||
@@ -314,11 +314,11 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
[Test]
|
||||
public void should_return_true_if_everything_is_the_same_for_failed_pending()
|
||||
{
|
||||
_artist.QualityProfile.Value.Cutoff = Quality.FLAC.Id;
|
||||
_author.QualityProfile.Value.Cutoff = Quality.FLAC.Id;
|
||||
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(r => r.Author = _artist)
|
||||
.With(r => r.Books = new List<Book> { _album })
|
||||
.With(r => r.Author = _author)
|
||||
.With(r => r.Books = new List<Book> { _book })
|
||||
.With(r => r.ParsedBookInfo = new ParsedBookInfo
|
||||
{
|
||||
Quality = new QualityModel(Quality.MP3_320)
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
public class RepackSpecificationFixture : CoreTest<RepackSpecification>
|
||||
{
|
||||
private ParsedBookInfo _parsedBookInfo;
|
||||
private List<Book> _albums;
|
||||
private List<Book> _books;
|
||||
private List<BookFile> _trackFiles;
|
||||
|
||||
[SetUp]
|
||||
@@ -31,13 +31,13 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
.With(p => p.ReleaseGroup = "Readarr")
|
||||
.Build();
|
||||
|
||||
_albums = Builder<Book>.CreateListOfSize(1)
|
||||
_books = Builder<Book>.CreateListOfSize(1)
|
||||
.All()
|
||||
.BuildList();
|
||||
|
||||
_trackFiles = Builder<BookFile>.CreateListOfSize(3)
|
||||
.All()
|
||||
.With(t => t.EditionId = _albums.First().Id)
|
||||
.With(t => t.EditionId = _books.First().Id)
|
||||
.BuildList();
|
||||
|
||||
Mocker.GetMock<IMediaFileService>()
|
||||
@@ -50,7 +50,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(e => e.ParsedBookInfo = _parsedBookInfo)
|
||||
.With(e => e.Books = _albums)
|
||||
.With(e => e.Books = _books)
|
||||
.Build();
|
||||
|
||||
Subject.IsSatisfiedBy(remoteBook, null)
|
||||
@@ -70,7 +70,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(e => e.ParsedBookInfo = _parsedBookInfo)
|
||||
.With(e => e.Books = _albums)
|
||||
.With(e => e.Books = _books)
|
||||
.Build();
|
||||
|
||||
Subject.IsSatisfiedBy(remoteBook, null)
|
||||
@@ -97,7 +97,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(e => e.ParsedBookInfo = _parsedBookInfo)
|
||||
.With(e => e.Books = _albums)
|
||||
.With(e => e.Books = _books)
|
||||
.Build();
|
||||
|
||||
Subject.IsSatisfiedBy(remoteBook, null)
|
||||
@@ -124,7 +124,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(e => e.ParsedBookInfo = _parsedBookInfo)
|
||||
.With(e => e.Books = _albums)
|
||||
.With(e => e.Books = _books)
|
||||
.Build();
|
||||
|
||||
Subject.IsSatisfiedBy(remoteBook, null)
|
||||
@@ -153,7 +153,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(e => e.ParsedBookInfo = _parsedBookInfo)
|
||||
.With(e => e.Books = _albums)
|
||||
.With(e => e.Books = _books)
|
||||
.Build();
|
||||
|
||||
Subject.IsSatisfiedBy(remoteBook, null)
|
||||
@@ -180,7 +180,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(e => e.ParsedBookInfo = _parsedBookInfo)
|
||||
.With(e => e.Books = _albums)
|
||||
.With(e => e.Books = _books)
|
||||
.Build();
|
||||
|
||||
Subject.IsSatisfiedBy(remoteBook, null)
|
||||
@@ -207,7 +207,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(e => e.ParsedBookInfo = _parsedBookInfo)
|
||||
.With(e => e.Books = _albums)
|
||||
.With(e => e.Books = _books)
|
||||
.Build();
|
||||
|
||||
Subject.IsSatisfiedBy(remoteBook, null)
|
||||
@@ -236,7 +236,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(e => e.ParsedBookInfo = _parsedBookInfo)
|
||||
.With(e => e.Books = _albums)
|
||||
.With(e => e.Books = _books)
|
||||
.Build();
|
||||
|
||||
Subject.IsSatisfiedBy(remoteBook, null)
|
||||
|
||||
@@ -37,12 +37,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
||||
.With(d => d.PreferredProtocol = DownloadProtocol.Usenet)
|
||||
.Build();
|
||||
|
||||
var artist = Builder<Author>.CreateNew()
|
||||
var author = Builder<Author>.CreateNew()
|
||||
.With(s => s.QualityProfile = _profile)
|
||||
.Build();
|
||||
|
||||
_remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(r => r.Author = artist)
|
||||
.With(r => r.Author = author)
|
||||
.Build();
|
||||
|
||||
_profile.Items = new List<QualityProfileQualityItem>();
|
||||
@@ -87,7 +87,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
||||
private void GivenUpgradeForExistingFile()
|
||||
{
|
||||
Mocker.GetMock<IUpgradableSpecification>()
|
||||
.Setup(s => s.IsUpgradable(It.IsAny<QualityProfile>(), It.IsAny<List<QualityModel>>(), It.IsAny<int>(), It.IsAny<QualityModel>(), It.IsAny<int>()))
|
||||
.Setup(s => s.IsUpgradable(It.IsAny<QualityProfile>(), It.IsAny<QualityModel>(), It.IsAny<int>(), It.IsAny<QualityModel>(), It.IsAny<int>()))
|
||||
.Returns(true);
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_true_when_release_is_a_proper_for_existing_album()
|
||||
public void should_be_true_when_release_is_a_proper_for_existing_book()
|
||||
{
|
||||
_remoteBook.ParsedBookInfo.Quality = new QualityModel(Quality.MP3_320, new Revision(version: 2));
|
||||
_remoteBook.Release.PublishDate = DateTime.UtcNow;
|
||||
@@ -165,7 +165,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_true_when_release_is_a_real_for_existing_album()
|
||||
public void should_be_true_when_release_is_a_real_for_existing_book()
|
||||
{
|
||||
_remoteBook.ParsedBookInfo.Quality = new QualityModel(Quality.MP3_320, new Revision(real: 1));
|
||||
_remoteBook.Release.PublishDate = DateTime.UtcNow;
|
||||
@@ -183,19 +183,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_false_when_release_is_proper_for_existing_album_of_different_quality()
|
||||
public void should_be_false_when_release_is_proper_for_existing_book_of_different_quality()
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
_remoteBook.ParsedBookInfo.Quality = new QualityModel(Quality.AZW3, new Revision(version: 2));
|
||||
_remoteBook.Release.PublishDate = DateTime.UtcNow;
|
||||
|
||||
GivenExistingFile(new QualityModel(Quality.PDF));
|
||||
=======
|
||||
_remoteAlbum.ParsedAlbumInfo.Quality = new QualityModel(Quality.MP3_320, new Revision(version: 2));
|
||||
_remoteAlbum.Release.PublishDate = DateTime.UtcNow;
|
||||
|
||||
GivenExistingFile(new QualityModel(Quality.MP3_256));
|
||||
>>>>>>> Fixed: Delay profile being ignored for non-revision upgrades
|
||||
|
||||
_delayProfile.UsenetDelay = 720;
|
||||
|
||||
|
||||
+10
-10
@@ -33,7 +33,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
||||
new BookFile
|
||||
{
|
||||
Id = 1,
|
||||
Path = "/My.Artist.S01E01.mp3",
|
||||
Path = "/My.Author.S01E01.mp3",
|
||||
Quality = new QualityModel(Quality.FLAC, new Revision(version: 1)),
|
||||
DateAdded = DateTime.Now,
|
||||
EditionId = 1
|
||||
@@ -42,36 +42,36 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
||||
new BookFile
|
||||
{
|
||||
Id = 2,
|
||||
Path = "/My.Artist.S01E02.mp3",
|
||||
Path = "/My.Author.S01E02.mp3",
|
||||
Quality = new QualityModel(Quality.FLAC, new Revision(version: 1)),
|
||||
DateAdded = DateTime.Now,
|
||||
EditionId = 2
|
||||
};
|
||||
|
||||
var singleAlbumList = new List<Book> { new Book { Id = 1 } };
|
||||
var doubleAlbumList = new List<Book>
|
||||
var singleBookList = new List<Book> { new Book { Id = 1 } };
|
||||
var doubleBookList = new List<Book>
|
||||
{
|
||||
new Book { Id = 1 },
|
||||
new Book { Id = 2 }
|
||||
};
|
||||
|
||||
var fakeArtist = Builder<Author>.CreateNew()
|
||||
var fakeAuthor = Builder<Author>.CreateNew()
|
||||
.With(c => c.QualityProfile = new QualityProfile { Cutoff = Quality.FLAC.Id })
|
||||
.With(c => c.Path = @"C:\Music\My.Artist".AsOsAgnostic())
|
||||
.With(c => c.Path = @"C:\Music\My.Author".AsOsAgnostic())
|
||||
.Build();
|
||||
|
||||
_parseResultMulti = new RemoteBook
|
||||
{
|
||||
Author = fakeArtist,
|
||||
Author = fakeAuthor,
|
||||
ParsedBookInfo = new ParsedBookInfo { Quality = new QualityModel(Quality.MP3_320, new Revision(version: 2)) },
|
||||
Books = doubleAlbumList
|
||||
Books = doubleBookList
|
||||
};
|
||||
|
||||
_parseResultSingle = new RemoteBook
|
||||
{
|
||||
Author = fakeArtist,
|
||||
Author = fakeAuthor,
|
||||
ParsedBookInfo = new ParsedBookInfo { Quality = new QualityModel(Quality.MP3_320, new Revision(version: 2)) },
|
||||
Books = singleAlbumList
|
||||
Books = singleBookList
|
||||
};
|
||||
|
||||
GivenUnmonitorDeletedTracks(true);
|
||||
|
||||
@@ -34,10 +34,10 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
||||
_firstFile = new BookFile { Quality = new QualityModel(Quality.FLAC, new Revision(version: 1)), DateAdded = DateTime.Now };
|
||||
_secondFile = new BookFile { Quality = new QualityModel(Quality.FLAC, new Revision(version: 1)), DateAdded = DateTime.Now };
|
||||
|
||||
var singleAlbumList = new List<Book> { new Book { }, new Book { } };
|
||||
var doubleAlbumList = new List<Book> { new Book { }, new Book { }, new Book { } };
|
||||
var singleBookList = new List<Book> { new Book { }, new Book { } };
|
||||
var doubleBookList = new List<Book> { new Book { }, new Book { }, new Book { } };
|
||||
|
||||
var fakeArtist = Builder<Author>.CreateNew()
|
||||
var fakeAuthor = Builder<Author>.CreateNew()
|
||||
.With(c => c.QualityProfile = new QualityProfile { Cutoff = Quality.FLAC.Id })
|
||||
.Build();
|
||||
|
||||
@@ -47,16 +47,16 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
||||
|
||||
_parseResultMulti = new RemoteBook
|
||||
{
|
||||
Author = fakeArtist,
|
||||
Author = fakeAuthor,
|
||||
ParsedBookInfo = new ParsedBookInfo { Quality = new QualityModel(Quality.MOBI, new Revision(version: 2)) },
|
||||
Books = doubleAlbumList
|
||||
Books = doubleBookList
|
||||
};
|
||||
|
||||
_parseResultSingle = new RemoteBook
|
||||
{
|
||||
Author = fakeArtist,
|
||||
Author = fakeAuthor,
|
||||
ParsedBookInfo = new ParsedBookInfo { Quality = new QualityModel(Quality.MOBI, new Revision(version: 2)) },
|
||||
Books = singleAlbumList
|
||||
Books = singleBookList
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -10,34 +10,34 @@ using NzbDrone.Test.Common;
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests.Search
|
||||
{
|
||||
[TestFixture]
|
||||
public class ArtistSpecificationFixture : TestBase<AuthorSpecification>
|
||||
public class AuthorSpecificationFixture : TestBase<AuthorSpecification>
|
||||
{
|
||||
private Author _artist1;
|
||||
private Author _artist2;
|
||||
private Author _author1;
|
||||
private Author _author2;
|
||||
private RemoteBook _remoteBook = new RemoteBook();
|
||||
private SearchCriteriaBase _searchCriteria = new BookSearchCriteria();
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_artist1 = Builder<Author>.CreateNew().With(s => s.Id = 1).Build();
|
||||
_artist2 = Builder<Author>.CreateNew().With(s => s.Id = 2).Build();
|
||||
_author1 = Builder<Author>.CreateNew().With(s => s.Id = 1).Build();
|
||||
_author2 = Builder<Author>.CreateNew().With(s => s.Id = 2).Build();
|
||||
|
||||
_remoteBook.Author = _artist1;
|
||||
_remoteBook.Author = _author1;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_artist_doesnt_match()
|
||||
public void should_return_false_if_author_doesnt_match()
|
||||
{
|
||||
_searchCriteria.Author = _artist2;
|
||||
_searchCriteria.Author = _author2;
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteBook, _searchCriteria).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_when_artist_ids_match()
|
||||
public void should_return_true_when_author_ids_match()
|
||||
{
|
||||
_searchCriteria.Author = _artist1;
|
||||
_searchCriteria.Author = _author1;
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteBook, _searchCriteria).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
+5
-5
@@ -15,22 +15,22 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.Search
|
||||
[TestFixture]
|
||||
public class TorrentSeedingSpecificationFixture : TestBase<TorrentSeedingSpecification>
|
||||
{
|
||||
private Author _artist;
|
||||
private Author _author;
|
||||
private RemoteBook _remoteBook;
|
||||
private IndexerDefinition _indexerDefinition;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_artist = Builder<Author>.CreateNew().With(s => s.Id = 1).Build();
|
||||
_author = Builder<Author>.CreateNew().With(s => s.Id = 1).Build();
|
||||
|
||||
_remoteBook = new RemoteBook
|
||||
{
|
||||
Author = _artist,
|
||||
Author = _author,
|
||||
Release = new TorrentInfo
|
||||
{
|
||||
IndexerId = 1,
|
||||
Title = "Artist - Album [FLAC-RlsGrp]",
|
||||
Title = "Author - Book [FLAC-RlsGrp]",
|
||||
Seeders = 0
|
||||
}
|
||||
};
|
||||
@@ -56,7 +56,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.Search
|
||||
_remoteBook.Release = new ReleaseInfo
|
||||
{
|
||||
IndexerId = 1,
|
||||
Title = "Artist - Album [FLAC-RlsGrp]"
|
||||
Title = "Author - Book [FLAC-RlsGrp]"
|
||||
};
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
UpgradeAllowed = false
|
||||
},
|
||||
new List<QualityModel> { new QualityModel(Quality.MP3_320) },
|
||||
new QualityModel(Quality.MP3_320),
|
||||
new QualityModel(Quality.FLAC))
|
||||
.Should().BeFalse();
|
||||
}
|
||||
@@ -36,7 +36,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
UpgradeAllowed = true
|
||||
},
|
||||
new List<QualityModel> { new QualityModel(Quality.MP3_320) },
|
||||
new QualityModel(Quality.MP3_320),
|
||||
new QualityModel(Quality.FLAC))
|
||||
.Should().BeTrue();
|
||||
}
|
||||
@@ -51,7 +51,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
UpgradeAllowed = true
|
||||
},
|
||||
new List<QualityModel> { new QualityModel(Quality.MP3_320) },
|
||||
new QualityModel(Quality.MP3_320),
|
||||
new QualityModel(Quality.MP3_320))
|
||||
.Should().BeTrue();
|
||||
}
|
||||
@@ -66,7 +66,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
UpgradeAllowed = false
|
||||
},
|
||||
new List<QualityModel> { new QualityModel(Quality.MP3_320) },
|
||||
new QualityModel(Quality.MP3_320),
|
||||
new QualityModel(Quality.MP3_320))
|
||||
.Should().BeTrue();
|
||||
}
|
||||
@@ -81,7 +81,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
UpgradeAllowed = true
|
||||
},
|
||||
new List<QualityModel> { new QualityModel(Quality.MP3_320) },
|
||||
new QualityModel(Quality.MP3_320),
|
||||
new QualityModel(Quality.MP3_320))
|
||||
.Should().BeTrue();
|
||||
}
|
||||
@@ -96,7 +96,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
UpgradeAllowed = false
|
||||
},
|
||||
new List<QualityModel> { new QualityModel(Quality.MP3_320) },
|
||||
new QualityModel(Quality.MP3_320),
|
||||
new QualityModel(Quality.MP3_320))
|
||||
.Should().BeTrue();
|
||||
}
|
||||
|
||||
@@ -32,10 +32,10 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
_firstFile = new BookFile { Quality = new QualityModel(Quality.FLAC, new Revision(version: 2)), DateAdded = DateTime.Now };
|
||||
_secondFile = new BookFile { Quality = new QualityModel(Quality.FLAC, new Revision(version: 2)), DateAdded = DateTime.Now };
|
||||
|
||||
var singleAlbumList = new List<Book> { new Book { BookFiles = new List<BookFile>() } };
|
||||
var doubleAlbumList = new List<Book> { new Book { BookFiles = new List<BookFile>() }, new Book { BookFiles = new List<BookFile>() }, new Book { BookFiles = new List<BookFile>() } };
|
||||
var singleBookList = new List<Book> { new Book { BookFiles = new List<BookFile>() } };
|
||||
var doubleBookList = new List<Book> { new Book { BookFiles = new List<BookFile>() }, new Book { BookFiles = new List<BookFile>() }, new Book { BookFiles = new List<BookFile>() } };
|
||||
|
||||
var fakeArtist = Builder<Author>.CreateNew()
|
||||
var fakeAuthor = Builder<Author>.CreateNew()
|
||||
.With(c => c.QualityProfile = new QualityProfile
|
||||
{
|
||||
UpgradeAllowed = true,
|
||||
@@ -50,16 +50,16 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
|
||||
_parseResultMulti = new RemoteBook
|
||||
{
|
||||
Author = fakeArtist,
|
||||
Author = fakeAuthor,
|
||||
ParsedBookInfo = new ParsedBookInfo { Quality = new QualityModel(Quality.MP3_320, new Revision(version: 2)) },
|
||||
Books = doubleAlbumList
|
||||
Books = doubleBookList
|
||||
};
|
||||
|
||||
_parseResultSingle = new RemoteBook
|
||||
{
|
||||
Author = fakeArtist,
|
||||
Author = fakeAuthor,
|
||||
ParsedBookInfo = new ParsedBookInfo { Quality = new QualityModel(Quality.MP3_320, new Revision(version: 2)) },
|
||||
Books = singleAlbumList
|
||||
Books = singleBookList
|
||||
};
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_album_has_no_existing_file()
|
||||
public void should_return_true_if_book_has_no_existing_file()
|
||||
{
|
||||
_parseResultSingle.Books.First().BookFiles = new List<BookFile>();
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_single_album_doesnt_exist_on_disk()
|
||||
public void should_return_true_if_single_book_doesnt_exist_on_disk()
|
||||
{
|
||||
_parseResultSingle.Books = new List<Book>();
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
|
||||
Subject.IsUpgradable(
|
||||
profile,
|
||||
new List<QualityModel> { new QualityModel(current, new Revision(version: currentVersion)) },
|
||||
new QualityModel(current, new Revision(version: currentVersion)),
|
||||
NoPreferredWordScore,
|
||||
new QualityModel(newQuality, new Revision(version: newVersion)),
|
||||
NoPreferredWordScore)
|
||||
@@ -65,7 +65,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
|
||||
Subject.IsUpgradable(
|
||||
profile,
|
||||
new List<QualityModel> { new QualityModel(Quality.MP3_320, new Revision(version: 1)) },
|
||||
new QualityModel(Quality.MP3_320, new Revision(version: 1)),
|
||||
NoPreferredWordScore,
|
||||
new QualityModel(Quality.MP3_320, new Revision(version: 2)),
|
||||
NoPreferredWordScore)
|
||||
@@ -84,7 +84,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
|
||||
Subject.IsUpgradable(
|
||||
profile,
|
||||
new List<QualityModel> { new QualityModel(Quality.MP3_320, new Revision(version: 1)) },
|
||||
new QualityModel(Quality.MP3_320, new Revision(version: 1)),
|
||||
NoPreferredWordScore,
|
||||
new QualityModel(Quality.MP3_320, new Revision(version: 2)),
|
||||
NoPreferredWordScore)
|
||||
|
||||
Reference in New Issue
Block a user