From 1d78bb7210fec06f0f3b2507c7669d6b8f1ca2d9 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sun, 24 Feb 2013 12:24:31 -0800 Subject: [PATCH] more fixed tests. --- NzbDrone.Api/AutomapperBootstraper.cs | 1 + NzbDrone.Api/Series/SeriesModule.cs | 5 +++-- .../UpgradeHistorySpecificationFixture.cs | 8 ++++---- NzbDrone.Core.Test/EpisodeStatusTest.cs | 14 ++++++++------ NzbDrone.Core.Test/JobTests/SeriesSearchJobTest.cs | 8 ++++---- .../EpisodeProviderTests/EpisodeProviderTest.cs | 6 +++--- .../DecisionEngine/UpgradeHistorySpecification.cs | 7 ++----- NzbDrone.Core/Tv/Episode.cs | 2 +- NzbDrone.Core/Tv/EpisodeService.cs | 4 ++-- NzbDrone.Core/Tv/SeriesService.cs | 2 +- 10 files changed, 29 insertions(+), 28 deletions(-) diff --git a/NzbDrone.Api/AutomapperBootstraper.cs b/NzbDrone.Api/AutomapperBootstraper.cs index dcb0a246d..100be68d1 100644 --- a/NzbDrone.Api/AutomapperBootstraper.cs +++ b/NzbDrone.Api/AutomapperBootstraper.cs @@ -6,6 +6,7 @@ using NzbDrone.Api.QualityType; using NzbDrone.Api.Resolvers; using NzbDrone.Api.Series; using NzbDrone.Api.Upcoming; +using NzbDrone.Core.Datastore; using NzbDrone.Core.Repository.Quality; using NzbDrone.Core.Tv; diff --git a/NzbDrone.Api/Series/SeriesModule.cs b/NzbDrone.Api/Series/SeriesModule.cs index ae7b9a6f5..69a3b62bd 100644 --- a/NzbDrone.Api/Series/SeriesModule.cs +++ b/NzbDrone.Api/Series/SeriesModule.cs @@ -7,6 +7,7 @@ using FluentValidation; using Nancy; using NzbDrone.Api.Extensions; using NzbDrone.Common; +using NzbDrone.Core.Datastore; using NzbDrone.Core.Tv; using NzbDrone.Core.Jobs; using NzbDrone.Core.Model; @@ -58,7 +59,7 @@ namespace NzbDrone.Api.Series //(we can just create the folder and it won't blow up if it already exists) //We also need to remove any special characters from the filename before attempting to create it - _seriesService.AddSeries("", request.Path, request.SeriesId, request.QualityProfileId, null); + _seriesService.AddSeries("", request.Path, request.OID, request.QualityProfileId, null); _jobProvider.QueueJob(typeof(ImportNewSeriesJob)); return new Response { StatusCode = HttpStatusCode.Created }; @@ -116,7 +117,7 @@ namespace NzbDrone.Api.Series { RuleSet("POST", () => { - RuleFor(s => s.OID).GreaterThan(0); + RuleFor(s => ((ModelBase)s).OID).GreaterThan(0); RuleFor(s => s.Path).NotEmpty().Must(_diskProvider.FolderExists); RuleFor(s => s.QualityProfileId).GreaterThan(0); }); diff --git a/NzbDrone.Core.Test/DecisionEngineTests/UpgradeHistorySpecificationFixture.cs b/NzbDrone.Core.Test/DecisionEngineTests/UpgradeHistorySpecificationFixture.cs index 038f9cecf..af6262599 100644 --- a/NzbDrone.Core.Test/DecisionEngineTests/UpgradeHistorySpecificationFixture.cs +++ b/NzbDrone.Core.Test/DecisionEngineTests/UpgradeHistorySpecificationFixture.cs @@ -66,9 +66,9 @@ namespace NzbDrone.Core.Test.DecisionEngineTests firstQuality = new QualityModel(QualityTypes.Bluray1080p, true); secondQuality = new QualityModel(QualityTypes.Bluray1080p, true); - Mocker.GetMock().Setup(c => c.GetBestQualityInHistory(fakeSeries.OID, 12, 3)).Returns(firstQuality); - Mocker.GetMock().Setup(c => c.GetBestQualityInHistory(fakeSeries.OID, 12, 4)).Returns(secondQuality); - Mocker.GetMock().Setup(c => c.GetBestQualityInHistory(fakeSeries.OID, 12, 5)).Returns(null); + Mocker.GetMock().Setup(c => c.GetBestQualityInHistory(fakeSeries.OID, 12, 3)).Returns(firstQuality); + Mocker.GetMock().Setup(c => c.GetBestQualityInHistory(fakeSeries.OID, 12, 4)).Returns(secondQuality); + Mocker.GetMock().Setup(c => c.GetBestQualityInHistory(fakeSeries.OID, 12, 5)).Returns(null); } private void WithFirstReportUpgradable() @@ -124,7 +124,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests parseResultSingle.Quality = new QualityModel(QualityTypes.WEBDL1080p, false); firstQuality = new QualityModel(QualityTypes.WEBDL1080p, false); - Mocker.GetMock().Setup(c => c.GetBestQualityInHistory(fakeSeries.OID, 12, 3)).Returns(firstQuality); + Mocker.GetMock().Setup(c => c.GetBestQualityInHistory(fakeSeries.OID, 12, 3)).Returns(firstQuality); _upgradeHistory.IsSatisfiedBy(parseResultSingle).Should().BeFalse(); } diff --git a/NzbDrone.Core.Test/EpisodeStatusTest.cs b/NzbDrone.Core.Test/EpisodeStatusTest.cs index 33e333e01..ddfe215d8 100644 --- a/NzbDrone.Core.Test/EpisodeStatusTest.cs +++ b/NzbDrone.Core.Test/EpisodeStatusTest.cs @@ -12,12 +12,11 @@ namespace NzbDrone.Core.Test [TestFixture] // ReSharper disable InconsistentNaming public class EpisodeStatusTest : CoreTest - { + { [TestCase(1, false, false, EpisodeStatusType.NotAired)] [TestCase(-2, false, false, EpisodeStatusType.Missing)] [TestCase(0, false, false, EpisodeStatusType.AirsToday)] [TestCase(1, true, false, EpisodeStatusType.Ready)] - [TestCase(0, true, false, EpisodeStatusType.Ready)] public void no_grab_date(int offsetDays, bool hasEpisodes, bool ignored, EpisodeStatusType status) { Episode episode = Builder.CreateNew() @@ -31,7 +30,7 @@ namespace NzbDrone.Core.Test episode.EpisodeFile = new EpisodeFile(); } - Assert.AreEqual(status, episode.Status); + episode.Status.Should().Be(status); } [TestCase(1, false, false, EpisodeStatusType.Missing)] @@ -73,7 +72,8 @@ namespace NzbDrone.Core.Test episode.EpisodeFile = new EpisodeFile(); } - Assert.AreEqual(status, episode.Status); + episode.Status.Should().Be(status); + } [TestCase(1, true, true, EpisodeStatusType.Ready)] @@ -90,7 +90,8 @@ namespace NzbDrone.Core.Test episode.EpisodeFile = new EpisodeFile(); } - Assert.AreEqual(status, episode.Status); + episode.Status.Should().Be(status); + } [Test] @@ -124,7 +125,8 @@ namespace NzbDrone.Core.Test episode.EpisodeFile = new EpisodeFile(); } - Assert.AreEqual(status, episode.Status); + episode.Status.Should().Be(status); + } } } \ No newline at end of file diff --git a/NzbDrone.Core.Test/JobTests/SeriesSearchJobTest.cs b/NzbDrone.Core.Test/JobTests/SeriesSearchJobTest.cs index c3a4ced3d..f546fec2d 100644 --- a/NzbDrone.Core.Test/JobTests/SeriesSearchJobTest.cs +++ b/NzbDrone.Core.Test/JobTests/SeriesSearchJobTest.cs @@ -25,10 +25,10 @@ namespace NzbDrone.Core.Test.JobTests var notification = new ProgressNotification("Series Search"); - Mocker.GetMock() + Mocker.GetMock() .Setup(c => c.GetSeasonNumbers(1)).Returns(seasons); - Mocker.GetMock() + Mocker.GetMock() .Setup(c => c.IsIgnored(It.IsAny(), It.IsAny())).Returns(false); Mocker.GetMock() @@ -52,7 +52,7 @@ namespace NzbDrone.Core.Test.JobTests var notification = new ProgressNotification("Series Search"); - Mocker.GetMock() + Mocker.GetMock() .Setup(c => c.GetSeasonNumbers(1)).Returns(seasons); //Act @@ -67,7 +67,7 @@ namespace NzbDrone.Core.Test.JobTests [Test] public void SeriesSearch_should_not_search_for_season_0() { - Mocker.GetMock() + Mocker.GetMock() .Setup(c => c.GetSeasonNumbers(It.IsAny())) .Returns(new List { 0, 1, 2 }); diff --git a/NzbDrone.Core.Test/TvTests/EpisodeProviderTests/EpisodeProviderTest.cs b/NzbDrone.Core.Test/TvTests/EpisodeProviderTests/EpisodeProviderTest.cs index 692336248..58f048e19 100644 --- a/NzbDrone.Core.Test/TvTests/EpisodeProviderTests/EpisodeProviderTest.cs +++ b/NzbDrone.Core.Test/TvTests/EpisodeProviderTests/EpisodeProviderTest.cs @@ -462,7 +462,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests .Setup(c => c.GetSeries(seriesId, true, false)) .Returns(fakeEpisodes); - Mocker.GetMock() + Mocker.GetMock() .Setup(s => s.IsIgnored(seriesId, 0)) .Returns(true); @@ -795,7 +795,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests .Setup(c => c.GetSeries(seriesId, true, false)) .Returns(tvdbSeries); - Mocker.GetMock() + Mocker.GetMock() .Setup(s => s.IsIgnored(seriesId, It.IsAny())) .Returns(true); @@ -977,7 +977,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests .With(e => e.Ignored = false) .Build(); - Mocker.GetMock() + Mocker.GetMock() .Setup(s => s.IsIgnored(newEpisode.SeriesId, newEpisode.SeasonNumber)) .Returns(true); diff --git a/NzbDrone.Core/DecisionEngine/UpgradeHistorySpecification.cs b/NzbDrone.Core/DecisionEngine/UpgradeHistorySpecification.cs index 4ce7ba886..d3b2f2a5d 100644 --- a/NzbDrone.Core/DecisionEngine/UpgradeHistorySpecification.cs +++ b/NzbDrone.Core/DecisionEngine/UpgradeHistorySpecification.cs @@ -1,7 +1,6 @@ using System.Linq; using NLog; using NzbDrone.Core.History; -using NzbDrone.Core.Tv; using NzbDrone.Core.Model; using NzbDrone.Core.Providers; @@ -9,14 +8,12 @@ namespace NzbDrone.Core.DecisionEngine { public class UpgradeHistorySpecification { - private readonly IEpisodeService _episodeService; - private readonly HistoryService _historyService; + private readonly IHistoryService _historyService; private readonly QualityUpgradeSpecification _qualityUpgradeSpecification; private static readonly Logger logger = LogManager.GetCurrentClassLogger(); - public UpgradeHistorySpecification(IEpisodeService episodeService, HistoryService historyService, QualityUpgradeSpecification qualityUpgradeSpecification) + public UpgradeHistorySpecification(IHistoryService historyService, QualityUpgradeSpecification qualityUpgradeSpecification) { - _episodeService = episodeService; _historyService = historyService; _qualityUpgradeSpecification = qualityUpgradeSpecification; } diff --git a/NzbDrone.Core/Tv/Episode.cs b/NzbDrone.Core/Tv/Episode.cs index 3e3b28f84..25402ade7 100644 --- a/NzbDrone.Core/Tv/Episode.cs +++ b/NzbDrone.Core/Tv/Episode.cs @@ -47,7 +47,7 @@ namespace NzbDrone.Core.Tv { get { - if (EpisodeFileId != 0) return EpisodeStatusType.Ready; + if (HasFile) return EpisodeStatusType.Ready; if (GrabDate != null) { diff --git a/NzbDrone.Core/Tv/EpisodeService.cs b/NzbDrone.Core/Tv/EpisodeService.cs index 3b7fc537d..7d762dce9 100644 --- a/NzbDrone.Core/Tv/EpisodeService.cs +++ b/NzbDrone.Core/Tv/EpisodeService.cs @@ -42,9 +42,9 @@ namespace NzbDrone.Core.Tv private readonly TvDbProvider _tvDbProvider; private readonly ISeasonRepository _seasonRepository; - private readonly EpisodeRepository _episodeRepository; + private readonly IEpisodeRepository _episodeRepository; - public EpisodeService(TvDbProvider tvDbProviderProvider, ISeasonRepository seasonRepository, EpisodeRepository episodeRepository) + public EpisodeService(TvDbProvider tvDbProviderProvider, ISeasonRepository seasonRepository, IEpisodeRepository episodeRepository) { _tvDbProvider = tvDbProviderProvider; _seasonRepository = seasonRepository; diff --git a/NzbDrone.Core/Tv/SeriesService.cs b/NzbDrone.Core/Tv/SeriesService.cs index a060dcf48..87d5c5b73 100644 --- a/NzbDrone.Core/Tv/SeriesService.cs +++ b/NzbDrone.Core/Tv/SeriesService.cs @@ -36,7 +36,7 @@ namespace NzbDrone.Core.Tv private readonly SceneMappingProvider _sceneNameMappingProvider; - public SeriesService(ISeriesRepository seriesRepository, ConfigService configServiceService, + public SeriesService(ISeriesRepository seriesRepository, IConfigService configServiceService, TvDbProvider tvDbProviderProvider, SceneMappingProvider sceneNameMappingProvider, MetadataProvider metadataProvider, TvRageMappingProvider tvRageMappingProvider, IEventAggregator eventAggregator) {