2012-12-20 21:23:09 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using FizzWare.NBuilder;
|
|
|
|
|
using NUnit.Framework;
|
2013-03-05 05:37:33 +00:00
|
|
|
|
using NzbDrone.Core.Jobs.Implementations;
|
2013-03-01 07:03:41 +00:00
|
|
|
|
using NzbDrone.Core.MediaFiles;
|
2013-02-19 06:01:03 +00:00
|
|
|
|
using NzbDrone.Core.Tv;
|
2012-12-20 21:23:09 +00:00
|
|
|
|
using NzbDrone.Core.Model.Notification;
|
|
|
|
|
using NzbDrone.Test.Common;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test.JobTests
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
public class RenameSeasonJobFixture : TestBase
|
|
|
|
|
{
|
|
|
|
|
private ProgressNotification _testNotification;
|
|
|
|
|
private Series _series;
|
|
|
|
|
private IList<EpisodeFile> _episodeFiles;
|
2013-03-07 04:49:00 +00:00
|
|
|
|
|
2012-12-20 21:23:09 +00:00
|
|
|
|
[SetUp]
|
|
|
|
|
public void Setup()
|
|
|
|
|
{
|
|
|
|
|
_testNotification = new ProgressNotification("TEST");
|
|
|
|
|
|
|
|
|
|
_series = Builder<Series>
|
|
|
|
|
.CreateNew()
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
_episodeFiles = Builder<EpisodeFile>
|
|
|
|
|
.CreateListOfSize(5)
|
|
|
|
|
.All()
|
|
|
|
|
.With(e => e.SeasonNumber = 5)
|
|
|
|
|
.Build();
|
|
|
|
|
|
2013-02-19 06:56:02 +00:00
|
|
|
|
Mocker.GetMock<ISeriesRepository>()
|
2013-02-26 03:58:57 +00:00
|
|
|
|
.Setup(s => s.Get(_series.Id))
|
2012-12-20 21:23:09 +00:00
|
|
|
|
.Returns(_series);
|
|
|
|
|
|
2013-03-01 07:03:41 +00:00
|
|
|
|
Mocker.GetMock<IMediaFileService>()
|
|
|
|
|
.Setup(s => s.GetFilesBySeason(_series.Id, 5))
|
2013-03-06 21:20:33 +00:00
|
|
|
|
.Returns(_episodeFiles.ToList());
|
2012-12-20 21:23:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_throw_if_seriesId_is_zero()
|
|
|
|
|
{
|
2013-03-07 04:49:00 +00:00
|
|
|
|
Assert.Throws<ArgumentException>(() =>
|
2012-12-20 21:23:09 +00:00
|
|
|
|
Mocker.Resolve<RenameSeasonJob>().Start(_testNotification, new { SeriesId = 0, SeasonNumber = 10 }));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_throw_if_seasonId_is_less_than_zero()
|
|
|
|
|
{
|
2013-03-07 04:49:00 +00:00
|
|
|
|
Assert.Throws<ArgumentException>(() =>
|
2013-02-26 03:58:57 +00:00
|
|
|
|
Mocker.Resolve<RenameSeasonJob>().Start(_testNotification, new { SeriesId = _series.Id, SeasonNumber = -10 }));
|
2012-12-20 21:23:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_log_warning_if_no_episode_files_are_found()
|
|
|
|
|
{
|
2013-02-26 03:58:57 +00:00
|
|
|
|
Mocker.Resolve<RenameSeasonJob>().Start(_testNotification, new { SeriesId = _series.Id, SeasonNumber = 10 });
|
2012-12-20 21:23:09 +00:00
|
|
|
|
|
|
|
|
|
ExceptionVerification.ExpectedWarns(1);
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-07 04:49:00 +00:00
|
|
|
|
|
2012-12-20 21:23:09 +00:00
|
|
|
|
}
|
|
|
|
|
}
|