using System.Collections.Generic; using Moq; using NUnit.Framework; using NzbDrone.Core.Jobs.Implementations; using NzbDrone.Core.Tv; using NzbDrone.Core.Jobs; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; using NzbDrone.Test.Common.AutoMoq; namespace NzbDrone.Core.Test.JobTests { [TestFixture] public class SeriesSearchJobTest : CoreTest { [Test] public void SeriesSearch_success() { var seasons = new List { 1, 2, 3, 4, 5 }; WithStrictMocker(); var notification = new ProgressNotification("Series Search"); Mocker.GetMock() .Setup(c => c.GetSeasonNumbers(1)).Returns(seasons); Mocker.GetMock() .Setup(c => c.IsIgnored(It.IsAny(), It.IsAny())).Returns(false); Mocker.GetMock() .Setup(c => c.Start(notification, It.Is(d => d.GetPropertyValue("SeriesId") == 1 && d.GetPropertyValue("SeasonNumber") >= 0))).Verifiable(); Mocker.Resolve().Start(notification, new { SeriesId = 1 }); Mocker.VerifyAllMocks(); Mocker.GetMock().Verify(c => c.Start(notification, It.Is(d => d.GetPropertyValue("SeriesId") == 1 && d.GetPropertyValue("SeasonNumber") >= 0)), Times.Exactly(seasons.Count)); } [Test] public void SeriesSearch_no_seasons() { var seasons = new List(); WithStrictMocker(); var notification = new ProgressNotification("Series Search"); Mocker.GetMock() .Setup(c => c.GetSeasonNumbers(1)).Returns(seasons); Mocker.Resolve().Start(notification, new { SeriesId = 1 }); Mocker.VerifyAllMocks(); Mocker.GetMock().Verify(c => c.Start(notification, new { SeriesId = 1, SeasonNumber = It.IsAny() }), Times.Never()); } [Test] public void SeriesSearch_should_not_search_for_season_0() { Mocker.GetMock() .Setup(c => c.GetSeasonNumbers(It.IsAny())) .Returns(new List { 0, 1, 2 }); Mocker.Resolve().Start(MockNotification, new { SeriesId = 12 }); Mocker.GetMock() .Verify(c => c.Start(It.IsAny(), new { SeriesId = It.IsAny(), SeasonNumber = 0 }), Times.Never()); } } }