2011-10-21 01:42:17 +02:00
|
|
|
|
using System.Collections.Generic;
|
2011-11-14 01:22:18 +01:00
|
|
|
|
|
2011-08-23 07:29:12 +02:00
|
|
|
|
using Moq;
|
|
|
|
|
using NUnit.Framework;
|
2011-12-02 02:33:17 +01:00
|
|
|
|
using NzbDrone.Core.Jobs;
|
2011-08-23 07:29:12 +02:00
|
|
|
|
using NzbDrone.Core.Model.Notification;
|
|
|
|
|
using NzbDrone.Core.Providers;
|
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
2011-11-14 01:22:18 +01:00
|
|
|
|
using NzbDrone.Test.Common.AutoMoq;
|
2011-08-23 07:29:12 +02:00
|
|
|
|
|
2011-10-21 01:42:17 +02:00
|
|
|
|
namespace NzbDrone.Core.Test.JobTests
|
2011-08-23 07:29:12 +02:00
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
// ReSharper disable InconsistentNaming
|
2011-11-13 08:27:16 +01:00
|
|
|
|
public class SeriesSearchJobTest : CoreTest
|
2011-08-23 07:29:12 +02:00
|
|
|
|
{
|
|
|
|
|
[Test]
|
|
|
|
|
public void SeriesSearch_success()
|
|
|
|
|
{
|
2011-08-28 08:37:34 +02:00
|
|
|
|
var seasons = new List<int> { 1, 2, 3, 4, 5 };
|
2011-08-23 07:29:12 +02:00
|
|
|
|
|
2011-12-15 05:15:53 +01:00
|
|
|
|
WithStrictMocker();
|
2011-08-23 07:29:12 +02:00
|
|
|
|
|
|
|
|
|
var notification = new ProgressNotification("Series Search");
|
|
|
|
|
|
2011-12-15 05:15:53 +01:00
|
|
|
|
Mocker.GetMock<EpisodeProvider>()
|
2011-08-28 08:37:34 +02:00
|
|
|
|
.Setup(c => c.GetSeasons(1)).Returns(seasons);
|
2011-08-23 07:29:12 +02:00
|
|
|
|
|
2011-12-15 05:15:53 +01:00
|
|
|
|
Mocker.GetMock<EpisodeProvider>()
|
2011-08-28 21:24:16 +02:00
|
|
|
|
.Setup(c => c.IsIgnored(It.IsAny<int>(), It.IsAny<int>())).Returns(false);
|
|
|
|
|
|
2011-12-15 05:15:53 +01:00
|
|
|
|
Mocker.GetMock<SeasonSearchJob>()
|
2011-08-28 08:37:34 +02:00
|
|
|
|
.Setup(c => c.Start(notification, 1, It.IsAny<int>())).Verifiable();
|
2011-08-23 07:29:12 +02:00
|
|
|
|
|
|
|
|
|
//Act
|
2011-12-15 05:15:53 +01:00
|
|
|
|
Mocker.Resolve<SeriesSearchJob>().Start(notification, 1, 0);
|
2011-08-23 07:29:12 +02:00
|
|
|
|
|
|
|
|
|
//Assert
|
2011-12-15 05:15:53 +01:00
|
|
|
|
Mocker.VerifyAllMocks();
|
|
|
|
|
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, 1, It.IsAny<int>()),
|
2011-08-28 08:37:34 +02:00
|
|
|
|
Times.Exactly(seasons.Count));
|
2011-08-23 07:29:12 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
2011-08-28 08:37:34 +02:00
|
|
|
|
public void SeriesSearch_no_seasons()
|
2011-08-23 07:29:12 +02:00
|
|
|
|
{
|
2011-08-28 08:37:34 +02:00
|
|
|
|
var seasons = new List<int>();
|
2011-08-23 07:29:12 +02:00
|
|
|
|
|
2011-12-15 05:15:53 +01:00
|
|
|
|
WithStrictMocker();
|
2011-08-23 07:29:12 +02:00
|
|
|
|
|
|
|
|
|
var notification = new ProgressNotification("Series Search");
|
|
|
|
|
|
2011-12-15 05:15:53 +01:00
|
|
|
|
Mocker.GetMock<EpisodeProvider>()
|
2011-08-28 08:37:34 +02:00
|
|
|
|
.Setup(c => c.GetSeasons(1)).Returns(seasons);
|
2011-08-23 07:29:12 +02:00
|
|
|
|
|
|
|
|
|
//Act
|
2011-12-15 05:15:53 +01:00
|
|
|
|
Mocker.Resolve<SeriesSearchJob>().Start(notification, 1, 0);
|
2011-08-23 07:29:12 +02:00
|
|
|
|
|
|
|
|
|
//Assert
|
2011-12-15 05:15:53 +01:00
|
|
|
|
Mocker.VerifyAllMocks();
|
|
|
|
|
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, 1, It.IsAny<int>()),
|
2011-08-28 08:37:34 +02:00
|
|
|
|
Times.Never());
|
2011-08-23 07:29:12 +02:00
|
|
|
|
}
|
2011-11-26 08:52:54 +01:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void SeriesSearch_should_not_search_for_season_0()
|
|
|
|
|
{
|
|
|
|
|
Mocker.GetMock<EpisodeProvider>()
|
|
|
|
|
.Setup(c => c.GetSeasons(It.IsAny<int>()))
|
|
|
|
|
.Returns(new List<int> { 0, 1, 2 });
|
|
|
|
|
|
|
|
|
|
Mocker.Resolve<SeriesSearchJob>().Start(MockNotification, 12, 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<SeasonSearchJob>()
|
|
|
|
|
.Verify(c => c.Start(It.IsAny<ProgressNotification>(), It.IsAny<int>(), 0), Times.Never());
|
|
|
|
|
}
|
2011-08-23 07:29:12 +02:00
|
|
|
|
}
|
|
|
|
|
}
|