From 85e62caccfd6df7331f0551efce6a99e9b355b89 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sat, 19 Aug 2023 10:52:39 -0700 Subject: [PATCH] Fix tests for ImportListSyncService (cherry picked from commit b271b3b694081a2889d75d39dc0296d53c734aaf) --- .../ImportListSyncServiceFixture.cs | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/NzbDrone.Core.Test/ImportListTests/ImportListSyncServiceFixture.cs b/src/NzbDrone.Core.Test/ImportListTests/ImportListSyncServiceFixture.cs index a6b22092e..aa6eef7ff 100644 --- a/src/NzbDrone.Core.Test/ImportListTests/ImportListSyncServiceFixture.cs +++ b/src/NzbDrone.Core.Test/ImportListTests/ImportListSyncServiceFixture.cs @@ -28,6 +28,8 @@ namespace NzbDrone.Core.Test.ImportListTests _importListReports = new List { importListItem1 }; + var mockImportList = new Mock(); + Mocker.GetMock() .Setup(v => v.SearchForNewArtist(It.IsAny())) .Returns(new List()); @@ -40,6 +42,10 @@ namespace NzbDrone.Core.Test.ImportListTests .Setup(v => v.All()) .Returns(new List { new () { ShouldMonitor = ImportListMonitorType.SpecificAlbum } }); + Mocker.GetMock() + .Setup(v => v.AutomaticAddEnabled(It.IsAny())) + .Returns(new List { mockImportList.Object }); + Mocker.GetMock() .Setup(v => v.Fetch()) .Returns(_importListReports); @@ -516,5 +522,31 @@ namespace NzbDrone.Core.Test.ImportListTests Mocker.GetMock() .Verify(v => v.Push(It.IsAny(), CommandPriority.Normal, CommandTrigger.Unspecified), Times.Never); } + + [Test] + public void should_not_fetch_if_no_lists_are_enabled() + { + Mocker.GetMock() + .Setup(v => v.AutomaticAddEnabled(It.IsAny())) + .Returns(new List()); + + Subject.Execute(new ImportListSyncCommand()); + + Mocker.GetMock() + .Verify(v => v.Fetch(), Times.Never); + } + + [Test] + public void should_not_process_if_no_items_are_returned() + { + Mocker.GetMock() + .Setup(v => v.Fetch()) + .Returns(new List()); + + Subject.Execute(new ImportListSyncCommand()); + + Mocker.GetMock() + .Verify(v => v.All(), Times.Never); + } } }