mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-23 06:45:19 -07:00
Added: A Huge Cleanup of old Series Code. (Let's pray nothing breaks :P) (#2589)
This commit is contained in:
parent
8a6d67a6d7
commit
25e10e26e3
551 changed files with 2835 additions and 18867 deletions
|
@ -31,8 +31,6 @@ namespace NzbDrone.Api.Blacklist
|
|||
{
|
||||
Id = model.Id,
|
||||
MovieId = model.MovieId,
|
||||
SeriesId = model.SeriesId,
|
||||
EpisodeIds = model.EpisodeIds,
|
||||
SourceTitle = model.SourceTitle,
|
||||
Quality = model.Quality,
|
||||
Date = model.Date,
|
||||
|
|
|
@ -8,7 +8,7 @@ using Ical.Net.General;
|
|||
using Ical.Net.Interfaces.Serialization;
|
||||
using Ical.Net.Serialization;
|
||||
using Ical.Net.Serialization.iCalendar.Factory;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
using Nancy.Responses;
|
||||
using NzbDrone.Core.Tags;
|
||||
using NzbDrone.Common.Extensions;
|
||||
|
|
|
@ -8,11 +8,9 @@ using NzbDrone.Core.MediaCover;
|
|||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.MediaFiles.Events;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
using NzbDrone.Core.MovieStats;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Tv.Events;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.Movies.Events;
|
||||
using NzbDrone.Core.Validation.Paths;
|
||||
using NzbDrone.Core.DataAugmentation.Scene;
|
||||
using NzbDrone.Core.Validation;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
using NzbDrone.SignalR;
|
||||
|
@ -23,10 +21,8 @@ namespace NzbDrone.Api.Calendar
|
|||
{
|
||||
public CalendarModule(IBroadcastSignalRMessage signalR,
|
||||
IMovieService moviesService,
|
||||
IMovieStatisticsService moviesStatisticsService,
|
||||
ISceneMappingService sceneMappingService,
|
||||
IMapCoversToLocal coverMapper)
|
||||
: base(signalR, moviesService, moviesStatisticsService, sceneMappingService, coverMapper, "calendar")
|
||||
: base(signalR, moviesService, coverMapper, "calendar")
|
||||
{
|
||||
|
||||
GetResourceAll = GetCalendar;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FluentValidation;
|
||||
using FluentValidation.Results;
|
||||
|
@ -131,20 +131,8 @@ namespace NzbDrone.Api.Config
|
|||
|
||||
private void ValidateFormatResult(NamingConfig nameSpec)
|
||||
{
|
||||
var singleEpisodeSampleResult = _filenameSampleService.GetStandardSample(nameSpec);
|
||||
var multiEpisodeSampleResult = _filenameSampleService.GetMultiEpisodeSample(nameSpec);
|
||||
var dailyEpisodeSampleResult = _filenameSampleService.GetDailySample(nameSpec);
|
||||
var animeEpisodeSampleResult = _filenameSampleService.GetAnimeSample(nameSpec);
|
||||
var animeMultiEpisodeSampleResult = _filenameSampleService.GetAnimeMultiEpisodeSample(nameSpec);
|
||||
|
||||
var movieSampleResult = _filenameSampleService.GetMovieSample(nameSpec);
|
||||
|
||||
var singleEpisodeValidationResult = _filenameValidationService.ValidateStandardFilename(singleEpisodeSampleResult);
|
||||
var multiEpisodeValidationResult = _filenameValidationService.ValidateStandardFilename(multiEpisodeSampleResult);
|
||||
var dailyEpisodeValidationResult = _filenameValidationService.ValidateDailyFilename(dailyEpisodeSampleResult);
|
||||
var animeEpisodeValidationResult = _filenameValidationService.ValidateAnimeFilename(animeEpisodeSampleResult);
|
||||
var animeMultiEpisodeValidationResult = _filenameValidationService.ValidateAnimeFilename(animeMultiEpisodeSampleResult);
|
||||
|
||||
//var standardMovieValidationResult = _filenameValidationService.ValidateMovieFilename(movieSampleResult); For now, let's hope the user is not stupid enough :/
|
||||
|
||||
var validationFailures = new List<ValidationFailure>();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using NzbDrone.Api.REST;
|
||||
using NzbDrone.Api.REST;
|
||||
using NzbDrone.Core.Organizer;
|
||||
|
||||
namespace NzbDrone.Api.Config
|
||||
|
@ -10,11 +10,6 @@ namespace NzbDrone.Api.Config
|
|||
public string StandardMovieFormat { get; set; }
|
||||
public string MovieFolderFormat { get; set; }
|
||||
public int MultiEpisodeStyle { get; set; }
|
||||
public string StandardEpisodeFormat { get; set; }
|
||||
public string DailyEpisodeFormat { get; set; }
|
||||
public string AnimeEpisodeFormat { get; set; }
|
||||
public string SeriesFolderFormat { get; set; }
|
||||
public string SeasonFolderFormat { get; set; }
|
||||
public bool IncludeSeriesTitle { get; set; }
|
||||
public bool IncludeEpisodeTitle { get; set; }
|
||||
public bool IncludeQuality { get; set; }
|
||||
|
@ -34,11 +29,6 @@ namespace NzbDrone.Api.Config
|
|||
RenameEpisodes = model.RenameEpisodes,
|
||||
ReplaceIllegalCharacters = model.ReplaceIllegalCharacters,
|
||||
MultiEpisodeStyle = model.MultiEpisodeStyle,
|
||||
StandardEpisodeFormat = model.StandardEpisodeFormat,
|
||||
DailyEpisodeFormat = model.DailyEpisodeFormat,
|
||||
AnimeEpisodeFormat = model.AnimeEpisodeFormat,
|
||||
SeriesFolderFormat = model.SeriesFolderFormat,
|
||||
SeasonFolderFormat = model.SeasonFolderFormat,
|
||||
StandardMovieFormat = model.StandardMovieFormat,
|
||||
MovieFolderFormat = model.MovieFolderFormat
|
||||
//IncludeSeriesTitle
|
||||
|
@ -79,4 +69,4 @@ namespace NzbDrone.Api.Config
|
|||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FluentValidation;
|
||||
using Nancy;
|
||||
|
@ -24,8 +24,7 @@ namespace NzbDrone.Api.Indexers
|
|||
private readonly IPrioritizeDownloadDecision _prioritizeDownloadDecision;
|
||||
private readonly IDownloadService _downloadService;
|
||||
private readonly Logger _logger;
|
||||
|
||||
private readonly ICached<RemoteEpisode> _remoteEpisodeCache;
|
||||
|
||||
private readonly ICached<RemoteMovie> _remoteMovieCache;
|
||||
|
||||
public ReleaseModule(IFetchAndParseRss rssFetcherAndParser,
|
||||
|
@ -48,44 +47,23 @@ namespace NzbDrone.Api.Indexers
|
|||
|
||||
//PostValidator.RuleFor(s => s.DownloadAllowed).Equal(true);
|
||||
PostValidator.RuleFor(s => s.Guid).NotEmpty();
|
||||
|
||||
_remoteEpisodeCache = cacheManager.GetCache<RemoteEpisode>(GetType(), "remoteEpisodes");
|
||||
|
||||
_remoteMovieCache = cacheManager.GetCache<RemoteMovie>(GetType(), "remoteMovies");
|
||||
}
|
||||
|
||||
private Response DownloadRelease(ReleaseResource release)
|
||||
{
|
||||
var remoteEpisode = _remoteEpisodeCache.Find(release.Guid);
|
||||
var remoteMovie = _remoteMovieCache.Find(release.Guid);
|
||||
|
||||
if (remoteEpisode == null)
|
||||
if (remoteMovie == null)
|
||||
{
|
||||
_logger.Debug("Couldn't find requested release in cache, cache timeout probably expired.");
|
||||
|
||||
var remoteMovie = _remoteMovieCache.Find(release.Guid);
|
||||
|
||||
if (remoteMovie == null)
|
||||
{
|
||||
return new NotFoundResponse();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_downloadService.DownloadReport(remoteMovie, false);
|
||||
}
|
||||
catch (ReleaseDownloadException ex)
|
||||
{
|
||||
_logger.Error(ex, ex.Message);
|
||||
throw new NzbDroneClientException(HttpStatusCode.Conflict, "Getting release from indexer failed");
|
||||
}
|
||||
|
||||
return release.AsResponse();
|
||||
|
||||
|
||||
return new NotFoundResponse();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_downloadService.DownloadReport(remoteEpisode);
|
||||
_downloadService.DownloadReport(remoteMovie, false);
|
||||
}
|
||||
catch (ReleaseDownloadException ex)
|
||||
{
|
||||
|
@ -98,11 +76,6 @@ namespace NzbDrone.Api.Indexers
|
|||
|
||||
private List<ReleaseResource> GetReleases()
|
||||
{
|
||||
if (Request.Query.episodeId != null)
|
||||
{
|
||||
return GetEpisodeReleases(Request.Query.episodeId);
|
||||
}
|
||||
|
||||
if (Request.Query.movieId != null)
|
||||
{
|
||||
return GetMovieReleases(Request.Query.movieId);
|
||||
|
@ -111,23 +84,6 @@ namespace NzbDrone.Api.Indexers
|
|||
return GetRss();
|
||||
}
|
||||
|
||||
private List<ReleaseResource> GetEpisodeReleases(int episodeId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var decisions = _nzbSearchService.EpisodeSearch(episodeId, true);
|
||||
var prioritizedDecisions = _prioritizeDownloadDecision.PrioritizeDecisions(decisions);
|
||||
|
||||
return MapDecisions(prioritizedDecisions);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error(ex, "Episode search failed: " + ex.Message);
|
||||
}
|
||||
|
||||
return new List<ReleaseResource>();
|
||||
}
|
||||
|
||||
private List<ReleaseResource> GetMovieReleases(int movieId)
|
||||
{
|
||||
try
|
||||
|
@ -153,23 +109,17 @@ namespace NzbDrone.Api.Indexers
|
|||
{
|
||||
var reports = _rssFetcherAndParser.Fetch();
|
||||
var decisions = _downloadDecisionMaker.GetRssDecision(reports);
|
||||
var prioritizedDecisions = _prioritizeDownloadDecision.PrioritizeDecisions(decisions);
|
||||
var prioritizedDecisions = _prioritizeDownloadDecision.PrioritizeDecisionsForMovies(decisions);
|
||||
|
||||
return MapDecisions(prioritizedDecisions);
|
||||
}
|
||||
|
||||
protected override ReleaseResource MapDecision(DownloadDecision decision, int initialWeight)
|
||||
{
|
||||
if (decision.IsForMovie)
|
||||
{
|
||||
_remoteMovieCache.Set(decision.RemoteMovie.Release.Guid, decision.RemoteMovie, TimeSpan.FromMinutes(30));
|
||||
}
|
||||
else
|
||||
{
|
||||
_remoteEpisodeCache.Set(decision.RemoteEpisode.Release.Guid, decision.RemoteEpisode, TimeSpan.FromMinutes(30));
|
||||
}
|
||||
|
||||
_remoteMovieCache.Set(decision.RemoteMovie.Release.Guid, decision.RemoteMovie, TimeSpan.FromMinutes(30));
|
||||
|
||||
return base.MapDecision(decision, initialWeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using NzbDrone.Api.REST;
|
||||
|
@ -48,7 +48,7 @@ namespace NzbDrone.Api.Indexers
|
|||
public int ReleaseWeight { get; set; }
|
||||
public int SuspectedMovieId { get; set; }
|
||||
|
||||
public IEnumerable<string> IndexerFlags { get; set; }
|
||||
public IEnumerable<string> IndexerFlags { get; set; }
|
||||
|
||||
public string MagnetUrl { get; set; }
|
||||
public string InfoHash { get; set; }
|
||||
|
@ -86,90 +86,31 @@ namespace NzbDrone.Api.Indexers
|
|||
{
|
||||
public static ReleaseResource ToResource(this DownloadDecision model)
|
||||
{
|
||||
var releaseInfo = model.RemoteEpisode.Release;
|
||||
var parsedEpisodeInfo = model.RemoteEpisode.ParsedEpisodeInfo;
|
||||
var remoteEpisode = model.RemoteEpisode;
|
||||
var torrentInfo = (model.RemoteEpisode.Release as TorrentInfo) ?? new TorrentInfo();
|
||||
var releaseInfo = model.RemoteMovie.Release;
|
||||
var remoteMovie = model.RemoteMovie;
|
||||
var torrentInfo = (model.RemoteMovie.Release as TorrentInfo) ?? new TorrentInfo();
|
||||
var mappingResult = MappingResultType.Success;
|
||||
if (model.IsForMovie)
|
||||
{
|
||||
mappingResult = model.RemoteMovie.MappingResult;
|
||||
var parsedMovieInfo = model.RemoteMovie.ParsedMovieInfo;
|
||||
var movieId = model.RemoteMovie.Movie?.Id ?? 0;
|
||||
mappingResult = model.RemoteMovie.MappingResult;
|
||||
var parsedMovieInfo = model.RemoteMovie.ParsedMovieInfo;
|
||||
var movieId = model.RemoteMovie.Movie?.Id ?? 0; //Why not pull this out in frontend instead of passing another variable
|
||||
|
||||
return new ReleaseResource
|
||||
{
|
||||
Guid = releaseInfo.Guid,
|
||||
Quality = parsedMovieInfo.Quality,
|
||||
QualityWeight = parsedMovieInfo.Quality.Quality.Id, //Id kinda hacky for wheight, but what you gonna do? TODO: Fix this shit!
|
||||
Age = releaseInfo.Age,
|
||||
AgeHours = releaseInfo.AgeHours,
|
||||
AgeMinutes = releaseInfo.AgeMinutes,
|
||||
Size = releaseInfo.Size,
|
||||
IndexerId = releaseInfo.IndexerId,
|
||||
Indexer = releaseInfo.Indexer,
|
||||
ReleaseGroup = parsedMovieInfo.ReleaseGroup,
|
||||
ReleaseHash = parsedMovieInfo.ReleaseHash,
|
||||
Title = releaseInfo.Title,
|
||||
//FullSeason = parsedMovieInfo.FullSeason,
|
||||
//SeasonNumber = parsedMovieInfo.SeasonNumber,
|
||||
Language = parsedMovieInfo.Language,
|
||||
Year = parsedMovieInfo.Year,
|
||||
MovieTitle = parsedMovieInfo.MovieTitle,
|
||||
EpisodeNumbers = new int[0],
|
||||
AbsoluteEpisodeNumbers = new int[0],
|
||||
Approved = model.Approved,
|
||||
TemporarilyRejected = model.TemporarilyRejected,
|
||||
Rejected = model.Rejected,
|
||||
TvdbId = releaseInfo.TvdbId,
|
||||
TvRageId = releaseInfo.TvRageId,
|
||||
Rejections = model.Rejections.Select(r => r.Reason).ToList(),
|
||||
PublishDate = releaseInfo.PublishDate,
|
||||
CommentUrl = releaseInfo.CommentUrl,
|
||||
DownloadUrl = releaseInfo.DownloadUrl,
|
||||
InfoUrl = releaseInfo.InfoUrl,
|
||||
MappingResult = mappingResult,
|
||||
//ReleaseWeight
|
||||
|
||||
SuspectedMovieId = movieId,
|
||||
|
||||
MagnetUrl = torrentInfo.MagnetUrl,
|
||||
InfoHash = torrentInfo.InfoHash,
|
||||
Seeders = torrentInfo.Seeders,
|
||||
Leechers = (torrentInfo.Peers.HasValue && torrentInfo.Seeders.HasValue) ? (torrentInfo.Peers.Value - torrentInfo.Seeders.Value) : (int?)null,
|
||||
Protocol = releaseInfo.DownloadProtocol,
|
||||
IndexerFlags = torrentInfo.IndexerFlags.ToString().Split(new string[] { ", " }, StringSplitOptions.None),
|
||||
Edition = parsedMovieInfo.Edition,
|
||||
|
||||
IsDaily = false,
|
||||
IsAbsoluteNumbering = false,
|
||||
IsPossibleSpecialEpisode = false,
|
||||
//Special = parsedMovieInfo.Special,
|
||||
};
|
||||
}
|
||||
|
||||
// TODO: Clean this mess up. don't mix data from multiple classes, use sub-resources instead? (Got a huge Deja Vu, didn't we talk about this already once?)
|
||||
return new ReleaseResource
|
||||
{
|
||||
Guid = releaseInfo.Guid,
|
||||
Quality = parsedEpisodeInfo.Quality,
|
||||
//QualityWeight
|
||||
Quality = parsedMovieInfo.Quality,
|
||||
QualityWeight = parsedMovieInfo.Quality.Quality.Id, //Id kinda hacky for wheight, but what you gonna do? TODO: Fix this shit!
|
||||
Age = releaseInfo.Age,
|
||||
AgeHours = releaseInfo.AgeHours,
|
||||
AgeMinutes = releaseInfo.AgeMinutes,
|
||||
Size = releaseInfo.Size,
|
||||
IndexerId = releaseInfo.IndexerId,
|
||||
Indexer = releaseInfo.Indexer,
|
||||
ReleaseGroup = parsedEpisodeInfo.ReleaseGroup,
|
||||
ReleaseHash = parsedEpisodeInfo.ReleaseHash,
|
||||
ReleaseGroup = parsedMovieInfo.ReleaseGroup,
|
||||
ReleaseHash = parsedMovieInfo.ReleaseHash,
|
||||
Title = releaseInfo.Title,
|
||||
FullSeason = parsedEpisodeInfo.FullSeason,
|
||||
SeasonNumber = parsedEpisodeInfo.SeasonNumber,
|
||||
Language = parsedEpisodeInfo.Language,
|
||||
//AirDate = parsedEpisodeInfo.AirDate,
|
||||
//SeriesTitle = parsedEpisodeInfo.SeriesTitle,
|
||||
EpisodeNumbers = parsedEpisodeInfo.EpisodeNumbers,
|
||||
AbsoluteEpisodeNumbers = parsedEpisodeInfo.AbsoluteEpisodeNumbers,
|
||||
Language = parsedMovieInfo.Language,
|
||||
Year = parsedMovieInfo.Year,
|
||||
MovieTitle = parsedMovieInfo.MovieTitle,
|
||||
Approved = model.Approved,
|
||||
TemporarilyRejected = model.TemporarilyRejected,
|
||||
Rejected = model.Rejected,
|
||||
|
@ -180,19 +121,20 @@ namespace NzbDrone.Api.Indexers
|
|||
CommentUrl = releaseInfo.CommentUrl,
|
||||
DownloadUrl = releaseInfo.DownloadUrl,
|
||||
InfoUrl = releaseInfo.InfoUrl,
|
||||
//DownloadAllowed = downloadAllowed,
|
||||
MappingResult = mappingResult,
|
||||
//ReleaseWeight
|
||||
|
||||
SuspectedMovieId = movieId,
|
||||
|
||||
MagnetUrl = torrentInfo.MagnetUrl,
|
||||
InfoHash = torrentInfo.InfoHash,
|
||||
Seeders = torrentInfo.Seeders,
|
||||
Leechers = (torrentInfo.Peers.HasValue && torrentInfo.Seeders.HasValue) ? (torrentInfo.Peers.Value - torrentInfo.Seeders.Value) : (int?)null,
|
||||
Protocol = releaseInfo.DownloadProtocol,
|
||||
|
||||
IsDaily = parsedEpisodeInfo.IsDaily,
|
||||
IsAbsoluteNumbering = parsedEpisodeInfo.IsAbsoluteNumbering,
|
||||
IsPossibleSpecialEpisode = parsedEpisodeInfo.IsPossibleSpecialEpisode,
|
||||
Special = parsedEpisodeInfo.Special,
|
||||
IndexerFlags = torrentInfo.IndexerFlags.ToString().Split(new string[] { ", " }, StringSplitOptions.None),
|
||||
Edition = parsedMovieInfo.Edition,
|
||||
|
||||
//Special = parsedMovieInfo.Special,
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -232,4 +174,4 @@ namespace NzbDrone.Api.Indexers
|
|||
return model;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NzbDrone.Core.MediaFiles.EpisodeImport.Manual;
|
||||
using NzbDrone.Core.MediaFiles.MovieImport.Manual;
|
||||
using NzbDrone.Core.Qualities;
|
||||
|
||||
namespace NzbDrone.Api.ManualImport
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace NzbDrone.Api.ManualImport
|
|||
|
||||
public static class ManualImportResourceMapper
|
||||
{
|
||||
public static ManualImportResource ToResource(this Core.MediaFiles.EpisodeImport.Manual.ManualImportItem model)
|
||||
public static ManualImportResource ToResource(this Core.MediaFiles.MovieImport.Manual.ManualImportItem model)
|
||||
{
|
||||
if (model == null) return null;
|
||||
|
||||
|
@ -43,7 +43,7 @@ namespace NzbDrone.Api.ManualImport
|
|||
};
|
||||
}
|
||||
|
||||
public static List<ManualImportResource> ToResource(this IEnumerable<Core.MediaFiles.EpisodeImport.Manual.ManualImportItem> models)
|
||||
public static List<ManualImportResource> ToResource(this IEnumerable<Core.MediaFiles.MovieImport.Manual.ManualImportItem> models)
|
||||
{
|
||||
return models.Select(ToResource).ToList();
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ using NzbDrone.Core.Datastore.Events;
|
|||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.MediaFiles.Events;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
using NzbDrone.SignalR;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ using System.Linq;
|
|||
using NzbDrone.Api.REST;
|
||||
using NzbDrone.Api.Movies;
|
||||
using NzbDrone.Core.MediaCover;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
|
||||
|
|
|
@ -8,14 +8,14 @@ using NzbDrone.Common.Cache;
|
|||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.MediaCover;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.MediaFiles.EpisodeImport;
|
||||
using NzbDrone.Core.MediaFiles.MovieImport;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
using NzbDrone.Core.MetadataSource;
|
||||
using NzbDrone.Core.MetadataSource.RadarrAPI;
|
||||
using NzbDrone.Core.Movies.AlternativeTitles;
|
||||
using NzbDrone.Core.RootFolders;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Tv.Events;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.Movies.Events;
|
||||
|
||||
namespace NzbDrone.Api.Movies
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using NzbDrone.Api.REST;
|
||||
using NzbDrone.Core.MediaCover;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Movies.AlternativeTitles;
|
||||
|
|
|
@ -9,14 +9,14 @@ using NzbDrone.Common.Extensions;
|
|||
using NzbDrone.Common.Messaging;
|
||||
using NzbDrone.Core.MediaCover;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.MediaFiles.EpisodeImport;
|
||||
using NzbDrone.Core.MediaFiles.MovieImport;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
using NzbDrone.Core.MetadataSource;
|
||||
using NzbDrone.Core.MetadataSource.RadarrAPI;
|
||||
using NzbDrone.Core.Movies.AlternativeTitles;
|
||||
using NzbDrone.Core.RootFolders;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Tv.Events;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.Movies.Events;
|
||||
|
||||
namespace NzbDrone.Api.Movies
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using NzbDrone.Api.REST;
|
||||
using NzbDrone.Core.MediaCover;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Movies.AlternativeTitles;
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace NzbDrone.Api.Movies
|
|||
{
|
||||
var results = _fetchNetImport.FetchAndFilter((int) Request.Query.listId, false);
|
||||
|
||||
List<Core.Tv.Movie> realResults = new List<Core.Tv.Movie>();
|
||||
List<Core.Movies.Movie> realResults = new List<Core.Movies.Movie>();
|
||||
|
||||
/*foreach (var movie in results)
|
||||
{
|
||||
|
@ -42,7 +42,7 @@ namespace NzbDrone.Api.Movies
|
|||
}
|
||||
|
||||
|
||||
private static IEnumerable<MovieResource> MapToResource(IEnumerable<Core.Tv.Movie> movies)
|
||||
private static IEnumerable<MovieResource> MapToResource(IEnumerable<Core.Movies.Movie> movies)
|
||||
{
|
||||
foreach (var currentSeries in movies)
|
||||
{
|
||||
|
|
|
@ -10,10 +10,10 @@ using Marr.Data;
|
|||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.MediaFiles.EpisodeImport;
|
||||
using NzbDrone.Core.MediaFiles.MovieImport;
|
||||
using NzbDrone.Core.RootFolders;
|
||||
using NzbDrone.Common.Cache;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
|
||||
namespace NzbDrone.Api.Movies
|
||||
{
|
||||
|
@ -32,7 +32,7 @@ namespace NzbDrone.Api.Movies
|
|||
private readonly IRootFolderService _rootFolderService;
|
||||
private readonly IMakeImportDecision _importDecisionMaker;
|
||||
private readonly IDiskScanService _diskScanService;
|
||||
private readonly ICached<Core.Tv.Movie> _mappedMovies;
|
||||
private readonly ICached<Core.Movies.Movie> _mappedMovies;
|
||||
private readonly IMovieService _movieService;
|
||||
|
||||
public MovieBulkImportModule(ISearchForNewMovie searchProxy, IRootFolderService rootFolderService, IMakeImportDecision importDecisionMaker,
|
||||
|
@ -43,7 +43,7 @@ namespace NzbDrone.Api.Movies
|
|||
_rootFolderService = rootFolderService;
|
||||
_importDecisionMaker = importDecisionMaker;
|
||||
_diskScanService = diskScanService;
|
||||
_mappedMovies = cacheManager.GetCache<Core.Tv.Movie>(GetType(), "mappedMoviesCache");
|
||||
_mappedMovies = cacheManager.GetCache<Core.Movies.Movie>(GetType(), "mappedMoviesCache");
|
||||
_movieService = movieService;
|
||||
Get["/"] = x => Search();
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ namespace NzbDrone.Api.Movies
|
|||
|
||||
var mapped = paged.Select(f =>
|
||||
{
|
||||
Core.Tv.Movie m = null;
|
||||
Core.Movies.Movie m = null;
|
||||
|
||||
var mappedMovie = _mappedMovies.Find(f.Name);
|
||||
|
||||
|
@ -92,7 +92,7 @@ namespace NzbDrone.Api.Movies
|
|||
var parsedTitle = Parser.ParseMoviePath(f.Name, false);
|
||||
if (parsedTitle == null)
|
||||
{
|
||||
m = new Core.Tv.Movie
|
||||
m = new Core.Movies.Movie
|
||||
{
|
||||
Title = f.Name.Replace(".", " ").Replace("-", " "),
|
||||
Path = f.Path,
|
||||
|
@ -100,7 +100,7 @@ namespace NzbDrone.Api.Movies
|
|||
}
|
||||
else
|
||||
{
|
||||
m = new Core.Tv.Movie
|
||||
m = new Core.Movies.Movie
|
||||
{
|
||||
Title = parsedTitle.MovieTitle,
|
||||
Year = parsedTitle.Year,
|
||||
|
@ -156,7 +156,7 @@ namespace NzbDrone.Api.Movies
|
|||
}
|
||||
|
||||
|
||||
private static IEnumerable<MovieResource> MapToResource(IEnumerable<Core.Tv.Movie> movies)
|
||||
private static IEnumerable<MovieResource> MapToResource(IEnumerable<Core.Movies.Movie> movies)
|
||||
{
|
||||
foreach (var currentMovie in movies)
|
||||
{
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace NzbDrone.Api.Movies
|
|||
}).AsResponse();
|
||||
}
|
||||
|
||||
private static IEnumerable<MovieResource> MapToResource(IEnumerable<Core.Tv.Movie> movies)
|
||||
private static IEnumerable<MovieResource> MapToResource(IEnumerable<Core.Movies.Movie> movies)
|
||||
{
|
||||
foreach (var currentSeries in movies)
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@ using Nancy;
|
|||
using Nancy.Responses;
|
||||
using NzbDrone.Api.Extensions;
|
||||
using NzbDrone.Api.REST;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
|
||||
namespace NzbDrone.Api.Movies
|
||||
{
|
||||
|
|
|
@ -49,7 +49,7 @@ namespace NzbDrone.Api.Movies
|
|||
return MapToResource(imdbResults).AsResponse();
|
||||
}
|
||||
|
||||
private static IEnumerable<MovieResource> MapToResource(IEnumerable<Core.Tv.Movie> movies)
|
||||
private static IEnumerable<MovieResource> MapToResource(IEnumerable<Core.Movies.Movie> movies)
|
||||
{
|
||||
foreach (var currentSeries in movies)
|
||||
{
|
||||
|
|
|
@ -9,11 +9,9 @@ using NzbDrone.Core.MediaCover;
|
|||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.MediaFiles.Events;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
using NzbDrone.Core.MovieStats;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Tv.Events;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.Movies.Events;
|
||||
using NzbDrone.Core.Validation.Paths;
|
||||
using NzbDrone.Core.DataAugmentation.Scene;
|
||||
using NzbDrone.Core.Validation;
|
||||
using NzbDrone.SignalR;
|
||||
using NzbDrone.Core.Datastore;
|
||||
|
@ -22,8 +20,8 @@ using Nancy;
|
|||
|
||||
namespace NzbDrone.Api.Movies
|
||||
{
|
||||
public class MovieModule : NzbDroneRestModuleWithSignalR<MovieResource, Core.Tv.Movie>,
|
||||
IHandle<MovieImportedEvent>,
|
||||
public class MovieModule : NzbDroneRestModuleWithSignalR<MovieResource, Core.Movies.Movie>,
|
||||
IHandle<MovieImportedEvent>,
|
||||
IHandle<MovieFileDeletedEvent>,
|
||||
IHandle<MovieUpdatedEvent>,
|
||||
IHandle<MovieEditedEvent>,
|
||||
|
@ -33,15 +31,12 @@ namespace NzbDrone.Api.Movies
|
|||
|
||||
{
|
||||
protected readonly IMovieService _moviesService;
|
||||
private readonly IMovieStatisticsService _moviesStatisticsService;
|
||||
private readonly IMapCoversToLocal _coverMapper;
|
||||
|
||||
private const string TITLE_SLUG_ROUTE = "/titleslug/(?<slug>[^/]+)";
|
||||
|
||||
public MovieModule(IBroadcastSignalRMessage signalRBroadcaster,
|
||||
IMovieService moviesService,
|
||||
IMovieStatisticsService moviesStatisticsService,
|
||||
ISceneMappingService sceneMappingService,
|
||||
IMapCoversToLocal coverMapper,
|
||||
RootFolderValidator rootFolderValidator,
|
||||
MoviePathValidator moviesPathValidator,
|
||||
|
@ -53,7 +48,6 @@ namespace NzbDrone.Api.Movies
|
|||
: base(signalRBroadcaster)
|
||||
{
|
||||
_moviesService = moviesService;
|
||||
_moviesStatisticsService = moviesStatisticsService;
|
||||
|
||||
_coverMapper = coverMapper;
|
||||
|
||||
|
@ -93,14 +87,11 @@ namespace NzbDrone.Api.Movies
|
|||
|
||||
public MovieModule(IBroadcastSignalRMessage signalRBroadcaster,
|
||||
IMovieService moviesService,
|
||||
IMovieStatisticsService moviesStatisticsService,
|
||||
ISceneMappingService sceneMappingService,
|
||||
IMapCoversToLocal coverMapper,
|
||||
string resource)
|
||||
: base(signalRBroadcaster, resource)
|
||||
{
|
||||
_moviesService = moviesService;
|
||||
_moviesStatisticsService = moviesStatisticsService;
|
||||
|
||||
_coverMapper = coverMapper;
|
||||
|
||||
|
@ -119,14 +110,14 @@ namespace NzbDrone.Api.Movies
|
|||
|
||||
private PagingResource<MovieResource> GetMoviePaged(PagingResource<MovieResource> pagingResource)
|
||||
{
|
||||
var pagingSpec = pagingResource.MapToPagingSpec<MovieResource, Core.Tv.Movie>();
|
||||
var pagingSpec = pagingResource.MapToPagingSpec<MovieResource, Core.Movies.Movie>();
|
||||
|
||||
pagingSpec.FilterExpression = _moviesService.ConstructFilterExpression(pagingResource.FilterKey, pagingResource.FilterValue, pagingResource.FilterType);
|
||||
|
||||
return ApplyToPage(_moviesService.Paged, pagingSpec, MapToResource);
|
||||
}
|
||||
|
||||
protected MovieResource MapToResource(Core.Tv.Movie movies)
|
||||
protected MovieResource MapToResource(Core.Movies.Movie movies)
|
||||
{
|
||||
if (movies == null) return null;
|
||||
|
||||
|
@ -140,11 +131,11 @@ namespace NzbDrone.Api.Movies
|
|||
|
||||
private List<MovieResource> AllMovie()
|
||||
{
|
||||
var moviesStats = _moviesStatisticsService.MovieStatistics();
|
||||
//var moviesStats = _moviesStatisticsService.MovieStatistics();
|
||||
var moviesResources = _moviesService.GetAllMovies().ToResource();
|
||||
|
||||
MapCoversToLocal(moviesResources.ToArray());
|
||||
LinkMovieStatistics(moviesResources, moviesStats);
|
||||
//LinkMovieStatistics(moviesResources, moviesStats);
|
||||
PopulateAlternateTitles(moviesResources);
|
||||
|
||||
return moviesResources;
|
||||
|
@ -216,28 +207,28 @@ namespace NzbDrone.Api.Movies
|
|||
}
|
||||
}
|
||||
|
||||
private void FetchAndLinkMovieStatistics(MovieResource resource)
|
||||
{
|
||||
LinkMovieStatistics(resource, _moviesStatisticsService.MovieStatistics(resource.Id));
|
||||
}
|
||||
//private void FetchAndLinkMovieStatistics(MovieResource resource)
|
||||
//{
|
||||
// LinkMovieStatistics(resource, _moviesStatisticsService.MovieStatistics(resource.Id));
|
||||
//}
|
||||
|
||||
private void LinkMovieStatistics(List<MovieResource> resources, List<MovieStatistics> moviesStatistics)
|
||||
{
|
||||
var dictMovieStats = moviesStatistics.ToDictionary(v => v.MovieId);
|
||||
//private void LinkMovieStatistics(List<MovieResource> resources, List<MovieStatistics> moviesStatistics)
|
||||
//{
|
||||
// var dictMovieStats = moviesStatistics.ToDictionary(v => v.MovieId);
|
||||
|
||||
foreach (var movies in resources)
|
||||
{
|
||||
var stats = dictMovieStats.GetValueOrDefault(movies.Id);
|
||||
if (stats == null) continue;
|
||||
// foreach (var movies in resources)
|
||||
// {
|
||||
// var stats = dictMovieStats.GetValueOrDefault(movies.Id);
|
||||
// if (stats == null) continue;
|
||||
|
||||
LinkMovieStatistics(movies, stats);
|
||||
}
|
||||
}
|
||||
// LinkMovieStatistics(movies, stats);
|
||||
// }
|
||||
//}
|
||||
|
||||
private void LinkMovieStatistics(MovieResource resource, MovieStatistics moviesStatistics)
|
||||
{
|
||||
//resource.SizeOnDisk = 0;//TODO: incorporate movie statistics moviesStatistics.SizeOnDisk;
|
||||
}
|
||||
//private void LinkMovieStatistics(MovieResource resource, MovieStatistics moviesStatistics)
|
||||
//{
|
||||
// //resource.SizeOnDisk = 0;//TODO: incorporate movie statistics moviesStatistics.SizeOnDisk;
|
||||
//}
|
||||
|
||||
private void PopulateAlternateTitles(List<MovieResource> resources)
|
||||
{
|
||||
|
|
|
@ -4,12 +4,12 @@ using NzbDrone.Core.DecisionEngine;
|
|||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.MediaFiles.Events;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.SignalR;
|
||||
|
||||
namespace NzbDrone.Api.Movies
|
||||
{
|
||||
public abstract class MovieModuleWithSignalR : NzbDroneRestModuleWithSignalR<MovieResource, Core.Tv.Movie>,
|
||||
public abstract class MovieModuleWithSignalR : NzbDroneRestModuleWithSignalR<MovieResource, Core.Movies.Movie>,
|
||||
IHandle<MovieGrabbedEvent>,
|
||||
IHandle<MovieDownloadedEvent>
|
||||
{
|
||||
|
@ -46,7 +46,7 @@ namespace NzbDrone.Api.Movies
|
|||
return resource;
|
||||
}
|
||||
|
||||
protected MovieResource MapToResource(Core.Tv.Movie episode, bool includeSeries)
|
||||
protected MovieResource MapToResource(Core.Movies.Movie episode, bool includeSeries)
|
||||
{
|
||||
var resource = episode.ToResource();
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using NzbDrone.Api.REST;
|
||||
using NzbDrone.Core.MediaCover;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Api.MovieFiles;
|
||||
|
||||
namespace NzbDrone.Api.Movies
|
||||
|
@ -88,7 +88,7 @@ namespace NzbDrone.Api.Movies
|
|||
|
||||
public static class MovieResourceMapper
|
||||
{
|
||||
public static MovieResource ToResource(this Core.Tv.Movie model)
|
||||
public static MovieResource ToResource(this Core.Movies.Movie model)
|
||||
{
|
||||
if (model == null) return null;
|
||||
|
||||
|
@ -171,11 +171,11 @@ namespace NzbDrone.Api.Movies
|
|||
};
|
||||
}
|
||||
|
||||
public static Core.Tv.Movie ToModel(this MovieResource resource)
|
||||
public static Core.Movies.Movie ToModel(this MovieResource resource)
|
||||
{
|
||||
if (resource == null) return null;
|
||||
|
||||
return new Core.Tv.Movie
|
||||
return new Core.Movies.Movie
|
||||
{
|
||||
Id = resource.Id,
|
||||
TmdbId = resource.TmdbId,
|
||||
|
@ -225,7 +225,7 @@ namespace NzbDrone.Api.Movies
|
|||
};
|
||||
}
|
||||
|
||||
public static Core.Tv.Movie ToModel(this MovieResource resource, Core.Tv.Movie movie)
|
||||
public static Core.Movies.Movie ToModel(this MovieResource resource, Core.Movies.Movie movie)
|
||||
{
|
||||
movie.ImdbId = resource.ImdbId;
|
||||
movie.TmdbId = resource.TmdbId;
|
||||
|
@ -244,7 +244,7 @@ namespace NzbDrone.Api.Movies
|
|||
return movie;
|
||||
}
|
||||
|
||||
public static List<MovieResource> ToResource(this IEnumerable<Core.Tv.Movie> movies)
|
||||
public static List<MovieResource> ToResource(this IEnumerable<Core.Movies.Movie> movies)
|
||||
{
|
||||
return movies.Select(ToResource).ToList();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NzbDrone.Core.NetImport;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
|
||||
namespace NzbDrone.Api.NetImport
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@ using Nancy.Extensions;
|
|||
using NzbDrone.Api.Extensions;
|
||||
using NzbDrone.Api.Movies;
|
||||
using NzbDrone.Core.MetadataSource;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
|
||||
namespace NzbDrone.Api.NetImport
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
|
||||
namespace NzbDrone.Api.NetImport
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@ using NzbDrone.SignalR;
|
|||
namespace NzbDrone.Api.Series
|
||||
{
|
||||
[Obsolete("SeriesModule is Obsolete, Remove with new UI")]
|
||||
public class SeriesModule : NzbDroneRestModuleWithSignalR<SeriesResource, Core.Tv.Series>
|
||||
public class SeriesModule : NzbDroneRestModuleWithSignalR<SeriesResource, Core.Movies.Movie>
|
||||
|
||||
{
|
||||
public SeriesModule(IBroadcastSignalRMessage signalRBroadcaster
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using NzbDrone.Api.Movies;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.SignalR;
|
||||
|
||||
|
@ -22,7 +22,7 @@ namespace NzbDrone.Api.Wanted
|
|||
|
||||
private PagingResource<MovieResource> GetCutoffUnmetMovies(PagingResource<MovieResource> pagingResource)
|
||||
{
|
||||
var pagingSpec = pagingResource.MapToPagingSpec<MovieResource, Core.Tv.Movie>("title", SortDirection.Ascending);
|
||||
var pagingSpec = pagingResource.MapToPagingSpec<MovieResource, Core.Movies.Movie>("title", SortDirection.Ascending);
|
||||
|
||||
pagingSpec.FilterExpression = _movieService.ConstructFilterExpression(pagingResource.FilterKey, pagingResource.FilterValue);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using NzbDrone.Api.Movies;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.SignalR;
|
||||
using NzbDrone.Core.Download;
|
||||
|
@ -27,7 +27,7 @@ namespace NzbDrone.Api.Wanted
|
|||
|
||||
private PagingResource<MovieResource> GetMissingMovies(PagingResource<MovieResource> pagingResource)
|
||||
{
|
||||
var pagingSpec = pagingResource.MapToPagingSpec<MovieResource, Core.Tv.Movie>("title", SortDirection.Descending);
|
||||
var pagingSpec = pagingResource.MapToPagingSpec<MovieResource, Core.Movies.Movie>("title", SortDirection.Descending);
|
||||
|
||||
pagingSpec.FilterExpression = _movieService.ConstructFilterExpression(pagingResource.FilterKey, pagingResource.FilterValue);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
|
@ -77,8 +77,8 @@ namespace NzbDrone.App.Test
|
|||
[Test]
|
||||
public void should_return_same_instance_of_singletons_by_different_same_interface()
|
||||
{
|
||||
var first = _container.ResolveAll<IHandle<EpisodeGrabbedEvent>>().OfType<DownloadMonitoringService>().Single();
|
||||
var second = _container.ResolveAll<IHandle<EpisodeGrabbedEvent>>().OfType<DownloadMonitoringService>().Single();
|
||||
var first = _container.ResolveAll<IHandle<MovieGrabbedEvent>>().OfType<DownloadMonitoringService>().Single();
|
||||
var second = _container.ResolveAll<IHandle<MovieGrabbedEvent>>().OfType<DownloadMonitoringService>().Single();
|
||||
|
||||
first.Should().BeSameAs(second);
|
||||
}
|
||||
|
@ -86,10 +86,10 @@ namespace NzbDrone.App.Test
|
|||
[Test]
|
||||
public void should_return_same_instance_of_singletons_by_different_interfaces()
|
||||
{
|
||||
var first = _container.ResolveAll<IHandle<EpisodeGrabbedEvent>>().OfType<DownloadMonitoringService>().Single();
|
||||
var first = _container.ResolveAll<IHandle<MovieGrabbedEvent>>().OfType<DownloadMonitoringService>().Single();
|
||||
var second = (DownloadMonitoringService)_container.Resolve<IExecute<CheckForFinishedDownloadCommand>>();
|
||||
|
||||
first.Should().BeSameAs(second);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
|
@ -19,9 +19,7 @@ namespace NzbDrone.Core.Test.Blacklisting
|
|||
{
|
||||
_blacklist = new Blacklist
|
||||
{
|
||||
SeriesId = 12345,
|
||||
MovieId = 1234,
|
||||
EpisodeIds = new List<int> { 1 },
|
||||
Quality = new QualityModel(Quality.Bluray720p),
|
||||
SourceTitle = "series.title.s01e01",
|
||||
Date = DateTime.UtcNow
|
||||
|
@ -40,7 +38,7 @@ namespace NzbDrone.Core.Test.Blacklisting
|
|||
{
|
||||
Subject.Insert(_blacklist);
|
||||
|
||||
Subject.All().First().EpisodeIds.Should().Contain(_blacklist.EpisodeIds);
|
||||
Subject.All().First().MovieId.Should().Be(_blacklist.MovieId);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
|
@ -19,9 +19,7 @@ namespace NzbDrone.Core.Test.Blacklisting
|
|||
{
|
||||
_event = new DownloadFailedEvent
|
||||
{
|
||||
SeriesId = 0,
|
||||
MovieId = 69,
|
||||
EpisodeIds = null,
|
||||
Quality = new QualityModel(Quality.Bluray720p),
|
||||
SourceTitle = "series.title.s01e01",
|
||||
DownloadClient = "SabnzbdClient",
|
||||
|
|
|
@ -3,9 +3,9 @@ using FluentAssertions;
|
|||
using NUnit.Framework;
|
||||
using Moq;
|
||||
using NzbDrone.Core.Organizer;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv.Events;
|
||||
using NzbDrone.Core.Movies.Events;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NzbDrone.Core.Test.BulkImport
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.DataAugmentation.DailySeries;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.Categories;
|
||||
|
||||
namespace NzbDrone.Core.Test.DataAugmentation.DailySeries
|
||||
{
|
||||
[TestFixture]
|
||||
[IntegrationTest]
|
||||
public class DailySeriesDataProxyFixture : CoreTest<DailySeriesDataProxy>
|
||||
{
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
UseRealHttp();
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Ignore("Series")]
|
||||
public void should_get_list_of_daily_series()
|
||||
{
|
||||
var list = Subject.GetDailySeriesIds();
|
||||
list.Should().NotBeEmpty();
|
||||
list.Should().OnlyHaveUniqueItems();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.DataAugmentation.Scene;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.Categories;
|
||||
|
||||
namespace NzbDrone.Core.Test.DataAugmentation.Scene
|
||||
{
|
||||
[TestFixture]
|
||||
[Ignore("Series")]
|
||||
[IntegrationTest]
|
||||
public class SceneMappingProxyFixture : CoreTest<SceneMappingProxy>
|
||||
{
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
UseRealHttp();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
public void fetch_should_return_list_of_mappings()
|
||||
{
|
||||
var mappings = Subject.Fetch();
|
||||
|
||||
mappings.Should().NotBeEmpty();
|
||||
|
||||
mappings.Should().NotContain(c => c.SearchTerm.IsNullOrWhiteSpace());
|
||||
mappings.Should().NotContain(c => c.Title.IsNullOrWhiteSpace());
|
||||
mappings.Should().Contain(c => c.SeasonNumber > 0);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,337 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using FizzWare.NBuilder;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.DataAugmentation.Scene;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
using FluentAssertions;
|
||||
using NzbDrone.Common.Extensions;
|
||||
|
||||
namespace NzbDrone.Core.Test.DataAugmentation.Scene
|
||||
{
|
||||
[TestFixture]
|
||||
|
||||
public class SceneMappingServiceFixture : CoreTest<SceneMappingService>
|
||||
{
|
||||
private List<SceneMapping> _fakeMappings;
|
||||
|
||||
private Mock<ISceneMappingProvider> _provider1;
|
||||
private Mock<ISceneMappingProvider> _provider2;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_fakeMappings = Builder<SceneMapping>.CreateListOfSize(5).BuildListOfNew();
|
||||
|
||||
_fakeMappings[0].SearchTerm = "Words";
|
||||
_fakeMappings[1].SearchTerm = "That";
|
||||
_fakeMappings[2].SearchTerm = "Can";
|
||||
_fakeMappings[3].SearchTerm = "Be";
|
||||
_fakeMappings[4].SearchTerm = "Cleaned";
|
||||
|
||||
_fakeMappings[0].ParseTerm = "Words";
|
||||
_fakeMappings[1].ParseTerm = "That";
|
||||
_fakeMappings[2].ParseTerm = "Can";
|
||||
_fakeMappings[3].ParseTerm = "Be";
|
||||
_fakeMappings[4].ParseTerm = "Cleaned";
|
||||
|
||||
_provider1 = new Mock<ISceneMappingProvider>();
|
||||
_provider1.Setup(s => s.GetSceneMappings()).Returns(_fakeMappings);
|
||||
|
||||
_provider2 = new Mock<ISceneMappingProvider>();
|
||||
_provider2.Setup(s => s.GetSceneMappings()).Returns(_fakeMappings);
|
||||
}
|
||||
|
||||
private void GivenProviders(IEnumerable<Mock<ISceneMappingProvider>> providers)
|
||||
{
|
||||
Mocker.SetConstant<IEnumerable<ISceneMappingProvider>>(providers.Select(s => s.Object));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_purge_existing_mapping_and_add_new_ones()
|
||||
{
|
||||
GivenProviders(new [] { _provider1 });
|
||||
|
||||
Mocker.GetMock<ISceneMappingRepository>().Setup(c => c.All()).Returns(_fakeMappings);
|
||||
|
||||
Subject.Execute(new UpdateSceneMappingCommand());
|
||||
|
||||
AssertMappingUpdated();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_delete_if_fetch_fails()
|
||||
{
|
||||
GivenProviders(new[] { _provider1 });
|
||||
|
||||
_provider1.Setup(c => c.GetSceneMappings()).Throws(new WebException());
|
||||
|
||||
Subject.Execute(new UpdateSceneMappingCommand());
|
||||
|
||||
AssertNoUpdate();
|
||||
|
||||
ExceptionVerification.ExpectedErrors(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_delete_if_fetch_returns_empty_list()
|
||||
{
|
||||
GivenProviders(new[] { _provider1 });
|
||||
|
||||
_provider1.Setup(c => c.GetSceneMappings()).Returns(new List<SceneMapping>());
|
||||
|
||||
Subject.Execute(new UpdateSceneMappingCommand());
|
||||
|
||||
AssertNoUpdate();
|
||||
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_get_mappings_for_all_providers()
|
||||
{
|
||||
GivenProviders(new[] { _provider1, _provider2 });
|
||||
|
||||
Mocker.GetMock<ISceneMappingRepository>().Setup(c => c.All()).Returns(_fakeMappings);
|
||||
|
||||
Subject.Execute(new UpdateSceneMappingCommand());
|
||||
|
||||
_provider1.Verify(c => c.GetSceneMappings(), Times.Once());
|
||||
_provider2.Verify(c => c.GetSceneMappings(), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_refresh_cache_if_cache_is_empty_when_looking_for_tvdb_id()
|
||||
{
|
||||
Subject.FindTvdbId("title");
|
||||
|
||||
Mocker.GetMock<ISceneMappingRepository>()
|
||||
.Verify(v => v.All(), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_refresh_cache_if_cache_is_not_empty_when_looking_for_tvdb_id()
|
||||
{
|
||||
GivenProviders(new[] { _provider1 });
|
||||
|
||||
Mocker.GetMock<ISceneMappingRepository>()
|
||||
.Setup(s => s.All())
|
||||
.Returns(Builder<SceneMapping>.CreateListOfSize(1).Build());
|
||||
|
||||
|
||||
Subject.Execute(new UpdateSceneMappingCommand());
|
||||
|
||||
Mocker.GetMock<ISceneMappingRepository>()
|
||||
.Verify(v => v.All(), Times.Once());
|
||||
|
||||
Subject.FindTvdbId("title");
|
||||
|
||||
Mocker.GetMock<ISceneMappingRepository>()
|
||||
.Verify(v => v.All(), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_add_mapping_with_blank_title()
|
||||
{
|
||||
GivenProviders(new[] { _provider1 });
|
||||
|
||||
var fakeMappings = Builder<SceneMapping>.CreateListOfSize(2)
|
||||
.TheLast(1)
|
||||
.With(m => m.Title = null)
|
||||
.Build()
|
||||
.ToList();
|
||||
|
||||
_provider1.Setup(s => s.GetSceneMappings()).Returns(fakeMappings);
|
||||
|
||||
Mocker.GetMock<ISceneMappingRepository>().Setup(c => c.All()).Returns(_fakeMappings);
|
||||
|
||||
Subject.Execute(new UpdateSceneMappingCommand());
|
||||
|
||||
Mocker.GetMock<ISceneMappingRepository>().Verify(c => c.InsertMany(It.Is<IList<SceneMapping>>(m => !m.Any(s => s.Title.IsNullOrWhiteSpace()))), Times.Once());
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_add_mapping_with_blank_search_title()
|
||||
{
|
||||
GivenProviders(new[] { _provider1 });
|
||||
|
||||
var fakeMappings = Builder<SceneMapping>.CreateListOfSize(2)
|
||||
.TheLast(1)
|
||||
.With(m => m.SearchTerm = null)
|
||||
.Build()
|
||||
.ToList();
|
||||
|
||||
_provider1.Setup(s => s.GetSceneMappings()).Returns(fakeMappings);
|
||||
|
||||
Mocker.GetMock<ISceneMappingRepository>().Setup(c => c.All()).Returns(_fakeMappings);
|
||||
|
||||
Subject.Execute(new UpdateSceneMappingCommand());
|
||||
|
||||
Mocker.GetMock<ISceneMappingRepository>().Verify(c => c.InsertMany(It.Is<IList<SceneMapping>>(m => !m.Any(s => s. SearchTerm.IsNullOrWhiteSpace()))), Times.Once());
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
}
|
||||
|
||||
|
||||
[TestCase("Working!!", "Working!!", 1)]
|
||||
[TestCase("Working`!!", "Working`!!", 2)]
|
||||
[TestCase("Working!!!", "Working!!!", 3)]
|
||||
[TestCase("Working!!!!", "Working!!!", 3)]
|
||||
[TestCase("Working !!", "Working!!", 1)]
|
||||
public void should_return_single_match(string parseTitle, string title, int expectedSeasonNumber)
|
||||
{
|
||||
var mappings = new List<SceneMapping>
|
||||
{
|
||||
new SceneMapping { Title = "Working!!", ParseTerm = "working", SearchTerm = "Working!!", TvdbId = 100, SceneSeasonNumber = 1 },
|
||||
new SceneMapping { Title = "Working`!!", ParseTerm = "working", SearchTerm = "Working`!!", TvdbId = 100, SceneSeasonNumber = 2 },
|
||||
new SceneMapping { Title = "Working!!!", ParseTerm = "working", SearchTerm = "Working!!!", TvdbId = 100, SceneSeasonNumber = 3 },
|
||||
};
|
||||
|
||||
Mocker.GetMock<ISceneMappingRepository>().Setup(c => c.All()).Returns(mappings);
|
||||
|
||||
var tvdbId = Subject.FindTvdbId(parseTitle);
|
||||
var seasonNumber = Subject.GetSceneSeasonNumber(parseTitle);
|
||||
|
||||
tvdbId.Should().Be(100);
|
||||
seasonNumber.Should().Be(expectedSeasonNumber);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_alternate_title_for_global_season()
|
||||
{
|
||||
var mappings = new List<SceneMapping>
|
||||
{
|
||||
new SceneMapping { Title = "Fudanshi Koukou Seikatsu 1", ParseTerm = "fudanshikoukouseikatsu1", SearchTerm = "Fudanshi Koukou Seikatsu 1", TvdbId = 100, SeasonNumber = null, SceneSeasonNumber = null },
|
||||
new SceneMapping { Title = "Fudanshi Koukou Seikatsu 2", ParseTerm = "fudanshikoukouseikatsu2", SearchTerm = "Fudanshi Koukou Seikatsu 2", TvdbId = 100, SeasonNumber = -1, SceneSeasonNumber = null },
|
||||
new SceneMapping { Title = "Fudanshi Koukou Seikatsu 3", ParseTerm = "fudanshikoukouseikatsu3", SearchTerm = "Fudanshi Koukou Seikatsu 3", TvdbId = 100, SeasonNumber = null, SceneSeasonNumber = -1 },
|
||||
new SceneMapping { Title = "Fudanshi Koukou Seikatsu 4", ParseTerm = "fudanshikoukouseikatsu4", SearchTerm = "Fudanshi Koukou Seikatsu 4", TvdbId = 100, SeasonNumber = -1, SceneSeasonNumber = -1 },
|
||||
};
|
||||
|
||||
Mocker.GetMock<ISceneMappingRepository>().Setup(c => c.All()).Returns(mappings);
|
||||
|
||||
var names = Subject.GetSceneNames(100, new List<int> { 10 }, new List<int> { 10 });
|
||||
names.Should().HaveCount(4);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_alternate_title_for_season()
|
||||
{
|
||||
var mappings = new List<SceneMapping>
|
||||
{
|
||||
new SceneMapping { Title = "Fudanshi Koukou Seikatsu", ParseTerm = "fudanshikoukouseikatsu", SearchTerm = "Fudanshi Koukou Seikatsu", TvdbId = 100, SeasonNumber = 1, SceneSeasonNumber = null }
|
||||
};
|
||||
|
||||
Mocker.GetMock<ISceneMappingRepository>().Setup(c => c.All()).Returns(mappings);
|
||||
|
||||
var names = Subject.GetSceneNames(100, new List<int> { 1 }, new List<int> { 10 });
|
||||
names.Should().HaveCount(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_return_alternate_title_for_season()
|
||||
{
|
||||
var mappings = new List<SceneMapping>
|
||||
{
|
||||
new SceneMapping { Title = "Fudanshi Koukou Seikatsu", ParseTerm = "fudanshikoukouseikatsu", SearchTerm = "Fudanshi Koukou Seikatsu", TvdbId = 100, SeasonNumber = 1, SceneSeasonNumber = null }
|
||||
};
|
||||
|
||||
Mocker.GetMock<ISceneMappingRepository>().Setup(c => c.All()).Returns(mappings);
|
||||
|
||||
var names = Subject.GetSceneNames(100, new List<int> { 2 }, new List<int> { 10 });
|
||||
names.Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_alternate_title_for_sceneseason()
|
||||
{
|
||||
var mappings = new List<SceneMapping>
|
||||
{
|
||||
new SceneMapping { Title = "Fudanshi Koukou Seikatsu", ParseTerm = "fudanshikoukouseikatsu", SearchTerm = "Fudanshi Koukou Seikatsu", TvdbId = 100, SeasonNumber = null, SceneSeasonNumber = 1 }
|
||||
};
|
||||
|
||||
Mocker.GetMock<ISceneMappingRepository>().Setup(c => c.All()).Returns(mappings);
|
||||
|
||||
var names = Subject.GetSceneNames(100, new List<int> { 10 }, new List<int> { 1 });
|
||||
names.Should().HaveCount(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_return_alternate_title_for_sceneseason()
|
||||
{
|
||||
var mappings = new List<SceneMapping>
|
||||
{
|
||||
new SceneMapping { Title = "Fudanshi Koukou Seikatsu", ParseTerm = "fudanshikoukouseikatsu", SearchTerm = "Fudanshi Koukou Seikatsu", TvdbId = 100, SeasonNumber = null, SceneSeasonNumber = 1 }
|
||||
};
|
||||
|
||||
Mocker.GetMock<ISceneMappingRepository>().Setup(c => c.All()).Returns(mappings);
|
||||
|
||||
var names = Subject.GetSceneNames(100, new List<int> { 10 }, new List<int> { 2 });
|
||||
names.Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_alternate_title_for_fairy_tail()
|
||||
{
|
||||
var mappings = new List<SceneMapping>
|
||||
{
|
||||
new SceneMapping { Title = "Fairy Tail S2", ParseTerm = "fairytails2", SearchTerm = "Fairy Tail S2", TvdbId = 100, SeasonNumber = null, SceneSeasonNumber = 2 }
|
||||
};
|
||||
|
||||
Mocker.GetMock<ISceneMappingRepository>().Setup(c => c.All()).Returns(mappings);
|
||||
|
||||
Subject.GetSceneNames(100, new List<int> { 4 }, new List<int> { 20 }).Should().BeEmpty();
|
||||
Subject.GetSceneNames(100, new List<int> { 5 }, new List<int> { 20 }).Should().BeEmpty();
|
||||
Subject.GetSceneNames(100, new List<int> { 6 }, new List<int> { 20 }).Should().BeEmpty();
|
||||
Subject.GetSceneNames(100, new List<int> { 7 }, new List<int> { 20 }).Should().BeEmpty();
|
||||
|
||||
Subject.GetSceneNames(100, new List<int> { 20 }, new List<int> { 1 }).Should().BeEmpty();
|
||||
Subject.GetSceneNames(100, new List<int> { 20 }, new List<int> { 2 }).Should().NotBeEmpty();
|
||||
Subject.GetSceneNames(100, new List<int> { 20 }, new List<int> { 3 }).Should().BeEmpty();
|
||||
Subject.GetSceneNames(100, new List<int> { 20 }, new List<int> { 4 }).Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_alternate_title_for_fudanshi()
|
||||
{
|
||||
var mappings = new List<SceneMapping>
|
||||
{
|
||||
new SceneMapping { Title = "Fudanshi Koukou Seikatsu", ParseTerm = "fudanshikoukouseikatsu", SearchTerm = "Fudanshi Koukou Seikatsu", TvdbId = 100, SeasonNumber = null, SceneSeasonNumber = 1 }
|
||||
};
|
||||
|
||||
Mocker.GetMock<ISceneMappingRepository>().Setup(c => c.All()).Returns(mappings);
|
||||
|
||||
Subject.GetSceneNames(100, new List<int> { 1 }, new List<int> { 20 }).Should().BeEmpty();
|
||||
Subject.GetSceneNames(100, new List<int> { 2 }, new List<int> { 20 }).Should().BeEmpty();
|
||||
Subject.GetSceneNames(100, new List<int> { 3 }, new List<int> { 20 }).Should().BeEmpty();
|
||||
Subject.GetSceneNames(100, new List<int> { 4 }, new List<int> { 20 }).Should().BeEmpty();
|
||||
|
||||
Subject.GetSceneNames(100, new List<int> { 1 }, new List<int> { 1 }).Should().NotBeEmpty();
|
||||
Subject.GetSceneNames(100, new List<int> { 2 }, new List<int> { 2 }).Should().BeEmpty();
|
||||
Subject.GetSceneNames(100, new List<int> { 3 }, new List<int> { 3 }).Should().BeEmpty();
|
||||
Subject.GetSceneNames(100, new List<int> { 4 }, new List<int> { 4 }).Should().BeEmpty();
|
||||
}
|
||||
|
||||
private void AssertNoUpdate()
|
||||
{
|
||||
_provider1.Verify(c => c.GetSceneMappings(), Times.Once());
|
||||
Mocker.GetMock<ISceneMappingRepository>().Verify(c => c.Clear(It.IsAny<string>()), Times.Never());
|
||||
Mocker.GetMock<ISceneMappingRepository>().Verify(c => c.InsertMany(_fakeMappings), Times.Never());
|
||||
}
|
||||
|
||||
private void AssertMappingUpdated()
|
||||
{
|
||||
_provider1.Verify(c => c.GetSceneMappings(), Times.Once());
|
||||
Mocker.GetMock<ISceneMappingRepository>().Verify(c => c.Clear(It.IsAny<string>()), Times.Once());
|
||||
Mocker.GetMock<ISceneMappingRepository>().Verify(c => c.InsertMany(_fakeMappings), Times.Once());
|
||||
|
||||
foreach (var sceneMapping in _fakeMappings)
|
||||
{
|
||||
Subject.GetSceneNames(sceneMapping.TvdbId, _fakeMappings.Select(m => m.SeasonNumber.Value).Distinct().ToList(), new List<int>()).Should().Contain(sceneMapping.SearchTerm);
|
||||
Subject.FindTvdbId(sceneMapping.ParseTerm).Should().Be(sceneMapping.TvdbId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@ using FluentAssertions;
|
|||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
|
||||
namespace NzbDrone.Core.Test.Datastore
|
||||
{
|
||||
|
@ -14,7 +14,7 @@ namespace NzbDrone.Core.Test.Datastore
|
|||
public void SingleOrDefault_should_return_null_on_empty_db()
|
||||
{
|
||||
Mocker.Resolve<IDatabase>()
|
||||
.GetDataMapper().Query<Series>()
|
||||
.GetDataMapper().Query<Movie>()
|
||||
.SingleOrDefault(c => c.CleanTitle == "SomeTitle")
|
||||
.Should()
|
||||
.BeNull();
|
||||
|
@ -33,4 +33,4 @@ namespace NzbDrone.Core.Test.Datastore
|
|||
Mocker.Resolve<IDatabase>().Version.Should().BeGreaterThan(new Version("3.0.0"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
using System.Linq;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
|
||||
namespace NzbDrone.Core.Test.Datastore
|
||||
{
|
||||
|
@ -15,19 +15,19 @@ namespace NzbDrone.Core.Test.Datastore
|
|||
[Test]
|
||||
public void one_to_one()
|
||||
{
|
||||
var episodeFile = Builder<EpisodeFile>.CreateNew()
|
||||
var episodeFile = Builder<MovieFile>.CreateNew()
|
||||
.With(c => c.Quality = new QualityModel())
|
||||
.BuildNew();
|
||||
|
||||
Db.Insert(episodeFile);
|
||||
|
||||
var episode = Builder<Episode>.CreateNew()
|
||||
.With(c => c.EpisodeFileId = episodeFile.Id)
|
||||
var episode = Builder<Movie>.CreateNew()
|
||||
.With(c => c.MovieFileId = episodeFile.Id)
|
||||
.BuildNew();
|
||||
|
||||
Db.Insert(episode);
|
||||
|
||||
var loadedEpisodeFile = Db.Single<Episode>().EpisodeFile.Value;
|
||||
var loadedEpisodeFile = Db.Single<Movie>().MovieFile;
|
||||
|
||||
loadedEpisodeFile.Should().NotBeNull();
|
||||
loadedEpisodeFile.ShouldBeEquivalentTo(episodeFile,
|
||||
|
@ -35,20 +35,19 @@ namespace NzbDrone.Core.Test.Datastore
|
|||
.IncludingAllRuntimeProperties()
|
||||
.Excluding(c => c.DateAdded)
|
||||
.Excluding(c => c.Path)
|
||||
.Excluding(c => c.Series)
|
||||
.Excluding(c => c.Episodes));
|
||||
.Excluding(c => c.Movie));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void one_to_one_should_not_query_db_if_foreign_key_is_zero()
|
||||
{
|
||||
var episode = Builder<Episode>.CreateNew()
|
||||
.With(c => c.EpisodeFileId = 0)
|
||||
var episode = Builder<Movie>.CreateNew()
|
||||
.With(c => c.MovieFileId = 0)
|
||||
.BuildNew();
|
||||
|
||||
Db.Insert(episode);
|
||||
|
||||
Db.Single<Episode>().EpisodeFile.Value.Should().BeNull();
|
||||
Db.Single<Movie>().MovieFile.Should().BeNull();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using FluentAssertions;
|
||||
using Marr.Data;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Datastore.Converters;
|
||||
using NzbDrone.Core.Datastore.Extensions;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
|
||||
namespace NzbDrone.Core.Test.Datastore
|
||||
{
|
||||
|
@ -30,7 +30,7 @@ namespace NzbDrone.Core.Test.Datastore
|
|||
|
||||
public class TypeWithNoMappableProperties
|
||||
{
|
||||
public Series Series { get; set; }
|
||||
public Movie Movie { get; set; }
|
||||
|
||||
public int ReadOnly { get; private set; }
|
||||
public int WriteOnly { private get; set; }
|
||||
|
@ -62,4 +62,4 @@ namespace NzbDrone.Core.Test.Datastore
|
|||
properties.Should().NotContain(c => MappingExtensions.IsMappableProperty(c));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
using FizzWare.NBuilder;
|
||||
using FizzWare.NBuilder;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Profiles;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
|
||||
|
@ -26,82 +26,30 @@ namespace NzbDrone.Core.Test.Datastore
|
|||
|
||||
profile = Db.Insert(profile);
|
||||
|
||||
var series = Builder<Series>.CreateListOfSize(1)
|
||||
var series = Builder<Movie>.CreateListOfSize(1)
|
||||
.All()
|
||||
.With(v => v.ProfileId = profile.Id)
|
||||
.BuildListOfNew();
|
||||
|
||||
Db.InsertMany(series);
|
||||
|
||||
var episodeFiles = Builder<EpisodeFile>.CreateListOfSize(1)
|
||||
var episodeFiles = Builder<MovieFile>.CreateListOfSize(1)
|
||||
.All()
|
||||
.With(v => v.SeriesId = series[0].Id)
|
||||
.With(v => v.MovieId = series[0].Id)
|
||||
.With(v => v.Quality = new QualityModel())
|
||||
.BuildListOfNew();
|
||||
|
||||
Db.InsertMany(episodeFiles);
|
||||
|
||||
var episodes = Builder<Episode>.CreateListOfSize(10)
|
||||
var episodes = Builder<Movie>.CreateListOfSize(10)
|
||||
.All()
|
||||
.With(v => v.Monitored = true)
|
||||
.With(v => v.EpisodeFileId = episodeFiles[0].Id)
|
||||
.With(v => v.SeriesId = series[0].Id)
|
||||
.With(v => v.MovieFileId = episodeFiles[0].Id)
|
||||
.BuildListOfNew();
|
||||
|
||||
Db.InsertMany(episodes);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_lazy_load_profile_if_not_joined()
|
||||
{
|
||||
var db = Mocker.Resolve<IDatabase>();
|
||||
var DataMapper = db.GetDataMapper();
|
||||
|
||||
var episodes = DataMapper.Query<Episode>()
|
||||
.Join<Episode, Series>(Marr.Data.QGen.JoinType.Inner, v => v.Series, (l, r) => l.SeriesId == r.Id)
|
||||
.ToList();
|
||||
|
||||
foreach (var episode in episodes)
|
||||
{
|
||||
Assert.IsNotNull(episode.Series);
|
||||
Assert.IsFalse(episode.Series.Profile.IsLoaded);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_explicit_load_episodefile_if_joined()
|
||||
{
|
||||
var db = Mocker.Resolve<IDatabase>();
|
||||
var DataMapper = db.GetDataMapper();
|
||||
|
||||
var episodes = DataMapper.Query<Episode>()
|
||||
.Join<Episode, EpisodeFile>(Marr.Data.QGen.JoinType.Inner, v => v.EpisodeFile, (l, r) => l.EpisodeFileId == r.Id)
|
||||
.ToList();
|
||||
|
||||
foreach (var episode in episodes)
|
||||
{
|
||||
Assert.IsNull(episode.Series);
|
||||
Assert.IsTrue(episode.EpisodeFile.IsLoaded);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_explicit_load_profile_if_joined()
|
||||
{
|
||||
var db = Mocker.Resolve<IDatabase>();
|
||||
var DataMapper = db.GetDataMapper();
|
||||
|
||||
var episodes = DataMapper.Query<Episode>()
|
||||
.Join<Episode, Series>(Marr.Data.QGen.JoinType.Inner, v => v.Series, (l, r) => l.SeriesId == r.Id)
|
||||
.Join<Series, Profile>(Marr.Data.QGen.JoinType.Inner, v => v.Profile, (l, r) => l.ProfileId == r.Id)
|
||||
.ToList();
|
||||
|
||||
foreach (var episode in episodes)
|
||||
{
|
||||
Assert.IsNotNull(episode.Series);
|
||||
Assert.IsTrue(episode.Series.Profile.IsLoaded);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
using FluentAssertions;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Datastore.Extensions;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
|
||||
namespace NzbDrone.Core.Test.Datastore.PagingSpecExtensionsTests
|
||||
{
|
||||
|
@ -14,7 +14,7 @@ namespace NzbDrone.Core.Test.Datastore.PagingSpecExtensionsTests
|
|||
[TestCase(1, 100, 0)]
|
||||
public void should_calcuate_expected_offset(int page, int pageSize, int expected)
|
||||
{
|
||||
var pagingSpec = new PagingSpec<Episode>
|
||||
var pagingSpec = new PagingSpec<Movie>
|
||||
{
|
||||
Page = page,
|
||||
PageSize = pageSize,
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
using FluentAssertions;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Datastore.Extensions;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
|
||||
namespace NzbDrone.Core.Test.Datastore.PagingSpecExtensionsTests
|
||||
{
|
||||
|
@ -11,7 +11,7 @@ namespace NzbDrone.Core.Test.Datastore.PagingSpecExtensionsTests
|
|||
[Test]
|
||||
public void should_convert_default_to_asc()
|
||||
{
|
||||
var pagingSpec = new PagingSpec<Episode>
|
||||
var pagingSpec = new PagingSpec<Movie>
|
||||
{
|
||||
Page = 1,
|
||||
PageSize = 10,
|
||||
|
@ -25,7 +25,7 @@ namespace NzbDrone.Core.Test.Datastore.PagingSpecExtensionsTests
|
|||
[Test]
|
||||
public void should_convert_ascending_to_asc()
|
||||
{
|
||||
var pagingSpec = new PagingSpec<Episode>
|
||||
var pagingSpec = new PagingSpec<Movie>
|
||||
{
|
||||
Page = 1,
|
||||
PageSize = 10,
|
||||
|
@ -39,7 +39,7 @@ namespace NzbDrone.Core.Test.Datastore.PagingSpecExtensionsTests
|
|||
[Test]
|
||||
public void should_convert_descending_to_desc()
|
||||
{
|
||||
var pagingSpec = new PagingSpec<Episode>
|
||||
var pagingSpec = new PagingSpec<Movie>
|
||||
{
|
||||
Page = 1,
|
||||
PageSize = 10,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
|
@ -8,7 +8,7 @@ using NzbDrone.Core.DecisionEngine.Specifications;
|
|||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
|
@ -16,54 +16,23 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
|
||||
public class AcceptableSizeSpecificationFixture : CoreTest<AcceptableSizeSpecification>
|
||||
{
|
||||
private RemoteEpisode parseResultMultiSet;
|
||||
private RemoteEpisode parseResultMulti;
|
||||
private RemoteEpisode parseResultSingle;
|
||||
private Series series;
|
||||
private Movie movie;
|
||||
private RemoteMovie remoteMovie;
|
||||
private Movie movie;
|
||||
private RemoteMovie remoteMovie;
|
||||
private QualityDefinition qualityType;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
series = Builder<Series>.CreateNew()
|
||||
.Build();
|
||||
|
||||
movie = Builder<Movie>.CreateNew().Build();
|
||||
movie = Builder<Movie>.CreateNew().Build();
|
||||
|
||||
remoteMovie = new RemoteMovie
|
||||
{
|
||||
Movie = movie,
|
||||
Release = new ReleaseInfo(),
|
||||
ParsedMovieInfo = new ParsedMovieInfo { Quality = new QualityModel(Quality.SDTV, new Revision(version: 2)) },
|
||||
remoteMovie = new RemoteMovie
|
||||
{
|
||||
Movie = movie,
|
||||
Release = new ReleaseInfo(),
|
||||
ParsedMovieInfo = new ParsedMovieInfo { Quality = new QualityModel(Quality.SDTV, new Revision(version: 2)) },
|
||||
|
||||
};
|
||||
|
||||
parseResultMultiSet = new RemoteEpisode
|
||||
{
|
||||
Series = series,
|
||||
Release = new ReleaseInfo(),
|
||||
ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.SDTV, new Revision(version: 2)) },
|
||||
Episodes = new List<Episode> { new Episode(), new Episode(), new Episode(), new Episode(), new Episode(), new Episode() }
|
||||
};
|
||||
|
||||
parseResultMulti = new RemoteEpisode
|
||||
{
|
||||
Series = series,
|
||||
Release = new ReleaseInfo(),
|
||||
ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.SDTV, new Revision(version: 2)) },
|
||||
Episodes = new List<Episode> { new Episode(), new Episode() }
|
||||
};
|
||||
|
||||
parseResultSingle = new RemoteEpisode
|
||||
{
|
||||
Series = series,
|
||||
Release = new ReleaseInfo(),
|
||||
ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.SDTV, new Revision(version: 2)) },
|
||||
Episodes = new List<Episode> { new Episode() { Id = 2 } }
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
Mocker.GetMock<IQualityDefinitionService>()
|
||||
.Setup(v => v.Get(It.IsAny<Quality>()))
|
||||
|
@ -76,22 +45,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
.Build();
|
||||
|
||||
Mocker.GetMock<IQualityDefinitionService>().Setup(s => s.Get(Quality.SDTV)).Returns(qualityType);
|
||||
|
||||
Mocker.GetMock<IEpisodeService>().Setup(
|
||||
s => s.GetEpisodesBySeason(It.IsAny<int>(), It.IsAny<int>()))
|
||||
.Returns(new List<Episode>() {
|
||||
new Episode(), new Episode(), new Episode(), new Episode(), new Episode(),
|
||||
new Episode(), new Episode(), new Episode(), new Episode() { Id = 2 }, new Episode() });
|
||||
}
|
||||
|
||||
private void GivenLastEpisode()
|
||||
{
|
||||
Mocker.GetMock<IEpisodeService>().Setup(
|
||||
s => s.GetEpisodesBySeason(It.IsAny<int>(), It.IsAny<int>()))
|
||||
.Returns(new List<Episode>() {
|
||||
new Episode(), new Episode(), new Episode(), new Episode(), new Episode(),
|
||||
new Episode(), new Episode(), new Episode(), new Episode(), new Episode() { Id = 2 } });
|
||||
}
|
||||
|
||||
[TestCase(30, 50, false)]
|
||||
[TestCase(30, 250, true)]
|
||||
|
@ -100,145 +55,58 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
[TestCase(60, 500, true)]
|
||||
[TestCase(60, 1000, false)]
|
||||
public void single_episode(int runtime, int sizeInMegaBytes, bool expectedResult)
|
||||
{
|
||||
series.Runtime = runtime;
|
||||
parseResultSingle.Series = series;
|
||||
parseResultSingle.Release.Size = sizeInMegaBytes.Megabytes();
|
||||
|
||||
Subject.IsSatisfiedBy(parseResultSingle, null).Accepted.Should().Be(expectedResult);
|
||||
}
|
||||
|
||||
[TestCase(30, 500, true)]
|
||||
[TestCase(30, 1000, false)]
|
||||
[TestCase(60, 1000, true)]
|
||||
[TestCase(60, 2000, false)]
|
||||
public void single_episode_first_or_last(int runtime, int sizeInMegaBytes, bool expectedResult)
|
||||
{
|
||||
GivenLastEpisode();
|
||||
movie.Runtime = runtime;
|
||||
remoteMovie.Movie = movie;
|
||||
remoteMovie.Release.Size = sizeInMegaBytes.Megabytes();
|
||||
|
||||
series.Runtime = runtime;
|
||||
parseResultSingle.Series = series;
|
||||
parseResultSingle.Release.Size = sizeInMegaBytes.Megabytes();
|
||||
|
||||
Subject.IsSatisfiedBy(parseResultSingle, null).Accepted.Should().Be(expectedResult);
|
||||
}
|
||||
|
||||
[TestCase(30, 50 * 2, false)]
|
||||
[TestCase(30, 250 * 2, true)]
|
||||
[TestCase(30, 500 * 2, false)]
|
||||
[TestCase(60, 100 * 2, false)]
|
||||
[TestCase(60, 500 * 2, true)]
|
||||
[TestCase(60, 1000 * 2, false)]
|
||||
public void multi_episode(int runtime, int sizeInMegaBytes, bool expectedResult)
|
||||
{
|
||||
series.Runtime = runtime;
|
||||
parseResultMulti.Series = series;
|
||||
parseResultMulti.Release.Size = sizeInMegaBytes.Megabytes();
|
||||
|
||||
Subject.IsSatisfiedBy(parseResultMulti, null).Accepted.Should().Be(expectedResult);
|
||||
}
|
||||
|
||||
[TestCase(30, 50 * 6, false)]
|
||||
[TestCase(30, 250 * 6, true)]
|
||||
[TestCase(30, 500 * 6, false)]
|
||||
[TestCase(60, 100 * 6, false)]
|
||||
[TestCase(60, 500 * 6, true)]
|
||||
[TestCase(60, 1000 * 6, false)]
|
||||
public void multiset_episode(int runtime, int sizeInMegaBytes, bool expectedResult)
|
||||
{
|
||||
series.Runtime = runtime;
|
||||
parseResultMultiSet.Series = series;
|
||||
parseResultMultiSet.Release.Size = sizeInMegaBytes.Megabytes();
|
||||
|
||||
Subject.IsSatisfiedBy(parseResultMultiSet, null).Accepted.Should().Be(expectedResult);
|
||||
Subject.IsSatisfiedBy(remoteMovie, null).Accepted.Should().Be(expectedResult);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_size_is_zero()
|
||||
{
|
||||
GivenLastEpisode();
|
||||
|
||||
series.Runtime = 30;
|
||||
parseResultSingle.Series = series;
|
||||
parseResultSingle.Release.Size = 0;
|
||||
movie.Runtime = 120;
|
||||
remoteMovie.Movie = movie;
|
||||
remoteMovie.Release.Size = 0;
|
||||
qualityType.MinSize = 10;
|
||||
qualityType.MaxSize = 20;
|
||||
|
||||
Subject.IsSatisfiedBy(parseResultSingle, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(remoteMovie, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_unlimited_30_minute()
|
||||
{
|
||||
GivenLastEpisode();
|
||||
|
||||
series.Runtime = 30;
|
||||
parseResultSingle.Series = series;
|
||||
parseResultSingle.Release.Size = 18457280000;
|
||||
movie.Runtime = 30;
|
||||
remoteMovie.Movie = movie;
|
||||
remoteMovie.Release.Size = 18457280000;
|
||||
qualityType.MaxSize = null;
|
||||
|
||||
Subject.IsSatisfiedBy(parseResultSingle, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(remoteMovie, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_unlimited_60_minute()
|
||||
{
|
||||
GivenLastEpisode();
|
||||
|
||||
series.Runtime = 60;
|
||||
parseResultSingle.Series = series;
|
||||
parseResultSingle.Release.Size = 36857280000;
|
||||
movie.Runtime = 60;
|
||||
remoteMovie.Movie = movie;
|
||||
remoteMovie.Release.Size = 36857280000;
|
||||
qualityType.MaxSize = null;
|
||||
|
||||
Subject.IsSatisfiedBy(parseResultSingle, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(remoteMovie, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_treat_daily_series_as_single_episode()
|
||||
public void should_use_110_minutes_if_runtime_is_0()
|
||||
{
|
||||
GivenLastEpisode();
|
||||
movie.Runtime = 0;
|
||||
remoteMovie.Movie = movie;
|
||||
remoteMovie.Release.Size = 1095.Megabytes();
|
||||
|
||||
series.Runtime = 60;
|
||||
parseResultSingle.Series = series;
|
||||
parseResultSingle.Series.SeriesType = SeriesTypes.Daily;
|
||||
parseResultSingle.Release.Size = 300.Megabytes();
|
||||
|
||||
qualityType.MaxSize = 10;
|
||||
|
||||
Subject.IsSatisfiedBy(parseResultSingle, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(remoteMovie, null).Accepted.Should().Be(true);
|
||||
remoteMovie.Release.Size = 1105.Megabytes();
|
||||
Subject.IsSatisfiedBy(remoteMovie, null).Accepted.Should().Be(false);
|
||||
}
|
||||
|
||||
//[Test]
|
||||
//public void should_return_true_if_RAWHD()
|
||||
//{
|
||||
// parseResultSingle.ParsedEpisodeInfo.Quality = new QualityModel(Quality.RAWHD);
|
||||
|
||||
// series.Runtime = 45;
|
||||
// parseResultSingle.Series = series;
|
||||
// parseResultSingle.Series.SeriesType = SeriesTypes.Daily;
|
||||
// parseResultSingle.Release.Size = 8000.Megabytes();
|
||||
|
||||
// Subject.IsSatisfiedBy(parseResultSingle, null).Accepted.Should().BeTrue();
|
||||
//}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_for_special()
|
||||
{
|
||||
parseResultSingle.ParsedEpisodeInfo.Special = true;
|
||||
|
||||
Subject.IsSatisfiedBy(parseResultSingle, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_use_110_minutes_if_runtime_is_0()
|
||||
{
|
||||
movie.Runtime = 0;
|
||||
remoteMovie.Movie = movie;
|
||||
remoteMovie.Release.Size = 1095.Megabytes();
|
||||
|
||||
Subject.IsSatisfiedBy(remoteMovie, null).Accepted.Should().Be(true);
|
||||
remoteMovie.Release.Size = 1105.Megabytes();
|
||||
Subject.IsSatisfiedBy(remoteMovie, null).Accepted.Should().Be(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,110 +0,0 @@
|
|||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Marr.Data;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class AnimeVersionUpgradeSpecificationFixture : CoreTest<AnimeVersionUpgradeSpecification>
|
||||
{
|
||||
private AnimeVersionUpgradeSpecification _subject;
|
||||
private RemoteEpisode _remoteEpisode;
|
||||
private EpisodeFile _episodeFile;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
Mocker.Resolve<QualityUpgradableSpecification>();
|
||||
_subject = Mocker.Resolve<AnimeVersionUpgradeSpecification>();
|
||||
|
||||
_episodeFile = new EpisodeFile
|
||||
{
|
||||
Quality = new QualityModel(Quality.HDTV720p, new Revision()),
|
||||
ReleaseGroup = "DRONE2"
|
||||
};
|
||||
|
||||
_remoteEpisode = new RemoteEpisode();
|
||||
_remoteEpisode.Series = new Series { SeriesType = SeriesTypes.Anime };
|
||||
_remoteEpisode.ParsedEpisodeInfo = new ParsedEpisodeInfo
|
||||
{
|
||||
Quality = new QualityModel(Quality.HDTV720p, new Revision(2)),
|
||||
ReleaseGroup = "DRONE"
|
||||
};
|
||||
|
||||
_remoteEpisode.Episodes = Builder<Episode>.CreateListOfSize(1)
|
||||
.All()
|
||||
.With(e => e.EpisodeFile = new LazyLoaded<EpisodeFile>(_episodeFile))
|
||||
.Build()
|
||||
.ToList();
|
||||
}
|
||||
|
||||
private void GivenStandardSeries()
|
||||
{
|
||||
_remoteEpisode.Series.SeriesType = SeriesTypes.Standard;
|
||||
}
|
||||
|
||||
private void GivenNoVersionUpgrade()
|
||||
{
|
||||
_remoteEpisode.ParsedEpisodeInfo.Quality.Revision = new Revision();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_true_when_no_existing_file()
|
||||
{
|
||||
_remoteEpisode.Episodes.First().EpisodeFileId = 0;
|
||||
|
||||
_subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_true_if_series_is_not_anime()
|
||||
{
|
||||
GivenStandardSeries();
|
||||
_subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_true_if_is_not_a_version_upgrade_for_existing_file()
|
||||
{
|
||||
GivenNoVersionUpgrade();
|
||||
_subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_true_when_release_group_matches()
|
||||
{
|
||||
_episodeFile.ReleaseGroup = _remoteEpisode.ParsedEpisodeInfo.ReleaseGroup;
|
||||
|
||||
_subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_false_when_existing_file_doesnt_have_a_release_group()
|
||||
{
|
||||
_episodeFile.ReleaseGroup = string.Empty;
|
||||
_subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_should_be_false_when_release_doesnt_have_a_release_group()
|
||||
{
|
||||
_remoteEpisode.ParsedEpisodeInfo.ReleaseGroup = string.Empty;
|
||||
_subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_false_when_release_group_does_not_match()
|
||||
{
|
||||
_subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
|
@ -8,7 +8,7 @@ using NzbDrone.Core.IndexerSearch.Definitions;
|
|||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Test.Common;
|
||||
using FizzWare.NBuilder;
|
||||
|
||||
|
@ -206,51 +206,6 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
result.Should().HaveCount(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Ignore( "Series")]
|
||||
public void should_only_include_reports_for_requested_episodes()
|
||||
{
|
||||
var series = Builder<Series>.CreateNew().Build();
|
||||
|
||||
var episodes = Builder<Episode>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(v => v.SeriesId, series.Id)
|
||||
.With(v => v.Series, series)
|
||||
.With(v => v.SeasonNumber, 1)
|
||||
.With(v => v.SceneSeasonNumber, 2)
|
||||
.BuildList();
|
||||
|
||||
var criteria = new SeasonSearchCriteria { Episodes = episodes.Take(1).ToList(), SeasonNumber = 1 };
|
||||
|
||||
var reports = episodes.Select(v =>
|
||||
new ReleaseInfo()
|
||||
{
|
||||
Title = string.Format("{0}.S{1:00}E{2:00}.720p.WEB-DL-DRONE", series.Title, v.SceneSeasonNumber, v.SceneEpisodeNumber)
|
||||
}).ToList();
|
||||
|
||||
Mocker.GetMock<IParsingService>()
|
||||
.Setup(v => v.Map(It.IsAny<ParsedEpisodeInfo>(), It.IsAny<int>(), It.IsAny<int>(), It.IsAny<SearchCriteriaBase>()))
|
||||
.Returns<ParsedEpisodeInfo, int, int, SearchCriteriaBase>((p,tvdbid,tvrageid,c) =>
|
||||
new RemoteEpisode
|
||||
{
|
||||
DownloadAllowed = true,
|
||||
ParsedEpisodeInfo = p,
|
||||
Series = series,
|
||||
Episodes = episodes.Where(v => v.SceneEpisodeNumber == p.EpisodeNumbers.First()).ToList()
|
||||
});
|
||||
|
||||
Mocker.SetConstant<IEnumerable<IDecisionEngineSpecification>>(new List<IDecisionEngineSpecification>
|
||||
{
|
||||
Mocker.Resolve<NzbDrone.Core.DecisionEngine.Specifications.Search.EpisodeRequestedSpecification>()
|
||||
});
|
||||
|
||||
var decisions = Subject.GetSearchDecision(reports, criteria);
|
||||
|
||||
var approvedDecisions = decisions.Where(v => v.Approved).ToList();
|
||||
|
||||
approvedDecisions.Count.Should().Be(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_allow_download_if_series_is_unknown()
|
||||
{
|
||||
|
@ -299,4 +254,4 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
ExceptionVerification.ExpectedErrors(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,76 +0,0 @@
|
|||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using FizzWare.NBuilder;
|
||||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
using NzbDrone.Core.Tv;
|
||||
using Moq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
[TestFixture]
|
||||
[Ignore("Series")]
|
||||
public class FullSeasonSpecificationFixture : CoreTest<FullSeasonSpecification>
|
||||
{
|
||||
private RemoteEpisode _remoteEpisode;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
var show = Builder<Series>.CreateNew().With(s => s.Id = 1234).Build();
|
||||
_remoteEpisode = new RemoteEpisode
|
||||
{
|
||||
ParsedEpisodeInfo = new ParsedEpisodeInfo
|
||||
{
|
||||
FullSeason = true
|
||||
},
|
||||
Episodes = Builder<Episode>.CreateListOfSize(3)
|
||||
.All()
|
||||
.With(e => e.AirDateUtc = DateTime.UtcNow.AddDays(-8))
|
||||
.With(s => s.SeriesId = show.Id)
|
||||
.BuildList(),
|
||||
Series = show,
|
||||
Release = new ReleaseInfo
|
||||
{
|
||||
Title = "Series.Title.S01.720p.BluRay.X264-RlsGrp"
|
||||
}
|
||||
};
|
||||
|
||||
Mocker.GetMock<IEpisodeService>().Setup(s => s.EpisodesBetweenDates(It.IsAny<DateTime>(), It.IsAny<DateTime>(), false))
|
||||
.Returns(new List<Episode>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_is_not_a_full_season()
|
||||
{
|
||||
_remoteEpisode.ParsedEpisodeInfo.FullSeason = false;
|
||||
_remoteEpisode.Episodes.Last().AirDateUtc = DateTime.UtcNow.AddDays(+2);
|
||||
Mocker.Resolve<FullSeasonSpecification>().IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_all_episodes_have_aired()
|
||||
{
|
||||
Mocker.Resolve<FullSeasonSpecification>().IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_one_episode_has_not_aired()
|
||||
{
|
||||
_remoteEpisode.Episodes.Last().AirDateUtc = DateTime.UtcNow.AddDays(+2);
|
||||
Mocker.Resolve<FullSeasonSpecification>().IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_an_episode_does_not_have_an_air_date()
|
||||
{
|
||||
_remoteEpisode.Episodes.Last().AirDateUtc = null;
|
||||
Mocker.Resolve<FullSeasonSpecification>().IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,7 +11,7 @@ using NzbDrone.Core.IndexerSearch.Definitions;
|
|||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Profiles;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
@ -23,11 +23,11 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
{
|
||||
private HistorySpecification _upgradeHistory;
|
||||
|
||||
private RemoteEpisode _parseResultMulti;
|
||||
private RemoteEpisode _parseResultSingle;
|
||||
private RemoteMovie _parseResultMulti;
|
||||
private RemoteMovie _parseResultSingle;
|
||||
private QualityModel _upgradableQuality;
|
||||
private QualityModel _notupgradableQuality;
|
||||
private Series _fakeSeries;
|
||||
private Movie _fakeMovie;
|
||||
private const int FIRST_EPISODE_ID = 1;
|
||||
private const int SECOND_EPISODE_ID = 2;
|
||||
|
||||
|
@ -37,29 +37,14 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
Mocker.Resolve<QualityUpgradableSpecification>();
|
||||
_upgradeHistory = Mocker.Resolve<HistorySpecification>();
|
||||
|
||||
var singleEpisodeList = new List<Episode> { new Episode { Id = FIRST_EPISODE_ID, SeasonNumber = 12, EpisodeNumber = 3 } };
|
||||
var doubleEpisodeList = new List<Episode> {
|
||||
new Episode {Id = FIRST_EPISODE_ID, SeasonNumber = 12, EpisodeNumber = 3 },
|
||||
new Episode {Id = SECOND_EPISODE_ID, SeasonNumber = 12, EpisodeNumber = 4 },
|
||||
new Episode {Id = 3, SeasonNumber = 12, EpisodeNumber = 5 }
|
||||
};
|
||||
|
||||
_fakeSeries = Builder<Series>.CreateNew()
|
||||
_fakeMovie = Builder<Movie>.CreateNew()
|
||||
.With(c => c.Profile = new Profile { Cutoff = Quality.Bluray1080p, Items = Qualities.QualityFixture.GetDefaultQualities() })
|
||||
.Build();
|
||||
|
||||
_parseResultMulti = new RemoteEpisode
|
||||
_parseResultSingle = new RemoteMovie
|
||||
{
|
||||
Series = _fakeSeries,
|
||||
ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.DVD, new Revision(version: 2)) },
|
||||
Episodes = doubleEpisodeList
|
||||
};
|
||||
|
||||
_parseResultSingle = new RemoteEpisode
|
||||
{
|
||||
Series = _fakeSeries,
|
||||
ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.DVD, new Revision(version: 2)) },
|
||||
Episodes = singleEpisodeList
|
||||
Movie = _fakeMovie,
|
||||
ParsedMovieInfo = new ParsedMovieInfo { Quality = new QualityModel(Quality.DVD, new Revision(version: 2)) }
|
||||
};
|
||||
|
||||
_upgradableQuality = new QualityModel(Quality.SDTV, new Revision(version: 1));
|
||||
|
@ -86,7 +71,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
[Test]
|
||||
public void should_return_true_if_it_is_a_search()
|
||||
{
|
||||
_upgradeHistory.IsSatisfiedBy(_parseResultMulti, new SeasonSearchCriteria()).Accepted.Should().BeTrue();
|
||||
_upgradeHistory.IsSatisfiedBy(_parseResultMulti, new MovieSearchCriteria()).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -159,8 +144,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
[Test]
|
||||
public void should_not_be_upgradable_if_episode_is_of_same_quality_as_existing()
|
||||
{
|
||||
_fakeSeries.Profile = new Profile { Cutoff = Quality.Bluray1080p, Items = Qualities.QualityFixture.GetDefaultQualities() };
|
||||
_parseResultSingle.ParsedEpisodeInfo.Quality = new QualityModel(Quality.WEBDL1080p, new Revision(version: 1));
|
||||
_fakeMovie.Profile = new Profile { Cutoff = Quality.Bluray1080p, Items = Qualities.QualityFixture.GetDefaultQualities() };
|
||||
_parseResultSingle.ParsedMovieInfo.Quality = new QualityModel(Quality.WEBDL1080p, new Revision(version: 1));
|
||||
_upgradableQuality = new QualityModel(Quality.WEBDL1080p, new Revision(version: 1));
|
||||
|
||||
GivenMostRecentForEpisode(FIRST_EPISODE_ID, string.Empty, _upgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed);
|
||||
|
@ -171,8 +156,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
[Test]
|
||||
public void should_not_be_upgradable_if_cutoff_already_met()
|
||||
{
|
||||
_fakeSeries.Profile = new Profile { Cutoff = Quality.WEBDL1080p, Items = Qualities.QualityFixture.GetDefaultQualities() };
|
||||
_parseResultSingle.ParsedEpisodeInfo.Quality = new QualityModel(Quality.WEBDL1080p, new Revision(version: 1));
|
||||
_fakeMovie.Profile = new Profile { Cutoff = Quality.WEBDL1080p, Items = Qualities.QualityFixture.GetDefaultQualities() };
|
||||
_parseResultSingle.ParsedMovieInfo.Quality = new QualityModel(Quality.WEBDL1080p, new Revision(version: 1));
|
||||
_upgradableQuality = new QualityModel(Quality.Bluray1080p, new Revision(version: 1));
|
||||
|
||||
GivenMostRecentForEpisode(FIRST_EPISODE_ID, string.Empty, _upgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed);
|
||||
|
@ -199,8 +184,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
public void should_return_false_if_cutoff_already_met_and_cdh_is_disabled()
|
||||
{
|
||||
GivenCdhDisabled();
|
||||
_fakeSeries.Profile = new Profile { Cutoff = Quality.WEBDL1080p, Items = Qualities.QualityFixture.GetDefaultQualities() };
|
||||
_parseResultSingle.ParsedEpisodeInfo.Quality = new QualityModel(Quality.Bluray1080p, new Revision(version: 1));
|
||||
_fakeMovie.Profile = new Profile { Cutoff = Quality.WEBDL1080p, Items = Qualities.QualityFixture.GetDefaultQualities() };
|
||||
_parseResultSingle.ParsedMovieInfo.Quality = new QualityModel(Quality.Bluray1080p, new Revision(version: 1));
|
||||
_upgradableQuality = new QualityModel(Quality.WEBDL1080p, new Revision(version: 1));
|
||||
|
||||
GivenMostRecentForEpisode(FIRST_EPISODE_ID, "test", _upgradableQuality, DateTime.UtcNow.AddDays(-100), HistoryEventType.Grabbed);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using FluentAssertions;
|
||||
using FluentAssertions;
|
||||
using Marr.Data;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
|
@ -6,7 +6,7 @@ using NzbDrone.Core.Parser;
|
|||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Profiles;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
|
@ -14,18 +14,18 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
|
||||
public class LanguageSpecificationFixture : CoreTest
|
||||
{
|
||||
private RemoteEpisode _remoteEpisode;
|
||||
private RemoteMovie _remoteEpisode;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_remoteEpisode = new RemoteEpisode
|
||||
_remoteEpisode = new RemoteMovie
|
||||
{
|
||||
ParsedEpisodeInfo = new ParsedEpisodeInfo
|
||||
ParsedMovieInfo = new ParsedMovieInfo
|
||||
{
|
||||
Language = Language.English
|
||||
},
|
||||
Series = new Series
|
||||
Movie = new Movie
|
||||
{
|
||||
Profile = new LazyLoaded<Profile>(new Profile
|
||||
{
|
||||
|
@ -37,12 +37,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
|
||||
private void WithEnglishRelease()
|
||||
{
|
||||
_remoteEpisode.ParsedEpisodeInfo.Language = Language.English;
|
||||
_remoteEpisode.ParsedMovieInfo.Language = Language.English;
|
||||
}
|
||||
|
||||
private void WithGermanRelease()
|
||||
{
|
||||
_remoteEpisode.ParsedEpisodeInfo.Language = Language.German;
|
||||
_remoteEpisode.ParsedMovieInfo.Language = Language.German;
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -61,4 +61,4 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
Mocker.Resolve<LanguageSpecification>().IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Configuration;
|
||||
|
@ -13,12 +13,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
|
||||
public class MinimumAgeSpecificationFixture : CoreTest<MinimumAgeSpecification>
|
||||
{
|
||||
private RemoteEpisode _remoteEpisode;
|
||||
private RemoteMovie _remoteEpisode;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_remoteEpisode = new RemoteEpisode
|
||||
_remoteEpisode = new RemoteMovie
|
||||
{
|
||||
Release = new ReleaseInfo() { DownloadProtocol = DownloadProtocol.Usenet }
|
||||
};
|
||||
|
@ -61,4 +61,4 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,53 +1,51 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications.RssSync;
|
||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
[TestFixture]
|
||||
|
||||
public class MonitoredEpisodeSpecificationFixture : CoreTest<MonitoredEpisodeSpecification>
|
||||
public class MonitoredMovieSpecificationFixture : CoreTest<MonitoredMovieSpecification>
|
||||
{
|
||||
private MonitoredEpisodeSpecification _monitoredEpisodeSpecification;
|
||||
private MonitoredMovieSpecification _monitoredEpisodeSpecification;
|
||||
|
||||
private RemoteEpisode _parseResultMulti;
|
||||
private RemoteEpisode _parseResultSingle;
|
||||
private Series _fakeSeries;
|
||||
private Episode _firstEpisode;
|
||||
private Episode _secondEpisode;
|
||||
private RemoteMovie _parseResultMulti;
|
||||
private RemoteMovie _parseResultSingle;
|
||||
private Movie _fakeSeries;
|
||||
private Movie _firstEpisode;
|
||||
private Movie _secondEpisode;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_monitoredEpisodeSpecification = Mocker.Resolve<MonitoredEpisodeSpecification>();
|
||||
_monitoredEpisodeSpecification = Mocker.Resolve<MonitoredMovieSpecification>();
|
||||
|
||||
_fakeSeries = Builder<Series>.CreateNew()
|
||||
_fakeSeries = Builder<Movie>.CreateNew()
|
||||
.With(c => c.Monitored = true)
|
||||
.Build();
|
||||
|
||||
_firstEpisode = new Episode { Monitored = true };
|
||||
_secondEpisode = new Episode { Monitored = true };
|
||||
_firstEpisode = new Movie() { Monitored = true };
|
||||
_secondEpisode = new Movie() { Monitored = true };
|
||||
|
||||
|
||||
var singleEpisodeList = new List<Episode> { _firstEpisode };
|
||||
var doubleEpisodeList = new List<Episode> { _firstEpisode, _secondEpisode };
|
||||
var singleEpisodeList = new List<Movie> { _firstEpisode };
|
||||
var doubleEpisodeList = new List<Movie> { _firstEpisode, _secondEpisode };
|
||||
|
||||
_parseResultMulti = new RemoteEpisode
|
||||
_parseResultMulti = new RemoteMovie
|
||||
{
|
||||
Series = _fakeSeries,
|
||||
Episodes = doubleEpisodeList
|
||||
Movie = _fakeSeries
|
||||
};
|
||||
|
||||
_parseResultSingle = new RemoteEpisode
|
||||
_parseResultSingle = new RemoteMovie
|
||||
{
|
||||
Series = _fakeSeries,
|
||||
Episodes = singleEpisodeList
|
||||
Movie = _fakeSeries
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -108,34 +106,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
public void should_return_true_for_single_episode_search()
|
||||
{
|
||||
_fakeSeries.Monitored = false;
|
||||
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle, new SingleEpisodeSearchCriteria()).Accepted.Should().BeTrue();
|
||||
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle, new MovieSearchCriteria()).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_episode_is_monitored_for_season_search()
|
||||
{
|
||||
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle, new SeasonSearchCriteria()).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_episode_is_not_monitored_for_season_search()
|
||||
{
|
||||
WithFirstEpisodeUnmonitored();
|
||||
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle, new SeasonSearchCriteria()).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_episode_is_not_monitored_and_monitoredEpisodesOnly_flag_is_false()
|
||||
{
|
||||
WithFirstEpisodeUnmonitored();
|
||||
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle, new SingleEpisodeSearchCriteria { MonitoredEpisodesOnly = false }).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_episode_is_not_monitored_and_monitoredEpisodesOnly_flag_is_true()
|
||||
{
|
||||
WithFirstEpisodeUnmonitored();
|
||||
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle, new SingleEpisodeSearchCriteria{ MonitoredEpisodesOnly = true}).Accepted.Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@ using System.Linq;
|
|||
using Moq;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.Profiles.Delay;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.Profiles;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
|
@ -7,22 +7,22 @@ using NzbDrone.Core.Indexers;
|
|||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Profiles.Delay;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class ProtocolSpecificationFixture : CoreTest<ProtocolSpecification>
|
||||
{
|
||||
private RemoteEpisode _remoteEpisode;
|
||||
private RemoteMovie _remoteEpisode;
|
||||
private DelayProfile _delayProfile;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_remoteEpisode = new RemoteEpisode();
|
||||
_remoteEpisode = new RemoteMovie();
|
||||
_remoteEpisode.Release = new ReleaseInfo();
|
||||
_remoteEpisode.Series = new Series();
|
||||
_remoteEpisode.Movie = new Movie();
|
||||
|
||||
_delayProfile = new DelayProfile();
|
||||
|
||||
|
@ -72,4 +72,4 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().Be(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using FizzWare.NBuilder;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Marr.Data;
|
||||
using NUnit.Framework;
|
||||
|
@ -6,7 +6,7 @@ using NzbDrone.Core.DecisionEngine.Specifications;
|
|||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Profiles;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
|
@ -15,7 +15,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
|
||||
public class QualityAllowedByProfileSpecificationFixture : CoreTest<QualityAllowedByProfileSpecification>
|
||||
{
|
||||
private RemoteEpisode remoteEpisode;
|
||||
private RemoteMovie remoteMovie;
|
||||
|
||||
public static object[] AllowedTestCases =
|
||||
{
|
||||
|
@ -34,33 +34,33 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
var fakeSeries = Builder<Series>.CreateNew()
|
||||
var fakeSeries = Builder<Movie>.CreateNew()
|
||||
.With(c => c.Profile = (LazyLoaded<Profile>)new Profile { Cutoff = Quality.Bluray1080p })
|
||||
.Build();
|
||||
|
||||
remoteEpisode = new RemoteEpisode
|
||||
remoteMovie = new RemoteMovie
|
||||
{
|
||||
Series = fakeSeries,
|
||||
ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.DVD, new Revision(version: 2)) },
|
||||
Movie = fakeSeries,
|
||||
ParsedMovieInfo = new ParsedMovieInfo { Quality = new QualityModel(Quality.DVD, new Revision(version: 2)) },
|
||||
};
|
||||
}
|
||||
|
||||
[Test, TestCaseSource("AllowedTestCases")]
|
||||
public void should_allow_if_quality_is_defined_in_profile(Quality qualityType)
|
||||
{
|
||||
remoteEpisode.ParsedEpisodeInfo.Quality.Quality = qualityType;
|
||||
remoteEpisode.Series.Profile.Value.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.DVD, Quality.HDTV720p, Quality.Bluray1080p);
|
||||
remoteMovie.ParsedMovieInfo.Quality.Quality = qualityType;
|
||||
remoteMovie.Movie.Profile.Value.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.DVD, Quality.HDTV720p, Quality.Bluray1080p);
|
||||
|
||||
Subject.IsSatisfiedBy(remoteEpisode, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(remoteMovie, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test, TestCaseSource("DeniedTestCases")]
|
||||
public void should_not_allow_if_quality_is_not_defined_in_profile(Quality qualityType)
|
||||
{
|
||||
remoteEpisode.ParsedEpisodeInfo.Quality.Quality = qualityType;
|
||||
remoteEpisode.Series.Profile.Value.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.DVD, Quality.HDTV720p, Quality.Bluray1080p);
|
||||
remoteMovie.ParsedMovieInfo.Quality.Quality = qualityType;
|
||||
remoteMovie.Movie.Profile.Value.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.DVD, Quality.HDTV720p, Quality.Bluray1080p);
|
||||
|
||||
Subject.IsSatisfiedBy(remoteEpisode, null).Accepted.Should().BeFalse();
|
||||
Subject.IsSatisfiedBy(remoteMovie, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
|
@ -9,7 +9,7 @@ using NzbDrone.Core.Parser.Model;
|
|||
using NzbDrone.Core.Profiles;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Queue;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
|
@ -17,41 +17,27 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
[TestFixture]
|
||||
public class QueueSpecificationFixture : CoreTest<QueueSpecification>
|
||||
{
|
||||
private Series _series;
|
||||
private Episode _episode;
|
||||
private RemoteEpisode _remoteEpisode;
|
||||
private Movie _movie;
|
||||
private RemoteMovie _remoteMovie;
|
||||
|
||||
private Series _otherSeries;
|
||||
private Episode _otherEpisode;
|
||||
private Movie _otherMovie;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
Mocker.Resolve<QualityUpgradableSpecification>();
|
||||
|
||||
_series = Builder<Series>.CreateNew()
|
||||
_movie = Builder<Movie>.CreateNew()
|
||||
.With(e => e.Profile = new Profile { Items = Qualities.QualityFixture.GetDefaultQualities() })
|
||||
.Build();
|
||||
|
||||
_episode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.SeriesId = _series.Id)
|
||||
.Build();
|
||||
|
||||
_otherSeries = Builder<Series>.CreateNew()
|
||||
_otherMovie = Builder<Movie>.CreateNew()
|
||||
.With(s => s.Id = 2)
|
||||
.Build();
|
||||
|
||||
_otherEpisode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.SeriesId = _otherSeries.Id)
|
||||
.With(e => e.Id = 2)
|
||||
.With(e => e.SeasonNumber = 2)
|
||||
.With(e => e.EpisodeNumber = 2)
|
||||
.Build();
|
||||
|
||||
_remoteEpisode = Builder<RemoteEpisode>.CreateNew()
|
||||
.With(r => r.Series = _series)
|
||||
.With(r => r.Episodes = new List<Episode> { _episode })
|
||||
.With(r => r.ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.DVD) })
|
||||
_remoteMovie = Builder<RemoteMovie>.CreateNew()
|
||||
.With(r => r.Movie = _movie)
|
||||
.With(r => r.ParsedMovieInfo = new ParsedMovieInfo { Quality = new QualityModel(Quality.DVD) })
|
||||
.Build();
|
||||
}
|
||||
|
||||
|
@ -62,11 +48,11 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
.Returns(new List<Queue.Queue>());
|
||||
}
|
||||
|
||||
private void GivenQueue(IEnumerable<RemoteEpisode> remoteEpisodes)
|
||||
private void GivenQueue(IEnumerable<RemoteMovie> remoteEpisodes)
|
||||
{
|
||||
var queue = remoteEpisodes.Select(remoteEpisode => new Queue.Queue
|
||||
{
|
||||
RemoteEpisode = remoteEpisode
|
||||
RemoteMovie = remoteEpisode
|
||||
});
|
||||
|
||||
Mocker.GetMock<IQueueService>()
|
||||
|
@ -78,181 +64,100 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
public void should_return_true_when_queue_is_empty()
|
||||
{
|
||||
GivenEmptyQueue();
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_when_series_doesnt_match()
|
||||
{
|
||||
var remoteEpisode = Builder<RemoteEpisode>.CreateNew()
|
||||
.With(r => r.Series = _otherSeries)
|
||||
.With(r => r.Episodes = new List<Episode> { _episode })
|
||||
var remoteEpisode = Builder<RemoteMovie>.CreateNew()
|
||||
.With(r => r.Movie = _otherMovie)
|
||||
.Build();
|
||||
|
||||
GivenQueue(new List<RemoteEpisode> { remoteEpisode });
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
|
||||
GivenQueue(new List<RemoteMovie> { remoteEpisode });
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_when_quality_in_queue_is_lower()
|
||||
{
|
||||
_series.Profile.Value.Cutoff = Quality.Bluray1080p;
|
||||
_movie.Profile.Value.Cutoff = Quality.Bluray1080p;
|
||||
|
||||
var remoteEpisode = Builder<RemoteEpisode>.CreateNew()
|
||||
.With(r => r.Series = _series)
|
||||
.With(r => r.Episodes = new List<Episode> { _episode })
|
||||
.With(r => r.ParsedEpisodeInfo = new ParsedEpisodeInfo
|
||||
var remoteEpisode = Builder<RemoteMovie>.CreateNew()
|
||||
.With(r => r.Movie = _movie)
|
||||
.With(r => r.ParsedMovieInfo = new ParsedMovieInfo
|
||||
{
|
||||
Quality = new QualityModel(Quality.SDTV)
|
||||
})
|
||||
.Build();
|
||||
|
||||
GivenQueue(new List<RemoteEpisode> { remoteEpisode });
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
|
||||
GivenQueue(new List<RemoteMovie> { remoteEpisode });
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_when_episode_doesnt_match()
|
||||
{
|
||||
var remoteEpisode = Builder<RemoteEpisode>.CreateNew()
|
||||
.With(r => r.Series = _series)
|
||||
.With(r => r.Episodes = new List<Episode> { _otherEpisode })
|
||||
.With(r => r.ParsedEpisodeInfo = new ParsedEpisodeInfo
|
||||
var remoteEpisode = Builder<RemoteMovie>.CreateNew()
|
||||
.With(r => r.Movie = _movie)
|
||||
.With(r => r.ParsedMovieInfo = new ParsedMovieInfo
|
||||
{
|
||||
Quality = new QualityModel(Quality.DVD)
|
||||
})
|
||||
.Build();
|
||||
|
||||
GivenQueue(new List<RemoteEpisode> { remoteEpisode });
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
|
||||
GivenQueue(new List<RemoteMovie> { remoteEpisode });
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_when_qualities_are_the_same()
|
||||
{
|
||||
var remoteEpisode = Builder<RemoteEpisode>.CreateNew()
|
||||
.With(r => r.Series = _series)
|
||||
.With(r => r.Episodes = new List<Episode> { _episode })
|
||||
.With(r => r.ParsedEpisodeInfo = new ParsedEpisodeInfo
|
||||
var remoteEpisode = Builder<RemoteMovie>.CreateNew()
|
||||
.With(r => r.Movie = _movie)
|
||||
.With(r => r.ParsedMovieInfo = new ParsedMovieInfo
|
||||
{
|
||||
Quality = new QualityModel(Quality.DVD)
|
||||
})
|
||||
.Build();
|
||||
|
||||
GivenQueue(new List<RemoteEpisode> { remoteEpisode });
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
|
||||
GivenQueue(new List<RemoteMovie> { remoteEpisode });
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_when_quality_in_queue_is_better()
|
||||
{
|
||||
_series.Profile.Value.Cutoff = Quality.Bluray1080p;
|
||||
_movie.Profile.Value.Cutoff = Quality.Bluray1080p;
|
||||
|
||||
var remoteEpisode = Builder<RemoteEpisode>.CreateNew()
|
||||
.With(r => r.Series = _series)
|
||||
.With(r => r.Episodes = new List<Episode> { _episode })
|
||||
.With(r => r.ParsedEpisodeInfo = new ParsedEpisodeInfo
|
||||
var remoteEpisode = Builder<RemoteMovie>.CreateNew()
|
||||
.With(r => r.Movie = _movie)
|
||||
.With(r => r.ParsedMovieInfo = new ParsedMovieInfo
|
||||
{
|
||||
Quality = new QualityModel(Quality.HDTV720p)
|
||||
})
|
||||
.Build();
|
||||
|
||||
GivenQueue(new List<RemoteEpisode> { remoteEpisode });
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_matching_multi_episode_is_in_queue()
|
||||
{
|
||||
var remoteEpisode = Builder<RemoteEpisode>.CreateNew()
|
||||
.With(r => r.Series = _series)
|
||||
.With(r => r.Episodes = new List<Episode> { _episode, _otherEpisode })
|
||||
.With(r => r.ParsedEpisodeInfo = new ParsedEpisodeInfo
|
||||
{
|
||||
Quality = new QualityModel(Quality.HDTV720p)
|
||||
})
|
||||
.Build();
|
||||
|
||||
GivenQueue(new List<RemoteEpisode> { remoteEpisode });
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_multi_episode_has_one_episode_in_queue()
|
||||
{
|
||||
var remoteEpisode = Builder<RemoteEpisode>.CreateNew()
|
||||
.With(r => r.Series = _series)
|
||||
.With(r => r.Episodes = new List<Episode> { _episode })
|
||||
.With(r => r.ParsedEpisodeInfo = new ParsedEpisodeInfo
|
||||
{
|
||||
Quality = new QualityModel(Quality.HDTV720p)
|
||||
})
|
||||
.Build();
|
||||
|
||||
_remoteEpisode.Episodes.Add(_otherEpisode);
|
||||
|
||||
GivenQueue(new List<RemoteEpisode> { remoteEpisode });
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_multi_part_episode_is_already_in_queue()
|
||||
{
|
||||
var remoteEpisode = Builder<RemoteEpisode>.CreateNew()
|
||||
.With(r => r.Series = _series)
|
||||
.With(r => r.Episodes = new List<Episode> { _episode, _otherEpisode })
|
||||
.With(r => r.ParsedEpisodeInfo = new ParsedEpisodeInfo
|
||||
{
|
||||
Quality = new QualityModel(Quality.HDTV720p)
|
||||
})
|
||||
.Build();
|
||||
|
||||
_remoteEpisode.Episodes.Add(_otherEpisode);
|
||||
|
||||
GivenQueue(new List<RemoteEpisode> { remoteEpisode });
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_multi_part_episode_has_two_episodes_in_queue()
|
||||
{
|
||||
var remoteEpisodes = Builder<RemoteEpisode>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(r => r.Series = _series)
|
||||
.With(r => r.ParsedEpisodeInfo = new ParsedEpisodeInfo
|
||||
{
|
||||
Quality =
|
||||
new QualityModel(
|
||||
Quality.HDTV720p)
|
||||
})
|
||||
.TheFirst(1)
|
||||
.With(r => r.Episodes = new List<Episode> { _episode })
|
||||
.TheNext(1)
|
||||
.With(r => r.Episodes = new List<Episode> { _otherEpisode })
|
||||
.Build();
|
||||
|
||||
_remoteEpisode.Episodes.Add(_otherEpisode);
|
||||
GivenQueue(remoteEpisodes);
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
|
||||
GivenQueue(new List<RemoteMovie> { remoteEpisode });
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_quality_in_queue_meets_cutoff()
|
||||
{
|
||||
_series.Profile.Value.Cutoff = _remoteEpisode.ParsedEpisodeInfo.Quality.Quality;
|
||||
_movie.Profile.Value.Cutoff = _remoteMovie.ParsedMovieInfo.Quality.Quality;
|
||||
|
||||
var remoteEpisode = Builder<RemoteEpisode>.CreateNew()
|
||||
.With(r => r.Series = _series)
|
||||
.With(r => r.Episodes = new List<Episode> { _episode })
|
||||
.With(r => r.ParsedEpisodeInfo = new ParsedEpisodeInfo
|
||||
var remoteEpisode = Builder<RemoteMovie>.CreateNew()
|
||||
.With(r => r.Movie = _movie)
|
||||
.With(r => r.ParsedMovieInfo = new ParsedMovieInfo
|
||||
{
|
||||
Quality = new QualityModel(Quality.HDTV720p)
|
||||
})
|
||||
.Build();
|
||||
|
||||
GivenQueue(new List<RemoteEpisode> { remoteEpisode });
|
||||
GivenQueue(new List<RemoteMovie> { remoteEpisode });
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using FluentAssertions;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
@ -12,12 +12,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
|
||||
public class RawDiskSpecificationFixture : CoreTest<RawDiskSpecification>
|
||||
{
|
||||
private RemoteEpisode _remoteEpisode;
|
||||
private RemoteMovie _remoteMovie;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_remoteEpisode = new RemoteEpisode
|
||||
_remoteMovie = new RemoteMovie
|
||||
{
|
||||
Release = new ReleaseInfo() { DownloadProtocol = DownloadProtocol.Torrent }
|
||||
};
|
||||
|
@ -25,49 +25,49 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
|
||||
private void WithContainer(string container)
|
||||
{
|
||||
_remoteEpisode.Release.Container = container;
|
||||
_remoteMovie.Release.Container = container;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_no_container_specified()
|
||||
{
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_mkv()
|
||||
{
|
||||
WithContainer("MKV");
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_vob()
|
||||
{
|
||||
WithContainer("VOB");
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_iso()
|
||||
{
|
||||
WithContainer("ISO");
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_m2ts()
|
||||
{
|
||||
WithContainer("M2TS");
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_compare_case_insensitive()
|
||||
{
|
||||
WithContainer("vob");
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
|
@ -6,21 +6,21 @@ using NzbDrone.Core.DecisionEngine.Specifications;
|
|||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Restrictions;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class ReleaseRestrictionsSpecificationFixture : CoreTest<ReleaseRestrictionsSpecification>
|
||||
{
|
||||
private RemoteEpisode _remoteEpisode;
|
||||
private RemoteMovie _remoteMovie;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_remoteEpisode = new RemoteEpisode
|
||||
{
|
||||
Series = new Series
|
||||
_remoteMovie = new RemoteMovie
|
||||
{
|
||||
Movie = new Movie
|
||||
{
|
||||
Tags = new HashSet<int>()
|
||||
},
|
||||
|
@ -52,7 +52,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
.Setup(s => s.AllForTags(It.IsAny<HashSet<int>>()))
|
||||
.Returns(new List<Restriction>());
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -60,7 +60,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
{
|
||||
GivenRestictions("WEBRip", null);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -68,7 +68,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
{
|
||||
GivenRestictions("doesnt,exist", null);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -76,7 +76,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
{
|
||||
GivenRestictions(null, "ignored");
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -84,7 +84,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
{
|
||||
GivenRestictions(null, "edited");
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[TestCase("EdiTED")]
|
||||
|
@ -95,7 +95,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
{
|
||||
GivenRestictions(required, null);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[TestCase("EdiTED")]
|
||||
|
@ -106,13 +106,13 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
{
|
||||
GivenRestictions(null, ignored);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_false_when_release_contains_one_restricted_word_and_one_required_word()
|
||||
{
|
||||
_remoteEpisode.Release.Title = "[ www.Speed.cd ] -Whose.Line.is.it.Anyway.US.S10E24.720p.HDTV.x264-BAJSKORV";
|
||||
_remoteMovie.Release.Title = "[ www.Speed.cd ] -Whose.Line.is.it.Anyway.US.S10E24.720p.HDTV.x264-BAJSKORV";
|
||||
|
||||
Mocker.GetMock<IRestrictionService>()
|
||||
.Setup(s => s.AllForTags(It.IsAny<HashSet<int>>()))
|
||||
|
@ -121,7 +121,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
new Restriction { Required = "x264", Ignored = "www.Speed.cd" }
|
||||
});
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Configuration;
|
||||
|
@ -13,12 +13,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
|
||||
public class RetentionSpecificationFixture : CoreTest<RetentionSpecification>
|
||||
{
|
||||
private RemoteEpisode _remoteEpisode;
|
||||
private RemoteMovie _remoteMovie;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_remoteEpisode = new RemoteEpisode
|
||||
_remoteMovie = new RemoteMovie
|
||||
{
|
||||
Release = new ReleaseInfo() { DownloadProtocol = DownloadProtocol.Usenet }
|
||||
};
|
||||
|
@ -31,7 +31,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
|
||||
private void WithAge(int days)
|
||||
{
|
||||
_remoteEpisode.Release.PublishDate = DateTime.UtcNow.AddDays(-days);
|
||||
_remoteMovie.Release.PublishDate = DateTime.UtcNow.AddDays(-days);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -40,7 +40,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
WithRetention(0);
|
||||
WithAge(100);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -49,7 +49,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
WithRetention(1000);
|
||||
WithAge(100);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -58,7 +58,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
WithRetention(100);
|
||||
WithAge(100);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -67,7 +67,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
WithRetention(10);
|
||||
WithAge(100);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -76,18 +76,18 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
WithRetention(0);
|
||||
WithAge(100);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_when_release_is_not_usenet()
|
||||
{
|
||||
_remoteEpisode.Release.DownloadProtocol = DownloadProtocol.Torrent;
|
||||
_remoteMovie.Release.DownloadProtocol = DownloadProtocol.Torrent;
|
||||
|
||||
WithRetention(10);
|
||||
WithAge(100);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
|
@ -17,7 +17,7 @@ using NzbDrone.Core.Profiles;
|
|||
using NzbDrone.Core.Profiles.Delay;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
||||
{
|
||||
|
@ -91,7 +91,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
|||
[Test]
|
||||
public void should_be_true_when_user_invoked_search()
|
||||
{
|
||||
Subject.IsSatisfiedBy(new RemoteEpisode(), new SingleEpisodeSearchCriteria { UserInvokedSearch = true }).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(new RemoteMovie(), new MovieSearchCriteria() { UserInvokedSearch = true }).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -102,7 +102,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
|||
|
||||
_delayProfile.UsenetDelay = 720;
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, new SingleEpisodeSearchCriteria()).Accepted.Should().BeFalse();
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, new MovieSearchCriteria()).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
|
@ -10,7 +10,7 @@ using NzbDrone.Core.MediaFiles;
|
|||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Profiles;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
@ -21,38 +21,26 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
|||
|
||||
public class ProperSpecificationFixture : CoreTest<ProperSpecification>
|
||||
{
|
||||
private RemoteEpisode _parseResultMulti;
|
||||
private RemoteEpisode _parseResultSingle;
|
||||
private EpisodeFile _firstFile;
|
||||
private EpisodeFile _secondFile;
|
||||
private RemoteMovie _parseResultSingle;
|
||||
private MovieFile _firstFile;
|
||||
private MovieFile _secondFile;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
Mocker.Resolve<QualityUpgradableSpecification>();
|
||||
|
||||
_firstFile = new EpisodeFile { Quality = new QualityModel(Quality.Bluray1080p, new Revision(version: 1)), DateAdded = DateTime.Now };
|
||||
_secondFile = new EpisodeFile { Quality = new QualityModel(Quality.Bluray1080p, new Revision(version: 1)), DateAdded = DateTime.Now };
|
||||
_firstFile = new MovieFile { Quality = new QualityModel(Quality.Bluray1080p, new Revision(version: 1)), DateAdded = DateTime.Now };
|
||||
_secondFile = new MovieFile { Quality = new QualityModel(Quality.Bluray1080p, new Revision(version: 1)), DateAdded = DateTime.Now };
|
||||
|
||||
var singleEpisodeList = new List<Episode> { new Episode { EpisodeFile = _firstFile, EpisodeFileId = 1 }, new Episode { EpisodeFile = null } };
|
||||
var doubleEpisodeList = new List<Episode> { new Episode { EpisodeFile = _firstFile, EpisodeFileId = 1 }, new Episode { EpisodeFile = _secondFile, EpisodeFileId = 1 }, new Episode { EpisodeFile = null } };
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew()
|
||||
var fakeSeries = Builder<Movie>.CreateNew()
|
||||
.With(c => c.Profile = new Profile { Cutoff = Quality.Bluray1080p })
|
||||
.Build();
|
||||
|
||||
_parseResultMulti = new RemoteEpisode
|
||||
_parseResultSingle = new RemoteMovie
|
||||
{
|
||||
Series = fakeSeries,
|
||||
ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.DVD, new Revision(version: 2)) },
|
||||
Episodes = doubleEpisodeList
|
||||
};
|
||||
|
||||
_parseResultSingle = new RemoteEpisode
|
||||
{
|
||||
Series = fakeSeries,
|
||||
ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.DVD, new Revision(version: 2)) },
|
||||
Episodes = singleEpisodeList
|
||||
Movie = fakeSeries,
|
||||
ParsedMovieInfo = new ParsedMovieInfo { Quality = new QualityModel(Quality.DVD, new Revision(version: 2)) },
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -69,7 +57,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
|||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_when_episodeFile_was_added_more_than_7_days_ago()
|
||||
public void should_return_false_when_movieFile_was_added_more_than_7_days_ago()
|
||||
{
|
||||
_firstFile.Quality.Quality = Quality.DVD;
|
||||
|
||||
|
@ -78,27 +66,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
|||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_when_first_episodeFile_was_added_more_than_7_days_ago()
|
||||
{
|
||||
_firstFile.Quality.Quality = Quality.DVD;
|
||||
_secondFile.Quality.Quality = Quality.DVD;
|
||||
|
||||
_firstFile.DateAdded = DateTime.Today.AddDays(-30);
|
||||
Subject.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_when_second_episodeFile_was_added_more_than_7_days_ago()
|
||||
{
|
||||
_firstFile.Quality.Quality = Quality.DVD;
|
||||
_secondFile.Quality.Quality = Quality.DVD;
|
||||
|
||||
_secondFile.DateAdded = DateTime.Today.AddDays(-30);
|
||||
Subject.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_when_episodeFile_was_added_more_than_7_days_ago_but_proper_is_for_better_quality()
|
||||
public void should_return_true_when_movieFile_was_added_more_than_7_days_ago_but_proper_is_for_better_quality()
|
||||
{
|
||||
WithFirstFileUpgradable();
|
||||
|
||||
|
@ -112,7 +80,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
|||
WithFirstFileUpgradable();
|
||||
|
||||
_firstFile.DateAdded = DateTime.Today.AddDays(-30);
|
||||
Subject.IsSatisfiedBy(_parseResultSingle, new SingleEpisodeSearchCriteria()).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_parseResultSingle, new MovieSearchCriteria()).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -125,7 +93,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
|||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_when_episodeFile_was_added_today()
|
||||
public void should_return_true_when_movieFile_was_added_today()
|
||||
{
|
||||
GivenAutoDownloadPropers();
|
||||
|
||||
|
@ -135,4 +103,4 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
|||
Subject.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,76 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class SameEpisodesSpecificationFixture : CoreTest<SameEpisodesSpecification>
|
||||
{
|
||||
private List<Episode> _episodes;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_episodes = Builder<Episode>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(e => e.EpisodeFileId = 1)
|
||||
.BuildList();
|
||||
}
|
||||
|
||||
private void GivenEpisodesInFile(List<Episode> episodes)
|
||||
{
|
||||
Mocker.GetMock<IEpisodeService>()
|
||||
.Setup(s => s.GetEpisodesByFileId(It.IsAny<int>()))
|
||||
.Returns(episodes);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_upgrade_when_new_release_contains_less_episodes()
|
||||
{
|
||||
GivenEpisodesInFile(_episodes);
|
||||
|
||||
Subject.IsSatisfiedBy(new List<Episode> { _episodes.First() }).Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_upgrade_when_new_release_contains_more_episodes()
|
||||
{
|
||||
GivenEpisodesInFile(new List<Episode> { _episodes.First() });
|
||||
|
||||
Subject.IsSatisfiedBy(_episodes).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_upgrade_when_new_release_contains_the_same_episodes()
|
||||
{
|
||||
GivenEpisodesInFile(_episodes);
|
||||
|
||||
Subject.IsSatisfiedBy(_episodes).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_upgrade_when_release_contains_the_same_episodes_as_multiple_files()
|
||||
{
|
||||
var episodes = Builder<Episode>.CreateListOfSize(2)
|
||||
.BuildList();
|
||||
|
||||
Mocker.GetMock<IEpisodeService>()
|
||||
.Setup(s => s.GetEpisodesByFileId(episodes.First().EpisodeFileId))
|
||||
.Returns(new List<Episode> { episodes.First() });
|
||||
|
||||
Mocker.GetMock<IEpisodeService>()
|
||||
.Setup(s => s.GetEpisodesByFileId(episodes.Last().EpisodeFileId))
|
||||
.Returns(new List<Episode> { episodes.Last() });
|
||||
|
||||
Subject.IsSatisfiedBy(episodes).Should().BeTrue();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,35 +1,35 @@
|
|||
using FizzWare.NBuilder;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications.Search;
|
||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests.Search
|
||||
{
|
||||
[TestFixture]
|
||||
public class SeriesSpecificationFixture : TestBase<SeriesSpecification>
|
||||
public class MovieSpecificationFixture : TestBase<MovieSpecification>
|
||||
{
|
||||
private Series _series1;
|
||||
private Series _series2;
|
||||
private RemoteEpisode _remoteEpisode = new RemoteEpisode();
|
||||
private SearchCriteriaBase _searchCriteria = new SingleEpisodeSearchCriteria();
|
||||
private Movie _movie1;
|
||||
private Movie _movie2;
|
||||
private RemoteMovie _remoteEpisode = new RemoteMovie();
|
||||
private SearchCriteriaBase _searchCriteria = new MovieSearchCriteria();
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_series1 = Builder<Series>.CreateNew().With(s => s.Id = 1).Build();
|
||||
_series2 = Builder<Series>.CreateNew().With(s => s.Id = 2).Build();
|
||||
_movie1 = Builder<Movie>.CreateNew().With(s => s.Id = 1).Build();
|
||||
_movie2 = Builder<Movie>.CreateNew().With(s => s.Id = 2).Build();
|
||||
|
||||
_remoteEpisode.Series = _series1;
|
||||
_remoteEpisode.Movie = _movie1;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_series_doesnt_match()
|
||||
{
|
||||
_searchCriteria.Series = _series2;
|
||||
_searchCriteria.Movie = _movie2;
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, _searchCriteria).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.Search
|
|||
[Test]
|
||||
public void should_return_true_when_series_ids_match()
|
||||
{
|
||||
_searchCriteria.Series = _series1;
|
||||
_searchCriteria.Movie = _movie1;
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, _searchCriteria).Accepted.Should().BeTrue();
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
using FizzWare.NBuilder;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
|
@ -8,7 +8,7 @@ using NzbDrone.Core.Indexers;
|
|||
using NzbDrone.Core.Indexers.TorrentRss;
|
||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests.Search
|
||||
|
@ -16,18 +16,18 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.Search
|
|||
[TestFixture]
|
||||
public class TorrentSeedingSpecificationFixture : TestBase<TorrentSeedingSpecification>
|
||||
{
|
||||
private Series _series;
|
||||
private RemoteEpisode _remoteEpisode;
|
||||
private Movie _movie;
|
||||
private RemoteMovie _remoteMovie;
|
||||
private IndexerDefinition _indexerDefinition;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_series = Builder<Series>.CreateNew().With(s => s.Id = 1).Build();
|
||||
_movie = Builder<Movie>.CreateNew().With(s => s.Id = 1).Build();
|
||||
|
||||
_remoteEpisode = new RemoteEpisode
|
||||
_remoteMovie = new RemoteMovie
|
||||
{
|
||||
Series = _series,
|
||||
Movie = _movie,
|
||||
Release = new TorrentInfo
|
||||
{
|
||||
IndexerId = 1,
|
||||
|
@ -49,27 +49,27 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.Search
|
|||
|
||||
private void GivenReleaseSeeders(int? seeders)
|
||||
{
|
||||
(_remoteEpisode.Release as TorrentInfo).Seeders = seeders;
|
||||
(_remoteMovie.Release as TorrentInfo).Seeders = seeders;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_not_torrent()
|
||||
{
|
||||
_remoteEpisode.Release = new ReleaseInfo
|
||||
_remoteMovie.Release = new ReleaseInfo
|
||||
{
|
||||
IndexerId = 1,
|
||||
Title = "Series.Title.S01.720p.BluRay.X264-RlsGrp"
|
||||
};
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_indexer_not_specified()
|
||||
{
|
||||
_remoteEpisode.Release.IndexerId = 0;
|
||||
_remoteMovie.Release.IndexerId = 0;
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -79,7 +79,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.Search
|
|||
.Setup(v => v.Get(It.IsAny<int>()))
|
||||
.Callback<int>(i => { throw new ModelNotFoundException(typeof(IndexerDefinition), i); });
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -87,7 +87,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.Search
|
|||
{
|
||||
GivenReleaseSeeders(null);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[TestCase(5)]
|
||||
|
@ -96,7 +96,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.Search
|
|||
{
|
||||
GivenReleaseSeeders(seeders);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[TestCase(0)]
|
||||
|
@ -105,7 +105,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.Search
|
|||
{
|
||||
GivenReleaseSeeders(seeders);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
|
@ -8,7 +8,7 @@ using NzbDrone.Core.MediaFiles;
|
|||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Profiles;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
@ -20,11 +20,9 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
public class UpgradeDiskSpecificationFixture : CoreTest<UpgradeDiskSpecification>
|
||||
{
|
||||
private UpgradeDiskSpecification _upgradeDisk;
|
||||
|
||||
private RemoteEpisode _parseResultMulti;
|
||||
private RemoteEpisode _parseResultSingle;
|
||||
private EpisodeFile _firstFile;
|
||||
private EpisodeFile _secondFile;
|
||||
|
||||
private RemoteMovie _parseResultSingle;
|
||||
private MovieFile _firstFile;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
|
@ -32,28 +30,17 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
Mocker.Resolve<QualityUpgradableSpecification>();
|
||||
_upgradeDisk = Mocker.Resolve<UpgradeDiskSpecification>();
|
||||
|
||||
_firstFile = new EpisodeFile { Quality = new QualityModel(Quality.Bluray1080p, new Revision(version: 2)), DateAdded = DateTime.Now };
|
||||
_secondFile = new EpisodeFile { Quality = new QualityModel(Quality.Bluray1080p, new Revision(version: 2)), DateAdded = DateTime.Now };
|
||||
_firstFile = new MovieFile { Quality = new QualityModel(Quality.Bluray1080p, new Revision(version: 2)), DateAdded = DateTime.Now };
|
||||
|
||||
var singleEpisodeList = new List<Episode> { new Episode { EpisodeFile = _firstFile, EpisodeFileId = 1 }, new Episode { EpisodeFile = null } };
|
||||
var doubleEpisodeList = new List<Episode> { new Episode { EpisodeFile = _firstFile, EpisodeFileId = 1 }, new Episode { EpisodeFile = _secondFile, EpisodeFileId = 1 }, new Episode { EpisodeFile = null } };
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew()
|
||||
var fakeSeries = Builder<Movie>.CreateNew()
|
||||
.With(c => c.Profile = new Profile { Cutoff = Quality.Bluray1080p, Items = Qualities.QualityFixture.GetDefaultQualities() })
|
||||
.With(e => e.MovieFile = _firstFile)
|
||||
.Build();
|
||||
|
||||
_parseResultMulti = new RemoteEpisode
|
||||
_parseResultSingle = new RemoteMovie
|
||||
{
|
||||
Series = fakeSeries,
|
||||
ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.DVD, new Revision(version: 2)) },
|
||||
Episodes = doubleEpisodeList
|
||||
};
|
||||
|
||||
_parseResultSingle = new RemoteEpisode
|
||||
{
|
||||
Series = fakeSeries,
|
||||
ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.DVD, new Revision(version: 2)) },
|
||||
Episodes = singleEpisodeList
|
||||
Movie = fakeSeries,
|
||||
ParsedMovieInfo = new ParsedMovieInfo() { Quality = new QualityModel(Quality.DVD, new Revision(version: 2)) },
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -62,23 +49,10 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
_firstFile.Quality = new QualityModel(Quality.SDTV);
|
||||
}
|
||||
|
||||
private void WithSecondFileUpgradable()
|
||||
{
|
||||
_secondFile.Quality = new QualityModel(Quality.SDTV);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_episode_has_no_existing_file()
|
||||
{
|
||||
_parseResultSingle.Episodes.ForEach(c => c.EpisodeFileId = 0);
|
||||
_upgradeDisk.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_single_episode_doesnt_exist_on_disk()
|
||||
{
|
||||
_parseResultSingle.Episodes = new List<Episode>();
|
||||
|
||||
_parseResultSingle.Movie.MovieFileId = 0;
|
||||
_upgradeDisk.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
|
@ -89,40 +63,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
_upgradeDisk.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_upgradable_if_both_episodes_are_upgradable()
|
||||
{
|
||||
WithFirstFileUpgradable();
|
||||
WithSecondFileUpgradable();
|
||||
_upgradeDisk.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_not_upgradable_if_both_episodes_are_not_upgradable()
|
||||
{
|
||||
_upgradeDisk.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_not_upgradable_if_only_first_episodes_is_upgradable()
|
||||
{
|
||||
WithFirstFileUpgradable();
|
||||
_upgradeDisk.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_not_upgradable_if_only_second_episodes_is_upgradable()
|
||||
{
|
||||
WithSecondFileUpgradable();
|
||||
_upgradeDisk.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_be_upgradable_if_qualities_are_the_same()
|
||||
{
|
||||
_firstFile.Quality = new QualityModel(Quality.WEBDL1080p);
|
||||
_parseResultSingle.ParsedEpisodeInfo.Quality = new QualityModel(Quality.WEBDL1080p);
|
||||
_parseResultSingle.ParsedMovieInfo.Quality = new QualityModel(Quality.WEBDL1080p);
|
||||
_upgradeDisk.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
|
@ -10,12 +10,12 @@ using NzbDrone.Core.Download;
|
|||
using NzbDrone.Core.Download.TrackedDownloads;
|
||||
using NzbDrone.Core.History;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.MediaFiles.EpisodeImport;
|
||||
using NzbDrone.Core.MediaFiles.MovieImport;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.Download
|
||||
|
@ -83,7 +83,7 @@ namespace NzbDrone.Core.Test.Download
|
|||
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Movie>(), It.IsAny<DownloadClientItem>()))
|
||||
.Returns(new List<ImportResult>
|
||||
{
|
||||
new ImportResult(new ImportDecision(new LocalEpisode() { Path = @"C:\TestPath\Droned.1998.mkv" }))
|
||||
new ImportResult(new ImportDecision(new LocalMovie() { Path = @"C:\TestPath\Droned.1998.mkv" }))
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -307,7 +307,7 @@ namespace NzbDrone.Core.Test.Download
|
|||
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Movie>(), It.IsAny<DownloadClientItem>()))
|
||||
.Returns(new List<ImportResult>
|
||||
{
|
||||
new ImportResult(new ImportDecision(new LocalEpisode {Path = @"C:\TestPath\Droned.1998.mkv"}))
|
||||
new ImportResult(new ImportDecision(new LocalMovie {Path = @"C:\TestPath\Droned.1998.mkv"}))
|
||||
});
|
||||
|
||||
Mocker.GetMock<IHistoryService>()
|
||||
|
|
|
@ -11,7 +11,7 @@ using NzbDrone.Core.Parser.Model;
|
|||
using NzbDrone.Core.Profiles;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests
|
||||
|
|
|
@ -8,7 +8,7 @@ using NzbDrone.Core.IndexerSearch.Definitions;
|
|||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.RemotePathMappings;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using Moq;
|
||||
|
@ -38,8 +38,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
|
|||
_remoteMovie.Release.Title = _title;
|
||||
_remoteMovie.Release.DownloadUrl = _nzbUrl;
|
||||
|
||||
_remoteMovie.ParsedEpisodeInfo = new ParsedEpisodeInfo();
|
||||
_remoteMovie.ParsedEpisodeInfo.FullSeason = false;
|
||||
_remoteMovie.ParsedMovieInfo = new ParsedMovieInfo();
|
||||
|
||||
Subject.Definition = new DownloadClientDefinition();
|
||||
Subject.Definition.Settings = new PneumaticSettings
|
||||
|
@ -70,15 +69,6 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
|
|||
Assert.Throws<WebException>(() => Subject.Download(_remoteMovie));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_throw_if_full_season_download()
|
||||
{
|
||||
_remoteMovie.Release.Title = "30 Rock - Season 1";
|
||||
_remoteMovie.ParsedEpisodeInfo.FullSeason = true;
|
||||
|
||||
Assert.Throws<NotSupportedException>(() => Subject.Download(_remoteMovie));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_throw_item_is_removed()
|
||||
{
|
||||
|
|
|
@ -8,7 +8,7 @@ using NUnit.Framework;
|
|||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.Download.Clients.Sabnzbd;
|
||||
using NzbDrone.Core.Download.Clients.Sabnzbd.Responses;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Test.Common;
|
||||
using NzbDrone.Core.RemotePathMappings;
|
||||
using NzbDrone.Common.Disk;
|
||||
|
|
|
@ -12,7 +12,7 @@ using NzbDrone.Core.Exceptions;
|
|||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.Download
|
||||
|
@ -20,7 +20,7 @@ namespace NzbDrone.Core.Test.Download
|
|||
[TestFixture]
|
||||
public class DownloadServiceFixture : CoreTest<DownloadService>
|
||||
{
|
||||
private RemoteEpisode _parseResult;
|
||||
private RemoteMovie _parseResult;
|
||||
private List<IDownloadClient> _downloadClients;
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
|
@ -35,21 +35,14 @@ namespace NzbDrone.Core.Test.Download
|
|||
.Setup(v => v.GetDownloadClient(It.IsAny<DownloadProtocol>()))
|
||||
.Returns<DownloadProtocol>(v => _downloadClients.FirstOrDefault(d => d.Protocol == v));
|
||||
|
||||
var episodes = Builder<Episode>.CreateListOfSize(2)
|
||||
.TheFirst(1).With(s => s.Id = 12)
|
||||
.TheNext(1).With(s => s.Id = 99)
|
||||
.All().With(s => s.SeriesId = 5)
|
||||
.Build().ToList();
|
||||
|
||||
var releaseInfo = Builder<ReleaseInfo>.CreateNew()
|
||||
.With(v => v.DownloadProtocol = DownloadProtocol.Usenet)
|
||||
.With(v => v.DownloadUrl = "http://test.site/download1.ext")
|
||||
.Build();
|
||||
|
||||
_parseResult = Builder<RemoteEpisode>.CreateNew()
|
||||
.With(c => c.Series = Builder<Series>.CreateNew().Build())
|
||||
_parseResult = Builder<RemoteMovie>.CreateNew()
|
||||
.With(c => c.Movie = Builder<Movie>.CreateNew().Build())
|
||||
.With(c => c.Release = releaseInfo)
|
||||
.With(c => c.Episodes = episodes)
|
||||
.Build();
|
||||
}
|
||||
|
||||
|
@ -81,42 +74,42 @@ namespace NzbDrone.Core.Test.Download
|
|||
public void Download_report_should_publish_on_grab_event()
|
||||
{
|
||||
var mock = WithUsenetClient();
|
||||
mock.Setup(s => s.Download(It.IsAny<RemoteEpisode>()));
|
||||
mock.Setup(s => s.Download(It.IsAny<RemoteMovie>()));
|
||||
|
||||
Subject.DownloadReport(_parseResult);
|
||||
|
||||
VerifyEventPublished<EpisodeGrabbedEvent>();
|
||||
VerifyEventPublished<MovieGrabbedEvent>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Download_report_should_grab_using_client()
|
||||
{
|
||||
var mock = WithUsenetClient();
|
||||
mock.Setup(s => s.Download(It.IsAny<RemoteEpisode>()));
|
||||
mock.Setup(s => s.Download(It.IsAny<RemoteMovie>()));
|
||||
|
||||
Subject.DownloadReport(_parseResult);
|
||||
|
||||
mock.Verify(s => s.Download(It.IsAny<RemoteEpisode>()), Times.Once());
|
||||
mock.Verify(s => s.Download(It.IsAny<RemoteMovie>()), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Download_report_should_not_publish_on_failed_grab_event()
|
||||
{
|
||||
var mock = WithUsenetClient();
|
||||
mock.Setup(s => s.Download(It.IsAny<RemoteEpisode>()))
|
||||
mock.Setup(s => s.Download(It.IsAny<RemoteMovie>()))
|
||||
.Throws(new WebException());
|
||||
|
||||
Assert.Throws<WebException>(() => Subject.DownloadReport(_parseResult));
|
||||
|
||||
VerifyEventNotPublished<EpisodeGrabbedEvent>();
|
||||
VerifyEventNotPublished<MovieGrabbedEvent>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Download_report_should_trigger_indexer_backoff_on_indexer_error()
|
||||
{
|
||||
var mock = WithUsenetClient();
|
||||
mock.Setup(s => s.Download(It.IsAny<RemoteEpisode>()))
|
||||
.Callback<RemoteEpisode>(v => {
|
||||
mock.Setup(s => s.Download(It.IsAny<RemoteMovie>()))
|
||||
.Callback<RemoteMovie>(v => {
|
||||
throw new ReleaseDownloadException(v.Release, "Error", new WebException());
|
||||
});
|
||||
|
||||
|
@ -134,8 +127,8 @@ namespace NzbDrone.Core.Test.Download
|
|||
response.Headers["Retry-After"] = "300";
|
||||
|
||||
var mock = WithUsenetClient();
|
||||
mock.Setup(s => s.Download(It.IsAny<RemoteEpisode>()))
|
||||
.Callback<RemoteEpisode>(v => {
|
||||
mock.Setup(s => s.Download(It.IsAny<RemoteMovie>()))
|
||||
.Callback<RemoteMovie>(v => {
|
||||
throw new ReleaseDownloadException(v.Release, "Error", new TooManyRequestsException(request, response));
|
||||
});
|
||||
|
||||
|
@ -153,8 +146,8 @@ namespace NzbDrone.Core.Test.Download
|
|||
response.Headers["Retry-After"] = DateTime.UtcNow.AddSeconds(300).ToString("r");
|
||||
|
||||
var mock = WithUsenetClient();
|
||||
mock.Setup(s => s.Download(It.IsAny<RemoteEpisode>()))
|
||||
.Callback<RemoteEpisode>(v =>
|
||||
mock.Setup(s => s.Download(It.IsAny<RemoteMovie>()))
|
||||
.Callback<RemoteMovie>(v =>
|
||||
{
|
||||
throw new ReleaseDownloadException(v.Release, "Error", new TooManyRequestsException(request, response));
|
||||
});
|
||||
|
@ -170,7 +163,7 @@ namespace NzbDrone.Core.Test.Download
|
|||
public void Download_report_should_not_trigger_indexer_backoff_on_downloadclient_error()
|
||||
{
|
||||
var mock = WithUsenetClient();
|
||||
mock.Setup(s => s.Download(It.IsAny<RemoteEpisode>()))
|
||||
mock.Setup(s => s.Download(It.IsAny<RemoteMovie>()))
|
||||
.Throws(new DownloadClientException("Some Error"));
|
||||
|
||||
Assert.Throws<DownloadClientException>(() => Subject.DownloadReport(_parseResult));
|
||||
|
@ -184,8 +177,8 @@ namespace NzbDrone.Core.Test.Download
|
|||
{
|
||||
Subject.DownloadReport(_parseResult);
|
||||
|
||||
Mocker.GetMock<IDownloadClient>().Verify(c => c.Download(It.IsAny<RemoteEpisode>()), Times.Never());
|
||||
VerifyEventNotPublished<EpisodeGrabbedEvent>();
|
||||
Mocker.GetMock<IDownloadClient>().Verify(c => c.Download(It.IsAny<RemoteMovie>()), Times.Never());
|
||||
VerifyEventNotPublished<MovieGrabbedEvent>();
|
||||
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
}
|
||||
|
@ -198,8 +191,8 @@ namespace NzbDrone.Core.Test.Download
|
|||
|
||||
Subject.DownloadReport(_parseResult);
|
||||
|
||||
mockTorrent.Verify(c => c.Download(It.IsAny<RemoteEpisode>()), Times.Never());
|
||||
mockUsenet.Verify(c => c.Download(It.IsAny<RemoteEpisode>()), Times.Once());
|
||||
mockTorrent.Verify(c => c.Download(It.IsAny<RemoteMovie>()), Times.Never());
|
||||
mockUsenet.Verify(c => c.Download(It.IsAny<RemoteMovie>()), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -212,8 +205,8 @@ namespace NzbDrone.Core.Test.Download
|
|||
|
||||
Subject.DownloadReport(_parseResult);
|
||||
|
||||
mockTorrent.Verify(c => c.Download(It.IsAny<RemoteEpisode>()), Times.Once());
|
||||
mockUsenet.Verify(c => c.Download(It.IsAny<RemoteEpisode>()), Times.Never());
|
||||
mockTorrent.Verify(c => c.Download(It.IsAny<RemoteMovie>()), Times.Once());
|
||||
mockUsenet.Verify(c => c.Download(It.IsAny<RemoteMovie>()), Times.Never());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
|
@ -10,7 +10,7 @@ using NzbDrone.Core.History;
|
|||
using NzbDrone.Core.Messaging.Events;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.Download
|
||||
|
@ -32,16 +32,15 @@ namespace NzbDrone.Core.Test.Download
|
|||
|
||||
_grabHistory = Builder<History.History>.CreateListOfSize(2).BuildList();
|
||||
|
||||
var remoteEpisode = new RemoteEpisode
|
||||
var remoteEpisode = new RemoteMovie
|
||||
{
|
||||
Series = new Series(),
|
||||
Episodes = new List<Episode> { new Episode { Id = 1 } }
|
||||
Movie = new Movie(),
|
||||
};
|
||||
|
||||
_trackedDownload = Builder<TrackedDownload>.CreateNew()
|
||||
.With(c => c.State = TrackedDownloadStage.Downloading)
|
||||
.With(c => c.DownloadItem = completed)
|
||||
.With(c => c.RemoteEpisode = remoteEpisode)
|
||||
.With(c => c.RemoteMovie = remoteEpisode)
|
||||
.Build();
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FizzWare.NBuilder;
|
||||
using Marr.Data;
|
||||
|
@ -12,7 +12,7 @@ using NzbDrone.Core.Parser.Model;
|
|||
using NzbDrone.Core.Profiles;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
|
||||
namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
|
||||
{
|
||||
|
@ -67,7 +67,7 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
|
|||
.Returns(_movie);
|
||||
|
||||
Mocker.GetMock<IPrioritizeDownloadDecision>()
|
||||
.Setup(s => s.PrioritizeDecisions(It.IsAny<List<DownloadDecision>>()))
|
||||
.Setup(s => s.PrioritizeDecisionsForMovies(It.IsAny<List<DownloadDecision>>()))
|
||||
.Returns((List<DownloadDecision> d) => d);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using FizzWare.NBuilder;
|
||||
using Marr.Data;
|
||||
using Moq;
|
||||
|
@ -12,7 +12,7 @@ using NzbDrone.Core.Parser.Model;
|
|||
using NzbDrone.Core.Profiles;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
|
||||
namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
|
||||
{
|
||||
|
@ -72,7 +72,7 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
|
|||
// .Returns(_episode);
|
||||
|
||||
Mocker.GetMock<IPrioritizeDownloadDecision>()
|
||||
.Setup(s => s.PrioritizeDecisions(It.IsAny<List<DownloadDecision>>()))
|
||||
.Setup(s => s.PrioritizeDecisionsForMovies(It.IsAny<List<DownloadDecision>>()))
|
||||
.Returns((List<DownloadDecision> d) => d);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using Moq;
|
||||
|
@ -8,7 +8,7 @@ using NzbDrone.Core.Download.Pending;
|
|||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
|
||||
namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
|
||||
{
|
||||
|
@ -17,18 +17,18 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
|
|||
public class RemovePendingFixture : CoreTest<PendingReleaseService>
|
||||
{
|
||||
private List<PendingRelease> _pending;
|
||||
private Episode _episode;
|
||||
private Movie _movie;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_pending = new List<PendingRelease>();
|
||||
|
||||
_episode = Builder<Episode>.CreateNew()
|
||||
_movie = Builder<Movie>.CreateNew()
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<IPendingReleaseRepository>()
|
||||
.Setup(s => s.AllBySeriesId(It.IsAny<int>()))
|
||||
.Setup(s => s.AllByMovieId(It.IsAny<int>()))
|
||||
.Returns(_pending);
|
||||
|
||||
Mocker.GetMock<IPendingReleaseRepository>()
|
||||
|
@ -44,21 +44,21 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
|
|||
.Returns(_movie);*/
|
||||
}
|
||||
|
||||
private void AddPending(int id, int seasonNumber, int[] episodes)
|
||||
private void AddPending(int id, string title, int year)
|
||||
{
|
||||
_pending.Add(new PendingRelease
|
||||
{
|
||||
Id = id,
|
||||
ParsedEpisodeInfo = new ParsedEpisodeInfo { SeasonNumber = seasonNumber, EpisodeNumbers = episodes }
|
||||
ParsedMovieInfo = new ParsedMovieInfo { MovieTitle = title, Year = year }
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_remove_same_release()
|
||||
{
|
||||
AddPending(id: 1, seasonNumber: 2, episodes: new[] { 3 });
|
||||
AddPending(id: 1, title: "Movie", year: 2001);
|
||||
|
||||
var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-ep{1}", 1, _episode.Id));
|
||||
var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-ep{1}", 1, _movie.Id));
|
||||
|
||||
Subject.RemovePendingQueueItems(queueId);
|
||||
|
||||
|
@ -68,12 +68,12 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
|
|||
[Test]
|
||||
public void should_remove_multiple_releases_release()
|
||||
{
|
||||
AddPending(id: 1, seasonNumber: 2, episodes: new[] { 1 });
|
||||
AddPending(id: 2, seasonNumber: 2, episodes: new[] { 2 });
|
||||
AddPending(id: 3, seasonNumber: 2, episodes: new[] { 3 });
|
||||
AddPending(id: 4, seasonNumber: 2, episodes: new[] { 3 });
|
||||
AddPending(id: 1, title: "Movie", year: 2001);
|
||||
AddPending(id: 2, title: "Movie", year: 2002);
|
||||
AddPending(id: 3, title: "Movie", year: 2003);
|
||||
AddPending(id: 4, title: "Movie", year: 2003);
|
||||
|
||||
var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-ep{1}", 3, _episode.Id));
|
||||
var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-ep{1}", 3, _movie.Id));
|
||||
|
||||
Subject.RemovePendingQueueItems(queueId);
|
||||
|
||||
|
@ -83,12 +83,12 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
|
|||
[Test]
|
||||
public void should_not_remove_diffrent_season()
|
||||
{
|
||||
AddPending(id: 1, seasonNumber: 2, episodes: new[] { 1 });
|
||||
AddPending(id: 2, seasonNumber: 2, episodes: new[] { 1 });
|
||||
AddPending(id: 3, seasonNumber: 3, episodes: new[] { 1 });
|
||||
AddPending(id: 4, seasonNumber: 3, episodes: new[] { 1 });
|
||||
AddPending(id: 1, title: "Movie", year: 2001);
|
||||
AddPending(id: 2, title: "Movie", year: 2001);
|
||||
AddPending(id: 3, title: "Movie", year: 2001);
|
||||
AddPending(id: 4, title: "Movie", year: 2001);
|
||||
|
||||
var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-ep{1}", 1, _episode.Id));
|
||||
var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-ep{1}", 1, _movie.Id));
|
||||
|
||||
Subject.RemovePendingQueueItems(queueId);
|
||||
|
||||
|
@ -98,12 +98,12 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
|
|||
[Test]
|
||||
public void should_not_remove_diffrent_episodes()
|
||||
{
|
||||
AddPending(id: 1, seasonNumber: 2, episodes: new[] { 1 });
|
||||
AddPending(id: 2, seasonNumber: 2, episodes: new[] { 1 });
|
||||
AddPending(id: 3, seasonNumber: 2, episodes: new[] { 2 });
|
||||
AddPending(id: 4, seasonNumber: 2, episodes: new[] { 3 });
|
||||
AddPending(id: 1, title: "Movie", year: 2001);
|
||||
AddPending(id: 2, title: "Movie", year: 2001);
|
||||
AddPending(id: 3, title: "Movie", year: 2001);
|
||||
AddPending(id: 4, title: "Movie", year: 2001);
|
||||
|
||||
var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-ep{1}", 1, _episode.Id));
|
||||
var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-ep{1}", 1, _movie.Id));
|
||||
|
||||
Subject.RemovePendingQueueItems(queueId);
|
||||
|
||||
|
@ -113,10 +113,10 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
|
|||
[Test]
|
||||
public void should_not_remove_multiepisodes()
|
||||
{
|
||||
AddPending(id: 1, seasonNumber: 2, episodes: new[] { 1 });
|
||||
AddPending(id: 2, seasonNumber: 2, episodes: new[] { 1, 2 });
|
||||
AddPending(id: 1, title: "Movie", year: 2001);
|
||||
AddPending(id: 2, title: "Movie", year: 2001);
|
||||
|
||||
var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-ep{1}", 1, _episode.Id));
|
||||
var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-ep{1}", 1, _movie.Id));
|
||||
|
||||
Subject.RemovePendingQueueItems(queueId);
|
||||
|
||||
|
@ -126,10 +126,10 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
|
|||
[Test]
|
||||
public void should_not_remove_singleepisodes()
|
||||
{
|
||||
AddPending(id: 1, seasonNumber: 2, episodes: new[] { 1 });
|
||||
AddPending(id: 2, seasonNumber: 2, episodes: new[] { 1, 2 });
|
||||
AddPending(id: 1, title: "Movie", year: 2001);
|
||||
AddPending(id: 2, title: "Movie", year: 2001);
|
||||
|
||||
var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-ep{1}", 2, _episode.Id));
|
||||
var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-ep{1}", 2, _movie.Id));
|
||||
|
||||
Subject.RemovePendingQueueItems(queueId);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FizzWare.NBuilder;
|
||||
using Marr.Data;
|
||||
|
@ -14,7 +14,7 @@ using NzbDrone.Core.Parser.Model;
|
|||
using NzbDrone.Core.Profiles;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
|
||||
namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
|
||||
{
|
||||
|
@ -75,7 +75,7 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
|
|||
.Returns(_movie);
|
||||
|
||||
Mocker.GetMock<IPrioritizeDownloadDecision>()
|
||||
.Setup(s => s.PrioritizeDecisions(It.IsAny<List<DownloadDecision>>()))
|
||||
.Setup(s => s.PrioritizeDecisionsForMovies(It.IsAny<List<DownloadDecision>>()))
|
||||
.Returns((List<DownloadDecision> d) => d);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
|
@ -8,7 +8,7 @@ using NzbDrone.Core.History;
|
|||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using System.Linq;
|
||||
|
||||
|
@ -25,8 +25,6 @@ namespace NzbDrone.Core.Test.Download.TrackedDownloads
|
|||
new History.History(){
|
||||
DownloadId = "35238",
|
||||
SourceTitle = "TV Series S01",
|
||||
SeriesId = 5,
|
||||
EpisodeId = 4,
|
||||
MovieId = 3,
|
||||
}
|
||||
});
|
||||
|
|
|
@ -11,7 +11,7 @@ using NzbDrone.Core.Extras.Metadata;
|
|||
using NzbDrone.Core.Extras.Metadata.Files;
|
||||
using NzbDrone.Core.Housekeeping.Housekeepers;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.HealthCheck.Checks
|
||||
|
@ -80,7 +80,7 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
|
|||
Subject.Clean();
|
||||
|
||||
Mocker.GetMock<IConfigService>().VerifySet(c => c.CleanupMetadataImages = true, Times.Never());
|
||||
Mocker.GetMock<ISeriesService>().Verify(c => c.GetAllSeries(), Times.Never());
|
||||
Mocker.GetMock<IMovieService>().Verify(c => c.GetAllMovies(), Times.Never());
|
||||
|
||||
AssertImageWasNotRemoved();
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using Moq;
|
||||
|
@ -6,7 +6,7 @@ using NUnit.Framework;
|
|||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.HealthCheck.Checks;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
|
||||
namespace NzbDrone.Core.Test.HealthCheck.Checks
|
||||
{
|
||||
|
@ -15,17 +15,17 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
|
|||
{
|
||||
private void GivenMissingRootFolder()
|
||||
{
|
||||
var series = Builder<Series>.CreateListOfSize(1)
|
||||
var movies = Builder<Movie>.CreateListOfSize(1)
|
||||
.Build()
|
||||
.ToList();
|
||||
|
||||
Mocker.GetMock<ISeriesService>()
|
||||
.Setup(s => s.GetAllSeries())
|
||||
.Returns(series);
|
||||
Mocker.GetMock<IMovieService>()
|
||||
.Setup(s => s.GetAllMovies())
|
||||
.Returns(movies);
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(s => s.GetParentFolder(series.First().Path))
|
||||
.Returns(@"C:\TV");
|
||||
.Setup(s => s.GetParentFolder(movies.First().Path))
|
||||
.Returns(@"C:\Movies");
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(s => s.FolderExists(It.IsAny<string>()))
|
||||
|
@ -33,17 +33,17 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
|
|||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_return_error_when_no_series()
|
||||
public void should_not_return_error_when_no_movie()
|
||||
{
|
||||
Mocker.GetMock<ISeriesService>()
|
||||
.Setup(s => s.GetAllSeries())
|
||||
.Returns(new List<Series>());
|
||||
Mocker.GetMock<IMovieService>()
|
||||
.Setup(s => s.GetAllMovies())
|
||||
.Returns(new List<Movie>());
|
||||
|
||||
Subject.Check().ShouldBeOk();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_error_if_series_parent_is_missing()
|
||||
public void should_return_error_if_movie_parent_is_missing()
|
||||
{
|
||||
GivenMissingRootFolder();
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ using NzbDrone.Core.Qualities;
|
|||
using System.Collections.Generic;
|
||||
using NzbDrone.Core.Test.Qualities;
|
||||
using FluentAssertions;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
|
||||
namespace NzbDrone.Core.Test.HistoryTests
|
||||
{
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
using FizzWare.NBuilder;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Blacklisting;
|
||||
using NzbDrone.Core.Housekeeping.Housekeepers;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NzbDrone.Core.Test.Housekeeping.Housekeepers
|
||||
|
@ -17,7 +17,7 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers
|
|||
public void should_delete_orphaned_blacklist_items()
|
||||
{
|
||||
var blacklist = Builder<Blacklist>.CreateNew()
|
||||
.With(h => h.EpisodeIds = new List<int>())
|
||||
.With(h => h.MovieId = new int())
|
||||
.With(h => h.Quality = new QualityModel())
|
||||
.BuildNew();
|
||||
|
||||
|
@ -34,7 +34,7 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers
|
|||
Db.Insert(movie);
|
||||
|
||||
var blacklist = Builder<Blacklist>.CreateNew()
|
||||
.With(h => h.EpisodeIds = new List<int>())
|
||||
.With(h => h.MovieId = new int())
|
||||
.With(h => h.Quality = new QualityModel())
|
||||
.With(b => b.MovieId = movie.Id)
|
||||
.BuildNew();
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Housekeeping.Housekeepers;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.Test.Housekeeping.Housekeepers
|
||||
{
|
||||
[TestFixture]
|
||||
public class CleanupOrphanedEpisodesFixture : DbTest<CleanupOrphanedEpisodes, Episode>
|
||||
{
|
||||
[Test]
|
||||
public void should_delete_orphaned_episodes()
|
||||
{
|
||||
var episode = Builder<Episode>.CreateNew()
|
||||
.BuildNew();
|
||||
|
||||
Db.Insert(episode);
|
||||
Subject.Clean();
|
||||
AllStoredModels.Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_delete_unorphaned_episodes()
|
||||
{
|
||||
var series = Builder<Series>.CreateNew()
|
||||
.BuildNew();
|
||||
|
||||
Db.Insert(series);
|
||||
|
||||
var episodes = Builder<Episode>.CreateListOfSize(2)
|
||||
.TheFirst(1)
|
||||
.With(e => e.SeriesId = series.Id)
|
||||
.BuildListOfNew();
|
||||
|
||||
Db.InsertMany(episodes);
|
||||
Subject.Clean();
|
||||
AllStoredModels.Should().HaveCount(1);
|
||||
AllStoredModels.Should().Contain(e => e.SeriesId == series.Id);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@ using NUnit.Framework;
|
|||
using NzbDrone.Core.Housekeeping.Housekeepers;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
|
||||
namespace NzbDrone.Core.Test.Housekeeping.Housekeepers
|
||||
{
|
||||
|
|
|
@ -7,7 +7,7 @@ using NzbDrone.Core.Housekeeping.Housekeepers;
|
|||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
|
||||
namespace NzbDrone.Core.Test.Housekeeping.Housekeepers
|
||||
{
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
using System.Linq;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Housekeeping.Housekeepers;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.Qualities;
|
||||
|
||||
namespace NzbDrone.Core.Test.Housekeeping.Housekeepers
|
||||
{
|
||||
[TestFixture]
|
||||
public class CleanupOrphanedEpisodeFilesFixture : DbTest<CleanupOrphanedEpisodeFiles, MovieFile>
|
||||
public class CleanupOrphanedMovieFilesFixture : DbTest<CleanupOrphanedMovieFiles, MovieFile>
|
||||
{
|
||||
[Test]
|
||||
public void should_delete_orphaned_episode_files()
|
|
@ -5,7 +5,7 @@ using NzbDrone.Core.Download.Pending;
|
|||
using NzbDrone.Core.Housekeeping.Housekeepers;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
|
||||
namespace NzbDrone.Core.Test.Housekeeping.Housekeepers
|
||||
{
|
||||
|
|
|
@ -1,265 +0,0 @@
|
|||
using NzbDrone.Core.DecisionEngine;
|
||||
using NzbDrone.Core.DataAugmentation.Scene;
|
||||
using NzbDrone.Core.IndexerSearch;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using FizzWare.NBuilder;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
|
||||
namespace NzbDrone.Core.Test.IndexerSearchTests
|
||||
{
|
||||
public class NzbSearchServiceFixture : CoreTest<NzbSearchService>
|
||||
{
|
||||
private Mock<IIndexer> _mockIndexer;
|
||||
private Series _xemSeries;
|
||||
private List<Episode> _xemEpisodes;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
_mockIndexer = Mocker.GetMock<IIndexer>();
|
||||
_mockIndexer.SetupGet(s => s.Definition).Returns(new IndexerDefinition { Id = 1 });
|
||||
_mockIndexer.SetupGet(s => s.SupportsSearch).Returns(true);
|
||||
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(s => s.SearchEnabled(true))
|
||||
.Returns(new List<IIndexer> { _mockIndexer.Object });
|
||||
|
||||
Mocker.GetMock<IMakeDownloadDecision>()
|
||||
.Setup(s => s.GetSearchDecision(It.IsAny<List<Parser.Model.ReleaseInfo>>(), It.IsAny<SearchCriteriaBase>()))
|
||||
.Returns(new List<DownloadDecision>());
|
||||
|
||||
_xemSeries = Builder<Series>.CreateNew()
|
||||
.With(v => v.UseSceneNumbering = true)
|
||||
.With(v => v.Monitored = true)
|
||||
.Build();
|
||||
|
||||
_xemEpisodes = new List<Episode>();
|
||||
|
||||
Mocker.GetMock<ISeriesService>()
|
||||
.Setup(v => v.GetSeries(_xemSeries.Id))
|
||||
.Returns(_xemSeries);
|
||||
|
||||
Mocker.GetMock<IEpisodeService>()
|
||||
.Setup(v => v.GetEpisodesBySeason(_xemSeries.Id, It.IsAny<int>()))
|
||||
.Returns<int, int>((i, j) => _xemEpisodes.Where(d => d.SeasonNumber == j).ToList());
|
||||
|
||||
Mocker.GetMock<ISceneMappingService>()
|
||||
.Setup(s => s.GetSceneNames(It.IsAny<int>(), It.IsAny<List<int>>(), It.IsAny<List<int>>()))
|
||||
.Returns(new List<string>());
|
||||
}
|
||||
|
||||
private void WithEpisode(int seasonNumber, int episodeNumber, int? sceneSeasonNumber, int? sceneEpisodeNumber)
|
||||
{
|
||||
var episode = Builder<Episode>.CreateNew()
|
||||
.With(v => v.SeriesId == _xemSeries.Id)
|
||||
.With(v => v.Series == _xemSeries)
|
||||
.With(v => v.SeasonNumber, seasonNumber)
|
||||
.With(v => v.EpisodeNumber, episodeNumber)
|
||||
.With(v => v.SceneSeasonNumber, sceneSeasonNumber)
|
||||
.With(v => v.SceneEpisodeNumber, sceneEpisodeNumber)
|
||||
.With(v => v.Monitored = true)
|
||||
.Build();
|
||||
|
||||
_xemEpisodes.Add(episode);
|
||||
}
|
||||
|
||||
private void WithEpisodes()
|
||||
{
|
||||
// Season 1 maps to Scene Season 2 (one-to-one)
|
||||
WithEpisode(1, 12, 2, 3);
|
||||
WithEpisode(1, 13, 2, 4);
|
||||
|
||||
// Season 2 maps to Scene Season 3 & 4 (one-to-one)
|
||||
WithEpisode(2, 1, 3, 11);
|
||||
WithEpisode(2, 2, 3, 12);
|
||||
WithEpisode(2, 3, 4, 11);
|
||||
WithEpisode(2, 4, 4, 12);
|
||||
|
||||
// Season 3 maps to Scene Season 5 (partial)
|
||||
// Season 4 maps to Scene Season 5 & 6 (partial)
|
||||
WithEpisode(3, 1, 5, 11);
|
||||
WithEpisode(3, 2, 5, 12);
|
||||
WithEpisode(4, 1, 5, 13);
|
||||
WithEpisode(4, 2, 5, 14);
|
||||
WithEpisode(4, 3, 6, 11);
|
||||
WithEpisode(5, 1, 6, 12);
|
||||
|
||||
// Season 7+ maps normally, so no mapping specified.
|
||||
WithEpisode(7, 1, null, null);
|
||||
WithEpisode(7, 2, null, null);
|
||||
}
|
||||
|
||||
private List<SearchCriteriaBase> WatchForSearchCriteria()
|
||||
{
|
||||
var result = new List<SearchCriteriaBase>();
|
||||
|
||||
_mockIndexer.Setup(v => v.Fetch(It.IsAny<SingleEpisodeSearchCriteria>()))
|
||||
.Callback<SingleEpisodeSearchCriteria>(s => result.Add(s))
|
||||
.Returns(new List<Parser.Model.ReleaseInfo>());
|
||||
|
||||
_mockIndexer.Setup(v => v.Fetch(It.IsAny<SeasonSearchCriteria>()))
|
||||
.Callback<SeasonSearchCriteria>(s => result.Add(s))
|
||||
.Returns(new List<Parser.Model.ReleaseInfo>());
|
||||
|
||||
_mockIndexer.Setup(v => v.Fetch(It.IsAny<AnimeEpisodeSearchCriteria>()))
|
||||
.Callback<AnimeEpisodeSearchCriteria>(s => result.Add(s))
|
||||
.Returns(new List<Parser.Model.ReleaseInfo>());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void scene_episodesearch()
|
||||
{
|
||||
WithEpisodes();
|
||||
|
||||
var allCriteria = WatchForSearchCriteria();
|
||||
|
||||
Subject.EpisodeSearch(_xemEpisodes.First(), true);
|
||||
|
||||
var criteria = allCriteria.OfType<SingleEpisodeSearchCriteria>().ToList();
|
||||
|
||||
criteria.Count.Should().Be(1);
|
||||
criteria[0].SeasonNumber.Should().Be(2);
|
||||
criteria[0].EpisodeNumber.Should().Be(3);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void scene_seasonsearch()
|
||||
{
|
||||
WithEpisodes();
|
||||
|
||||
var allCriteria = WatchForSearchCriteria();
|
||||
|
||||
Subject.SeasonSearch(_xemSeries.Id, 1, false, true);
|
||||
|
||||
var criteria = allCriteria.OfType<SeasonSearchCriteria>().ToList();
|
||||
|
||||
criteria.Count.Should().Be(1);
|
||||
criteria[0].SeasonNumber.Should().Be(2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void scene_seasonsearch_should_search_multiple_seasons()
|
||||
{
|
||||
WithEpisodes();
|
||||
|
||||
var allCriteria = WatchForSearchCriteria();
|
||||
|
||||
Subject.SeasonSearch(_xemSeries.Id, 2, false, true);
|
||||
|
||||
var criteria = allCriteria.OfType<SeasonSearchCriteria>().ToList();
|
||||
|
||||
criteria.Count.Should().Be(2);
|
||||
criteria[0].SeasonNumber.Should().Be(3);
|
||||
criteria[1].SeasonNumber.Should().Be(4);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void scene_seasonsearch_should_search_single_episode_if_possible()
|
||||
{
|
||||
WithEpisodes();
|
||||
|
||||
var allCriteria = WatchForSearchCriteria();
|
||||
|
||||
Subject.SeasonSearch(_xemSeries.Id, 4, false, true);
|
||||
|
||||
var criteria1 = allCriteria.OfType<SeasonSearchCriteria>().ToList();
|
||||
var criteria2 = allCriteria.OfType<SingleEpisodeSearchCriteria>().ToList();
|
||||
|
||||
criteria1.Count.Should().Be(1);
|
||||
criteria1[0].SeasonNumber.Should().Be(5);
|
||||
|
||||
criteria2.Count.Should().Be(1);
|
||||
criteria2[0].SeasonNumber.Should().Be(6);
|
||||
criteria2[0].EpisodeNumber.Should().Be(11);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void scene_seasonsearch_should_use_seasonnumber_if_no_scene_number_is_available()
|
||||
{
|
||||
WithEpisodes();
|
||||
|
||||
var allCriteria = WatchForSearchCriteria();
|
||||
|
||||
Subject.SeasonSearch(_xemSeries.Id, 7, false, true);
|
||||
|
||||
var criteria = allCriteria.OfType<SeasonSearchCriteria>().ToList();
|
||||
|
||||
criteria.Count.Should().Be(1);
|
||||
criteria[0].SeasonNumber.Should().Be(7);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void season_search_for_anime_should_search_for_each_monitored_episode()
|
||||
{
|
||||
WithEpisodes();
|
||||
_xemSeries.SeriesType = SeriesTypes.Anime;
|
||||
_xemEpisodes.ForEach(e => e.EpisodeFileId = 0);
|
||||
|
||||
var seasonNumber = 1;
|
||||
var allCriteria = WatchForSearchCriteria();
|
||||
|
||||
Subject.SeasonSearch(_xemSeries.Id, seasonNumber, true, true);
|
||||
|
||||
var criteria = allCriteria.OfType<AnimeEpisodeSearchCriteria>().ToList();
|
||||
|
||||
criteria.Count.Should().Be(_xemEpisodes.Count(e => e.SeasonNumber == seasonNumber));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void season_search_for_anime_should_not_search_for_unmonitored_episodes()
|
||||
{
|
||||
WithEpisodes();
|
||||
_xemSeries.SeriesType = SeriesTypes.Anime;
|
||||
_xemEpisodes.ForEach(e => e.Monitored = false);
|
||||
_xemEpisodes.ForEach(e => e.EpisodeFileId = 0);
|
||||
|
||||
var seasonNumber = 1;
|
||||
var allCriteria = WatchForSearchCriteria();
|
||||
|
||||
Subject.SeasonSearch(_xemSeries.Id, seasonNumber, false, true);
|
||||
|
||||
var criteria = allCriteria.OfType<AnimeEpisodeSearchCriteria>().ToList();
|
||||
|
||||
criteria.Count.Should().Be(0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void season_search_for_anime_should_not_search_for_episodes_with_files()
|
||||
{
|
||||
WithEpisodes();
|
||||
_xemSeries.SeriesType = SeriesTypes.Anime;
|
||||
_xemEpisodes.ForEach(e => e.EpisodeFileId = 1);
|
||||
|
||||
var seasonNumber = 1;
|
||||
var allCriteria = WatchForSearchCriteria();
|
||||
|
||||
Subject.SeasonSearch(_xemSeries.Id, seasonNumber, true, true);
|
||||
|
||||
var criteria = allCriteria.OfType<AnimeEpisodeSearchCriteria>().ToList();
|
||||
|
||||
criteria.Count.Should().Be(0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void getscenenames_should_use_seasonnumber_if_no_scene_seasonnumber_is_available()
|
||||
{
|
||||
WithEpisodes();
|
||||
|
||||
var allCriteria = WatchForSearchCriteria();
|
||||
|
||||
Subject.SeasonSearch(_xemSeries.Id, 7, false, true);
|
||||
|
||||
Mocker.GetMock<ISceneMappingService>()
|
||||
.Verify(v => v.GetSceneNames(_xemSeries.Id, It.Is<List<int>>(l => l.Contains(7)), It.Is<List<int>>(l => l.Contains(7))), Times.Once());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,7 +7,7 @@ using NzbDrone.Core.Test.Framework;
|
|||
|
||||
namespace NzbDrone.Core.Test.IndexerSearchTests
|
||||
{
|
||||
public class SearchDefinitionFixture : CoreTest<SingleEpisodeSearchCriteria>
|
||||
public class SearchDefinitionFixture : CoreTest<MovieSearchCriteria>
|
||||
{
|
||||
[TestCase("Betty White's Off Their Rockers", "Betty+Whites+Off+Their+Rockers")]
|
||||
[TestCase("Star Wars: The Clone Wars", "Star+Wars+The+Clone+Wars")]
|
||||
|
|
|
@ -1,80 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.IndexerSearch;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Messaging.Commands;
|
||||
|
||||
namespace NzbDrone.Core.Test.IndexerSearchTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class SeriesSearchServiceFixture : CoreTest<SeriesSearchService>
|
||||
{
|
||||
private Series _series;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_series = new Series
|
||||
{
|
||||
Id = 1,
|
||||
Title = "Title",
|
||||
Seasons = new List<Season>()
|
||||
};
|
||||
|
||||
Mocker.GetMock<ISeriesService>()
|
||||
.Setup(s => s.GetSeries(It.IsAny<int>()))
|
||||
.Returns(_series);
|
||||
|
||||
Mocker.GetMock<ISearchForNzb>()
|
||||
.Setup(s => s.SeasonSearch(_series.Id, It.IsAny<int>(), false, true))
|
||||
.Returns(new List<DownloadDecision>());
|
||||
|
||||
Mocker.GetMock<IProcessDownloadDecisions>()
|
||||
.Setup(s => s.ProcessDecisions(It.IsAny<List<DownloadDecision>>()))
|
||||
.Returns(new ProcessedDecisions(new List<DownloadDecision>(), new List<DownloadDecision>(), new List<DownloadDecision>()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_only_include_monitored_seasons()
|
||||
{
|
||||
_series.Seasons = new List<Season>
|
||||
{
|
||||
new Season { SeasonNumber = 0, Monitored = false },
|
||||
new Season { SeasonNumber = 1, Monitored = true }
|
||||
};
|
||||
|
||||
Subject.Execute(new SeriesSearchCommand { SeriesId = _series.Id, Trigger = CommandTrigger.Manual });
|
||||
|
||||
Mocker.GetMock<ISearchForNzb>()
|
||||
.Verify(v => v.SeasonSearch(_series.Id, It.IsAny<int>(), false, true), Times.Exactly(_series.Seasons.Count(s => s.Monitored)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_start_with_lower_seasons_first()
|
||||
{
|
||||
var seasonOrder = new List<int>();
|
||||
|
||||
_series.Seasons = new List<Season>
|
||||
{
|
||||
new Season { SeasonNumber = 3, Monitored = true },
|
||||
new Season { SeasonNumber = 1, Monitored = true },
|
||||
new Season { SeasonNumber = 2, Monitored = true }
|
||||
};
|
||||
|
||||
Mocker.GetMock<ISearchForNzb>()
|
||||
.Setup(s => s.SeasonSearch(_series.Id, It.IsAny<int>(), false, true))
|
||||
.Returns(new List<DownloadDecision>())
|
||||
.Callback<int, int, bool, bool>((seriesId, seasonNumber, missingOnly, userInvokedSearch) => seasonOrder.Add(seasonNumber));
|
||||
|
||||
Subject.Execute(new SeriesSearchCommand { SeriesId = _series.Id, Trigger = CommandTrigger.Manual });
|
||||
|
||||
seasonOrder.First().Should().Be(_series.Seasons.OrderBy(s => s.SeasonNumber).First().SeasonNumber);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
|
@ -17,26 +17,17 @@ namespace NzbDrone.Core.Test.IndexerTests.IntegrationTests
|
|||
[Ignore("Nyaa is down!")]
|
||||
public class IndexerIntegrationTests : CoreTest
|
||||
{
|
||||
private SingleEpisodeSearchCriteria _singleSearchCriteria;
|
||||
private AnimeEpisodeSearchCriteria _animeSearchCriteria;
|
||||
private MovieSearchCriteria _singleSearchCriteria;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
UseRealHttp();
|
||||
|
||||
_singleSearchCriteria = new SingleEpisodeSearchCriteria()
|
||||
_singleSearchCriteria = new MovieSearchCriteria()
|
||||
{
|
||||
SceneTitles = new List<string> { "Person of Interest" },
|
||||
SeasonNumber = 1,
|
||||
EpisodeNumber = 1
|
||||
};
|
||||
|
||||
_animeSearchCriteria = new AnimeEpisodeSearchCriteria()
|
||||
{
|
||||
SceneTitles = new List<string> { "Steins;Gate" },
|
||||
AbsoluteEpisodeNumber = 1
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -66,7 +57,7 @@ namespace NzbDrone.Core.Test.IndexerTests.IntegrationTests
|
|||
Settings = new NyaaSettings()
|
||||
};
|
||||
|
||||
var result = indexer.Fetch(_animeSearchCriteria);
|
||||
var result = indexer.Fetch(_singleSearchCriteria);
|
||||
|
||||
ValidateTorrentResult(result, hasSize: true);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
|
|||
|
||||
_movieSearchCriteria = new MovieSearchCriteria
|
||||
{
|
||||
Movie = new Tv.Movie { ImdbId = "tt0076759", Title = "Star Wars", Year = 1977 }
|
||||
Movie = new Movies.Movie { ImdbId = "tt0076759", Title = "Star Wars", Year = 1977 }
|
||||
};
|
||||
|
||||
_capabilities = new NewznabCapabilities();
|
||||
|
|
|
@ -1,92 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
using FizzWare.NBuilder;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.IndexerTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class SeasonSearchFixture : TestBase<TestIndexer>
|
||||
{
|
||||
private Series _series;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_series = Builder<Series>.CreateNew().Build();
|
||||
|
||||
Mocker.GetMock<IHttpClient>()
|
||||
.Setup(o => o.Execute(It.Is<HttpRequest>(v => v.Method == HttpMethod.GET)))
|
||||
.Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), "<xml></xml>"));
|
||||
}
|
||||
|
||||
private void WithIndexer(bool paging, int resultCount)
|
||||
{
|
||||
var definition = new IndexerDefinition();
|
||||
definition.Name = "Test";
|
||||
Subject.Definition = definition;
|
||||
|
||||
Subject._supportedPageSize = paging ? 100 : 0;
|
||||
|
||||
var requestGenerator = Mocker.GetMock<IIndexerRequestGenerator>();
|
||||
Subject._requestGenerator = requestGenerator.Object;
|
||||
|
||||
var requests = Builder<IndexerRequest>.CreateListOfSize(paging ? 100 : 1)
|
||||
.All()
|
||||
.WithConstructor(() => new IndexerRequest("http://my.feed.local/", HttpAccept.Rss))
|
||||
.With(v => v.HttpRequest.Method = HttpMethod.GET)
|
||||
.Build();
|
||||
|
||||
var pageable = new IndexerPageableRequestChain();
|
||||
pageable.Add(requests);
|
||||
|
||||
requestGenerator.Setup(s => s.GetSearchRequests(It.IsAny<SeasonSearchCriteria>()))
|
||||
.Returns(pageable);
|
||||
|
||||
var parser = Mocker.GetMock<IParseIndexerResponse>();
|
||||
Subject._parser = parser.Object;
|
||||
|
||||
var results = Builder<ReleaseInfo>.CreateListOfSize(resultCount)
|
||||
.Build();
|
||||
|
||||
parser.Setup(s => s.ParseResponse(It.IsAny<IndexerResponse>()))
|
||||
.Returns(results);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_use_offset_if_result_count_is_less_than_90()
|
||||
{
|
||||
WithIndexer(true, 25);
|
||||
|
||||
Subject.Fetch(new SeasonSearchCriteria { Series = _series, SceneTitles = new List<string>{_series.Title} });
|
||||
|
||||
Mocker.GetMock<IHttpClient>().Verify(v => v.Execute(It.IsAny<HttpRequest>()), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_use_offset_for_sites_that_do_not_support_it()
|
||||
{
|
||||
WithIndexer(false, 125);
|
||||
|
||||
Subject.Fetch(new SeasonSearchCriteria { Series = _series, SceneTitles = new List<string> { _series.Title } });
|
||||
|
||||
Mocker.GetMock<IHttpClient>().Verify(v => v.Execute(It.IsAny<HttpRequest>()), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_use_offset_if_its_already_tried_10_times()
|
||||
{
|
||||
WithIndexer(true, 100);
|
||||
|
||||
Subject.Fetch(new SeasonSearchCriteria { Series = _series, SceneTitles = new List<string> { _series.Title } });
|
||||
|
||||
Mocker.GetMock<IHttpClient>().Verify(v => v.Execute(It.IsAny<HttpRequest>()), Times.Exactly(10));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using FluentAssertions;
|
||||
using Marr.Data;
|
||||
|
@ -118,7 +118,7 @@ namespace NzbDrone.Core.Test.InstrumentationTests
|
|||
[Test]
|
||||
public void null_string_as_arg_should_not_fail()
|
||||
{
|
||||
var epFile = new EpisodeFile();
|
||||
var epFile = new MovieFile();
|
||||
_logger.Debug("File {0} no longer exists on disk. removing from database.", epFile.RelativePath);
|
||||
|
||||
Thread.Sleep(600);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
|
@ -9,22 +9,22 @@ using NzbDrone.Common.Disk;
|
|||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Core.MediaCover;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Tv.Events;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.Movies.Events;
|
||||
|
||||
namespace NzbDrone.Core.Test.MediaCoverTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class MediaCoverServiceFixture : CoreTest<MediaCoverService>
|
||||
{
|
||||
Series _series;
|
||||
Movie _movie;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
Mocker.SetConstant<IAppFolderInfo>(new AppFolderInfo(Mocker.Resolve<IStartupContext>()));
|
||||
|
||||
_series = Builder<Series>.CreateNew()
|
||||
_movie = Builder<Movie>.CreateNew()
|
||||
.With(v => v.Id = 2)
|
||||
.With(v => v.Images = new List<MediaCover.MediaCover> { new MediaCover.MediaCover(MediaCoverTypes.Poster, "") })
|
||||
.Build();
|
||||
|
@ -76,7 +76,7 @@ namespace NzbDrone.Core.Test.MediaCoverTests
|
|||
.Setup(v => v.FileExists(It.IsAny<string>()))
|
||||
.Returns(true);
|
||||
|
||||
Subject.HandleAsync(new SeriesUpdatedEvent(_series));
|
||||
Subject.HandleAsync(new MovieUpdatedEvent(_movie));
|
||||
|
||||
Mocker.GetMock<IImageResizer>()
|
||||
.Verify(v => v.Resize(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>()), Times.Exactly(2));
|
||||
|
@ -93,7 +93,7 @@ namespace NzbDrone.Core.Test.MediaCoverTests
|
|||
.Setup(v => v.FileExists(It.IsAny<string>()))
|
||||
.Returns(false);
|
||||
|
||||
Subject.HandleAsync(new SeriesUpdatedEvent(_series));
|
||||
Subject.HandleAsync(new MovieUpdatedEvent(_movie));
|
||||
|
||||
Mocker.GetMock<IImageResizer>()
|
||||
.Verify(v => v.Resize(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>()), Times.Exactly(2));
|
||||
|
@ -114,7 +114,7 @@ namespace NzbDrone.Core.Test.MediaCoverTests
|
|||
.Setup(v => v.GetFileSize(It.IsAny<string>()))
|
||||
.Returns(1000);
|
||||
|
||||
Subject.HandleAsync(new SeriesUpdatedEvent(_series));
|
||||
Subject.HandleAsync(new MovieUpdatedEvent(_movie));
|
||||
|
||||
Mocker.GetMock<IImageResizer>()
|
||||
.Verify(v => v.Resize(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>()), Times.Never());
|
||||
|
@ -135,7 +135,7 @@ namespace NzbDrone.Core.Test.MediaCoverTests
|
|||
.Setup(v => v.GetFileSize(It.IsAny<string>()))
|
||||
.Returns(0);
|
||||
|
||||
Subject.HandleAsync(new SeriesUpdatedEvent(_series));
|
||||
Subject.HandleAsync(new MovieUpdatedEvent(_movie));
|
||||
|
||||
Mocker.GetMock<IImageResizer>()
|
||||
.Verify(v => v.Resize(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>()), Times.Exactly(2));
|
||||
|
@ -156,10 +156,10 @@ namespace NzbDrone.Core.Test.MediaCoverTests
|
|||
.Setup(v => v.Resize(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>()))
|
||||
.Throws<ApplicationException>();
|
||||
|
||||
Subject.HandleAsync(new SeriesUpdatedEvent(_series));
|
||||
Subject.HandleAsync(new MovieUpdatedEvent(_movie));
|
||||
|
||||
Mocker.GetMock<IImageResizer>()
|
||||
.Verify(v => v.Resize(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>()), Times.Exactly(2));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
|
@ -6,9 +6,9 @@ using Moq;
|
|||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.MediaFiles.EpisodeImport;
|
||||
using NzbDrone.Core.MediaFiles.MovieImport;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
||||
|
@ -16,13 +16,13 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
|||
[TestFixture]
|
||||
public class ScanFixture : CoreTest<DiskScanService>
|
||||
{
|
||||
private Series _series;
|
||||
private Movie _movie;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_series = Builder<Series>.CreateNew()
|
||||
.With(s => s.Path = @"C:\Test\TV\Series".AsOsAgnostic())
|
||||
_movie = Builder<Movie>.CreateNew()
|
||||
.With(s => s.Path = @"C:\Test\Movies\Movie".AsOsAgnostic())
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
|
@ -38,7 +38,7 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
|||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(s => s.GetDirectories(It.IsAny<string>()))
|
||||
.Returns(new string[] { @"C:\Test\TV\Series2".AsOsAgnostic() });
|
||||
.Returns(new string[] { @"C:\Test\Movies\Movie2".AsOsAgnostic() });
|
||||
}
|
||||
|
||||
private void GivenFiles(IEnumerable<string> files)
|
||||
|
@ -49,18 +49,18 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
|||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_scan_if_series_root_folder_does_not_exist()
|
||||
public void should_not_scan_if_movie_root_folder_does_not_exist()
|
||||
{
|
||||
Subject.Scan(_series);
|
||||
Subject.Scan(_movie);
|
||||
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
|
||||
Mocker.GetMock<IMediaFileTableCleanupService>()
|
||||
.Verify(v => v.Clean(It.IsAny<Series>(), It.IsAny<List<string>>()), Times.Never());
|
||||
.Verify(v => v.Clean(It.IsAny<Movie>(), It.IsAny<List<string>>()), Times.Never());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_scan_if_series_root_folder_is_empty()
|
||||
public void should_not_scan_if_movie_root_folder_is_empty()
|
||||
{
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(s => s.FolderExists(It.IsAny<string>()))
|
||||
|
@ -70,12 +70,12 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
|||
.Setup(s => s.GetDirectories(It.IsAny<string>()))
|
||||
.Returns(new string[0]);
|
||||
|
||||
Subject.Scan(_series);
|
||||
Subject.Scan(_movie);
|
||||
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
|
||||
Mocker.GetMock<IMediaFileTableCleanupService>()
|
||||
.Verify(v => v.Clean(It.IsAny<Series>(), new List<string>()), Times.Never());
|
||||
.Verify(v => v.Clean(It.IsAny<Movie>(), new List<string>()), Times.Never());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -85,17 +85,17 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
|||
|
||||
GivenFiles(new List<string>
|
||||
{
|
||||
Path.Combine(_series.Path, "EXTRAS", "file1.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_series.Path, "Extras", "file2.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_series.Path, "EXTRAs", "file3.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_series.Path, "ExTrAs", "file4.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_series.Path, "Season 1", "s01e01.mkv").AsOsAgnostic()
|
||||
Path.Combine(_movie.Path, "EXTRAS", "file1.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_movie.Path, "Extras", "file2.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_movie.Path, "EXTRAs", "file3.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_movie.Path, "ExTrAs", "file4.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_movie.Path, "Season 1", "s01e01.mkv").AsOsAgnostic()
|
||||
});
|
||||
|
||||
Subject.Scan(_series);
|
||||
Subject.Scan(_movie);
|
||||
|
||||
Mocker.GetMock<IMakeImportDecision>()
|
||||
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 1), _series), Times.Once());
|
||||
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 1), _movie), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -105,37 +105,37 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
|||
|
||||
GivenFiles(new List<string>
|
||||
{
|
||||
Path.Combine(_series.Path, ".AppleDouble", "file1.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_series.Path, ".appledouble", "file2.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_series.Path, "Season 1", "s01e01.mkv").AsOsAgnostic()
|
||||
Path.Combine(_movie.Path, ".AppleDouble", "file1.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_movie.Path, ".appledouble", "file2.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_movie.Path, "Season 1", "s01e01.mkv").AsOsAgnostic()
|
||||
});
|
||||
|
||||
Subject.Scan(_series);
|
||||
Subject.Scan(_movie);
|
||||
|
||||
Mocker.GetMock<IMakeImportDecision>()
|
||||
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 1), _series), Times.Once());
|
||||
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 1), _movie), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_scan_extras_series_and_subfolders()
|
||||
public void should_scan_extras_movie_and_subfolders()
|
||||
{
|
||||
GivenParentFolderExists();
|
||||
_series.Path = @"C:\Test\TV\Extras".AsOsAgnostic();
|
||||
_movie.Path = @"C:\Test\Movies\Extras".AsOsAgnostic();
|
||||
|
||||
GivenFiles(new List<string>
|
||||
{
|
||||
Path.Combine(_series.Path, "Extras", "file1.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_series.Path, ".AppleDouble", "file2.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_series.Path, "Season 1", "s01e01.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_series.Path, "Season 1", "s01e02.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_series.Path, "Season 2", "s02e01.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_series.Path, "Season 2", "s02e02.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_movie.Path, "Extras", "file1.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_movie.Path, ".AppleDouble", "file2.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_movie.Path, "Season 1", "s01e01.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_movie.Path, "Season 1", "s01e02.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_movie.Path, "Season 2", "s02e01.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_movie.Path, "Season 2", "s02e02.mkv").AsOsAgnostic(),
|
||||
});
|
||||
|
||||
Subject.Scan(_series);
|
||||
Subject.Scan(_movie);
|
||||
|
||||
Mocker.GetMock<IMakeImportDecision>()
|
||||
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 4), _series), Times.Once());
|
||||
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 4), _movie), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -145,16 +145,16 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
|||
|
||||
GivenFiles(new List<string>
|
||||
{
|
||||
Path.Combine(_series.Path, ".@__thumb", "file1.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_series.Path, ".@__THUMB", "file2.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_series.Path, ".hidden", "file2.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_series.Path, "Season 1", "s01e01.mkv").AsOsAgnostic()
|
||||
Path.Combine(_movie.Path, ".@__thumb", "file1.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_movie.Path, ".@__THUMB", "file2.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_movie.Path, ".hidden", "file2.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_movie.Path, "Season 1", "s01e01.mkv").AsOsAgnostic()
|
||||
});
|
||||
|
||||
Subject.Scan(_series);
|
||||
Subject.Scan(_movie);
|
||||
|
||||
Mocker.GetMock<IMakeImportDecision>()
|
||||
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 1), _series), Times.Once());
|
||||
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 1), _movie), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -164,17 +164,17 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
|||
|
||||
GivenFiles(new List<string>
|
||||
{
|
||||
Path.Combine(_series.Path, "Season 1", ".@__thumb", "file1.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_series.Path, "Season 1", ".@__THUMB", "file2.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_series.Path, "Season 1", ".hidden", "file2.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_series.Path, "Season 1", ".AppleDouble", "s01e01.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_series.Path, "Season 1", "s01e01.mkv").AsOsAgnostic()
|
||||
Path.Combine(_movie.Path, "Season 1", ".@__thumb", "file1.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_movie.Path, "Season 1", ".@__THUMB", "file2.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_movie.Path, "Season 1", ".hidden", "file2.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_movie.Path, "Season 1", ".AppleDouble", "s01e01.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_movie.Path, "Season 1", "s01e01.mkv").AsOsAgnostic()
|
||||
});
|
||||
|
||||
Subject.Scan(_series);
|
||||
Subject.Scan(_movie);
|
||||
|
||||
Mocker.GetMock<IMakeImportDecision>()
|
||||
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 1), _series), Times.Once());
|
||||
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 1), _movie), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -184,14 +184,14 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
|||
|
||||
GivenFiles(new List<string>
|
||||
{
|
||||
Path.Combine(_series.Path, "@eaDir", "file1.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_series.Path, "Season 1", "s01e01.mkv").AsOsAgnostic()
|
||||
Path.Combine(_movie.Path, "@eaDir", "file1.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_movie.Path, "Season 1", "s01e01.mkv").AsOsAgnostic()
|
||||
});
|
||||
|
||||
Subject.Scan(_series);
|
||||
Subject.Scan(_movie);
|
||||
|
||||
Mocker.GetMock<IMakeImportDecision>()
|
||||
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 1), _series), Times.Once());
|
||||
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 1), _movie), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -201,32 +201,32 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
|||
|
||||
GivenFiles(new List<string>
|
||||
{
|
||||
Path.Combine(_series.Path, ".@__thumb", "file1.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_series.Path, "Season 1", "s01e01.mkv").AsOsAgnostic()
|
||||
Path.Combine(_movie.Path, ".@__thumb", "file1.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_movie.Path, "Season 1", "s01e01.mkv").AsOsAgnostic()
|
||||
});
|
||||
|
||||
Subject.Scan(_series);
|
||||
Subject.Scan(_movie);
|
||||
|
||||
Mocker.GetMock<IMakeImportDecision>()
|
||||
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 1), _series), Times.Once());
|
||||
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 1), _movie), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_scan_dotHack_folder()
|
||||
{
|
||||
GivenParentFolderExists();
|
||||
_series.Path = @"C:\Test\TV\.hack".AsOsAgnostic();
|
||||
_movie.Path = @"C:\Test\TV\.hack".AsOsAgnostic();
|
||||
|
||||
GivenFiles(new List<string>
|
||||
{
|
||||
Path.Combine(_series.Path, "Season 1", "file1.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_series.Path, "Season 1", "s01e01.mkv").AsOsAgnostic()
|
||||
Path.Combine(_movie.Path, "Season 1", "file1.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_movie.Path, "Season 1", "s01e01.mkv").AsOsAgnostic()
|
||||
});
|
||||
|
||||
Subject.Scan(_series);
|
||||
Subject.Scan(_movie);
|
||||
|
||||
Mocker.GetMock<IMakeImportDecision>()
|
||||
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 2), _series), Times.Once());
|
||||
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 2), _movie), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -236,14 +236,14 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
|||
|
||||
GivenFiles(new List<string>
|
||||
{
|
||||
Path.Combine(_series.Path, "file1.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_series.Path, "s01e01.mkv").AsOsAgnostic()
|
||||
Path.Combine(_movie.Path, "file1.mkv").AsOsAgnostic(),
|
||||
Path.Combine(_movie.Path, "s01e01.mkv").AsOsAgnostic()
|
||||
});
|
||||
|
||||
Subject.Scan(_series);
|
||||
Subject.Scan(_movie);
|
||||
|
||||
Mocker.GetMock<IMakeImportDecision>()
|
||||
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 2), _series), Times.Once());
|
||||
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 2), _movie), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -253,14 +253,14 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
|||
|
||||
GivenFiles(new List<string>
|
||||
{
|
||||
Path.Combine(_series.Path, "._24 The Status Quo Combustion.mp4").AsOsAgnostic(),
|
||||
Path.Combine(_series.Path, "24 The Status Quo Combustion.mkv").AsOsAgnostic()
|
||||
Path.Combine(_movie.Path, "._24 The Status Quo Combustion.mp4").AsOsAgnostic(),
|
||||
Path.Combine(_movie.Path, "24 The Status Quo Combustion.mkv").AsOsAgnostic()
|
||||
});
|
||||
|
||||
Subject.Scan(_series);
|
||||
Subject.Scan(_movie);
|
||||
|
||||
Mocker.GetMock<IMakeImportDecision>()
|
||||
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 1), _series), Times.Once());
|
||||
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 1), _movie), Times.Once());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,10 +9,10 @@ using NzbDrone.Core.Download;
|
|||
using NzbDrone.Core.Download.TrackedDownloads;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.MediaFiles.Commands;
|
||||
using NzbDrone.Core.MediaFiles.EpisodeImport;
|
||||
using NzbDrone.Core.MediaFiles.MovieImport;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.MediaFiles
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
|
@ -6,12 +6,12 @@ using Moq;
|
|||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.MediaFiles.EpisodeImport;
|
||||
using NzbDrone.Core.MediaFiles.MovieImport;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Test.Common;
|
||||
using FluentAssertions;
|
||||
using NzbDrone.Core.Download;
|
||||
|
@ -341,7 +341,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
.Setup(s => s.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Movie>(), It.IsAny<DownloadClientItem>(), null, true))
|
||||
.Returns(imported);
|
||||
|
||||
Mocker.GetMock<IImportApprovedEpisodes>()
|
||||
Mocker.GetMock<IImportApprovedMovie>()
|
||||
.Setup(s => s.Import(It.IsAny<List<ImportDecision>>(), true, null, ImportMode.Auto))
|
||||
.Returns(new List<ImportResult>());
|
||||
|
||||
|
@ -365,13 +365,13 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
|
||||
private void VerifyNoImport()
|
||||
{
|
||||
Mocker.GetMock<IImportApprovedEpisodes>().Verify(c => c.Import(It.IsAny<List<ImportDecision>>(), true, null, ImportMode.Auto),
|
||||
Mocker.GetMock<IImportApprovedMovie>().Verify(c => c.Import(It.IsAny<List<ImportDecision>>(), true, null, ImportMode.Auto),
|
||||
Times.Never());
|
||||
}
|
||||
|
||||
private void VerifyImport()
|
||||
{
|
||||
Mocker.GetMock<IImportApprovedEpisodes>().Verify(c => c.Import(It.IsAny<List<ImportDecision>>(), true, null, ImportMode.Auto),
|
||||
Mocker.GetMock<IImportApprovedMovie>().Verify(c => c.Import(It.IsAny<List<ImportDecision>>(), true, null, ImportMode.Auto),
|
||||
Times.Once());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
|
@ -12,47 +12,42 @@ using NzbDrone.Core.Messaging.Events;
|
|||
using NzbDrone.Core.Organizer;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.MediaFiles.EpisodeFileMovingServiceTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class MoveEpisodeFileFixture : CoreTest<EpisodeFileMovingService>
|
||||
public class MoveEpisodeFileFixture : CoreTest<MovieFileMovingService>
|
||||
{
|
||||
private Series _series;
|
||||
private EpisodeFile _episodeFile;
|
||||
private LocalEpisode _localEpisode;
|
||||
private Movie _series;
|
||||
private MovieFile _episodeFile;
|
||||
private LocalMovie _localEpisode;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_series = Builder<Series>.CreateNew()
|
||||
_series = Builder<Movie>.CreateNew()
|
||||
.With(s => s.Path = @"C:\Test\TV\Series".AsOsAgnostic())
|
||||
.Build();
|
||||
|
||||
_episodeFile = Builder<EpisodeFile>.CreateNew()
|
||||
_episodeFile = Builder<MovieFile>.CreateNew()
|
||||
.With(f => f.Path = null)
|
||||
.With(f => f.RelativePath = @"Season 1\File.avi")
|
||||
.Build();
|
||||
|
||||
_localEpisode = Builder<LocalEpisode>.CreateNew()
|
||||
.With(l => l.Series = _series)
|
||||
.With(l => l.Episodes = Builder<Episode>.CreateListOfSize(1).Build().ToList())
|
||||
_localEpisode = Builder<LocalMovie>.CreateNew()
|
||||
.With(l => l.Movie = _series)
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<IBuildFileNames>()
|
||||
.Setup(s => s.BuildFileName(It.IsAny<List<Episode>>(), It.IsAny<Series>(), It.IsAny<EpisodeFile>(), null))
|
||||
.Setup(s => s.BuildFileName(It.IsAny<Movie>(), It.IsAny<MovieFile>(), null))
|
||||
.Returns("File Name");
|
||||
|
||||
Mocker.GetMock<IBuildFileNames>()
|
||||
.Setup(s => s.BuildFilePath(It.IsAny<Series>(), It.IsAny<int>(), It.IsAny<string>(), It.IsAny<string>()))
|
||||
.Setup(s => s.BuildFilePath(It.IsAny<Movie>(), It.IsAny<string>(), It.IsAny<string>()))
|
||||
.Returns(@"C:\Test\TV\Series\Season 01\File Name.avi".AsOsAgnostic());
|
||||
|
||||
Mocker.GetMock<IBuildFileNames>()
|
||||
.Setup(s => s.BuildSeasonPath(It.IsAny<Series>(), It.IsAny<int>()))
|
||||
.Returns(@"C:\Test\TV\Series\Season 01".AsOsAgnostic());
|
||||
|
||||
var rootFolder = @"C:\Test\TV\".AsOsAgnostic();
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(s => s.FolderExists(rootFolder))
|
||||
|
@ -72,7 +67,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeFileMovingServiceTests
|
|||
.Setup(s => s.InheritFolderPermissions(It.IsAny<string>()))
|
||||
.Throws<UnauthorizedAccessException>();
|
||||
|
||||
Subject.MoveEpisodeFile(_episodeFile, _localEpisode);
|
||||
Subject.MoveMovieFile(_episodeFile, _localEpisode);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -84,29 +79,19 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeFileMovingServiceTests
|
|||
.Setup(s => s.InheritFolderPermissions(It.IsAny<string>()))
|
||||
.Throws<InvalidOperationException>();
|
||||
|
||||
Subject.MoveEpisodeFile(_episodeFile, _localEpisode);
|
||||
Subject.MoveMovieFile(_episodeFile, _localEpisode);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_notify_on_series_folder_creation()
|
||||
{
|
||||
Subject.MoveEpisodeFile(_episodeFile, _localEpisode);
|
||||
Subject.MoveMovieFile(_episodeFile, _localEpisode);
|
||||
|
||||
Mocker.GetMock<IEventAggregator>()
|
||||
.Verify(s => s.PublishEvent<EpisodeFolderCreatedEvent>(It.Is<EpisodeFolderCreatedEvent>(p =>
|
||||
.Verify(s => s.PublishEvent<MovieFolderCreatedEvent>(It.Is<MovieFolderCreatedEvent>(p =>
|
||||
p.SeriesFolder.IsNotNullOrWhiteSpace())), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_notify_on_season_folder_creation()
|
||||
{
|
||||
Subject.MoveEpisodeFile(_episodeFile, _localEpisode);
|
||||
|
||||
Mocker.GetMock<IEventAggregator>()
|
||||
.Verify(s => s.PublishEvent<EpisodeFolderCreatedEvent>(It.Is<EpisodeFolderCreatedEvent>(p =>
|
||||
p.SeasonFolder.IsNotNullOrWhiteSpace())), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_notify_if_series_folder_already_exists()
|
||||
{
|
||||
|
@ -114,10 +99,10 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeFileMovingServiceTests
|
|||
.Setup(s => s.FolderExists(_series.Path))
|
||||
.Returns(true);
|
||||
|
||||
Subject.MoveEpisodeFile(_episodeFile, _localEpisode);
|
||||
Subject.MoveMovieFile(_episodeFile, _localEpisode);
|
||||
|
||||
Mocker.GetMock<IEventAggregator>()
|
||||
.Verify(s => s.PublishEvent<EpisodeFolderCreatedEvent>(It.Is<EpisodeFolderCreatedEvent>(p =>
|
||||
.Verify(s => s.PublishEvent<MovieFolderCreatedEvent>(It.Is<MovieFolderCreatedEvent>(p =>
|
||||
p.SeriesFolder.IsNotNullOrWhiteSpace())), Times.Never());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.MediaFiles.EpisodeImport.Specifications;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications
|
||||
{
|
||||
[TestFixture]
|
||||
public class FullSeasonSpecificationFixture : CoreTest<FullSeasonSpecification>
|
||||
{
|
||||
private LocalEpisode _localEpisode;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_localEpisode = new LocalEpisode
|
||||
{
|
||||
Path = @"C:\Test\30 Rock\30.rock.s01e01.avi".AsOsAgnostic(),
|
||||
Size = 100,
|
||||
Series = Builder<Series>.CreateNew().Build(),
|
||||
ParsedEpisodeInfo = new ParsedEpisodeInfo
|
||||
{
|
||||
FullSeason = false
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_when_file_contains_the_full_season()
|
||||
{
|
||||
_localEpisode.ParsedEpisodeInfo.FullSeason = true;
|
||||
|
||||
Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_when_file_does_not_contain_the_full_season()
|
||||
{
|
||||
Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeTrue();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,84 +0,0 @@
|
|||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.MediaFiles.EpisodeImport.Specifications;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications
|
||||
{
|
||||
[TestFixture]
|
||||
public class MatchesFolderSpecificationFixture : CoreTest<MatchesFolderSpecification>
|
||||
{
|
||||
private LocalEpisode _localEpisode;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_localEpisode = Builder<LocalEpisode>.CreateNew()
|
||||
.With(l => l.Path = @"C:\Test\Unsorted\Series.Title.S01E01.720p.HDTV-Sonarr\S01E05.mkv".AsOsAgnostic())
|
||||
.With(l => l.ParsedEpisodeInfo =
|
||||
Builder<ParsedEpisodeInfo>.CreateNew()
|
||||
.With(p => p.EpisodeNumbers = new[] {5})
|
||||
.With(p => p.FullSeason = false)
|
||||
.Build())
|
||||
.Build();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_accepted_for_existing_file()
|
||||
{
|
||||
_localEpisode.ExistingFile = true;
|
||||
|
||||
Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_accepted_if_folder_name_is_not_parseable()
|
||||
{
|
||||
_localEpisode.Path = @"C:\Test\Unsorted\Series.Title\S01E01.mkv".AsOsAgnostic();
|
||||
|
||||
Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_should_be_accepted_for_full_season()
|
||||
{
|
||||
_localEpisode.Path = @"C:\Test\Unsorted\Series.Title.S01\S01E01.mkv".AsOsAgnostic();
|
||||
|
||||
Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_accepted_if_file_and_folder_have_the_same_episode()
|
||||
{
|
||||
_localEpisode.ParsedEpisodeInfo.EpisodeNumbers = new[] { 1 };
|
||||
_localEpisode.Path = @"C:\Test\Unsorted\Series.Title.S01E01.720p.HDTV-Sonarr\S01E01.mkv".AsOsAgnostic();
|
||||
Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_accepted_if_file_is_one_episode_in_folder()
|
||||
{
|
||||
_localEpisode.ParsedEpisodeInfo.EpisodeNumbers = new[] { 1 };
|
||||
_localEpisode.Path = @"C:\Test\Unsorted\Series.Title.S01E01E02.720p.HDTV-Sonarr\S01E01.mkv".AsOsAgnostic();
|
||||
Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_rejected_if_file_and_folder_do_not_have_same_episode()
|
||||
{
|
||||
_localEpisode.Path = @"C:\Test\Unsorted\Series.Title.S01E01.720p.HDTV-Sonarr\S01E05.mkv".AsOsAgnostic();
|
||||
Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_rejected_if_file_and_folder_do_not_have_same_episodes()
|
||||
{
|
||||
_localEpisode.ParsedEpisodeInfo.EpisodeNumbers = new[] { 5, 6 };
|
||||
_localEpisode.Path = @"C:\Test\Unsorted\Series.Title.S01E01E02.720p.HDTV-Sonarr\S01E05E06.mkv".AsOsAgnostic();
|
||||
Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.MediaFiles.EpisodeImport.Specifications;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications
|
||||
{
|
||||
[TestFixture]
|
||||
public class NotSampleSpecificationFixture : CoreTest<NotSampleSpecification>
|
||||
{
|
||||
private Series _series;
|
||||
private LocalEpisode _localEpisode;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_series = Builder<Series>.CreateNew()
|
||||
.With(s => s.SeriesType = SeriesTypes.Standard)
|
||||
.Build();
|
||||
|
||||
var episodes = Builder<Episode>.CreateListOfSize(1)
|
||||
.All()
|
||||
.With(e => e.SeasonNumber = 1)
|
||||
.Build()
|
||||
.ToList();
|
||||
|
||||
_localEpisode = new LocalEpisode
|
||||
{
|
||||
Path = @"C:\Test\30 Rock\30.rock.s01e01.avi",
|
||||
Episodes = episodes,
|
||||
Series = _series,
|
||||
Quality = new QualityModel(Quality.HDTV720p)
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_for_existing_file()
|
||||
{
|
||||
_localEpisode.ExistingFile = true;
|
||||
Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeTrue();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,156 +0,0 @@
|
|||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Marr.Data;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.MediaFiles.EpisodeImport.Specifications;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Profiles;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications
|
||||
{
|
||||
[TestFixture]
|
||||
public class UpgradeSpecificationFixture : CoreTest<UpgradeSpecification>
|
||||
{
|
||||
private Series _series;
|
||||
private LocalEpisode _localEpisode;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_series = Builder<Series>.CreateNew()
|
||||
.With(s => s.SeriesType = SeriesTypes.Standard)
|
||||
.With(e => e.Profile = new Profile { Items = Qualities.QualityFixture.GetDefaultQualities() })
|
||||
.Build();
|
||||
|
||||
_localEpisode = new LocalEpisode
|
||||
{
|
||||
Path = @"C:\Test\30 Rock\30.rock.s01e01.avi",
|
||||
Quality = new QualityModel(Quality.HDTV720p, new Revision(version: 1)),
|
||||
Series = _series
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_no_existing_episodeFile()
|
||||
{
|
||||
_localEpisode.Episodes = Builder<Episode>.CreateListOfSize(1)
|
||||
.All()
|
||||
.With(e => e.EpisodeFileId = 0)
|
||||
.With(e => e.EpisodeFile = null)
|
||||
.Build()
|
||||
.ToList();
|
||||
|
||||
Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_no_existing_episodeFile_for_multi_episodes()
|
||||
{
|
||||
_localEpisode.Episodes = Builder<Episode>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(e => e.EpisodeFileId = 0)
|
||||
.With(e => e.EpisodeFile = null)
|
||||
.Build()
|
||||
.ToList();
|
||||
|
||||
Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_upgrade_for_existing_episodeFile()
|
||||
{
|
||||
_localEpisode.Episodes = Builder<Episode>.CreateListOfSize(1)
|
||||
.All()
|
||||
.With(e => e.EpisodeFileId = 1)
|
||||
.With(e => e.EpisodeFile = new LazyLoaded<EpisodeFile>(
|
||||
new EpisodeFile
|
||||
{
|
||||
Quality = new QualityModel(Quality.SDTV, new Revision(version: 1))
|
||||
}))
|
||||
.Build()
|
||||
.ToList();
|
||||
|
||||
Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_upgrade_for_existing_episodeFile_for_multi_episodes()
|
||||
{
|
||||
_localEpisode.Episodes = Builder<Episode>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(e => e.EpisodeFileId = 1)
|
||||
.With(e => e.EpisodeFile = new LazyLoaded<EpisodeFile>(
|
||||
new EpisodeFile
|
||||
{
|
||||
Quality = new QualityModel(Quality.SDTV, new Revision(version: 1))
|
||||
}))
|
||||
.Build()
|
||||
.ToList();
|
||||
|
||||
Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_not_an_upgrade_for_existing_episodeFile()
|
||||
{
|
||||
_localEpisode.Episodes = Builder<Episode>.CreateListOfSize(1)
|
||||
.All()
|
||||
.With(e => e.EpisodeFileId = 1)
|
||||
.With(e => e.EpisodeFile = new LazyLoaded<EpisodeFile>(
|
||||
new EpisodeFile
|
||||
{
|
||||
Quality = new QualityModel(Quality.Bluray720p, new Revision(version: 1))
|
||||
}))
|
||||
.Build()
|
||||
.ToList();
|
||||
|
||||
Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_not_an_upgrade_for_existing_episodeFile_for_multi_episodes()
|
||||
{
|
||||
_localEpisode.Episodes = Builder<Episode>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(e => e.EpisodeFileId = 1)
|
||||
.With(e => e.EpisodeFile = new LazyLoaded<EpisodeFile>(
|
||||
new EpisodeFile
|
||||
{
|
||||
Quality = new QualityModel(Quality.Bluray720p, new Revision(version: 1))
|
||||
}))
|
||||
.Build()
|
||||
.ToList();
|
||||
|
||||
Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_not_an_upgrade_for_one_existing_episodeFile_for_multi_episode()
|
||||
{
|
||||
_localEpisode.Episodes = Builder<Episode>.CreateListOfSize(2)
|
||||
.TheFirst(1)
|
||||
.With(e => e.EpisodeFileId = 1)
|
||||
.With(e => e.EpisodeFile = new LazyLoaded<EpisodeFile>(
|
||||
new EpisodeFile
|
||||
{
|
||||
Quality = new QualityModel(Quality.SDTV, new Revision(version: 1))
|
||||
}))
|
||||
.TheNext(1)
|
||||
.With(e => e.EpisodeFileId = 2)
|
||||
.With(e => e.EpisodeFile = new LazyLoaded<EpisodeFile>(
|
||||
new EpisodeFile
|
||||
{
|
||||
Quality = new QualityModel(Quality.Bluray720p, new Revision(version: 1))
|
||||
}))
|
||||
.Build()
|
||||
.ToList();
|
||||
|
||||
Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue