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.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 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 @@ private Response AddSeries() //(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 @@ public SeriesValidator() { 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 @@ public void Setup() 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 @@ public void should_not_be_upgradable_if_episode_is_of_same_quality_as_existing() 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 @@ public void no_grab_date(int offsetDays, bool hasEpisodes, bool ignored, Episode episode.EpisodeFile = new EpisodeFile(); } - Assert.AreEqual(status, episode.Status); + episode.Status.Should().Be(status); } [TestCase(1, false, false, EpisodeStatusType.Missing)] @@ -73,7 +72,8 @@ public void recent_grab_date(int offsetDays, bool hasEpisodes, bool ignored, episode.EpisodeFile = new EpisodeFile(); } - Assert.AreEqual(status, episode.Status); + episode.Status.Should().Be(status); + } [TestCase(1, true, true, EpisodeStatusType.Ready)] @@ -90,7 +90,8 @@ public void ignored_episode(int offsetDays, bool ignored, bool hasEpisodes, Epis episode.EpisodeFile = new EpisodeFile(); } - Assert.AreEqual(status, episode.Status); + episode.Status.Should().Be(status); + } [Test] @@ -124,7 +125,8 @@ public void episode_downloaded_post_download_status_is_used(bool hasEpisodes, bo 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 @@ public void SeriesSearch_success() 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 @@ public void SeriesSearch_no_seasons() var notification = new ProgressNotification("Series Search"); - Mocker.GetMock() + Mocker.GetMock() .Setup(c => c.GetSeasonNumbers(1)).Returns(seasons); //Act @@ -67,7 +67,7 @@ public void SeriesSearch_no_seasons() [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 @@ public void RefreshEpisodeInfo_ignore_season_zero() .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 @@ public void RefreshEpisodeInfo_should_ignore_new_episode_for_ignored_season() .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 @@ public void AddEpisode_episode_is_ignored_when_full_season_is_ignored() .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 @@ public EpisodeStatusType Status { 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 @@ public class EpisodeService : IEpisodeService, IHandle 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 @@ public class SeriesService : ISeriesService 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) {