1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2024-12-21 23:32:27 +00:00

Fix tests for ImportListSyncService

(cherry picked from commit b271b3b694081a2889d75d39dc0296d53c734aaf)
This commit is contained in:
Mark McDowall 2023-08-19 10:52:39 -07:00 committed by Bogdan
parent 78610ff6ee
commit 85e62caccf

View file

@ -28,6 +28,8 @@ public void SetUp()
_importListReports = new List<ImportListItemInfo> { importListItem1 };
var mockImportList = new Mock<IImportList>();
Mocker.GetMock<ISearchForNewArtist>()
.Setup(v => v.SearchForNewArtist(It.IsAny<string>()))
.Returns(new List<Artist>());
@ -40,6 +42,10 @@ public void SetUp()
.Setup(v => v.All())
.Returns(new List<ImportListDefinition> { new () { ShouldMonitor = ImportListMonitorType.SpecificAlbum } });
Mocker.GetMock<IImportListFactory>()
.Setup(v => v.AutomaticAddEnabled(It.IsAny<bool>()))
.Returns(new List<IImportList> { mockImportList.Object });
Mocker.GetMock<IFetchAndParseImportList>()
.Setup(v => v.Fetch())
.Returns(_importListReports);
@ -516,5 +522,31 @@ public void should_not_search_unmonitored_artist()
Mocker.GetMock<IManageCommandQueue>()
.Verify(v => v.Push<Command>(It.IsAny<MissingAlbumSearchCommand>(), CommandPriority.Normal, CommandTrigger.Unspecified), Times.Never);
}
[Test]
public void should_not_fetch_if_no_lists_are_enabled()
{
Mocker.GetMock<IImportListFactory>()
.Setup(v => v.AutomaticAddEnabled(It.IsAny<bool>()))
.Returns(new List<IImportList>());
Subject.Execute(new ImportListSyncCommand());
Mocker.GetMock<IFetchAndParseImportList>()
.Verify(v => v.Fetch(), Times.Never);
}
[Test]
public void should_not_process_if_no_items_are_returned()
{
Mocker.GetMock<IFetchAndParseImportList>()
.Setup(v => v.Fetch())
.Returns(new List<ImportListItemInfo>());
Subject.Execute(new ImportListSyncCommand());
Mocker.GetMock<IImportListExclusionService>()
.Verify(v => v.All(), Times.Never);
}
}
}