using System; using System.Collections.Generic; using System.Linq; using System.Text; using FizzWare.NBuilder; using Moq; using NUnit.Framework; using NzbDrone.Core.Jobs.Implementations; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Tv; using NzbDrone.Core.Jobs; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; using NzbDrone.Core.Repository; using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.JobTests { [TestFixture] public class RenameSeasonJobFixture : TestBase { private ProgressNotification _testNotification; private Series _series; private IList _episodeFiles; [SetUp] public void Setup() { _testNotification = new ProgressNotification("TEST"); _series = Builder .CreateNew() .Build(); _episodeFiles = Builder .CreateListOfSize(5) .All() .With(e => e.SeasonNumber = 5) .Build(); Mocker.GetMock() .Setup(s => s.Get(_series.Id)) .Returns(_series); Mocker.GetMock() .Setup(s => s.GetFilesBySeason(_series.Id, 5)) .Returns(_episodeFiles.ToList()); } private void WithMovedFiles() { Mocker.GetMock() .Setup(s => s.MoveEpisodeFile(It.IsAny(), false)) .Returns(_episodeFiles.First()); } [Test] public void should_throw_if_seriesId_is_zero() { Assert.Throws(() => Mocker.Resolve().Start(_testNotification, new { SeriesId = 0, SeasonNumber = 10 })); } [Test] public void should_throw_if_seasonId_is_less_than_zero() { Assert.Throws(() => Mocker.Resolve().Start(_testNotification, new { SeriesId = _series.Id, SeasonNumber = -10 })); } [Test] public void should_log_warning_if_no_episode_files_are_found() { Mocker.Resolve().Start(_testNotification, new { SeriesId = _series.Id, SeasonNumber = 10 }); ExceptionVerification.ExpectedWarns(1); } } }