1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2025-01-03 05:25:10 +00:00

Use All() for import lists in ImportListSyncService

This commit is contained in:
Bogdan 2023-08-19 12:45:56 +03:00
parent f9b8d7720c
commit 78610ff6ee
2 changed files with 6 additions and 9 deletions

View file

@ -28,10 +28,6 @@ public void SetUp()
_importListReports = new List<ImportListItemInfo> { importListItem1 }; _importListReports = new List<ImportListItemInfo> { importListItem1 };
Mocker.GetMock<IFetchAndParseImportList>()
.Setup(v => v.Fetch())
.Returns(_importListReports);
Mocker.GetMock<ISearchForNewArtist>() Mocker.GetMock<ISearchForNewArtist>()
.Setup(v => v.SearchForNewArtist(It.IsAny<string>())) .Setup(v => v.SearchForNewArtist(It.IsAny<string>()))
.Returns(new List<Artist>()); .Returns(new List<Artist>());
@ -41,8 +37,8 @@ public void SetUp()
.Returns(new List<Album>()); .Returns(new List<Album>());
Mocker.GetMock<IImportListFactory>() Mocker.GetMock<IImportListFactory>()
.Setup(v => v.Get(It.IsAny<int>())) .Setup(v => v.All())
.Returns(new ImportListDefinition { ShouldMonitor = ImportListMonitorType.SpecificAlbum }); .Returns(new List<ImportListDefinition> { new () { ShouldMonitor = ImportListMonitorType.SpecificAlbum } });
Mocker.GetMock<IFetchAndParseImportList>() Mocker.GetMock<IFetchAndParseImportList>()
.Setup(v => v.Fetch()) .Setup(v => v.Fetch())
@ -145,8 +141,8 @@ private void WithExcludedAlbum()
private void WithListSettings(ImportListMonitorType monitor = ImportListMonitorType.EntireArtist, bool shouldMonitorExisting = false, bool shouldSearch = true) private void WithListSettings(ImportListMonitorType monitor = ImportListMonitorType.EntireArtist, bool shouldMonitorExisting = false, bool shouldSearch = true)
{ {
Mocker.GetMock<IImportListFactory>() Mocker.GetMock<IImportListFactory>()
.Setup(v => v.Get(It.IsAny<int>())) .Setup(v => v.All())
.Returns(new ImportListDefinition { ShouldMonitor = monitor, ShouldMonitorExisting = shouldMonitorExisting, ShouldSearch = shouldSearch }); .Returns(new List<ImportListDefinition> { new () { ShouldMonitor = monitor, ShouldMonitorExisting = shouldMonitorExisting, ShouldSearch = shouldSearch } });
} }
[Test] [Test]

View file

@ -100,12 +100,13 @@ private List<Album> ProcessListItems(List<ImportListItemInfo> items)
var reportNumber = 1; var reportNumber = 1;
var listExclusions = _importListExclusionService.All().ToDictionary(x => x.ForeignId); var listExclusions = _importListExclusionService.All().ToDictionary(x => x.ForeignId);
var importLists = _importListFactory.All();
foreach (var item in items) foreach (var item in items)
{ {
_logger.ProgressTrace("Processing list item {0}/{1}", reportNumber++, items.Count); _logger.ProgressTrace("Processing list item {0}/{1}", reportNumber++, items.Count);
var importList = _importListFactory.Get(item.ImportListId); var importList = importLists.Single(x => x.Id == item.ImportListId);
if (item.Album.IsNotNullOrWhiteSpace() || item.AlbumMusicBrainzId.IsNotNullOrWhiteSpace()) if (item.Album.IsNotNullOrWhiteSpace() || item.AlbumMusicBrainzId.IsNotNullOrWhiteSpace())
{ {