From b271b3b694081a2889d75d39dc0296d53c734aaf 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 --- .../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 da938b34e..870dd66fc 100644 --- a/src/NzbDrone.Core.Test/ImportListTests/ImportListSyncServiceFixture.cs +++ b/src/NzbDrone.Core.Test/ImportListTests/ImportListSyncServiceFixture.cs @@ -25,6 +25,8 @@ namespace NzbDrone.Core.Test.ImportListTests _importListReports = new List { importListItem1 }; + var mockImportList = new Mock(); + Mocker.GetMock() .Setup(v => v.AllSeriesTvdbIds()) .Returns(new List()); @@ -41,6 +43,10 @@ namespace NzbDrone.Core.Test.ImportListTests .Setup(v => v.All()) .Returns(new List { new ImportListDefinition { ShouldMonitor = MonitorTypes.All } }); + Mocker.GetMock() + .Setup(v => v.AutomaticAddEnabled(It.IsAny())) + .Returns(new List { mockImportList.Object }); + Mocker.GetMock() .Setup(v => v.Fetch()) .Returns(_importListReports); @@ -152,5 +158,31 @@ namespace NzbDrone.Core.Test.ImportListTests Mocker.GetMock() .Verify(v => v.AddSeries(It.Is>(t => t.Count == 0), It.IsAny())); } + + [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); + } } }