1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00
Sonarr/NzbDrone.Core.Test/JobTests/RenameSeasonJobFixture.cs

82 lines
2.4 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FizzWare.NBuilder;
using Moq;
using NUnit.Framework;
2013-03-05 08:37:33 +03:00
using NzbDrone.Core.Jobs.Implementations;
2013-03-01 10:03:41 +03:00
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Jobs;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers;
2013-03-07 04:51:47 +03:00
using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.JobTests
{
[TestFixture]
public class RenameSeasonJobFixture : TestBase
{
private ProgressNotification _testNotification;
private Series _series;
private IList<EpisodeFile> _episodeFiles;
[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 09:56:02 +03:00
Mocker.GetMock<ISeriesRepository>()
.Setup(s => s.Get(_series.Id))
.Returns(_series);
2013-03-01 10:03:41 +03:00
Mocker.GetMock<IMediaFileService>()
.Setup(s => s.GetFilesBySeason(_series.Id, 5))
.Returns(_episodeFiles.ToList());
}
private void WithMovedFiles()
{
Mocker.GetMock<DiskScanProvider>()
.Setup(s => s.MoveEpisodeFile(It.IsAny<EpisodeFile>(), false))
.Returns(_episodeFiles.First());
}
[Test]
public void should_throw_if_seriesId_is_zero()
{
Assert.Throws<ArgumentException>(() =>
Mocker.Resolve<RenameSeasonJob>().Start(_testNotification, new { SeriesId = 0, SeasonNumber = 10 }));
}
[Test]
public void should_throw_if_seasonId_is_less_than_zero()
{
Assert.Throws<ArgumentException>(() =>
Mocker.Resolve<RenameSeasonJob>().Start(_testNotification, new { SeriesId = _series.Id, SeasonNumber = -10 }));
}
[Test]
public void should_log_warning_if_no_episode_files_are_found()
{
Mocker.Resolve<RenameSeasonJob>().Start(_testNotification, new { SeriesId = _series.Id, SeasonNumber = 10 });
ExceptionVerification.ExpectedWarns(1);
}
2013-03-02 21:25:39 +03:00
}
}