mirror of
https://github.com/Readarr/Readarr
synced 2025-12-28 03:09:38 +01:00
Fix tests for ImportListSyncService
(cherry picked from commit b271b3b694081a2889d75d39dc0296d53c734aaf) Closes #2843
This commit is contained in:
parent
0d1ae0ca4e
commit
43dfdc8bf5
1 changed files with 32 additions and 0 deletions
|
|
@ -27,6 +27,8 @@ public void SetUp()
|
|||
|
||||
_importListReports = new List<ImportListItemInfo> { importListItem1 };
|
||||
|
||||
var mockImportList = new Mock<IImportList>();
|
||||
|
||||
Mocker.GetMock<IFetchAndParseImportList>()
|
||||
.Setup(v => v.Fetch())
|
||||
.Returns(_importListReports);
|
||||
|
|
@ -53,6 +55,10 @@ public void SetUp()
|
|||
.Setup(v => v.Get(It.IsAny<int>()))
|
||||
.Returns(new ImportListDefinition { ShouldMonitor = ImportListMonitorType.SpecificBook });
|
||||
|
||||
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);
|
||||
|
|
@ -322,5 +328,31 @@ public void should_add_two_books(ImportListMonitorType monitor, int expectedBook
|
|||
t.First().AddOptions.BooksToMonitor.Count == expectedBooksMonitored &&
|
||||
t.First().Monitored == expectedAuthorMonitored), false));
|
||||
}
|
||||
|
||||
[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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue