1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-14 11:23:42 +02:00
Sonarr/NzbDrone.Core.Test/JobTests/SeriesSearchJobTest.cs

82 lines
2.8 KiB
C#
Raw Normal View History

using System.Collections.Generic;
using Moq;
using NUnit.Framework;
2013-03-05 08:37:33 +03:00
using NzbDrone.Core.Jobs.Implementations;
using NzbDrone.Core.Tv;
2011-12-02 04:33:17 +03:00
using NzbDrone.Core.Jobs;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Test.Framework;
2012-09-11 09:35:25 +03:00
using NzbDrone.Test.Common;
using NzbDrone.Test.Common.AutoMoq;
namespace NzbDrone.Core.Test.JobTests
{
[TestFixture]
2013-03-29 01:07:09 +03:00
public class SeriesSearchJobTest : CoreTest
{
[Test]
public void SeriesSearch_success()
{
var seasons = new List<int> { 1, 2, 3, 4, 5 };
2011-12-15 07:15:53 +03:00
WithStrictMocker();
var notification = new ProgressNotification("Series Search");
2013-02-24 23:24:31 +03:00
Mocker.GetMock<ISeasonRepository>()
.Setup(c => c.GetSeasonNumbers(1)).Returns(seasons);
2013-02-24 23:24:31 +03:00
Mocker.GetMock<ISeasonRepository>()
2011-08-28 22:24:16 +03:00
.Setup(c => c.IsIgnored(It.IsAny<int>(), It.IsAny<int>())).Returns(false);
2011-12-15 07:15:53 +03:00
Mocker.GetMock<SeasonSearchJob>()
2012-09-11 09:35:25 +03:00
.Setup(c => c.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") == 1 && d.GetPropertyValue<int>("SeasonNumber") >= 0))).Verifiable();
2013-03-29 01:07:09 +03:00
2012-09-10 22:04:17 +03:00
Mocker.Resolve<SeriesSearchJob>().Start(notification, new { SeriesId = 1 });
2013-03-29 01:07:09 +03:00
2011-12-15 07:15:53 +03:00
Mocker.VerifyAllMocks();
2012-09-11 09:35:25 +03:00
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));
}
[Test]
public void SeriesSearch_no_seasons()
{
var seasons = new List<int>();
2011-12-15 07:15:53 +03:00
WithStrictMocker();
var notification = new ProgressNotification("Series Search");
2013-02-24 23:24:31 +03:00
Mocker.GetMock<ISeasonRepository>()
.Setup(c => c.GetSeasonNumbers(1)).Returns(seasons);
2013-03-29 01:07:09 +03:00
2012-09-10 22:04:17 +03:00
Mocker.Resolve<SeriesSearchJob>().Start(notification, new { SeriesId = 1 });
2013-03-29 01:07:09 +03:00
2011-12-15 07:15:53 +03:00
Mocker.VerifyAllMocks();
2012-09-10 22:04:17 +03:00
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, new { SeriesId = 1, SeasonNumber = It.IsAny<int>() }),
Times.Never());
}
[Test]
public void SeriesSearch_should_not_search_for_season_0()
{
2013-02-24 23:24:31 +03:00
Mocker.GetMock<ISeasonRepository>()
.Setup(c => c.GetSeasonNumbers(It.IsAny<int>()))
.Returns(new List<int> { 0, 1, 2 });
2012-09-10 22:04:17 +03:00
Mocker.Resolve<SeriesSearchJob>().Start(MockNotification, new { SeriesId = 12 });
Mocker.GetMock<SeasonSearchJob>()
2012-09-10 22:04:17 +03:00
.Verify(c => c.Start(It.IsAny<ProgressNotification>(), new { SeriesId = It.IsAny<int>(), SeasonNumber = 0 }), Times.Never());
}
}
}