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