mirror of
https://github.com/Radarr/Radarr
synced 2024-12-24 17:01:38 +00:00
more fixed tests.
This commit is contained in:
parent
9931bab998
commit
1d78bb7210
10 changed files with 29 additions and 28 deletions
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
|
@ -66,9 +66,9 @@ public void Setup()
|
|||
firstQuality = new QualityModel(QualityTypes.Bluray1080p, true);
|
||||
secondQuality = new QualityModel(QualityTypes.Bluray1080p, true);
|
||||
|
||||
Mocker.GetMock<HistoryService>().Setup(c => c.GetBestQualityInHistory(fakeSeries.OID, 12, 3)).Returns(firstQuality);
|
||||
Mocker.GetMock<HistoryService>().Setup(c => c.GetBestQualityInHistory(fakeSeries.OID, 12, 4)).Returns(secondQuality);
|
||||
Mocker.GetMock<HistoryService>().Setup(c => c.GetBestQualityInHistory(fakeSeries.OID, 12, 5)).Returns<QualityModel>(null);
|
||||
Mocker.GetMock<IHistoryService>().Setup(c => c.GetBestQualityInHistory(fakeSeries.OID, 12, 3)).Returns(firstQuality);
|
||||
Mocker.GetMock<IHistoryService>().Setup(c => c.GetBestQualityInHistory(fakeSeries.OID, 12, 4)).Returns(secondQuality);
|
||||
Mocker.GetMock<IHistoryService>().Setup(c => c.GetBestQualityInHistory(fakeSeries.OID, 12, 5)).Returns<QualityModel>(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<HistoryService>().Setup(c => c.GetBestQualityInHistory(fakeSeries.OID, 12, 3)).Returns(firstQuality);
|
||||
Mocker.GetMock<IHistoryService>().Setup(c => c.GetBestQualityInHistory(fakeSeries.OID, 12, 3)).Returns(firstQuality);
|
||||
|
||||
_upgradeHistory.IsSatisfiedBy(parseResultSingle).Should().BeFalse();
|
||||
}
|
||||
|
|
|
@ -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<Episode>.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);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -25,10 +25,10 @@ public void SeriesSearch_success()
|
|||
|
||||
var notification = new ProgressNotification("Series Search");
|
||||
|
||||
Mocker.GetMock<SeasonRepository>()
|
||||
Mocker.GetMock<ISeasonRepository>()
|
||||
.Setup(c => c.GetSeasonNumbers(1)).Returns(seasons);
|
||||
|
||||
Mocker.GetMock<SeasonRepository>()
|
||||
Mocker.GetMock<ISeasonRepository>()
|
||||
.Setup(c => c.IsIgnored(It.IsAny<int>(), It.IsAny<int>())).Returns(false);
|
||||
|
||||
Mocker.GetMock<SeasonSearchJob>()
|
||||
|
@ -52,7 +52,7 @@ public void SeriesSearch_no_seasons()
|
|||
|
||||
var notification = new ProgressNotification("Series Search");
|
||||
|
||||
Mocker.GetMock<SeasonRepository>()
|
||||
Mocker.GetMock<ISeasonRepository>()
|
||||
.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<SeasonRepository>()
|
||||
Mocker.GetMock<ISeasonRepository>()
|
||||
.Setup(c => c.GetSeasonNumbers(It.IsAny<int>()))
|
||||
.Returns(new List<int> { 0, 1, 2 });
|
||||
|
||||
|
|
|
@ -462,7 +462,7 @@ public void RefreshEpisodeInfo_ignore_season_zero()
|
|||
.Setup(c => c.GetSeries(seriesId, true, false))
|
||||
.Returns(fakeEpisodes);
|
||||
|
||||
Mocker.GetMock<SeasonRepository>()
|
||||
Mocker.GetMock<ISeasonRepository>()
|
||||
.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<SeasonRepository>()
|
||||
Mocker.GetMock<ISeasonRepository>()
|
||||
.Setup(s => s.IsIgnored(seriesId, It.IsAny<int>()))
|
||||
.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<SeasonRepository>()
|
||||
Mocker.GetMock<ISeasonRepository>()
|
||||
.Setup(s => s.IsIgnored(newEpisode.SeriesId, newEpisode.SeasonNumber))
|
||||
.Returns(true);
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public EpisodeStatusType Status
|
|||
{
|
||||
get
|
||||
{
|
||||
if (EpisodeFileId != 0) return EpisodeStatusType.Ready;
|
||||
if (HasFile) return EpisodeStatusType.Ready;
|
||||
|
||||
if (GrabDate != null)
|
||||
{
|
||||
|
|
|
@ -42,9 +42,9 @@ public class EpisodeService : IEpisodeService, IHandle<EpisodeGrabbedEvent>
|
|||
|
||||
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;
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue