Merge remote-tracking branch 'origin/dynamic-jobs'
This commit is contained in:
@@ -161,7 +161,7 @@ namespace NzbDrone.Core.Test.JobTests
|
||||
|
||||
private void StartUpdate()
|
||||
{
|
||||
Mocker.Resolve<AppUpdateJob>().Start(MockNotification, 0, 0);
|
||||
Mocker.Resolve<AppUpdateJob>().Start(MockNotification, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test.JobTests
|
||||
@@ -39,13 +40,13 @@ namespace NzbDrone.Core.Test.JobTests
|
||||
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<BacklogSearchJob>().Start(notification, 0, 0);
|
||||
Mocker.Resolve<BacklogSearchJob>().Start(notification, null);
|
||||
|
||||
//Assert
|
||||
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, It.IsAny<int>(), It.IsAny<int>()),
|
||||
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, new { SeriesId = It.IsAny<int>(), SeasonNumber = It.IsAny<int>() }),
|
||||
Times.Never());
|
||||
|
||||
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, It.IsAny<int>(), 0),
|
||||
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, new { SeriesId = It.IsAny<int>(), SeasonNumber = 0 }),
|
||||
Times.Never());
|
||||
}
|
||||
|
||||
@@ -65,23 +66,19 @@ namespace NzbDrone.Core.Test.JobTests
|
||||
.With(e => e.Series = series)
|
||||
.Build();
|
||||
|
||||
WithStrictMocker();
|
||||
WithEnableBacklogSearching();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
||||
|
||||
Mocker.GetMock<EpisodeSearchJob>()
|
||||
.Setup(s => s.Start(notification, It.IsAny<int>(), 0)).Verifiable();
|
||||
.Setup(s => s.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("EpisodeId") == 1)));
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<BacklogSearchJob>().Start(notification, 0, 0);
|
||||
Mocker.Resolve<BacklogSearchJob>().Start(notification, null);
|
||||
|
||||
//Assert
|
||||
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, It.IsAny<int>(), It.IsAny<int>()),
|
||||
Times.Never());
|
||||
|
||||
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, It.IsAny<int>(), 0),
|
||||
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("EpisodeId") >= 0)),
|
||||
Times.Once());
|
||||
}
|
||||
|
||||
@@ -101,23 +98,16 @@ namespace NzbDrone.Core.Test.JobTests
|
||||
.With(e => e.Series = series)
|
||||
.Build();
|
||||
|
||||
WithStrictMocker();
|
||||
WithEnableBacklogSearching();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
||||
|
||||
Mocker.GetMock<EpisodeSearchJob>()
|
||||
.Setup(s => s.Start(notification, It.IsAny<int>(), 0)).Verifiable();
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<BacklogSearchJob>().Start(notification, 0, 0);
|
||||
Mocker.Resolve<BacklogSearchJob>().Start(notification, null);
|
||||
|
||||
//Assert
|
||||
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, It.IsAny<int>(), It.IsAny<int>()),
|
||||
Times.Never());
|
||||
|
||||
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, It.IsAny<int>(), 0),
|
||||
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("EpisodeId") >= 0)),
|
||||
Times.Exactly(episodes.Count));
|
||||
}
|
||||
|
||||
@@ -138,27 +128,20 @@ namespace NzbDrone.Core.Test.JobTests
|
||||
.With(e => e.SeasonNumber = 1)
|
||||
.Build();
|
||||
|
||||
WithStrictMocker();
|
||||
WithEnableBacklogSearching();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
||||
|
||||
Mocker.GetMock<EpisodeSearchJob>()
|
||||
.Setup(s => s.Start(notification, It.IsAny<int>(), 0)).Verifiable();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
.Setup(s => s.GetEpisodeNumbersBySeason(1, 1)).Returns(new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<BacklogSearchJob>().Start(notification, 0, 0);
|
||||
Mocker.Resolve<BacklogSearchJob>().Start(notification, null);
|
||||
|
||||
//Assert
|
||||
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, It.IsAny<int>(), It.IsAny<int>()),
|
||||
Times.Never());
|
||||
|
||||
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, It.IsAny<int>(), 0),
|
||||
Times.Exactly(episodes.Count));
|
||||
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("EpisodeId") >= 0)),
|
||||
Times.Exactly(episodes.Count));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -179,27 +162,21 @@ namespace NzbDrone.Core.Test.JobTests
|
||||
.With(e => e.SeasonNumber = 1)
|
||||
.Build();
|
||||
|
||||
WithStrictMocker();
|
||||
WithEnableBacklogSearching();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
||||
|
||||
Mocker.GetMock<SeasonSearchJob>()
|
||||
.Setup(s => s.Start(notification, It.IsAny<int>(), It.IsAny<int>())).Verifiable();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
.Setup(s => s.GetEpisodeNumbersBySeason(1, 1)).Returns(episodes.Select(e => e.EpisodeNumber).ToList());
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<BacklogSearchJob>().Start(notification, 0, 0);
|
||||
Mocker.Resolve<BacklogSearchJob>().Start(notification, null);
|
||||
|
||||
//Assert
|
||||
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, It.IsAny<int>(), It.IsAny<int>()),
|
||||
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") >= 0 &&
|
||||
d.GetPropertyValue<int>("SeasonNumber") >= 0)),
|
||||
Times.Once());
|
||||
|
||||
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, It.IsAny<int>(), 0),
|
||||
Times.Never());
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -227,30 +204,24 @@ namespace NzbDrone.Core.Test.JobTests
|
||||
.With(e => e.Series = series2)
|
||||
.Build();
|
||||
|
||||
WithStrictMocker();
|
||||
WithEnableBacklogSearching();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
||||
|
||||
Mocker.GetMock<SeasonSearchJob>()
|
||||
.Setup(s => s.Start(notification, It.IsAny<int>(), It.IsAny<int>())).Verifiable();
|
||||
|
||||
Mocker.GetMock<EpisodeSearchJob>()
|
||||
.Setup(s => s.Start(notification, It.IsAny<int>(), 0)).Verifiable();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
.Setup(s => s.GetEpisodeNumbersBySeason(1, 1)).Returns(new List<int> { 1, 2, 3, 4, 5 });
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<BacklogSearchJob>().Start(notification, 0, 0);
|
||||
Mocker.Resolve<BacklogSearchJob>().Start(notification, null);
|
||||
|
||||
//Assert
|
||||
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, It.IsAny<int>(), It.IsAny<int>()),
|
||||
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") >= 0 &&
|
||||
d.GetPropertyValue<int>("SeasonNumber") >= 0)),
|
||||
Times.Once());
|
||||
|
||||
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, It.IsAny<int>(), 0),
|
||||
Times.Exactly(5));
|
||||
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("EpisodeId") >= 0)),
|
||||
Times.Exactly(5));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace NzbDrone.Core.Test.JobTests
|
||||
Mocker.GetMock<SeriesProvider>().Setup(s => s.GetAllSeries())
|
||||
.Returns(series);
|
||||
|
||||
Mocker.Resolve<BannerDownloadJob>().Start(_notification, 0, 0);
|
||||
Mocker.Resolve<BannerDownloadJob>().Start(_notification, null);
|
||||
VerifyDownloadMock(series.Count);
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace NzbDrone.Core.Test.JobTests
|
||||
Mocker.GetMock<SeriesProvider>().Setup(s => s.GetAllSeries())
|
||||
.Returns(series);
|
||||
|
||||
Mocker.Resolve<BannerDownloadJob>().Start(_notification, 0, 0);
|
||||
Mocker.Resolve<BannerDownloadJob>().Start(_notification, null);
|
||||
VerifyDownloadMock(3);
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace NzbDrone.Core.Test.JobTests
|
||||
Mocker.GetMock<SeriesProvider>().Setup(s => s.GetSeries(series.SeriesId))
|
||||
.Returns(series);
|
||||
|
||||
Mocker.Resolve<BannerDownloadJob>().Start(_notification, 1, 0);
|
||||
Mocker.Resolve<BannerDownloadJob>().Start(_notification, new { SeriesId = series.SeriesId });
|
||||
VerifyDownloadMock(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace NzbDrone.Core.Test.JobTests
|
||||
.Returns(new List<EpisodeFile>());
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<DiskScanJob>().Start(new ProgressNotification("Test"), series.SeriesId, 0);
|
||||
Mocker.Resolve<DiskScanJob>().Start(new ProgressNotification("Test"), new { SeriesId = series.SeriesId });
|
||||
|
||||
//Assert
|
||||
Mocker.VerifyAllMocks();
|
||||
@@ -68,7 +68,7 @@ namespace NzbDrone.Core.Test.JobTests
|
||||
.Setup(s => s.Scan(series[1]))
|
||||
.Returns(new List<EpisodeFile>());
|
||||
|
||||
Mocker.Resolve<DiskScanJob>().Start(new ProgressNotification("Test"), 0, 0);
|
||||
Mocker.Resolve<DiskScanJob>().Start(new ProgressNotification("Test"), null);
|
||||
|
||||
|
||||
Mocker.VerifyAllMocks();
|
||||
@@ -96,7 +96,7 @@ namespace NzbDrone.Core.Test.JobTests
|
||||
.Setup(s => s.Scan(series[1]))
|
||||
.Throws(new InvalidOperationException("Bad Job"));
|
||||
|
||||
Mocker.Resolve<DiskScanJob>().Start(new ProgressNotification("Test"), 0, 0);
|
||||
Mocker.Resolve<DiskScanJob>().Start(new ProgressNotification("Test"), null);
|
||||
|
||||
|
||||
Mocker.VerifyAllMocks();
|
||||
@@ -126,7 +126,7 @@ namespace NzbDrone.Core.Test.JobTests
|
||||
.Returns(new List<EpisodeFile>());
|
||||
|
||||
|
||||
Mocker.Resolve<DiskScanJob>().Start(new ProgressNotification("Test"), 0, 0);
|
||||
Mocker.Resolve<DiskScanJob>().Start(new ProgressNotification("Test"), null);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace NzbDrone.Core.Test.JobTests
|
||||
public class ImportNewSeriesJobTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void import_new_series_succesfull()
|
||||
public void import_new_series_succesful()
|
||||
{
|
||||
var series = Builder<Series>.CreateListOfSize(2)
|
||||
.All().With(s => s.LastInfoSync = null)
|
||||
@@ -39,23 +39,23 @@ namespace NzbDrone.Core.Test.JobTests
|
||||
|
||||
|
||||
Mocker.GetMock<DiskScanJob>()
|
||||
.Setup(j => j.Start(notification, series[0].SeriesId, 0))
|
||||
.Setup(j => j.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") == series[0].SeriesId)))
|
||||
.Callback(() => series[0].LastDiskSync = DateTime.Now);
|
||||
|
||||
|
||||
Mocker.GetMock<DiskScanJob>()
|
||||
.Setup(j => j.Start(notification, series[1].SeriesId, 0))
|
||||
.Setup(j => j.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") == series[1].SeriesId)))
|
||||
.Callback(() => series[1].LastDiskSync = DateTime.Now);
|
||||
|
||||
Mocker.GetMock<BannerDownloadJob>()
|
||||
.Setup(j => j.Start(notification, It.IsAny<int>(), 0));
|
||||
.Setup(j => j.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") >= 0)));
|
||||
|
||||
Mocker.GetMock<UpdateInfoJob>()
|
||||
.Setup(j => j.Start(notification, series[0].SeriesId, 0))
|
||||
.Setup(j => j.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") == series[0].SeriesId)))
|
||||
.Callback(() => series[0].LastInfoSync = DateTime.Now);
|
||||
|
||||
Mocker.GetMock<UpdateInfoJob>()
|
||||
.Setup(j => j.Start(notification, series[1].SeriesId, 0))
|
||||
.Setup(j => j.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") == series[1].SeriesId)))
|
||||
.Callback(() => series[1].LastInfoSync = DateTime.Now);
|
||||
|
||||
Mocker.GetMock<SeriesProvider>()
|
||||
@@ -68,16 +68,14 @@ namespace NzbDrone.Core.Test.JobTests
|
||||
.Setup(s => s.GetSeriesFiles(It.IsAny<int>())).Returns(new List<EpisodeFile>());
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<ImportNewSeriesJob>().Start(notification, 0, 0);
|
||||
Mocker.Resolve<ImportNewSeriesJob>().Start(notification, null);
|
||||
|
||||
//Assert
|
||||
Mocker.VerifyAllMocks();
|
||||
Mocker.GetMock<DiskScanJob>().Verify(j => j.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") == series[0].SeriesId)), Times.Once());
|
||||
Mocker.GetMock<DiskScanJob>().Verify(j => j.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") == series[1].SeriesId)), Times.Once());
|
||||
|
||||
Mocker.GetMock<DiskScanJob>().Verify(j => j.Start(notification, series[0].SeriesId, 0), Times.Once());
|
||||
Mocker.GetMock<DiskScanJob>().Verify(j => j.Start(notification, series[1].SeriesId, 0), Times.Once());
|
||||
|
||||
Mocker.GetMock<UpdateInfoJob>().Verify(j => j.Start(notification, series[0].SeriesId, 0), Times.Once());
|
||||
Mocker.GetMock<UpdateInfoJob>().Verify(j => j.Start(notification, series[1].SeriesId, 0), Times.Once());
|
||||
Mocker.GetMock<UpdateInfoJob>().Verify(j => j.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") == series[0].SeriesId)), Times.Once());
|
||||
Mocker.GetMock<UpdateInfoJob>().Verify(j => j.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") == series[1].SeriesId)), Times.Once());
|
||||
|
||||
}
|
||||
|
||||
@@ -103,19 +101,19 @@ namespace NzbDrone.Core.Test.JobTests
|
||||
.Returns(series);
|
||||
|
||||
Mocker.GetMock<UpdateInfoJob>()
|
||||
.Setup(j => j.Start(notification, series[0].SeriesId, 0))
|
||||
.Setup(j => j.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") == series[0].SeriesId)))
|
||||
.Callback(() => series[0].LastInfoSync = DateTime.Now);
|
||||
|
||||
Mocker.GetMock<UpdateInfoJob>()
|
||||
.Setup(j => j.Start(notification, series[1].SeriesId, 0))
|
||||
.Setup(j => j.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") == series[1].SeriesId)))
|
||||
.Throws(new InvalidOperationException());
|
||||
|
||||
Mocker.GetMock<DiskScanJob>()
|
||||
.Setup(j => j.Start(notification, series[0].SeriesId, 0))
|
||||
.Setup(j => j.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") == series[0].SeriesId)))
|
||||
.Callback(() => series[0].LastDiskSync = DateTime.Now);
|
||||
|
||||
Mocker.GetMock<BannerDownloadJob>()
|
||||
.Setup(j => j.Start(notification, series[0].SeriesId, 0));
|
||||
.Setup(j => j.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") == series[0].SeriesId)));
|
||||
|
||||
Mocker.GetMock<SeriesProvider>()
|
||||
.Setup(s => s.GetSeries(series[0].SeriesId)).Returns(series[0]);
|
||||
@@ -124,15 +122,13 @@ namespace NzbDrone.Core.Test.JobTests
|
||||
.Setup(s => s.GetSeriesFiles(It.IsAny<int>())).Returns(new List<EpisodeFile>());
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<ImportNewSeriesJob>().Start(notification, 0, 0);
|
||||
Mocker.Resolve<ImportNewSeriesJob>().Start(notification, null);
|
||||
|
||||
//Assert
|
||||
Mocker.VerifyAllMocks();
|
||||
Mocker.GetMock<UpdateInfoJob>().Verify(j => j.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") == series[0].SeriesId)), Times.Once());
|
||||
Mocker.GetMock<UpdateInfoJob>().Verify(j => j.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") == series[1].SeriesId)), Times.Once());
|
||||
|
||||
Mocker.GetMock<UpdateInfoJob>().Verify(j => j.Start(notification, series[0].SeriesId, 0), Times.Once());
|
||||
Mocker.GetMock<UpdateInfoJob>().Verify(j => j.Start(notification, series[1].SeriesId, 0), Times.Once());
|
||||
|
||||
Mocker.GetMock<DiskScanJob>().Verify(j => j.Start(notification, series[0].SeriesId, 0), Times.Once());
|
||||
Mocker.GetMock<DiskScanJob>().Verify(j => j.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") == series[0].SeriesId)), Times.Once());
|
||||
|
||||
ExceptionVerification.ExpectedErrors(1);
|
||||
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Jobs;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.JobTests
|
||||
{
|
||||
[TestFixture]
|
||||
internal class PostDownloadScanJobFixture : CoreTest
|
||||
{
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
Mocker.GetMock<DiskProvider>().Setup(s => s.FolderExists(It.IsAny<string>())).Returns(true);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_use_options_Path_when_provided()
|
||||
{
|
||||
var path = @"C:\Test\Unsorted TV";
|
||||
|
||||
Mocker.GetMock<PostDownloadProvider>().Setup(s => s.ProcessDropFolder(path));
|
||||
Mocker.Resolve<PostDownloadScanJob>().Start(MockNotification, new { Path = path });
|
||||
|
||||
Mocker.GetMock<PostDownloadProvider>().Verify(s => s.ProcessDropFolder(path), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_get_sabDropDir_when_path_is_supplied()
|
||||
{
|
||||
var path = @"C:\Test\Unsorted TV";
|
||||
|
||||
Mocker.GetMock<PostDownloadProvider>().Setup(s => s.ProcessDropFolder(path));
|
||||
Mocker.Resolve<PostDownloadScanJob>().Start(MockNotification, new { Path = path });
|
||||
|
||||
Mocker.GetMock<ConfigProvider>().Verify(s => s.SabDropDirectory, Times.Never());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_get_sabDropDir_when_path_is_not_supplied()
|
||||
{
|
||||
var path = @"C:\Test\Unsorted TV";
|
||||
|
||||
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.SabDropDirectory).Returns(path);
|
||||
Mocker.Resolve<PostDownloadScanJob>().Start(MockNotification, null);
|
||||
|
||||
Mocker.GetMock<ConfigProvider>().Verify(s => s.SabDropDirectory, Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_use_sabDropDir_when_options_Path_is_not_provided()
|
||||
{
|
||||
var path = @"C:\Test\Unsorted TV";
|
||||
|
||||
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.SabDropDirectory).Returns(path);
|
||||
Mocker.Resolve<PostDownloadScanJob>().Start(MockNotification, null);
|
||||
|
||||
Mocker.GetMock<PostDownloadProvider>().Verify(s => s.ProcessDropFolder(path), Times.Once());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test.JobTests
|
||||
@@ -41,10 +42,10 @@ namespace NzbDrone.Core.Test.JobTests
|
||||
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<RecentBacklogSearchJob>().Start(MockNotification, 0, 0);
|
||||
Mocker.Resolve<RecentBacklogSearchJob>().Start(MockNotification, null);
|
||||
|
||||
//Assert
|
||||
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(MockNotification, It.IsAny<int>(), 0),
|
||||
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(MockNotification, new { EpisodeId = It.IsAny<int>() }),
|
||||
Times.Never());
|
||||
}
|
||||
|
||||
@@ -87,13 +88,13 @@ namespace NzbDrone.Core.Test.JobTests
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
||||
|
||||
Mocker.GetMock<EpisodeSearchJob>().Setup(c => c.Start(It.IsAny<ProgressNotification>(), It.IsAny<int>(), 0));
|
||||
Mocker.GetMock<EpisodeSearchJob>().Setup(c => c.Start(It.IsAny<ProgressNotification>(), It.Is<object>(d => d.GetPropertyValue<int>("EpisodeId") >= 0)));
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<RecentBacklogSearchJob>().Start(MockNotification, 0, 0);
|
||||
Mocker.Resolve<RecentBacklogSearchJob>().Start(MockNotification, null);
|
||||
|
||||
//Assert
|
||||
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(It.IsAny<ProgressNotification>(), It.IsAny<int>(), 0),
|
||||
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(It.IsAny<ProgressNotification>(), It.Is<object>(d => d.GetPropertyValue<int>("EpisodeId") >= 0)),
|
||||
Times.Exactly(40));
|
||||
}
|
||||
|
||||
|
||||
@@ -15,21 +15,20 @@ namespace NzbDrone.Core.Test.JobTests
|
||||
[TestCase(0)]
|
||||
[TestCase(-1)]
|
||||
[TestCase(-100)]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentException))]
|
||||
public void start_target_id_less_than_0_throws_exception(int target)
|
||||
{
|
||||
WithStrictMocker();
|
||||
Mocker.Resolve<EpisodeSearchJob>().Start(new ProgressNotification("Test"), target, 0);
|
||||
Mocker.Resolve<EpisodeSearchJob>().Start(new ProgressNotification("Test"), new { EpisodeId = target });
|
||||
}
|
||||
|
||||
[TestCase(0)]
|
||||
[TestCase(-1)]
|
||||
[TestCase(-100)]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentException))]
|
||||
public void start_secondary_target_id_less_than_0_throws_exception(int target)
|
||||
{
|
||||
WithStrictMocker();
|
||||
Mocker.Resolve<SeasonSearchJob>().Start(new ProgressNotification("Test"), 0, target);
|
||||
Mocker.Resolve<SeasonSearchJob>().Start(new ProgressNotification("Test"), new { SeriesId = 1, SeasonNumber = target });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,12 +51,12 @@ namespace NzbDrone.Core.Test.JobTests
|
||||
.Returns(episodes.Select(e => e.EpisodeNumber).ToList());
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<SeasonSearchJob>().Start(notification, 1, 1);
|
||||
Mocker.Resolve<SeasonSearchJob>().Start(notification, new { SeriesId = 1, SeasonNumber = 1 });
|
||||
|
||||
//Assert
|
||||
Mocker.VerifyAllMocks();
|
||||
Mocker.GetMock<SearchProvider>().Verify(c => c.PartialSeasonSearch(notification, 1, 1), Times.Once());
|
||||
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, It.IsAny<int>(), 0), Times.Never());
|
||||
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, new { EpisodeId = It.IsAny<int>() }), Times.Never());
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -75,7 +75,7 @@ namespace NzbDrone.Core.Test.JobTests
|
||||
.Returns(new List<int>());
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<SeasonSearchJob>().Start(notification, 1, 1);
|
||||
Mocker.Resolve<SeasonSearchJob>().Start(notification, new { SeriesId = 1, SeasonNumber = 1 });
|
||||
|
||||
//Assert
|
||||
Mocker.VerifyAllMocks();
|
||||
@@ -104,7 +104,7 @@ namespace NzbDrone.Core.Test.JobTests
|
||||
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<SeasonSearchJob>().Start(notification, 1, 1);
|
||||
Mocker.Resolve<SeasonSearchJob>().Start(notification, new { SeriesId = 1, SeasonNumber = 1 });
|
||||
|
||||
//Assert
|
||||
Mocker.VerifyAllMocks();
|
||||
@@ -118,11 +118,11 @@ namespace NzbDrone.Core.Test.JobTests
|
||||
.Setup(c => c.PartialSeasonSearch(notification, 1, 0)).Returns(new List<int>());
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<SeasonSearchJob>().Start(notification, 1, 0);
|
||||
Mocker.Resolve<SeasonSearchJob>().Start(notification, new { SeriesId = 1, SeasonNumber = 0 });
|
||||
|
||||
//Assert
|
||||
Mocker.GetMock<SearchProvider>().Verify(c => c.PartialSeasonSearch(notification, 1, 1), Times.Never());
|
||||
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, It.IsAny<int>(), 0), Times.Never());
|
||||
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, new { EpisodeId = It.IsAny<int>() }), Times.Never());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ using NzbDrone.Core.Jobs;
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test.JobTests
|
||||
@@ -30,14 +31,14 @@ namespace NzbDrone.Core.Test.JobTests
|
||||
.Setup(c => c.IsIgnored(It.IsAny<int>(), It.IsAny<int>())).Returns(false);
|
||||
|
||||
Mocker.GetMock<SeasonSearchJob>()
|
||||
.Setup(c => c.Start(notification, 1, It.IsAny<int>())).Verifiable();
|
||||
.Setup(c => c.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") == 1 && d.GetPropertyValue<int>("SeasonNumber") >= 0))).Verifiable();
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<SeriesSearchJob>().Start(notification, 1, 0);
|
||||
Mocker.Resolve<SeriesSearchJob>().Start(notification, new { SeriesId = 1 });
|
||||
|
||||
//Assert
|
||||
Mocker.VerifyAllMocks();
|
||||
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, 1, It.IsAny<int>()),
|
||||
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") == 1 && d.GetPropertyValue<int>("SeasonNumber") >= 0)),
|
||||
Times.Exactly(seasons.Count));
|
||||
}
|
||||
|
||||
@@ -54,11 +55,11 @@ namespace NzbDrone.Core.Test.JobTests
|
||||
.Setup(c => c.GetSeasons(1)).Returns(seasons);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<SeriesSearchJob>().Start(notification, 1, 0);
|
||||
Mocker.Resolve<SeriesSearchJob>().Start(notification, new { SeriesId = 1 });
|
||||
|
||||
//Assert
|
||||
Mocker.VerifyAllMocks();
|
||||
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, 1, It.IsAny<int>()),
|
||||
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, new { SeriesId = 1, SeasonNumber = It.IsAny<int>() }),
|
||||
Times.Never());
|
||||
}
|
||||
|
||||
@@ -69,11 +70,11 @@ namespace NzbDrone.Core.Test.JobTests
|
||||
.Setup(c => c.GetSeasons(It.IsAny<int>()))
|
||||
.Returns(new List<int> { 0, 1, 2 });
|
||||
|
||||
Mocker.Resolve<SeriesSearchJob>().Start(MockNotification, 12, 0);
|
||||
Mocker.Resolve<SeriesSearchJob>().Start(MockNotification, new { SeriesId = 12 });
|
||||
|
||||
|
||||
Mocker.GetMock<SeasonSearchJob>()
|
||||
.Verify(c => c.Start(It.IsAny<ProgressNotification>(), It.IsAny<int>(), 0), Times.Never());
|
||||
.Verify(c => c.Start(It.IsAny<ProgressNotification>(), new { SeriesId = It.IsAny<int>(), SeasonNumber = 0 }), Times.Never());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user