Radarr/NzbDrone.Core.Test/JobTests/SeriesSearchJobTest.cs

79 lines
2.5 KiB
C#
Raw Normal View History

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