Merge commit '6bb918d025349b34341eb046b8a0d72dc51ce168'
This commit is contained in:
commit
a8f06e47a8
17
build.ps1
17
build.ps1
|
@ -39,7 +39,20 @@ Function Build()
|
|||
Function CleanFolder($path)
|
||||
{
|
||||
Write-Host Removing XMLDoc files
|
||||
get-childitem $path -File -Filter *.xml -Recurse | foreach ($_) {remove-item $_.fullname}
|
||||
get-childitem $path -File -Filter *.xml -Recurse | foreach ($_) {
|
||||
|
||||
$filename = $_.FullName
|
||||
$exeFilename = $filename -replace "xml", "exe"
|
||||
$dllFilename = $filename -replace "xml", "dll"
|
||||
|
||||
if (Test-Path $exeFilename) {
|
||||
remove-item $_.fullname
|
||||
}
|
||||
|
||||
if (Test-Path $dllFilename) {
|
||||
remove-item $_.fullname
|
||||
}
|
||||
}
|
||||
|
||||
get-childitem $path -File -Filter *.transform -Recurse | foreach ($_) {remove-item $_.fullname}
|
||||
|
||||
|
@ -161,7 +174,7 @@ Function PackageTests()
|
|||
Copy-Item $outputFolder\*.dll -Destination $testPackageFolder -Force
|
||||
Copy-Item $outputFolder\*.pdb -Destination $testPackageFolder -Force
|
||||
|
||||
Copy-Item .\*.sh -Destination $testPackageFolder -Force
|
||||
Copy-Item .\*.sh -Destination $testPackageFolder -Force
|
||||
|
||||
get-childitem $testPackageFolder -File -Filter *log.config | foreach ($_) {remove-item $_.fullname}
|
||||
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -11,15 +11,16 @@ using NzbDrone.Api.History;
|
|||
using NzbDrone.Api.Indexers;
|
||||
using NzbDrone.Api.Logs;
|
||||
using NzbDrone.Api.Mapping;
|
||||
using NzbDrone.Api.Qualities;
|
||||
using NzbDrone.Api.Profiles;
|
||||
using NzbDrone.Api.RootFolders;
|
||||
using NzbDrone.Api.Series;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.Instrumentation;
|
||||
using NzbDrone.Core.Messaging.Commands;
|
||||
using NzbDrone.Core.Organizer;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Profiles;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.RootFolders;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
@ -41,8 +42,8 @@ namespace NzbDrone.Api.Test.MappingTests
|
|||
[TestCase(typeof(ParsedEpisodeInfo), typeof(ReleaseResource))]
|
||||
[TestCase(typeof(DownloadDecision), typeof(ReleaseResource))]
|
||||
[TestCase(typeof(Core.History.History), typeof(HistoryResource))]
|
||||
[TestCase(typeof(QualityProfile), typeof(QualityProfileResource))]
|
||||
[TestCase(typeof(QualityProfileItem), typeof(QualityProfileItemResource))]
|
||||
[TestCase(typeof(Profile), typeof(ProfileResource))]
|
||||
[TestCase(typeof(ProfileQualityItem), typeof(ProfileQualityItemResource))]
|
||||
[TestCase(typeof(Log), typeof(LogResource))]
|
||||
[TestCase(typeof(Command), typeof(CommandResource))]
|
||||
public void matching_fields(Type modelType, Type resourceType)
|
||||
|
@ -105,16 +106,16 @@ namespace NzbDrone.Api.Test.MappingTests
|
|||
|
||||
|
||||
[Test]
|
||||
public void should_map_qualityprofile()
|
||||
public void should_map_profile()
|
||||
{
|
||||
var profileResource = new QualityProfileResource
|
||||
var profileResource = new ProfileResource
|
||||
{
|
||||
Cutoff = Quality.WEBDL1080p,
|
||||
Items = new List<QualityProfileItemResource> { new QualityProfileItemResource { Quality = Quality.WEBDL1080p, Allowed = true } }
|
||||
Items = new List<ProfileQualityItemResource> { new ProfileQualityItemResource { Quality = Quality.WEBDL1080p, Allowed = true } }
|
||||
};
|
||||
|
||||
|
||||
profileResource.InjectTo<QualityProfile>();
|
||||
profileResource.InjectTo<Profile>();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -38,9 +38,19 @@
|
|||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="FizzWare.NBuilder">
|
||||
<HintPath>..\packages\NBuilder.3.0.1.1\lib\FizzWare.NBuilder.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FluentAssertions">
|
||||
<HintPath>..\packages\FluentAssertions.2.1.0.0\lib\net40\FluentAssertions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Moq">
|
||||
<HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
|
||||
</Reference>
|
||||
|
@ -50,16 +60,6 @@
|
|||
<Reference Include="Omu.ValueInjecter">
|
||||
<HintPath>..\packages\valueinjecter.2.3.3\lib\net35\Omu.ValueInjecter.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="FluentAssertions">
|
||||
<HintPath>..\packages\FluentAssertions.2.1.0.0\lib\net40\FluentAssertions.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ClientSchemaTests\SchemaBuilderFixture.cs" />
|
||||
|
|
|
@ -85,19 +85,19 @@ namespace NzbDrone.Api.Config
|
|||
|
||||
sampleResource.SingleEpisodeExample = _filenameValidationService.ValidateStandardFilename(singleEpisodeSampleResult) != null
|
||||
? "Invalid format"
|
||||
: singleEpisodeSampleResult.Filename;
|
||||
: singleEpisodeSampleResult.FileName;
|
||||
|
||||
sampleResource.MultiEpisodeExample = _filenameValidationService.ValidateStandardFilename(multiEpisodeSampleResult) != null
|
||||
? "Invalid format"
|
||||
: multiEpisodeSampleResult.Filename;
|
||||
: multiEpisodeSampleResult.FileName;
|
||||
|
||||
sampleResource.DailyEpisodeExample = _filenameValidationService.ValidateDailyFilename(dailyEpisodeSampleResult) != null
|
||||
? "Invalid format"
|
||||
: dailyEpisodeSampleResult.Filename;
|
||||
: dailyEpisodeSampleResult.FileName;
|
||||
|
||||
sampleResource.AnimeEpisodeExample = _filenameValidationService.ValidateAnimeFilename(animeEpisodeSampleResult) != null
|
||||
? "Invalid format"
|
||||
: animeEpisodeSampleResult.Filename;
|
||||
: animeEpisodeSampleResult.FileName;
|
||||
|
||||
sampleResource.SeriesFolderExample = nameSpec.SeriesFolderFormat.IsNullOrWhiteSpace()
|
||||
? "Invalid format"
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using Omu.ValueInjecter;
|
||||
|
||||
namespace NzbDrone.Api.Config
|
||||
{
|
||||
public class UiConfigModule : NzbDroneRestModule<UiConfigResource>
|
||||
{
|
||||
private readonly IConfigService _configService;
|
||||
|
||||
public UiConfigModule(IConfigService configService)
|
||||
: base("/config/ui")
|
||||
{
|
||||
_configService = configService;
|
||||
|
||||
GetResourceSingle = GetUiConfig;
|
||||
GetResourceById = GetUiConfig;
|
||||
UpdateResource = SaveUiConfig;
|
||||
}
|
||||
|
||||
private UiConfigResource GetUiConfig()
|
||||
{
|
||||
var resource = new UiConfigResource();
|
||||
resource.InjectFrom(_configService);
|
||||
resource.Id = 1;
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
private UiConfigResource GetUiConfig(int id)
|
||||
{
|
||||
return GetUiConfig();
|
||||
}
|
||||
|
||||
private void SaveUiConfig(UiConfigResource resource)
|
||||
{
|
||||
var dictionary = resource.GetType()
|
||||
.GetProperties(BindingFlags.Instance | BindingFlags.Public)
|
||||
.ToDictionary(prop => prop.Name, prop => prop.GetValue(resource, null));
|
||||
|
||||
_configService.SaveConfigDictionary(dictionary);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
using System;
|
||||
using NzbDrone.Api.REST;
|
||||
|
||||
namespace NzbDrone.Api.Config
|
||||
{
|
||||
public class UiConfigResource : RestResource
|
||||
{
|
||||
//Calendar
|
||||
public Int32 FirstDayOfWeek { get; set; }
|
||||
public String CalendarWeekColumnHeader { get; set; }
|
||||
|
||||
//Dates
|
||||
public String ShortDateFormat { get; set; }
|
||||
public String LongDateFormat { get; set; }
|
||||
public String TimeFormat { get; set; }
|
||||
public Boolean ShowRelativeDates { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,5 +1,8 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Api.Episodes;
|
||||
using NzbDrone.Api.REST;
|
||||
using NzbDrone.Core.Datastore.Events;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
|
@ -7,6 +10,7 @@ using NzbDrone.Api.Mapping;
|
|||
using NzbDrone.Core.MediaFiles.Events;
|
||||
using NzbDrone.Core.Messaging.Commands;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Api.EpisodeFiles
|
||||
{
|
||||
|
@ -15,16 +19,19 @@ namespace NzbDrone.Api.EpisodeFiles
|
|||
{
|
||||
private readonly IMediaFileService _mediaFileService;
|
||||
private readonly IRecycleBinProvider _recycleBinProvider;
|
||||
private readonly ISeriesService _seriesService;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public EpisodeModule(ICommandExecutor commandExecutor,
|
||||
IMediaFileService mediaFileService,
|
||||
IRecycleBinProvider recycleBinProvider,
|
||||
ISeriesService seriesService,
|
||||
Logger logger)
|
||||
: base(commandExecutor)
|
||||
{
|
||||
_mediaFileService = mediaFileService;
|
||||
_recycleBinProvider = recycleBinProvider;
|
||||
_seriesService = seriesService;
|
||||
_logger = logger;
|
||||
GetResourceById = GetEpisodeFile;
|
||||
GetResourceAll = GetEpisodeFiles;
|
||||
|
@ -34,7 +41,10 @@ namespace NzbDrone.Api.EpisodeFiles
|
|||
|
||||
private EpisodeFileResource GetEpisodeFile(int id)
|
||||
{
|
||||
return _mediaFileService.Get(id).InjectTo<EpisodeFileResource>();
|
||||
var episodeFile = _mediaFileService.Get(id);
|
||||
var series = _seriesService.GetSeries(episodeFile.SeriesId);
|
||||
|
||||
return MapToResource(series, episodeFile);
|
||||
}
|
||||
|
||||
private List<EpisodeFileResource> GetEpisodeFiles()
|
||||
|
@ -46,7 +56,10 @@ namespace NzbDrone.Api.EpisodeFiles
|
|||
throw new BadRequestException("seriesId is missing");
|
||||
}
|
||||
|
||||
return ToListResource(() => _mediaFileService.GetFilesBySeries(seriesId.Value));
|
||||
var series = _seriesService.GetSeries(seriesId.Value);
|
||||
|
||||
return _mediaFileService.GetFilesBySeries(seriesId.Value)
|
||||
.Select(f => MapToResource(series, f)).ToList();
|
||||
}
|
||||
|
||||
private void SetQuality(EpisodeFileResource episodeFileResource)
|
||||
|
@ -59,12 +72,22 @@ namespace NzbDrone.Api.EpisodeFiles
|
|||
private void DeleteEpisodeFile(int id)
|
||||
{
|
||||
var episodeFile = _mediaFileService.Get(id);
|
||||
var series = _seriesService.GetSeries(episodeFile.SeriesId);
|
||||
var fullPath = Path.Combine(series.Path, episodeFile.RelativePath);
|
||||
|
||||
_logger.Info("Deleting episode file: {0}", episodeFile.Path);
|
||||
_recycleBinProvider.DeleteFile(episodeFile.Path);
|
||||
_logger.Info("Deleting episode file: {0}", fullPath);
|
||||
_recycleBinProvider.DeleteFile(fullPath);
|
||||
_mediaFileService.Delete(episodeFile);
|
||||
}
|
||||
|
||||
private static EpisodeFileResource MapToResource(Core.Tv.Series series, EpisodeFile episodeFile)
|
||||
{
|
||||
var resource = episodeFile.InjectTo<EpisodeFileResource>();
|
||||
resource.Path = Path.Combine(series.Path, episodeFile.RelativePath);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
public void Handle(EpisodeFileAddedEvent message)
|
||||
{
|
||||
BroadcastResourceChange(ModelAction.Updated, message.EpisodeFile.Id);
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using NzbDrone.Api.REST;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Api.EpisodeFiles
|
||||
{
|
||||
|
@ -9,6 +8,7 @@ namespace NzbDrone.Api.EpisodeFiles
|
|||
{
|
||||
public Int32 SeriesId { get; set; }
|
||||
public Int32 SeasonNumber { get; set; }
|
||||
public String RelativePath { get; set; }
|
||||
public String Path { get; set; }
|
||||
public Int64 Size { get; set; }
|
||||
public DateTime DateAdded { get; set; }
|
||||
|
|
|
@ -20,6 +20,7 @@ namespace NzbDrone.Api.ErrorManagement
|
|||
|
||||
public Response HandleException(NancyContext context, Exception exception)
|
||||
{
|
||||
_logger.Trace("Handling Exception");
|
||||
|
||||
var apiException = exception as ApiException;
|
||||
|
||||
|
@ -49,12 +50,11 @@ namespace NzbDrone.Api.ErrorManagement
|
|||
}.AsResponse((HttpStatusCode)clientException.StatusCode);
|
||||
}
|
||||
|
||||
var sqLiteException = exception as SQLiteException;
|
||||
|
||||
if (context.Request.Method == "PUT" || context.Request.Method == "POST")
|
||||
if (sqLiteException != null)
|
||||
{
|
||||
var sqLiteException = exception as SQLiteException;
|
||||
|
||||
if (sqLiteException != null)
|
||||
if (context.Request.Method == "PUT" || context.Request.Method == "POST")
|
||||
{
|
||||
if (sqLiteException.Message.Contains("constraint failed"))
|
||||
return new ErrorModel
|
||||
|
@ -62,8 +62,12 @@ namespace NzbDrone.Api.ErrorManagement
|
|||
Message = exception.Message,
|
||||
}.AsResponse(HttpStatusCode.Conflict);
|
||||
}
|
||||
}
|
||||
|
||||
var sqlErrorMessage = String.Format("[{0} {1}]", context.Request.Method, context.Request.Path);
|
||||
|
||||
_logger.ErrorException(sqlErrorMessage, sqLiteException);
|
||||
}
|
||||
|
||||
_logger.FatalException("Request Failed", exception);
|
||||
|
||||
return new ErrorModel
|
||||
|
|
|
@ -1,13 +1,22 @@
|
|||
using System.IO;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using Nancy;
|
||||
using Nancy.Bootstrapper;
|
||||
using NLog;
|
||||
|
||||
namespace NzbDrone.Api.Extensions.Pipelines
|
||||
{
|
||||
public class GzipCompressionPipeline : IRegisterNancyPipeline
|
||||
{
|
||||
private readonly Logger _logger;
|
||||
|
||||
public GzipCompressionPipeline(Logger logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void Register(IPipelines pipelines)
|
||||
{
|
||||
pipelines.AfterRequest.AddItemToEndOfPipeline(c => CompressResponse(c.Request, c.Response));
|
||||
|
@ -15,34 +24,43 @@ namespace NzbDrone.Api.Extensions.Pipelines
|
|||
|
||||
private Response CompressResponse(Request request, Response response)
|
||||
{
|
||||
if (!response.ContentType.Contains("image")
|
||||
try
|
||||
{
|
||||
if (!response.ContentType.Contains("image")
|
||||
&& request.Headers.AcceptEncoding.Any(x => x.Contains("gzip"))
|
||||
&& (!response.Headers.ContainsKey("Content-Encoding") || response.Headers["Content-Encoding"] != "gzip"))
|
||||
{
|
||||
var data = new MemoryStream();
|
||||
response.Contents.Invoke(data);
|
||||
data.Position = 0;
|
||||
if (data.Length < 1024)
|
||||
{
|
||||
response.Contents = stream =>
|
||||
var data = new MemoryStream();
|
||||
response.Contents.Invoke(data);
|
||||
data.Position = 0;
|
||||
if (data.Length < 1024)
|
||||
{
|
||||
data.CopyTo(stream);
|
||||
stream.Flush();
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
response.Headers["Content-Encoding"] = "gzip";
|
||||
response.Contents = s =>
|
||||
response.Contents = stream =>
|
||||
{
|
||||
data.CopyTo(stream);
|
||||
stream.Flush();
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
var gzip = new GZipStream(s, CompressionMode.Compress, true);
|
||||
data.CopyTo(gzip);
|
||||
gzip.Close();
|
||||
};
|
||||
response.Headers["Content-Encoding"] = "gzip";
|
||||
response.Contents = s =>
|
||||
{
|
||||
var gzip = new GZipStream(s, CompressionMode.Compress, true);
|
||||
data.CopyTo(gzip);
|
||||
gzip.Close();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
return response;
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Unable to gzip response", ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -21,7 +21,7 @@ namespace NzbDrone.Api.Frontend.Mappers
|
|||
_diskProvider = diskProvider;
|
||||
_logger = logger;
|
||||
|
||||
if (!RuntimeInfo.IsProduction)
|
||||
if (!RuntimeInfoBase.IsProduction)
|
||||
{
|
||||
_caseSensitive = true;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ using Nancy;
|
|||
using NLog;
|
||||
using NzbDrone.Api.Mapping;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.IndexerSearch;
|
||||
using NzbDrone.Core.Indexers;
|
||||
|
@ -15,7 +14,6 @@ using Omu.ValueInjecter;
|
|||
using System.Linq;
|
||||
using Nancy.ModelBinding;
|
||||
using NzbDrone.Api.Extensions;
|
||||
using NzbDrone.Core.Qualities;
|
||||
|
||||
namespace NzbDrone.Api.Indexers
|
||||
{
|
||||
|
@ -106,14 +104,14 @@ namespace NzbDrone.Api.Indexers
|
|||
release.InjectFrom(downloadDecision.RemoteEpisode.Release);
|
||||
release.InjectFrom(downloadDecision.RemoteEpisode.ParsedEpisodeInfo);
|
||||
release.InjectFrom(downloadDecision);
|
||||
release.Rejections = downloadDecision.Rejections.ToList();
|
||||
release.Rejections = downloadDecision.Rejections.Select(r => r.Reason).ToList();
|
||||
release.DownloadAllowed = downloadDecision.RemoteEpisode.DownloadAllowed;
|
||||
|
||||
release.ReleaseWeight = result.Count;
|
||||
|
||||
if (downloadDecision.RemoteEpisode.Series != null)
|
||||
{
|
||||
release.QualityWeight = downloadDecision.RemoteEpisode.Series.QualityProfile.Value.Items.FindIndex(v => v.Quality == release.Quality.Quality) * 2;
|
||||
release.QualityWeight = downloadDecision.RemoteEpisode.Series.Profile.Value.Items.FindIndex(v => v.Quality == release.Quality.Quality) * 2;
|
||||
}
|
||||
|
||||
if (!release.Quality.Proper)
|
||||
|
|
|
@ -28,6 +28,8 @@ namespace NzbDrone.Api.Indexers
|
|||
public int[] EpisodeNumbers { get; set; }
|
||||
public int[] AbsoluteEpisodeNumbers { get; set; }
|
||||
public Boolean Approved { get; set; }
|
||||
public Boolean TemporarilyRejected { get; set; }
|
||||
public Boolean Rejected { get; set; }
|
||||
public Int32 TvRageId { get; set; }
|
||||
public IEnumerable<String> Rejections { get; set; }
|
||||
public DateTime PublishDate { get; set; }
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
@ -26,6 +27,8 @@ namespace NzbDrone.Api.Logs
|
|||
|
||||
protected override IEnumerable<String> GetLogFiles()
|
||||
{
|
||||
if (!_diskProvider.FolderExists(_appFolderInfo.GetUpdateLogFolder())) return Enumerable.Empty<String>();
|
||||
|
||||
return _diskProvider.GetFiles(_appFolderInfo.GetUpdateLogFolder(), SearchOption.TopDirectoryOnly)
|
||||
.Where(f => Regex.IsMatch(Path.GetFileName(f), LOGFILE_ROUTE.TrimStart('/'), RegexOptions.IgnoreCase))
|
||||
.ToList();
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace NzbDrone.Api
|
|||
{
|
||||
_logger.Info("Starting NzbDrone API");
|
||||
|
||||
if (RuntimeInfo.IsProduction)
|
||||
if (RuntimeInfoBase.IsProduction)
|
||||
{
|
||||
DiagnosticsHook.Disable(pipelines);
|
||||
}
|
||||
|
|
|
@ -40,22 +40,20 @@
|
|||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="DDay.iCal">
|
||||
<HintPath>..\packages\DDay.iCal.1.0.2.575\lib\DDay.iCal.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FluentValidation">
|
||||
<HintPath>..\packages\FluentValidation.5.0.0.1\lib\Net40\FluentValidation.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.AspNet.SignalR.Core, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Microsoft.AspNet.SignalR.Core.1.1.3\lib\net40\Microsoft.AspNet.SignalR.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Omu.ValueInjecter">
|
||||
<HintPath>..\packages\ValueInjecter.2.3.3\lib\net35\Omu.ValueInjecter.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="FluentValidation">
|
||||
<HintPath>..\packages\FluentValidation.5.0.0.1\lib\Net40\FluentValidation.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Nancy">
|
||||
<HintPath>..\packages\Nancy.0.21.1\lib\net40\Nancy.dll</HintPath>
|
||||
</Reference>
|
||||
|
@ -71,10 +69,6 @@
|
|||
<Reference Include="Omu.ValueInjecter">
|
||||
<HintPath>..\packages\ValueInjecter.2.3.3\lib\net35\Omu.ValueInjecter.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Data.SQLite, Version=1.0.84.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Libraries\Sqlite\System.Data.SQLite.dll</HintPath>
|
||||
|
@ -89,128 +83,133 @@
|
|||
<Compile Include="Authentication\NzbDroneUser.cs" />
|
||||
<Compile Include="Blacklist\BlacklistModule.cs" />
|
||||
<Compile Include="Blacklist\BlacklistResource.cs" />
|
||||
<Compile Include="Calendar\CalendarModule.cs" />
|
||||
<Compile Include="Calendar\CalendarFeedModule.cs" />
|
||||
<Compile Include="ClientSchema\SchemaDeserializer.cs" />
|
||||
<Compile Include="ClientSchema\FieldDefinitionAttribute.cs" />
|
||||
<Compile Include="Calendar\CalendarModule.cs" />
|
||||
<Compile Include="ClientSchema\Field.cs" />
|
||||
<Compile Include="ClientSchema\FieldDefinitionAttribute.cs" />
|
||||
<Compile Include="ClientSchema\SchemaBuilder.cs" />
|
||||
<Compile Include="ClientSchema\SchemaDeserializer.cs" />
|
||||
<Compile Include="ClientSchema\SelectOption.cs" />
|
||||
<Compile Include="Commands\CommandModule.cs" />
|
||||
<Compile Include="Commands\CommandResource.cs" />
|
||||
<Compile Include="Config\IndexerConfigModule.cs" />
|
||||
<Compile Include="Config\MediaManagementConfigModule.cs" />
|
||||
<Compile Include="Config\MediaManagementConfigResource.cs" />
|
||||
<Compile Include="Config\NzbDroneConfigModule.cs" />
|
||||
<Compile Include="Config\UiConfigModule.cs" />
|
||||
<Compile Include="Config\UiConfigResource.cs" />
|
||||
<Compile Include="Config\DownloadClientConfigModule.cs" />
|
||||
<Compile Include="Config\DownloadClientConfigResource.cs" />
|
||||
<Compile Include="Config\HostConfigModule.cs" />
|
||||
<Compile Include="Config\HostConfigResource.cs" />
|
||||
<Compile Include="Config\NamingConfigResource.cs" />
|
||||
<Compile Include="Config\NamingConfigModule.cs" />
|
||||
<Compile Include="Config\IndexerConfigModule.cs" />
|
||||
<Compile Include="Config\IndexerConfigResource.cs" />
|
||||
<Compile Include="DownloadClient\DownloadClientModule.cs" />
|
||||
<Compile Include="DownloadClient\DownloadClientResource.cs" />
|
||||
<Compile Include="DiskSpace\DiskSpaceModule.cs" />
|
||||
<Compile Include="DiskSpace\DiskSpaceResource.cs" />
|
||||
<Compile Include="EpisodeFiles\EpisodeFileModule.cs" />
|
||||
<Compile Include="EpisodeFiles\EpisodeFileResource.cs" />
|
||||
<Compile Include="Config\MediaManagementConfigModule.cs" />
|
||||
<Compile Include="Config\MediaManagementConfigResource.cs" />
|
||||
<Compile Include="Config\NamingConfigModule.cs" />
|
||||
<Compile Include="Config\NamingConfigResource.cs" />
|
||||
<Compile Include="Config\NamingSampleResource.cs" />
|
||||
<Compile Include="Config\NzbDroneConfigModule.cs" />
|
||||
<Compile Include="Directories\DirectoryLookupService.cs" />
|
||||
<Compile Include="Directories\DirectoryModule.cs" />
|
||||
<Compile Include="Episodes\EpisodeModuleWithSignalR.cs" />
|
||||
<Compile Include="DiskSpace\DiskSpaceModule.cs" />
|
||||
<Compile Include="DiskSpace\DiskSpaceResource.cs" />
|
||||
<Compile Include="DownloadClient\DownloadClientModule.cs" />
|
||||
<Compile Include="DownloadClient\DownloadClientResource.cs" />
|
||||
<Compile Include="EpisodeFiles\EpisodeFileModule.cs" />
|
||||
<Compile Include="EpisodeFiles\EpisodeFileResource.cs" />
|
||||
<Compile Include="Episodes\EpisodeModule.cs" />
|
||||
<Compile Include="Episodes\EpisodeModuleWithSignalR.cs" />
|
||||
<Compile Include="Episodes\EpisodeResource.cs" />
|
||||
<Compile Include="Episodes\RenameEpisodeModule.cs" />
|
||||
<Compile Include="Episodes\RenameEpisodeResource.cs" />
|
||||
<Compile Include="Extensions\Pipelines\NzbDroneVersionPipeline.cs" />
|
||||
<Compile Include="ErrorManagement\ApiException.cs" />
|
||||
<Compile Include="ErrorManagement\ErrorHandler.cs" />
|
||||
<Compile Include="ErrorManagement\ErrorModel.cs" />
|
||||
<Compile Include="ErrorManagement\NzbDroneErrorPipeline.cs" />
|
||||
<Compile Include="Exceptions\InvalidApiKeyException.cs" />
|
||||
<Compile Include="Extensions\LazyExtensions.cs" />
|
||||
<Compile Include="Extensions\NancyJsonSerializer.cs" />
|
||||
<Compile Include="Extensions\Pipelines\CacheHeaderPipeline.cs" />
|
||||
<Compile Include="Extensions\Pipelines\GZipPipeline.cs" />
|
||||
<Compile Include="Extensions\Pipelines\IfModifiedPipeline.cs" />
|
||||
<Compile Include="Extensions\Pipelines\IRegisterNancyPipeline.cs" />
|
||||
<Compile Include="Extensions\NancyJsonSerializer.cs" />
|
||||
<Compile Include="Extensions\Pipelines\NzbDroneVersionPipeline.cs" />
|
||||
<Compile Include="Extensions\ReqResExtensions.cs" />
|
||||
<Compile Include="Extensions\RequestExtensions.cs" />
|
||||
<Compile Include="Frontend\CacheableSpecification.cs" />
|
||||
<Compile Include="Frontend\Mappers\UpdateLogFileMapper.cs" />
|
||||
<Compile Include="Frontend\Mappers\BackupFileMapper.cs" />
|
||||
<Compile Include="Frontend\Mappers\FaviconMapper.cs" />
|
||||
<Compile Include="Frontend\Mappers\IMapHttpRequestsToDisk.cs" />
|
||||
<Compile Include="Frontend\Mappers\IndexHtmlMapper.cs" />
|
||||
<Compile Include="Frontend\Mappers\LogFileMapper.cs" />
|
||||
<Compile Include="Frontend\Mappers\MediaCoverMapper.cs" />
|
||||
<Compile Include="Frontend\Mappers\StaticResourceMapper.cs" />
|
||||
<Compile Include="Frontend\Mappers\IMapHttpRequestsToDisk.cs" />
|
||||
<Compile Include="Frontend\Mappers\StaticResourceMapperBase.cs" />
|
||||
<Compile Include="Frontend\Mappers\UpdateLogFileMapper.cs" />
|
||||
<Compile Include="Frontend\StaticResourceModule.cs" />
|
||||
<Compile Include="Health\HealthResource.cs" />
|
||||
<Compile Include="Health\HealthModule.cs" />
|
||||
<Compile Include="History\HistoryResource.cs" />
|
||||
<Compile Include="Health\HealthResource.cs" />
|
||||
<Compile Include="History\HistoryModule.cs" />
|
||||
<Compile Include="Logs\LogFileModuleBase.cs" />
|
||||
<Compile Include="Logs\UpdateLogFileModule.cs" />
|
||||
<Compile Include="MediaCovers\MediaCoverModule.cs" />
|
||||
<Compile Include="Metadata\MetadataResource.cs" />
|
||||
<Compile Include="Metadata\MetadataModule.cs" />
|
||||
<Compile Include="NzbDroneFeedModule.cs" />
|
||||
<Compile Include="ProviderResource.cs" />
|
||||
<Compile Include="ProviderModuleBase.cs" />
|
||||
<Compile Include="History\HistoryResource.cs" />
|
||||
<Compile Include="Indexers\IndexerModule.cs" />
|
||||
<Compile Include="Indexers\IndexerResource.cs" />
|
||||
<Compile Include="Indexers\ReleaseModule.cs" />
|
||||
<Compile Include="Extensions\LazyExtensions.cs" />
|
||||
<Compile Include="Indexers\ReleaseResource.cs" />
|
||||
<Compile Include="Logs\LogFileResource.cs" />
|
||||
<Compile Include="Logs\LogFileModule.cs" />
|
||||
<Compile Include="Logs\LogFileModuleBase.cs" />
|
||||
<Compile Include="Logs\LogFileResource.cs" />
|
||||
<Compile Include="Logs\LogModule.cs" />
|
||||
<Compile Include="Logs\LogResource.cs" />
|
||||
<Compile Include="Logs\UpdateLogFileModule.cs" />
|
||||
<Compile Include="Mapping\CloneInjection.cs" />
|
||||
<Compile Include="Mapping\MappingValidation.cs" />
|
||||
<Compile Include="Mapping\ResourceMappingException.cs" />
|
||||
<Compile Include="Mapping\ValueInjectorExtensions.cs" />
|
||||
<Compile Include="Series\AlternateTitleResource.cs" />
|
||||
<Compile Include="Series\SeasonResource.cs" />
|
||||
<Compile Include="System\Backup\BackupModule.cs" />
|
||||
<Compile Include="System\Backup\BackupResource.cs" />
|
||||
<Compile Include="Update\UpdateResource.cs" />
|
||||
<Compile Include="Wanted\CutoffModule.cs" />
|
||||
<Compile Include="Wanted\LegacyMissingModule.cs" />
|
||||
<Compile Include="Wanted\MissingModule.cs" />
|
||||
<Compile Include="Config\NamingSampleResource.cs" />
|
||||
<Compile Include="MediaCovers\MediaCoverModule.cs" />
|
||||
<Compile Include="Metadata\MetadataModule.cs" />
|
||||
<Compile Include="Metadata\MetadataResource.cs" />
|
||||
<Compile Include="NancyBootstrapper.cs" />
|
||||
<Compile Include="Notifications\NotificationModule.cs" />
|
||||
<Compile Include="Notifications\NotificationResource.cs" />
|
||||
<Compile Include="NzbDroneApiModule.cs" />
|
||||
<Compile Include="NzbDroneFeedModule.cs" />
|
||||
<Compile Include="NzbDroneRestModule.cs" />
|
||||
<Compile Include="NzbDroneRestModuleWithSignalR.cs" />
|
||||
<Compile Include="Qualities\QualityProfileValidation.cs" />
|
||||
<Compile Include="PagingResource.cs" />
|
||||
<Compile Include="Profiles\Languages\LanguageModule.cs" />
|
||||
<Compile Include="Profiles\Languages\LanguageResource.cs" />
|
||||
<Compile Include="Profiles\LegacyProfileModule.cs" />
|
||||
<Compile Include="Profiles\ProfileModule.cs" />
|
||||
<Compile Include="Profiles\ProfileResource.cs" />
|
||||
<Compile Include="Profiles\ProfileSchemaModule.cs" />
|
||||
<Compile Include="Profiles\ProfileValidation.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ProviderModuleBase.cs" />
|
||||
<Compile Include="ProviderResource.cs" />
|
||||
<Compile Include="Qualities\QualityDefinitionModule.cs" />
|
||||
<Compile Include="Qualities\QualityDefinitionResource.cs" />
|
||||
<Compile Include="Queue\QueueModule.cs" />
|
||||
<Compile Include="Queue\QueueResource.cs" />
|
||||
<Compile Include="ResourceChangeMessage.cs" />
|
||||
<Compile Include="Notifications\NotificationModule.cs" />
|
||||
<Compile Include="Notifications\NotificationResource.cs" />
|
||||
<Compile Include="NzbDroneRestModule.cs" />
|
||||
<Compile Include="PagingResource.cs" />
|
||||
<Compile Include="Qualities\QualityProfileSchemaModule.cs" />
|
||||
<Compile Include="REST\BadRequestException.cs" />
|
||||
<Compile Include="REST\ResourceValidator.cs" />
|
||||
<Compile Include="REST\RestModule.cs" />
|
||||
<Compile Include="REST\RestResource.cs" />
|
||||
<Compile Include="RootFolders\RootFolderModule.cs" />
|
||||
<Compile Include="RootFolders\RootFolderResource.cs" />
|
||||
<Compile Include="Series\AlternateTitleResource.cs" />
|
||||
<Compile Include="Series\SeasonResource.cs" />
|
||||
<Compile Include="Series\SeriesEditorModule.cs" />
|
||||
<Compile Include="Series\SeriesResource.cs" />
|
||||
<Compile Include="Series\SeriesModule.cs" />
|
||||
<Compile Include="Series\SeriesLookupModule.cs" />
|
||||
<Compile Include="ErrorManagement\ApiException.cs" />
|
||||
<Compile Include="NancyBootstrapper.cs" />
|
||||
<Compile Include="ErrorManagement\ErrorHandler.cs" />
|
||||
<Compile Include="ErrorManagement\ErrorModel.cs" />
|
||||
<Compile Include="ErrorManagement\NzbDroneErrorPipeline.cs" />
|
||||
<Compile Include="Exceptions\InvalidApiKeyException.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="NzbDroneApiModule.cs" />
|
||||
<Compile Include="Qualities\QualityProfileResource.cs" />
|
||||
<Compile Include="Qualities\QualityProfileModule.cs" />
|
||||
<Compile Include="Qualities\QualityDefinitionResource.cs" />
|
||||
<Compile Include="Qualities\QualityDefinitionModule.cs" />
|
||||
<Compile Include="Extensions\ReqResExtensions.cs" />
|
||||
<Compile Include="Series\SeriesModule.cs" />
|
||||
<Compile Include="Series\SeriesResource.cs" />
|
||||
<Compile Include="System\Backup\BackupModule.cs" />
|
||||
<Compile Include="System\Backup\BackupResource.cs" />
|
||||
<Compile Include="System\SystemModule.cs" />
|
||||
<Compile Include="TinyIoCNancyBootstrapper.cs" />
|
||||
<Compile Include="Update\UpdateModule.cs" />
|
||||
<Compile Include="Update\UpdateResource.cs" />
|
||||
<Compile Include="Validation\RuleBuilderExtensions.cs" />
|
||||
<Compile Include="Wanted\CutoffModule.cs" />
|
||||
<Compile Include="Wanted\LegacyMissingModule.cs" />
|
||||
<Compile Include="Wanted\MissingModule.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config">
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NzbDrone.Core.Parser;
|
||||
|
||||
namespace NzbDrone.Api.Profiles.Languages
|
||||
{
|
||||
public class LanguageModule : NzbDroneRestModule<LanguageResource>
|
||||
{
|
||||
public LanguageModule()
|
||||
{
|
||||
GetResourceAll = GetAll;
|
||||
GetResourceById = GetById;
|
||||
}
|
||||
|
||||
private LanguageResource GetById(int id)
|
||||
{
|
||||
var language = (Language)id;
|
||||
|
||||
return new LanguageResource
|
||||
{
|
||||
Id = (int)language,
|
||||
Name = language.ToString()
|
||||
};
|
||||
}
|
||||
|
||||
private List<LanguageResource> GetAll()
|
||||
{
|
||||
return ((Language[])Enum.GetValues(typeof (Language)))
|
||||
.Select(l => new LanguageResource
|
||||
{
|
||||
Id = (int) l,
|
||||
Name = l.ToString()
|
||||
})
|
||||
.OrderBy(l => l.Name)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using NzbDrone.Api.REST;
|
||||
|
||||
namespace NzbDrone.Api.Profiles.Languages
|
||||
{
|
||||
public class LanguageResource : RestResource
|
||||
{
|
||||
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Include)]
|
||||
public Int32 Id { get; set; }
|
||||
public String Name { get; set; }
|
||||
public String NameLower { get { return Name.ToLowerInvariant(); } }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
using System;
|
||||
using System.Text;
|
||||
using Nancy;
|
||||
using Nancy.Responses;
|
||||
|
||||
namespace NzbDrone.Api.Profiles
|
||||
{
|
||||
class LegacyProfileModule : NzbDroneApiModule
|
||||
{
|
||||
public LegacyProfileModule()
|
||||
: base("qualityprofile")
|
||||
{
|
||||
Get["/"] = x =>
|
||||
{
|
||||
string queryString = ConvertQueryParams(Request.Query);
|
||||
var url = String.Format("/api/profile?{0}", queryString);
|
||||
|
||||
return Response.AsRedirect(url);
|
||||
};
|
||||
}
|
||||
|
||||
private string ConvertQueryParams(DynamicDictionary query)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
|
||||
foreach (var key in query)
|
||||
{
|
||||
var value = query[key];
|
||||
|
||||
sb.AppendFormat("&{0}={1}", key, value);
|
||||
}
|
||||
|
||||
return sb.ToString().Trim('&');
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
using System.Collections.Generic;
|
||||
using FluentValidation;
|
||||
using NzbDrone.Api.Mapping;
|
||||
using NzbDrone.Core.Profiles;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Validation;
|
||||
|
||||
namespace NzbDrone.Api.Profiles
|
||||
{
|
||||
public class ProfileModule : NzbDroneRestModule<ProfileResource>
|
||||
{
|
||||
private readonly IProfileService _profileService;
|
||||
|
||||
public ProfileModule(IProfileService profileService)
|
||||
{
|
||||
_profileService = profileService;
|
||||
SharedValidator.RuleFor(c => c.Name).NotEmpty();
|
||||
SharedValidator.RuleFor(c => c.Cutoff).NotNull();
|
||||
SharedValidator.RuleFor(c => c.Items).MustHaveAllowedQuality();
|
||||
SharedValidator.RuleFor(c => c.Language).ValidLanguage();
|
||||
|
||||
GetResourceAll = GetAll;
|
||||
GetResourceById = GetById;
|
||||
UpdateResource = Update;
|
||||
CreateResource = Create;
|
||||
DeleteResource = DeleteProfile;
|
||||
}
|
||||
|
||||
private int Create(ProfileResource resource)
|
||||
{
|
||||
var model = resource.InjectTo<Profile>();
|
||||
model = _profileService.Add(model);
|
||||
return model.Id;
|
||||
}
|
||||
|
||||
private void DeleteProfile(int id)
|
||||
{
|
||||
_profileService.Delete(id);
|
||||
}
|
||||
|
||||
private void Update(ProfileResource resource)
|
||||
{
|
||||
var model = _profileService.Get(resource.Id);
|
||||
|
||||
model.Name = resource.Name;
|
||||
model.Cutoff = (Quality)resource.Cutoff.Id;
|
||||
model.Items = resource.Items.InjectTo<List<ProfileQualityItem>>();
|
||||
model.Language = resource.Language;
|
||||
model.GrabDelay = resource.GrabDelay;
|
||||
model.GrabDelayMode = resource.GrabDelayMode;
|
||||
|
||||
_profileService.Update(model);
|
||||
}
|
||||
|
||||
private ProfileResource GetById(int id)
|
||||
{
|
||||
return _profileService.Get(id).InjectTo<ProfileResource>();
|
||||
}
|
||||
|
||||
private List<ProfileResource> GetAll()
|
||||
{
|
||||
var profiles = _profileService.All().InjectTo<List<ProfileResource>>();
|
||||
|
||||
return profiles;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using NzbDrone.Api.REST;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Profiles;
|
||||
using NzbDrone.Core.Qualities;
|
||||
|
||||
namespace NzbDrone.Api.Profiles
|
||||
{
|
||||
public class ProfileResource : RestResource
|
||||
{
|
||||
public String Name { get; set; }
|
||||
public Quality Cutoff { get; set; }
|
||||
public List<ProfileQualityItemResource> Items { get; set; }
|
||||
public Language Language { get; set; }
|
||||
public Int32 GrabDelay { get; set; }
|
||||
public GrabDelayMode GrabDelayMode { get; set; }
|
||||
}
|
||||
|
||||
public class ProfileQualityItemResource : RestResource
|
||||
{
|
||||
public Quality Quality { get; set; }
|
||||
public bool Allowed { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,34 +1,37 @@
|
|||
using System.Collections.Generic;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Api.Mapping;
|
||||
using System.Linq;
|
||||
using NzbDrone.Api.Mapping;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Profiles;
|
||||
using NzbDrone.Core.Qualities;
|
||||
|
||||
namespace NzbDrone.Api.Qualities
|
||||
namespace NzbDrone.Api.Profiles
|
||||
{
|
||||
public class QualityProfileSchemaModule : NzbDroneRestModule<QualityProfileResource>
|
||||
public class ProfileSchemaModule : NzbDroneRestModule<ProfileResource>
|
||||
{
|
||||
private readonly IQualityDefinitionService _qualityDefinitionService;
|
||||
|
||||
public QualityProfileSchemaModule(IQualityDefinitionService qualityDefinitionService)
|
||||
: base("/qualityprofile/schema")
|
||||
public ProfileSchemaModule(IQualityDefinitionService qualityDefinitionService)
|
||||
: base("/profile/schema")
|
||||
{
|
||||
_qualityDefinitionService = qualityDefinitionService;
|
||||
|
||||
GetResourceAll = GetAll;
|
||||
}
|
||||
|
||||
private List<QualityProfileResource> GetAll()
|
||||
private List<ProfileResource> GetAll()
|
||||
{
|
||||
var items = _qualityDefinitionService.All()
|
||||
.OrderBy(v => v.Weight)
|
||||
.Select(v => new QualityProfileItem { Quality = v.Quality, Allowed = false })
|
||||
.Select(v => new ProfileQualityItem { Quality = v.Quality, Allowed = false })
|
||||
.ToList();
|
||||
|
||||
var profile = new QualityProfile();
|
||||
var profile = new Profile();
|
||||
profile.Cutoff = Quality.Unknown;
|
||||
profile.Items = items;
|
||||
profile.Language = Language.English;
|
||||
|
||||
return new List<QualityProfileResource> { profile.InjectTo<QualityProfileResource>() };
|
||||
return new List<ProfileResource> { profile.InjectTo<ProfileResource>() };
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,11 +3,11 @@ using System.Linq;
|
|||
using FluentValidation;
|
||||
using FluentValidation.Validators;
|
||||
|
||||
namespace NzbDrone.Api.Qualities
|
||||
namespace NzbDrone.Api.Profiles
|
||||
{
|
||||
public static class QualityProfileValidation
|
||||
public static class ProfileValidation
|
||||
{
|
||||
public static IRuleBuilderOptions<T, IList<QualityProfileItemResource>> MustHaveAllowedQuality<T>(this IRuleBuilder<T, IList<QualityProfileItemResource>> ruleBuilder)
|
||||
public static IRuleBuilderOptions<T, IList<ProfileQualityItemResource>> MustHaveAllowedQuality<T>(this IRuleBuilder<T, IList<ProfileQualityItemResource>> ruleBuilder)
|
||||
{
|
||||
ruleBuilder.SetValidator(new NotEmptyValidator(null));
|
||||
|
||||
|
@ -25,7 +25,7 @@ namespace NzbDrone.Api.Qualities
|
|||
|
||||
protected override bool IsValid(PropertyValidatorContext context)
|
||||
{
|
||||
var list = context.PropertyValue as IList<QualityProfileItemResource>;
|
||||
var list = context.PropertyValue as IList<ProfileQualityItemResource>;
|
||||
|
||||
if (list == null)
|
||||
{
|
|
@ -1,60 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Api.Mapping;
|
||||
using FluentValidation;
|
||||
|
||||
namespace NzbDrone.Api.Qualities
|
||||
{
|
||||
public class QualityProfileModule : NzbDroneRestModule<QualityProfileResource>
|
||||
{
|
||||
private readonly IQualityProfileService _qualityProfileService;
|
||||
|
||||
public QualityProfileModule(IQualityProfileService qualityProfileService)
|
||||
{
|
||||
_qualityProfileService = qualityProfileService;
|
||||
SharedValidator.RuleFor(c => c.Name).NotEmpty();
|
||||
SharedValidator.RuleFor(c => c.Cutoff).NotNull();
|
||||
SharedValidator.RuleFor(c => c.Items).MustHaveAllowedQuality();//.SetValidator(new AllowedValidator<QualityProfileItemResource>());
|
||||
|
||||
GetResourceAll = GetAll;
|
||||
GetResourceById = GetById;
|
||||
UpdateResource = Update;
|
||||
CreateResource = Create;
|
||||
DeleteResource = DeleteProfile;
|
||||
}
|
||||
|
||||
private int Create(QualityProfileResource resource)
|
||||
{
|
||||
var model = resource.InjectTo<QualityProfile>();
|
||||
model = _qualityProfileService.Add(model);
|
||||
return model.Id;
|
||||
}
|
||||
|
||||
private void DeleteProfile(int id)
|
||||
{
|
||||
_qualityProfileService.Delete(id);
|
||||
}
|
||||
|
||||
private void Update(QualityProfileResource resource)
|
||||
{
|
||||
var model = _qualityProfileService.Get(resource.Id);
|
||||
|
||||
model.Name = resource.Name;
|
||||
model.Cutoff = (Quality)resource.Cutoff.Id;
|
||||
model.Items = resource.Items.InjectTo<List<QualityProfileItem>>();
|
||||
_qualityProfileService.Update(model);
|
||||
}
|
||||
|
||||
private QualityProfileResource GetById(int id)
|
||||
{
|
||||
return _qualityProfileService.Get(id).InjectTo<QualityProfileResource>();
|
||||
}
|
||||
|
||||
private List<QualityProfileResource> GetAll()
|
||||
{
|
||||
var profiles = _qualityProfileService.All().InjectTo<List<QualityProfileResource>>();
|
||||
|
||||
return profiles;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using NzbDrone.Api.REST;
|
||||
using NzbDrone.Core.Qualities;
|
||||
|
||||
namespace NzbDrone.Api.Qualities
|
||||
{
|
||||
public class QualityProfileResource : RestResource
|
||||
{
|
||||
public String Name { get; set; }
|
||||
public Quality Cutoff { get; set; }
|
||||
public List<QualityProfileItemResource> Items { get; set; }
|
||||
}
|
||||
|
||||
public class QualityProfileItemResource : RestResource
|
||||
{
|
||||
public Quality Quality { get; set; }
|
||||
public bool Allowed { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NzbDrone.Core.Datastore.Events;
|
||||
using NzbDrone.Core.Download.Pending;
|
||||
using NzbDrone.Core.Messaging.Commands;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
using NzbDrone.Core.Queue;
|
||||
|
@ -7,25 +9,40 @@ using NzbDrone.Core.Queue;
|
|||
namespace NzbDrone.Api.Queue
|
||||
{
|
||||
public class QueueModule : NzbDroneRestModuleWithSignalR<QueueResource, Core.Queue.Queue>,
|
||||
IHandle<UpdateQueueEvent>
|
||||
IHandle<UpdateQueueEvent>, IHandle<PendingReleasesUpdatedEvent>
|
||||
{
|
||||
private readonly IQueueService _queueService;
|
||||
private readonly IPendingReleaseService _pendingReleaseService;
|
||||
|
||||
public QueueModule(ICommandExecutor commandExecutor, IQueueService queueService)
|
||||
public QueueModule(ICommandExecutor commandExecutor, IQueueService queueService, IPendingReleaseService pendingReleaseService)
|
||||
: base(commandExecutor)
|
||||
{
|
||||
_queueService = queueService;
|
||||
_pendingReleaseService = pendingReleaseService;
|
||||
GetResourceAll = GetQueue;
|
||||
}
|
||||
|
||||
private List<QueueResource> GetQueue()
|
||||
{
|
||||
return ToListResource(_queueService.GetQueue);
|
||||
return ToListResource(GetQueueItems);
|
||||
}
|
||||
|
||||
private IEnumerable<Core.Queue.Queue> GetQueueItems()
|
||||
{
|
||||
var queue = _queueService.GetQueue();
|
||||
var pending = _pendingReleaseService.GetPendingQueue();
|
||||
|
||||
return queue.Concat(pending);
|
||||
}
|
||||
|
||||
public void Handle(UpdateQueueEvent message)
|
||||
{
|
||||
BroadcastResourceChange(ModelAction.Sync);
|
||||
}
|
||||
|
||||
public void Handle(PendingReleasesUpdatedEvent message)
|
||||
{
|
||||
BroadcastResourceChange(ModelAction.Sync);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using NzbDrone.Api.REST;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Api.Series;
|
||||
using NzbDrone.Api.Episodes;
|
||||
|
||||
|
@ -16,6 +15,7 @@ namespace NzbDrone.Api.Queue
|
|||
public String Title { get; set; }
|
||||
public Decimal Sizeleft { get; set; }
|
||||
public TimeSpan? Timeleft { get; set; }
|
||||
public DateTime? EstimatedCompletionTime { get; set; }
|
||||
public String Status { get; set; }
|
||||
public String ErrorMessage { get; set; }
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ using NzbDrone.Api.Mapping;
|
|||
using NzbDrone.Core.Tv.Events;
|
||||
using NzbDrone.Core.Validation.Paths;
|
||||
using NzbDrone.Core.DataAugmentation.Scene;
|
||||
using Omu.ValueInjecter;
|
||||
|
||||
namespace NzbDrone.Api.Series
|
||||
{
|
||||
|
@ -27,7 +26,6 @@ namespace NzbDrone.Api.Series
|
|||
IHandle<SeriesDeletedEvent>
|
||||
|
||||
{
|
||||
private readonly ICommandExecutor _commandExecutor;
|
||||
private readonly ISeriesService _seriesService;
|
||||
private readonly ISeriesStatisticsService _seriesStatisticsService;
|
||||
private readonly ISceneMappingService _sceneMappingService;
|
||||
|
@ -39,7 +37,6 @@ namespace NzbDrone.Api.Series
|
|||
ISceneMappingService sceneMappingService,
|
||||
IMapCoversToLocal coverMapper,
|
||||
RootFolderValidator rootFolderValidator,
|
||||
PathExistsValidator pathExistsValidator,
|
||||
SeriesPathValidator seriesPathValidator,
|
||||
SeriesExistsValidator seriesExistsValidator,
|
||||
DroneFactoryValidator droneFactoryValidator,
|
||||
|
@ -47,7 +44,6 @@ namespace NzbDrone.Api.Series
|
|||
)
|
||||
: base(commandExecutor)
|
||||
{
|
||||
_commandExecutor = commandExecutor;
|
||||
_seriesService = seriesService;
|
||||
_seriesStatisticsService = seriesStatisticsService;
|
||||
_sceneMappingService = sceneMappingService;
|
||||
|
@ -60,7 +56,7 @@ namespace NzbDrone.Api.Series
|
|||
UpdateResource = UpdateSeries;
|
||||
DeleteResource = DeleteSeries;
|
||||
|
||||
SharedValidator.RuleFor(s => s.QualityProfileId).ValidId();
|
||||
SharedValidator.RuleFor(s => s.ProfileId).ValidId();
|
||||
|
||||
SharedValidator.RuleFor(s => s.Path)
|
||||
.Cascade(CascadeMode.StopOnFirstFailure)
|
||||
|
@ -164,6 +160,7 @@ namespace NzbDrone.Api.Series
|
|||
resource.EpisodeFileCount = seriesStatistics.EpisodeFileCount;
|
||||
resource.NextAiring = seriesStatistics.NextAiring;
|
||||
resource.PreviousAiring = seriesStatistics.PreviousAiring;
|
||||
resource.SizeOnDisk = seriesStatistics.SizeOnDisk;
|
||||
}
|
||||
|
||||
private void PopulateAlternateTitles(List<SeriesResource> resources)
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace NzbDrone.Api.Series
|
|||
{
|
||||
//Todo: Sorters should be done completely on the client
|
||||
//Todo: Is there an easy way to keep IgnoreArticlesWhenSorting in sync between, Series, History, Missing?
|
||||
//Todo: We should get the entire QualityProfile instead of ID and Name separately
|
||||
//Todo: We should get the entire Profile instead of ID and Name separately
|
||||
|
||||
//View Only
|
||||
public String Title { get; set; }
|
||||
|
@ -31,8 +31,9 @@ namespace NzbDrone.Api.Series
|
|||
|
||||
public Int32 EpisodeCount { get; set; }
|
||||
public Int32 EpisodeFileCount { get; set; }
|
||||
public Int64 SizeOnDisk { get; set; }
|
||||
public SeriesStatusType Status { get; set; }
|
||||
public String QualityProfileName { get; set; }
|
||||
public String ProfileName { get; set; }
|
||||
public String Overview { get; set; }
|
||||
public DateTime? NextAiring { get; set; }
|
||||
public DateTime? PreviousAiring { get; set; }
|
||||
|
@ -46,7 +47,7 @@ namespace NzbDrone.Api.Series
|
|||
|
||||
//View & Edit
|
||||
public String Path { get; set; }
|
||||
public Int32 QualityProfileId { get; set; }
|
||||
public Int32 ProfileId { get; set; }
|
||||
|
||||
//Editing Only
|
||||
public Boolean SeasonFolder { get; set; }
|
||||
|
@ -65,5 +66,21 @@ namespace NzbDrone.Api.Series
|
|||
public String RootFolderPath { get; set; }
|
||||
public String Certification { get; set; }
|
||||
public List<String> Genres { get; set; }
|
||||
|
||||
//Used to support legacy consumers
|
||||
public Int32 QualityProfileId
|
||||
{
|
||||
get
|
||||
{
|
||||
return ProfileId;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value > 0 && ProfileId == 0)
|
||||
{
|
||||
ProfileId = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ using NzbDrone.Common.EnvironmentInfo;
|
|||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Lifecycle;
|
||||
using NzbDrone.Core.Lifecycle.Commands;
|
||||
|
||||
namespace NzbDrone.Api.System
|
||||
{
|
||||
|
@ -46,9 +45,9 @@ namespace NzbDrone.Api.System
|
|||
Version = BuildInfo.Version.ToString(),
|
||||
BuildTime = BuildInfo.BuildDateTime,
|
||||
IsDebug = BuildInfo.IsDebug,
|
||||
IsProduction = RuntimeInfo.IsProduction,
|
||||
IsProduction = RuntimeInfoBase.IsProduction,
|
||||
IsAdmin = _runtimeInfo.IsAdmin,
|
||||
IsUserInteractive = _runtimeInfo.IsUserInteractive,
|
||||
IsUserInteractive = RuntimeInfoBase.IsUserInteractive,
|
||||
StartupPath = _appFolderInfo.StartUpFolder,
|
||||
AppData = _appFolderInfo.GetAppDataPath(),
|
||||
OsVersion = OsInfo.Version.ToString(),
|
||||
|
@ -59,9 +58,9 @@ namespace NzbDrone.Api.System
|
|||
IsWindows = OsInfo.IsWindows,
|
||||
Branch = _configFileProvider.Branch,
|
||||
Authentication = _configFileProvider.AuthenticationEnabled,
|
||||
StartOfWeek = (int)OsInfo.FirstDayOfWeek,
|
||||
SqliteVersion = _database.Version,
|
||||
UrlBase = _configFileProvider.UrlBase
|
||||
UrlBase = _configFileProvider.UrlBase,
|
||||
RuntimeVersion = OsInfo.IsMono ? _runtimeInfo.RuntimeVersion : null
|
||||
}.AsResponse();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
using System;
|
||||
using FizzWare.NBuilder;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Model;
|
||||
using NzbDrone.Common.Processes;
|
||||
using NzbDrone.Host;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.App.Test
|
||||
{
|
||||
[TestFixture]
|
||||
public class MonitoringProviderTest : TestBase<PriorityMonitor>
|
||||
{
|
||||
[Test]
|
||||
public void Ensure_priority_doesnt_fail_on_invalid_process_id()
|
||||
{
|
||||
Mocker.GetMock<IProcessProvider>().Setup(c => c.GetCurrentProcess())
|
||||
.Returns(Builder<ProcessInfo>.CreateNew().Build());
|
||||
|
||||
Mocker.GetMock<IProcessProvider>().Setup(c => c.GetProcessById(It.IsAny<int>())).Returns((ProcessInfo)null);
|
||||
|
||||
Subject.EnsurePriority(null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Ensure_should_log_warn_exception_rather_than_throw()
|
||||
{
|
||||
Mocker.GetMock<IProcessProvider>().Setup(c => c.GetCurrentProcess()).Throws<InvalidOperationException>();
|
||||
Subject.EnsurePriority(null);
|
||||
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -37,20 +37,20 @@
|
|||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Moq">
|
||||
<HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.ServiceProcess" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="FizzWare.NBuilder, Version=3.0.1.0, Culture=neutral, PublicKeyToken=5651b03e12e42c12">
|
||||
<HintPath>..\packages\NBuilder.3.0.1.1\lib\FizzWare.NBuilder.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FluentAssertions">
|
||||
<HintPath>..\packages\FluentAssertions.2.1.0.0\lib\net40\FluentAssertions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Moq">
|
||||
<HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NLog">
|
||||
<HintPath>..\packages\NLog.2.1.0\lib\net40\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
|
@ -61,9 +61,8 @@
|
|||
<ItemGroup>
|
||||
<Compile Include="ContainerFixture.cs" />
|
||||
<Compile Include="NzbDroneProcessServiceFixture.cs" />
|
||||
<Compile Include="RouterTest.cs" />
|
||||
<Compile Include="MonitoringProviderTest.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="RouterTest.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\NzbDrone.Test.Common\App.config">
|
||||
|
|
|
@ -40,14 +40,12 @@ namespace NzbDrone.Automation.Test
|
|||
_runner.KillAll();
|
||||
_runner.Start();
|
||||
|
||||
|
||||
driver.Url = "http://localhost:8989";
|
||||
|
||||
var page = new PageBase(driver);
|
||||
page.WaitForNoSpinner();
|
||||
|
||||
GetPageErrors().Should().BeEmpty();
|
||||
|
||||
}
|
||||
|
||||
protected IEnumerable<string> GetPageErrors()
|
||||
|
|
|
@ -10,14 +10,12 @@ namespace NzbDrone.Automation.Test
|
|||
{
|
||||
private PageBase page;
|
||||
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
page = new PageBase(driver);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void series_page()
|
||||
{
|
||||
|
@ -62,7 +60,6 @@ namespace NzbDrone.Automation.Test
|
|||
page.FindByClass("iv-system-systemlayout").Should().NotBeNull();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void add_series_page()
|
||||
{
|
||||
|
@ -75,7 +72,5 @@ namespace NzbDrone.Automation.Test
|
|||
|
||||
page.FindByClass("iv-addseries-addserieslayout").Should().NotBeNull();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -38,23 +38,23 @@
|
|||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="FluentAssertions">
|
||||
<HintPath>..\packages\FluentAssertions.2.1.0.0\lib\net40\FluentAssertions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NLog">
|
||||
<HintPath>..\packages\NLog.2.1.0\lib\net40\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework">
|
||||
<HintPath>..\packages\NUnit.2.6.2\lib\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="FluentAssertions">
|
||||
<HintPath>..\packages\FluentAssertions.2.1.0.0\lib\net40\FluentAssertions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="WebDriver, Version=2.41.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Selenium.WebDriver.2.41.0\lib\net40\WebDriver.dll</HintPath>
|
||||
|
@ -65,8 +65,8 @@
|
|||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AutomationTestAttribute.cs" />
|
||||
<Compile Include="AutomationTest.cs" />
|
||||
<Compile Include="AutomationTestAttribute.cs" />
|
||||
<Compile Include="MainPagesTest.cs" />
|
||||
<Compile Include="PageModel\PageBase.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
|
|
@ -27,11 +27,10 @@ namespace NzbDrone.Automation.Test.PageModel
|
|||
return wait.Until(d => d.FindElement(by));
|
||||
}
|
||||
|
||||
|
||||
public void WaitForNoSpinner(int timeout = 20)
|
||||
public void WaitForNoSpinner(int timeout = 30)
|
||||
{
|
||||
//give the spinner some time to show up.
|
||||
Thread.Sleep(100);
|
||||
Thread.Sleep(200);
|
||||
|
||||
var wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(timeout));
|
||||
wait.Until(d =>
|
||||
|
@ -48,7 +47,6 @@ namespace NzbDrone.Automation.Test.PageModel
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
public IWebElement SeriesNavIcon
|
||||
{
|
||||
get
|
||||
|
@ -96,6 +94,5 @@ namespace NzbDrone.Automation.Test.PageModel
|
|||
return FindByClass("x-system-nav");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -63,7 +63,7 @@ namespace NzbDrone.Common.Test.DiskProviderTests
|
|||
File.WriteAllText(source2, "SourceFile2");
|
||||
|
||||
Subject.MoveFile(source1, destination);
|
||||
Subject.MoveFile(source2, destination);
|
||||
Subject.MoveFile(source2, destination, true);
|
||||
|
||||
File.Exists(destination).Should().BeTrue();
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ namespace NzbDrone.Common.Test.DiskProviderTests
|
|||
|
||||
File.WriteAllText(source, "SourceFile1");
|
||||
|
||||
Subject.MoveFile(source, source);
|
||||
Subject.MoveFile(source, source, true);
|
||||
|
||||
File.Exists(source).Should().BeTrue();
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
|
@ -148,7 +148,7 @@ namespace NzbDrone.Common.Test.DiskProviderTests
|
|||
File.SetAttributes(source, FileAttributes.ReadOnly);
|
||||
File.SetAttributes(destination, FileAttributes.ReadOnly);
|
||||
|
||||
Subject.MoveFile(source, destination);
|
||||
Subject.MoveFile(source, destination, true);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace NzbDrone.Common.Test
|
|||
[Test]
|
||||
public void IsProduction_should_return_false_when_run_within_nunit()
|
||||
{
|
||||
RuntimeInfo.IsProduction.Should().BeFalse("Process name is " + Process.GetCurrentProcess().ProcessName + " Folder is " + Directory.GetCurrentDirectory());
|
||||
RuntimeInfoBase.IsProduction.Should().BeFalse("Process name is " + Process.GetCurrentProcess().ProcessName + " Folder is " + Directory.GetCurrentDirectory());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
|
@ -37,20 +37,20 @@
|
|||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Moq">
|
||||
<HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.ServiceProcess" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.ServiceProcess" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="FluentAssertions">
|
||||
<HintPath>..\packages\FluentAssertions.2.1.0.0\lib\net40\FluentAssertions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Moq">
|
||||
<HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NLog">
|
||||
<HintPath>..\packages\NLog.2.1.0\lib\net40\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
|
@ -59,21 +59,21 @@
|
|||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CacheTests\CachedManagerFixture.cs" />
|
||||
<Compile Include="CacheTests\CachedFixture.cs" />
|
||||
<Compile Include="CacheTests\CachedManagerFixture.cs" />
|
||||
<Compile Include="ConfigFileProviderTest.cs" />
|
||||
<Compile Include="DiskProviderTests\DiskProviderFixtureBase.cs" />
|
||||
<Compile Include="DiskProviderTests\FreeSpaceFixtureBase.cs" />
|
||||
<Compile Include="DiskProviderTests\IsParentFixtureBase.cs" />
|
||||
<Compile Include="EnsureTest\PathExtensionFixture.cs" />
|
||||
<Compile Include="EnvironmentTests\StartupArgumentsFixture.cs" />
|
||||
<Compile Include="EnvironmentProviderTest.cs" />
|
||||
<Compile Include="EnvironmentTests\EnvironmentProviderTest.cs" />
|
||||
<Compile Include="EnvironmentTests\StartupArgumentsFixture.cs" />
|
||||
<Compile Include="InstrumentationTests\CleanseLogMessageFixture.cs" />
|
||||
<Compile Include="LevenshteinDistanceFixture.cs" />
|
||||
<Compile Include="ReflectionExtensions.cs" />
|
||||
<Compile Include="PathExtensionFixture.cs" />
|
||||
<Compile Include="DiskProviderTests\DiskProviderFixtureBase.cs" />
|
||||
<Compile Include="EnvironmentProviderTest.cs" />
|
||||
<Compile Include="ProcessProviderTests.cs" />
|
||||
<Compile Include="ReflectionExtensions.cs" />
|
||||
<Compile Include="ReflectionTests\ReflectionExtensionFixture.cs" />
|
||||
<Compile Include="ServiceProviderTests.cs" />
|
||||
<Compile Include="WebClientTests.cs" />
|
||||
|
@ -97,6 +97,10 @@
|
|||
<Project>{95C11A9E-56ED-456A-8447-2C89C1139266}</Project>
|
||||
<Name>NzbDrone.Host</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\NzbDrone\NzbDrone.csproj">
|
||||
<Project>{D12F7F2F-8A3C-415F-88FA-6DD061A84869}</Project>
|
||||
<Name>NzbDrone</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\NzbDrone.Test.Common\NzbDrone.Test.Common.csproj">
|
||||
<Project>{CADDFCE0-7509-4430-8364-2074E1EEFCA2}</Project>
|
||||
<Name>NzbDrone.Test.Common</Name>
|
||||
|
@ -105,10 +109,6 @@
|
|||
<Project>{FAFB5948-A222-4CF6-AD14-026BE7564802}</Project>
|
||||
<Name>NzbDrone.Test.Dummy</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\NzbDrone\NzbDrone.csproj">
|
||||
<Project>{D12F7F2F-8A3C-415F-88FA-6DD061A84869}</Project>
|
||||
<Name>NzbDrone</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Properties\" />
|
||||
|
|
|
@ -5,8 +5,9 @@ using System.Security.AccessControl;
|
|||
using System.Security.Principal;
|
||||
using NLog;
|
||||
using NzbDrone.Common.EnsureThat;
|
||||
using NzbDrone.Common.Exceptions;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
using NzbDrone.Common.Instrumentation.Extensions;
|
||||
|
||||
namespace NzbDrone.Common.Disk
|
||||
{
|
||||
|
@ -106,17 +107,19 @@ namespace NzbDrone.Common.Disk
|
|||
public bool FileExists(string path)
|
||||
{
|
||||
Ensure.That(path, () => path).IsValidPath();
|
||||
return File.Exists(path);
|
||||
return FileExists(path, OsInfo.IsMono);
|
||||
}
|
||||
|
||||
public bool FileExists(string path, bool caseSensitive)
|
||||
{
|
||||
Ensure.That(path, () => path).IsValidPath();
|
||||
|
||||
if (caseSensitive)
|
||||
{
|
||||
return FileExists(path) && path == path.GetActualCasing();
|
||||
return File.Exists(path) && path == path.GetActualCasing();
|
||||
}
|
||||
|
||||
return FileExists(path);
|
||||
return File.Exists(path);
|
||||
}
|
||||
|
||||
public string[] GetDirectories(string path)
|
||||
|
@ -190,7 +193,7 @@ namespace NzbDrone.Common.Disk
|
|||
Ensure.That(source, () => source).IsValidPath();
|
||||
Ensure.That(target, () => target).IsValidPath();
|
||||
|
||||
Logger.Debug("{0} {1} -> {2}", transferAction, source, target);
|
||||
Logger.ProgressDebug("{0} {1} -> {2}", transferAction, source, target);
|
||||
|
||||
var sourceFolder = new DirectoryInfo(source);
|
||||
var targetFolder = new DirectoryInfo(target);
|
||||
|
@ -209,7 +212,7 @@ namespace NzbDrone.Common.Disk
|
|||
{
|
||||
var destFile = Path.Combine(target, sourceFile.Name);
|
||||
|
||||
Logger.Debug("{0} {1} -> {2}", transferAction, sourceFile, destFile);
|
||||
Logger.ProgressDebug("{0} {1} -> {2}", transferAction, sourceFile, destFile);
|
||||
|
||||
switch (transferAction)
|
||||
{
|
||||
|
@ -220,7 +223,7 @@ namespace NzbDrone.Common.Disk
|
|||
}
|
||||
case TransferAction.Move:
|
||||
{
|
||||
MoveFile(sourceFile.FullName, destFile);
|
||||
MoveFile(sourceFile.FullName, destFile, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -251,7 +254,7 @@ namespace NzbDrone.Common.Disk
|
|||
File.Copy(source, destination, overwrite);
|
||||
}
|
||||
|
||||
public void MoveFile(string source, string destination)
|
||||
public void MoveFile(string source, string destination, bool overwrite = false)
|
||||
{
|
||||
Ensure.That(source, () => source).IsValidPath();
|
||||
Ensure.That(destination, () => destination).IsValidPath();
|
||||
|
@ -262,7 +265,7 @@ namespace NzbDrone.Common.Disk
|
|||
return;
|
||||
}
|
||||
|
||||
if (FileExists(destination))
|
||||
if (FileExists(destination) && overwrite)
|
||||
{
|
||||
DeleteFile(destination);
|
||||
}
|
||||
|
@ -315,6 +318,7 @@ namespace NzbDrone.Common.Disk
|
|||
|
||||
File.SetLastWriteTime(path, dateTime);
|
||||
}
|
||||
|
||||
public void FileSetLastAccessTime(string path, DateTime dateTime)
|
||||
{
|
||||
Ensure.That(path, () => path).IsValidPath();
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace NzbDrone.Common.Disk
|
|||
void MoveFolder(string source, string destination);
|
||||
void DeleteFile(string path);
|
||||
void CopyFile(string source, string destination, bool overwrite = false);
|
||||
void MoveFile(string source, string destination);
|
||||
void MoveFile(string source, string destination, bool overwrite = false);
|
||||
void DeleteFolder(string path, bool recursive);
|
||||
string ReadAllText(string filePath);
|
||||
void WriteAllText(string filename, string contents);
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
using System;
|
||||
|
||||
namespace NzbDrone.Common.EnvironmentInfo
|
||||
{
|
||||
public interface IRuntimeInfo
|
||||
{
|
||||
Boolean IsUserInteractive { get; }
|
||||
Boolean IsAdmin { get; }
|
||||
Boolean IsWindowsService { get; }
|
||||
Boolean IsConsole { get; }
|
||||
Boolean IsRunning { get; set; }
|
||||
Boolean RestartPending { get; set; }
|
||||
String ExecutingApplication { get; }
|
||||
String RuntimeVersion { get; }
|
||||
}
|
||||
}
|
|
@ -9,23 +9,11 @@ using NzbDrone.Common.Processes;
|
|||
|
||||
namespace NzbDrone.Common.EnvironmentInfo
|
||||
{
|
||||
public interface IRuntimeInfo
|
||||
{
|
||||
bool IsUserInteractive { get; }
|
||||
bool IsAdmin { get; }
|
||||
bool IsWindowsService { get; }
|
||||
bool IsConsole { get; }
|
||||
bool IsRunning { get; set; }
|
||||
bool RestartPending { get; set; }
|
||||
string ExecutingApplication { get; }
|
||||
}
|
||||
|
||||
public class RuntimeInfo : IRuntimeInfo
|
||||
public abstract class RuntimeInfoBase : IRuntimeInfo
|
||||
{
|
||||
private readonly Logger _logger;
|
||||
private static readonly string ProcessName = Process.GetCurrentProcess().ProcessName.ToLower();
|
||||
|
||||
public RuntimeInfo(Logger logger, IServiceProvider serviceProvider)
|
||||
public RuntimeInfoBase(IServiceProvider serviceProvider, Logger logger)
|
||||
{
|
||||
_logger = logger;
|
||||
|
||||
|
@ -43,16 +31,24 @@ namespace NzbDrone.Common.EnvironmentInfo
|
|||
}
|
||||
}
|
||||
|
||||
static RuntimeInfo()
|
||||
static RuntimeInfoBase()
|
||||
{
|
||||
IsProduction = InternalIsProduction();
|
||||
}
|
||||
|
||||
public bool IsUserInteractive
|
||||
public static bool IsUserInteractive
|
||||
{
|
||||
get { return Environment.UserInteractive; }
|
||||
}
|
||||
|
||||
bool IRuntimeInfo.IsUserInteractive
|
||||
{
|
||||
get
|
||||
{
|
||||
return IsUserInteractive;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsAdmin
|
||||
{
|
||||
get
|
||||
|
@ -76,10 +72,12 @@ namespace NzbDrone.Common.EnvironmentInfo
|
|||
{
|
||||
get
|
||||
{
|
||||
return (OsInfo.IsWindows &&
|
||||
IsUserInteractive &&
|
||||
ProcessName.Equals(ProcessProvider.NZB_DRONE_CONSOLE_PROCESS_NAME, StringComparison.InvariantCultureIgnoreCase)) ||
|
||||
OsInfo.IsMono;
|
||||
if (OsInfo.IsWindows)
|
||||
{
|
||||
return IsUserInteractive && Process.GetCurrentProcess().ProcessName.Equals(ProcessProvider.NZB_DRONE_CONSOLE_PROCESS_NAME, StringComparison.InvariantCultureIgnoreCase);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,6 +85,8 @@ namespace NzbDrone.Common.EnvironmentInfo
|
|||
public bool RestartPending { get; set; }
|
||||
public string ExecutingApplication { get; private set; }
|
||||
|
||||
public abstract string RuntimeVersion { get; }
|
||||
|
||||
public static bool IsProduction { get; private set; }
|
||||
|
||||
private static bool InternalIsProduction()
|
||||
|
@ -94,11 +94,19 @@ namespace NzbDrone.Common.EnvironmentInfo
|
|||
if (BuildInfo.IsDebug || Debugger.IsAttached) return false;
|
||||
if (BuildInfo.Version.Revision > 10000) return false; //Official builds will never have such a high revision
|
||||
|
||||
var lowerProcessName = ProcessName.ToLower();
|
||||
if (lowerProcessName.Contains("vshost")) return false;
|
||||
if (lowerProcessName.Contains("nunit")) return false;
|
||||
if (lowerProcessName.Contains("jetbrain")) return false;
|
||||
if (lowerProcessName.Contains("resharper")) return false;
|
||||
try
|
||||
{
|
||||
var lowerProcessName = Process.GetCurrentProcess().ProcessName.ToLower();
|
||||
|
||||
if (lowerProcessName.Contains("vshost")) return false;
|
||||
if (lowerProcessName.Contains("nunit")) return false;
|
||||
if (lowerProcessName.Contains("jetbrain")) return false;
|
||||
if (lowerProcessName.Contains("resharper")) return false;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
string lowerCurrentDir = Directory.GetCurrentDirectory().ToLower();
|
||||
if (lowerCurrentDir.Contains("teamcity")) return false;
|
|
@ -22,6 +22,16 @@ namespace NzbDrone.Common.Http
|
|||
|
||||
public class HttpProvider : IHttpProvider
|
||||
{
|
||||
private class GZipWebClient : WebClient
|
||||
{
|
||||
protected override WebRequest GetWebRequest(Uri address)
|
||||
{
|
||||
HttpWebRequest request = (HttpWebRequest)base.GetWebRequest(address);
|
||||
request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
|
||||
return request;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly Logger _logger;
|
||||
|
||||
public const string CONTENT_LENGTH_HEADER = "Content-Length";
|
||||
|
@ -49,7 +59,7 @@ namespace NzbDrone.Common.Http
|
|||
{
|
||||
try
|
||||
{
|
||||
var client = new WebClient { Credentials = identity };
|
||||
var client = new GZipWebClient { Credentials = identity };
|
||||
client.Headers.Add(HttpRequestHeader.UserAgent, _userAgent);
|
||||
return client.DownloadString(url);
|
||||
}
|
||||
|
@ -107,7 +117,7 @@ namespace NzbDrone.Common.Http
|
|||
_logger.Debug("Downloading [{0}] to [{1}]", url, fileName);
|
||||
|
||||
var stopWatch = Stopwatch.StartNew();
|
||||
var webClient = new WebClient();
|
||||
var webClient = new GZipWebClient();
|
||||
webClient.Headers.Add(HttpRequestHeader.UserAgent, _userAgent);
|
||||
webClient.DownloadFile(url, fileName);
|
||||
stopWatch.Stop();
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace NzbDrone.Common.Instrumentation
|
|||
IncludeMachineName = true,
|
||||
};
|
||||
|
||||
if (RuntimeInfo.IsProduction)
|
||||
if (RuntimeInfoBase.IsProduction)
|
||||
{
|
||||
config.ApiKey = "cc4728a35aa9414f9a0baa8eed56bc67";
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using NLog;
|
||||
|
||||
namespace NzbDrone.Core.Instrumentation.Extensions
|
||||
namespace NzbDrone.Common.Instrumentation.Extensions
|
||||
{
|
||||
public static class LoggerExtensions
|
||||
{
|
|
@ -32,7 +32,7 @@ namespace NzbDrone.Common.Instrumentation
|
|||
}
|
||||
else
|
||||
{
|
||||
if (inConsole && (OsInfo.IsMono || new RuntimeInfo(null, new ServiceProvider(new ProcessProvider())).IsUserInteractive))
|
||||
if (inConsole && (OsInfo.IsMono || RuntimeInfoBase.IsUserInteractive))
|
||||
{
|
||||
RegisterConsole();
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ namespace NzbDrone.Common.Instrumentation
|
|||
{
|
||||
var level = LogLevel.Trace;
|
||||
|
||||
if (RuntimeInfo.IsProduction)
|
||||
if (RuntimeInfoBase.IsProduction)
|
||||
{
|
||||
level = LogLevel.Info;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace NzbDrone.Common.Instrumentation
|
|||
{
|
||||
string apiKey = string.Empty;
|
||||
|
||||
if (RuntimeInfo.IsProduction)
|
||||
if (RuntimeInfoBase.IsProduction)
|
||||
{
|
||||
apiKey = "4c4ecb69-d1b9-4e2a-b54b-b0c4cc143a95";
|
||||
}
|
||||
|
|
|
@ -39,19 +39,15 @@
|
|||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="ICSharpCode.SharpZipLib">
|
||||
<HintPath>..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="RestSharp, Version=104.4.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\RestSharp.104.4.0\lib\net4\RestSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Configuration.Install" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.ServiceProcess" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="ICSharpCode.SharpZipLib">
|
||||
<HintPath>..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Loggly">
|
||||
<HintPath>..\packages\loggly-csharp.2.3\lib\net35\Loggly.dll</HintPath>
|
||||
</Reference>
|
||||
|
@ -61,18 +57,24 @@
|
|||
<Reference Include="NLog">
|
||||
<HintPath>..\packages\NLog.2.1.0\lib\net40\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RestSharp, Version=104.4.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\RestSharp.104.4.0\lib\net4\RestSharp.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ConvertBase32.cs" />
|
||||
<Compile Include="ArchiveService.cs" />
|
||||
<Compile Include="Cache\Cached.cs" />
|
||||
<Compile Include="Cache\CacheManager.cs" />
|
||||
<Compile Include="Cache\ICached.cs" />
|
||||
<Compile Include="Composition\Container.cs" />
|
||||
<Compile Include="Composition\IContainer.cs" />
|
||||
<Compile Include="Composition\ContainerBuilderBase.cs" />
|
||||
<Compile Include="Composition\IContainer.cs" />
|
||||
<Compile Include="ConsoleService.cs" />
|
||||
<Compile Include="ConvertBase32.cs" />
|
||||
<Compile Include="DictionaryExtensions.cs" />
|
||||
<Compile Include="Disk\DiskProviderBase.cs" />
|
||||
<Compile Include="Disk\IDiskProvider.cs" />
|
||||
<Compile Include="EnsureThat\Ensure.cs" />
|
||||
<Compile Include="EnsureThat\EnsureBoolExtensions.cs" />
|
||||
<Compile Include="EnsureThat\EnsureCollectionExtensions.cs" />
|
||||
|
@ -91,61 +93,62 @@
|
|||
<Compile Include="EnsureThat\ExpressionExtensions.cs" />
|
||||
<Compile Include="EnsureThat\Param.cs" />
|
||||
<Compile Include="EnsureThat\Resources\ExceptionMessages.Designer.cs" />
|
||||
<Compile Include="EnsureThat\TypeParam.cs" />
|
||||
<Compile Include="EnvironmentInfo\AppFolderFactory.cs" />
|
||||
<Compile Include="EnvironmentInfo\AppFolderInfo.cs" />
|
||||
<Compile Include="EnvironmentInfo\BuildInfo.cs" />
|
||||
<Compile Include="EnvironmentInfo\StartupContext.cs" />
|
||||
<Compile Include="EnvironmentInfo\RuntimeInfo.cs" />
|
||||
<Compile Include="EnvironmentInfo\OsInfo.cs" />
|
||||
<Compile Include="EnvironmentInfo\IRuntimeInfo.cs" />
|
||||
<Compile Include="EnvironmentInfo\RuntimeInfoBase.cs" />
|
||||
<Compile Include="EnvironmentInfo\StartupContext.cs" />
|
||||
<Compile Include="Exceptions\NotParentException.cs" />
|
||||
<Compile Include="Exceptions\NzbDroneException.cs" />
|
||||
<Compile Include="Http\NzbDroneWebClient.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="IEnumerableExtensions.cs" />
|
||||
<Compile Include="Instrumentation\CleanseLogMessage.cs" />
|
||||
<Compile Include="Instrumentation\GlobalExceptionHandlers.cs" />
|
||||
<Compile Include="Instrumentation\ExceptronTarget.cs" />
|
||||
<Compile Include="Instrumentation\LogEventExtensions.cs" />
|
||||
<Compile Include="Instrumentation\NzbDroneFileTarget.cs" />
|
||||
<Compile Include="Instrumentation\NzbDroneLogger.cs" />
|
||||
<Compile Include="Instrumentation\LogTargets.cs" />
|
||||
<Compile Include="Messaging\IEvent.cs" />
|
||||
<Compile Include="Messaging\IMessage.cs" />
|
||||
<Compile Include="PathEqualityComparer.cs" />
|
||||
<Compile Include="Processes\PidFileProvider.cs" />
|
||||
<Compile Include="Processes\ProcessOutput.cs" />
|
||||
<Compile Include="RateGate.cs" />
|
||||
<Compile Include="Serializer\IntConverter.cs" />
|
||||
<Compile Include="Services.cs" />
|
||||
<Compile Include="Extensions\StreamExtensions.cs" />
|
||||
<Compile Include="LevenstheinExtensions.cs" />
|
||||
<Compile Include="TPL\LimitedConcurrencyLevelTaskScheduler.cs" />
|
||||
<Compile Include="Security\IgnoreCertErrorPolicy.cs" />
|
||||
<Compile Include="StringExtensions.cs" />
|
||||
<Compile Include="EnsureThat\TypeParam.cs" />
|
||||
<Compile Include="HashUtil.cs" />
|
||||
<Compile Include="Instrumentation\LogglyTarget.cs" />
|
||||
<Compile Include="Serializer\Json.cs" />
|
||||
<Compile Include="Expansive\CircularReferenceException.cs" />
|
||||
<Compile Include="Expansive\Expansive.cs" />
|
||||
<Compile Include="Expansive\PatternStyle.cs" />
|
||||
<Compile Include="Expansive\Tree.cs" />
|
||||
<Compile Include="Expansive\TreeNode.cs" />
|
||||
<Compile Include="Expansive\TreeNodeList.cs" />
|
||||
<Compile Include="Instrumentation\VersionLayoutRenderer.cs" />
|
||||
<Compile Include="Reflection\ReflectionExtensions.cs" />
|
||||
<Compile Include="ServiceFactory.cs" />
|
||||
<Compile Include="Extensions\StreamExtensions.cs" />
|
||||
<Compile Include="HashUtil.cs" />
|
||||
<Compile Include="Http\HttpProvider.cs" />
|
||||
<Compile Include="ConsoleService.cs" />
|
||||
<Compile Include="PathExtensions.cs" />
|
||||
<Compile Include="Disk\IDiskProvider.cs" />
|
||||
<Compile Include="EnvironmentInfo\AppFolderInfo.cs" />
|
||||
<Compile Include="Http\NzbDroneWebClient.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="IEnumerableExtensions.cs" />
|
||||
<Compile Include="Instrumentation\CleanseLogMessage.cs" />
|
||||
<Compile Include="Instrumentation\ExceptronTarget.cs" />
|
||||
<Compile Include="Instrumentation\Extensions\LoggerProgressExtensions.cs" />
|
||||
<Compile Include="Instrumentation\GlobalExceptionHandlers.cs" />
|
||||
<Compile Include="Instrumentation\LogEventExtensions.cs" />
|
||||
<Compile Include="Instrumentation\LogglyTarget.cs" />
|
||||
<Compile Include="Instrumentation\LogTargets.cs" />
|
||||
<Compile Include="Instrumentation\NzbDroneFileTarget.cs" />
|
||||
<Compile Include="Instrumentation\NzbDroneLogger.cs" />
|
||||
<Compile Include="Instrumentation\VersionLayoutRenderer.cs" />
|
||||
<Compile Include="LevenstheinExtensions.cs" />
|
||||
<Compile Include="Messaging\IEvent.cs" />
|
||||
<Compile Include="Messaging\IMessage.cs" />
|
||||
<Compile Include="Model\ProcessInfo.cs" />
|
||||
<Compile Include="PathEqualityComparer.cs" />
|
||||
<Compile Include="PathExtensions.cs" />
|
||||
<Compile Include="Processes\PidFileProvider.cs" />
|
||||
<Compile Include="Processes\ProcessOutput.cs" />
|
||||
<Compile Include="Processes\ProcessProvider.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Properties\SharedAssemblyInfo.cs" />
|
||||
<Compile Include="RateGate.cs" />
|
||||
<Compile Include="Reflection\ReflectionExtensions.cs" />
|
||||
<Compile Include="ResourceExtensions.cs" />
|
||||
<Compile Include="Security\IgnoreCertErrorPolicy.cs" />
|
||||
<Compile Include="Serializer\IntConverter.cs" />
|
||||
<Compile Include="Serializer\Json.cs" />
|
||||
<Compile Include="ServiceFactory.cs" />
|
||||
<Compile Include="ServiceProvider.cs" />
|
||||
<Compile Include="Services.cs" />
|
||||
<Compile Include="StringExtensions.cs" />
|
||||
<Compile Include="TinyIoC.cs" />
|
||||
<Compile Include="TPL\LimitedConcurrencyLevelTaskScheduler.cs" />
|
||||
<Compile Include="TPL\TaskExtensions.cs" />
|
||||
<Compile Include="TryParseExtension.cs" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
using NzbDrone.Common.EnsureThat;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
namespace NzbDrone.Common
|
||||
{
|
||||
public static class ResourceExtensions
|
||||
{
|
||||
public static Byte[] GetManifestResourceBytes(this Assembly assembly, String name)
|
||||
{
|
||||
var stream = assembly.GetManifestResourceStream(name);
|
||||
|
||||
var result = new Byte[stream.Length];
|
||||
var read = stream.Read(result, 0, result.Length);
|
||||
|
||||
if (read != result.Length)
|
||||
{
|
||||
throw new EndOfStreamException("Reached end of stream before reading enough bytes.");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -86,14 +86,10 @@ namespace NzbDrone.Core.Test.Datastore
|
|||
|
||||
Db.Insert(episode);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var loadedEpisodeFile = Db.Single<Episode>().EpisodeFile.Value;
|
||||
|
||||
loadedEpisodeFile.Should().NotBeNull();
|
||||
loadedEpisodeFile.ShouldHave().AllProperties().But(c => c.DateAdded).EqualTo(episodeFile);
|
||||
loadedEpisodeFile.ShouldHave().AllProperties().But(c => c.DateAdded).But(c => c.Path).EqualTo(episodeFile);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
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.Qualities;
|
||||
|
@ -15,19 +16,19 @@ namespace NzbDrone.Core.Test.Datastore
|
|||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
var qualityProfile = new NzbDrone.Core.Qualities.QualityProfile
|
||||
var profile = new Profile
|
||||
{
|
||||
Name = "Test",
|
||||
Cutoff = Quality.WEBDL720p,
|
||||
Items = NzbDrone.Core.Test.Qualities.QualityFixture.GetDefaultQualities()
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities()
|
||||
};
|
||||
|
||||
|
||||
qualityProfile = Db.Insert(qualityProfile);
|
||||
profile = Db.Insert(profile);
|
||||
|
||||
var series = Builder<Series>.CreateListOfSize(1)
|
||||
.All()
|
||||
.With(v => v.QualityProfileId = qualityProfile.Id)
|
||||
.With(v => v.ProfileId = profile.Id)
|
||||
.BuildListOfNew();
|
||||
|
||||
Db.InsertMany(series);
|
||||
|
@ -35,6 +36,7 @@ namespace NzbDrone.Core.Test.Datastore
|
|||
var episodeFiles = Builder<EpisodeFile>.CreateListOfSize(1)
|
||||
.All()
|
||||
.With(v => v.SeriesId = series[0].Id)
|
||||
.With(v => v.Quality = new QualityModel())
|
||||
.BuildListOfNew();
|
||||
|
||||
Db.InsertMany(episodeFiles);
|
||||
|
@ -50,7 +52,7 @@ namespace NzbDrone.Core.Test.Datastore
|
|||
}
|
||||
|
||||
[Test]
|
||||
public void should_lazy_load_qualityprofile_if_not_joined()
|
||||
public void should_lazy_load_profile_if_not_joined()
|
||||
{
|
||||
var db = Mocker.Resolve<IDatabase>();
|
||||
var DataMapper = db.GetDataMapper();
|
||||
|
@ -62,7 +64,7 @@ namespace NzbDrone.Core.Test.Datastore
|
|||
foreach (var episode in episodes)
|
||||
{
|
||||
Assert.IsNotNull(episode.Series);
|
||||
Assert.IsFalse(episode.Series.QualityProfile.IsLoaded);
|
||||
Assert.IsFalse(episode.Series.Profile.IsLoaded);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -84,20 +86,20 @@ namespace NzbDrone.Core.Test.Datastore
|
|||
}
|
||||
|
||||
[Test]
|
||||
public void should_explicit_load_qualityprofile_if_joined()
|
||||
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, QualityProfile>(Marr.Data.QGen.JoinType.Inner, v => v.QualityProfile, (l, r) => l.QualityProfileId == 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.QualityProfile.IsLoaded);
|
||||
Assert.IsTrue(episode.Series.Profile.IsLoaded);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ using NzbDrone.Core.Datastore.Migration.Framework;
|
|||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using System.Linq;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.Datastore.SQLiteMigrationHelperTests
|
||||
{
|
||||
|
@ -119,5 +120,23 @@ namespace NzbDrone.Core.Test.Datastore.SQLiteMigrationHelperTests
|
|||
newColumns.Values.Should().HaveSameCount(columns.Values);
|
||||
newIndexes.Should().Contain(i=>i.Column == "AirTime");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_create_indexes_with_the_same_uniqueness()
|
||||
{
|
||||
var columns = _subject.GetColumns("Series");
|
||||
var indexes = _subject.GetIndexes("Series");
|
||||
|
||||
var tempIndexes = indexes.JsonClone();
|
||||
|
||||
tempIndexes[0].Unique = false;
|
||||
tempIndexes[1].Unique = true;
|
||||
|
||||
_subject.CreateTable("Series_New", columns.Values, tempIndexes);
|
||||
var newIndexes = _subject.GetIndexes("Series_New");
|
||||
|
||||
newIndexes.Should().HaveSameCount(tempIndexes);
|
||||
newIndexes.ShouldAllBeEquivalentTo(tempIndexes, options => options.Excluding(o => o.IndexName).Excluding(o => o.Table));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -25,12 +25,12 @@ namespace NzbDrone.Core.Test.Datastore.SQLiteMigrationHelperTests
|
|||
{
|
||||
var series = Builder<Series>.CreateListOfSize(10)
|
||||
.Random(3)
|
||||
.With(c => c.QualityProfileId = 100)
|
||||
.With(c => c.ProfileId = 100)
|
||||
.BuildListOfNew();
|
||||
|
||||
Db.InsertMany(series);
|
||||
|
||||
var duplicates = _subject.GetDuplicates<int>("series", "QualityProfileId").ToList();
|
||||
var duplicates = _subject.GetDuplicates<int>("series", "ProfileId").ToList();
|
||||
|
||||
|
||||
duplicates.Should().HaveCount(1);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Profiles;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
|
@ -13,35 +14,35 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
[Test]
|
||||
public void should_return_true_if_current_episode_is_less_than_cutoff()
|
||||
{
|
||||
Subject.CutoffNotMet(new QualityProfile { Cutoff = Quality.Bluray1080p, Items = Qualities.QualityFixture.GetDefaultQualities() },
|
||||
Subject.CutoffNotMet(new Profile { Cutoff = Quality.Bluray1080p, Items = Qualities.QualityFixture.GetDefaultQualities() },
|
||||
new QualityModel(Quality.DVD, true)).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_current_episode_is_equal_to_cutoff()
|
||||
{
|
||||
Subject.CutoffNotMet(new QualityProfile { Cutoff = Quality.HDTV720p, Items = Qualities.QualityFixture.GetDefaultQualities() },
|
||||
Subject.CutoffNotMet(new Profile { Cutoff = Quality.HDTV720p, Items = Qualities.QualityFixture.GetDefaultQualities() },
|
||||
new QualityModel(Quality.HDTV720p, true)).Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_current_episode_is_greater_than_cutoff()
|
||||
{
|
||||
Subject.CutoffNotMet(new QualityProfile { Cutoff = Quality.HDTV720p, Items = Qualities.QualityFixture.GetDefaultQualities() },
|
||||
Subject.CutoffNotMet(new Profile { Cutoff = Quality.HDTV720p, Items = Qualities.QualityFixture.GetDefaultQualities() },
|
||||
new QualityModel(Quality.Bluray1080p, true)).Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_when_new_episode_is_proper_but_existing_is_not()
|
||||
{
|
||||
Subject.CutoffNotMet(new QualityProfile { Cutoff = Quality.HDTV720p, Items = Qualities.QualityFixture.GetDefaultQualities() },
|
||||
Subject.CutoffNotMet(new Profile { Cutoff = Quality.HDTV720p, Items = Qualities.QualityFixture.GetDefaultQualities() },
|
||||
new QualityModel(Quality.HDTV720p, false), new QualityModel(Quality.HDTV720p, true)).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_cutoff_is_met_and_quality_is_higher()
|
||||
{
|
||||
Subject.CutoffNotMet(new QualityProfile { Cutoff = Quality.HDTV720p, Items = Qualities.QualityFixture.GetDefaultQualities() },
|
||||
Subject.CutoffNotMet(new Profile { Cutoff = Quality.HDTV720p, Items = Qualities.QualityFixture.GetDefaultQualities() },
|
||||
new QualityModel(Quality.HDTV720p, true), new QualityModel(Quality.Bluray1080p, true)).Should().BeFalse();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ using NzbDrone.Core.Download.Clients.Sabnzbd;
|
|||
using NzbDrone.Core.History;
|
||||
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.DecisionEngine;
|
||||
|
@ -42,7 +43,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
};
|
||||
|
||||
_fakeSeries = Builder<Series>.CreateNew()
|
||||
.With(c => c.QualityProfile = new QualityProfile { Cutoff = Quality.Bluray1080p, Items = Qualities.QualityFixture.GetDefaultQualities() })
|
||||
.With(c => c.Profile = new Profile { Cutoff = Quality.Bluray1080p, Items = Qualities.QualityFixture.GetDefaultQualities() })
|
||||
.Build();
|
||||
|
||||
_parseResultMulti = new RemoteEpisode
|
||||
|
@ -62,9 +63,9 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
_upgradableQuality = new QualityModel(Quality.SDTV, false);
|
||||
_notupgradableQuality = new QualityModel(Quality.HDTV1080p, true);
|
||||
|
||||
Mocker.GetMock<IHistoryService>().Setup(c => c.GetBestQualityInHistory(It.IsAny<QualityProfile>(), 1)).Returns(_notupgradableQuality);
|
||||
Mocker.GetMock<IHistoryService>().Setup(c => c.GetBestQualityInHistory(It.IsAny<QualityProfile>(), 2)).Returns(_notupgradableQuality);
|
||||
Mocker.GetMock<IHistoryService>().Setup(c => c.GetBestQualityInHistory(It.IsAny<QualityProfile>(), 3)).Returns<QualityModel>(null);
|
||||
Mocker.GetMock<IHistoryService>().Setup(c => c.GetBestQualityInHistory(It.IsAny<Profile>(), 1)).Returns(_notupgradableQuality);
|
||||
Mocker.GetMock<IHistoryService>().Setup(c => c.GetBestQualityInHistory(It.IsAny<Profile>(), 2)).Returns(_notupgradableQuality);
|
||||
Mocker.GetMock<IHistoryService>().Setup(c => c.GetBestQualityInHistory(It.IsAny<Profile>(), 3)).Returns<QualityModel>(null);
|
||||
|
||||
Mocker.GetMock<IProvideDownloadClient>()
|
||||
.Setup(c => c.GetDownloadClients())
|
||||
|
@ -73,12 +74,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
|
||||
private void WithFirstReportUpgradable()
|
||||
{
|
||||
Mocker.GetMock<IHistoryService>().Setup(c => c.GetBestQualityInHistory(It.IsAny<QualityProfile>(), 1)).Returns(_upgradableQuality);
|
||||
Mocker.GetMock<IHistoryService>().Setup(c => c.GetBestQualityInHistory(It.IsAny<Profile>(), 1)).Returns(_upgradableQuality);
|
||||
}
|
||||
|
||||
private void WithSecondReportUpgradable()
|
||||
{
|
||||
Mocker.GetMock<IHistoryService>().Setup(c => c.GetBestQualityInHistory(It.IsAny<QualityProfile>(), 2)).Returns(_upgradableQuality);
|
||||
Mocker.GetMock<IHistoryService>().Setup(c => c.GetBestQualityInHistory(It.IsAny<Profile>(), 2)).Returns(_upgradableQuality);
|
||||
}
|
||||
|
||||
private void GivenSabnzbdDownloadClient()
|
||||
|
@ -132,11 +133,11 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
[Test]
|
||||
public void should_not_be_upgradable_if_episode_is_of_same_quality_as_existing()
|
||||
{
|
||||
_fakeSeries.QualityProfile = new QualityProfile { Cutoff = Quality.WEBDL1080p, Items = Qualities.QualityFixture.GetDefaultQualities() };
|
||||
_fakeSeries.Profile = new Profile { Cutoff = Quality.WEBDL1080p, Items = Qualities.QualityFixture.GetDefaultQualities() };
|
||||
_parseResultSingle.ParsedEpisodeInfo.Quality = new QualityModel(Quality.WEBDL1080p, false);
|
||||
_upgradableQuality = new QualityModel(Quality.WEBDL1080p, false);
|
||||
|
||||
Mocker.GetMock<IHistoryService>().Setup(c => c.GetBestQualityInHistory(It.IsAny<QualityProfile>(), 1)).Returns(_upgradableQuality);
|
||||
Mocker.GetMock<IHistoryService>().Setup(c => c.GetBestQualityInHistory(It.IsAny<Profile>(), 1)).Returns(_upgradableQuality);
|
||||
|
||||
_upgradeHistory.IsSatisfiedBy(_parseResultSingle, null).Should().BeFalse();
|
||||
}
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
using FluentAssertions;
|
||||
using Marr.Data;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Profiles;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
|
@ -11,28 +14,35 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
|
||||
public class LanguageSpecificationFixture : CoreTest
|
||||
{
|
||||
private RemoteEpisode parseResult;
|
||||
private RemoteEpisode _remoteEpisode;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_remoteEpisode = new RemoteEpisode
|
||||
{
|
||||
ParsedEpisodeInfo = new ParsedEpisodeInfo
|
||||
{
|
||||
Language = Language.English
|
||||
},
|
||||
Series = new Series
|
||||
{
|
||||
Profile = new LazyLoaded<Profile>(new Profile
|
||||
{
|
||||
Language = Language.English
|
||||
})
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void WithEnglishRelease()
|
||||
{
|
||||
parseResult = new RemoteEpisode
|
||||
{
|
||||
ParsedEpisodeInfo = new ParsedEpisodeInfo
|
||||
{
|
||||
Language = Language.English
|
||||
}
|
||||
};
|
||||
_remoteEpisode.ParsedEpisodeInfo.Language = Language.English;
|
||||
}
|
||||
|
||||
private void WithGermanRelease()
|
||||
{
|
||||
parseResult = new RemoteEpisode
|
||||
{
|
||||
ParsedEpisodeInfo = new ParsedEpisodeInfo
|
||||
{
|
||||
Language = Language.German
|
||||
}
|
||||
};
|
||||
_remoteEpisode.ParsedEpisodeInfo.Language = Language.German;
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -40,7 +50,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
{
|
||||
WithEnglishRelease();
|
||||
|
||||
Mocker.Resolve<LanguageSpecification>().IsSatisfiedBy(parseResult, null).Should().BeTrue();
|
||||
Mocker.Resolve<LanguageSpecification>().IsSatisfiedBy(_remoteEpisode, null).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -48,7 +58,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
{
|
||||
WithGermanRelease();
|
||||
|
||||
Mocker.Resolve<LanguageSpecification>().IsSatisfiedBy(parseResult, null).Should().BeFalse();
|
||||
Mocker.Resolve<LanguageSpecification>().IsSatisfiedBy(_remoteEpisode, null).Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@ using NUnit.Framework;
|
|||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Profiles;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
@ -27,7 +28,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
public void Setup()
|
||||
{
|
||||
_series = Builder<Series>.CreateNew()
|
||||
.With(e => e.QualityProfile = new QualityProfile { Items = Qualities.QualityFixture.GetDefaultQualities() })
|
||||
.With(e => e.Profile = new Profile { Items = Qualities.QualityFixture.GetDefaultQualities() })
|
||||
.Build();
|
||||
|
||||
_episode = Builder<Episode>.CreateNew()
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
using NzbDrone.Core.Profiles;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
|
@ -17,7 +18,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
[TestFixture]
|
||||
public class PrioritizeDownloadDecisionFixture : CoreTest<DownloadDecisionPriorizationService>
|
||||
{
|
||||
private Episode GetEpisode(int id)
|
||||
private Episode GivenEpisode(int id)
|
||||
{
|
||||
return Builder<Episode>.CreateNew()
|
||||
.With(e => e.Id = id)
|
||||
|
@ -25,7 +26,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
.Build();
|
||||
}
|
||||
|
||||
private RemoteEpisode GetRemoteEpisode(List<Episode> episodes, QualityModel quality, int Age = 0, long size = 0)
|
||||
private RemoteEpisode GivenRemoteEpisode(List<Episode> episodes, QualityModel quality, int age = 0, long size = 0)
|
||||
{
|
||||
var remoteEpisode = new RemoteEpisode();
|
||||
remoteEpisode.ParsedEpisodeInfo = new ParsedEpisodeInfo();
|
||||
|
@ -35,11 +36,11 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
remoteEpisode.Episodes.AddRange(episodes);
|
||||
|
||||
remoteEpisode.Release = new ReleaseInfo();
|
||||
remoteEpisode.Release.PublishDate = DateTime.Now.AddDays(-Age);
|
||||
remoteEpisode.Release.PublishDate = DateTime.Now.AddDays(-age);
|
||||
remoteEpisode.Release.Size = size;
|
||||
|
||||
remoteEpisode.Series = Builder<Series>.CreateNew()
|
||||
.With(e => e.QualityProfile = new QualityProfile { Items = Qualities.QualityFixture.GetDefaultQualities() })
|
||||
.With(e => e.Profile = new Profile { Items = Qualities.QualityFixture.GetDefaultQualities() })
|
||||
.Build();
|
||||
|
||||
return remoteEpisode;
|
||||
|
@ -48,8 +49,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
[Test]
|
||||
public void should_put_propers_before_non_propers()
|
||||
{
|
||||
var remoteEpisode1 = GetRemoteEpisode(new List<Episode> { GetEpisode(1) }, new QualityModel(Quality.HDTV720p, false));
|
||||
var remoteEpisode2 = GetRemoteEpisode(new List<Episode> { GetEpisode(1) }, new QualityModel(Quality.HDTV720p, true));
|
||||
var remoteEpisode1 = GivenRemoteEpisode(new List<Episode> { GivenEpisode(1) }, new QualityModel(Quality.HDTV720p, false));
|
||||
var remoteEpisode2 = GivenRemoteEpisode(new List<Episode> { GivenEpisode(1) }, new QualityModel(Quality.HDTV720p, true));
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteEpisode1));
|
||||
|
@ -62,8 +63,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
[Test]
|
||||
public void should_put_higher_quality_before_lower()
|
||||
{
|
||||
var remoteEpisode1 = GetRemoteEpisode(new List<Episode> { GetEpisode(1) }, new QualityModel(Quality.SDTV));
|
||||
var remoteEpisode2 = GetRemoteEpisode(new List<Episode> { GetEpisode(1) }, new QualityModel(Quality.HDTV720p));
|
||||
var remoteEpisode1 = GivenRemoteEpisode(new List<Episode> { GivenEpisode(1) }, new QualityModel(Quality.SDTV));
|
||||
var remoteEpisode2 = GivenRemoteEpisode(new List<Episode> { GivenEpisode(1) }, new QualityModel(Quality.HDTV720p));
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteEpisode1));
|
||||
|
@ -76,8 +77,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
[Test]
|
||||
public void should_order_by_lowest_number_of_episodes()
|
||||
{
|
||||
var remoteEpisode1 = GetRemoteEpisode(new List<Episode> { GetEpisode(2) }, new QualityModel(Quality.HDTV720p));
|
||||
var remoteEpisode2 = GetRemoteEpisode(new List<Episode> { GetEpisode(1) }, new QualityModel(Quality.HDTV720p));
|
||||
var remoteEpisode1 = GivenRemoteEpisode(new List<Episode> { GivenEpisode(2) }, new QualityModel(Quality.HDTV720p));
|
||||
var remoteEpisode2 = GivenRemoteEpisode(new List<Episode> { GivenEpisode(1) }, new QualityModel(Quality.HDTV720p));
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteEpisode1));
|
||||
|
@ -90,8 +91,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
[Test]
|
||||
public void should_order_by_lowest_number_of_episodes_with_multiple_episodes()
|
||||
{
|
||||
var remoteEpisode1 = GetRemoteEpisode(new List<Episode> { GetEpisode(2), GetEpisode(3) }, new QualityModel(Quality.HDTV720p));
|
||||
var remoteEpisode2 = GetRemoteEpisode(new List<Episode> { GetEpisode(1), GetEpisode(2) }, new QualityModel(Quality.HDTV720p));
|
||||
var remoteEpisode1 = GivenRemoteEpisode(new List<Episode> { GivenEpisode(2), GivenEpisode(3) }, new QualityModel(Quality.HDTV720p));
|
||||
var remoteEpisode2 = GivenRemoteEpisode(new List<Episode> { GivenEpisode(1), GivenEpisode(2) }, new QualityModel(Quality.HDTV720p));
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteEpisode1));
|
||||
|
@ -101,30 +102,29 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
qualifiedReports.First().RemoteEpisode.Episodes.First().EpisodeNumber.Should().Be(1);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void should_order_by_smallest_rounded_to_200mb_then_age()
|
||||
{
|
||||
var remoteEpisodeSd = GetRemoteEpisode(new List<Episode> { GetEpisode(1) }, new QualityModel(Quality.SDTV), size: 100.Megabytes(), Age: 1);
|
||||
var remoteEpisodeHdSmallOld = GetRemoteEpisode(new List<Episode> { GetEpisode(1) }, new QualityModel(Quality.HDTV720p), size: 1200.Megabytes(), Age: 1000);
|
||||
var remoteEpisodeHdSmallYounge = GetRemoteEpisode(new List<Episode> { GetEpisode(1) }, new QualityModel(Quality.HDTV720p), size: 1250.Megabytes(), Age: 10);
|
||||
var remoteEpisodeHdLargeYounge = GetRemoteEpisode(new List<Episode> { GetEpisode(1) }, new QualityModel(Quality.HDTV720p), size: 3000.Megabytes(), Age: 1);
|
||||
var remoteEpisodeSd = GivenRemoteEpisode(new List<Episode> { GivenEpisode(1) }, new QualityModel(Quality.SDTV), size: 100.Megabytes(), age: 1);
|
||||
var remoteEpisodeHdSmallOld = GivenRemoteEpisode(new List<Episode> { GivenEpisode(1) }, new QualityModel(Quality.HDTV720p), size: 1200.Megabytes(), age: 1000);
|
||||
var remoteEpisodeSmallYoung = GivenRemoteEpisode(new List<Episode> { GivenEpisode(1) }, new QualityModel(Quality.HDTV720p), size: 1250.Megabytes(), age: 10);
|
||||
var remoteEpisodeHdLargeYoung = GivenRemoteEpisode(new List<Episode> { GivenEpisode(1) }, new QualityModel(Quality.HDTV720p), size: 3000.Megabytes(), age: 1);
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteEpisodeSd));
|
||||
decisions.Add(new DownloadDecision(remoteEpisodeHdSmallOld));
|
||||
decisions.Add(new DownloadDecision(remoteEpisodeHdSmallYounge));
|
||||
decisions.Add(new DownloadDecision(remoteEpisodeHdLargeYounge));
|
||||
decisions.Add(new DownloadDecision(remoteEpisodeSmallYoung));
|
||||
decisions.Add(new DownloadDecision(remoteEpisodeHdLargeYoung));
|
||||
|
||||
var qualifiedReports = Subject.PrioritizeDecisions(decisions);
|
||||
qualifiedReports.First().RemoteEpisode.Should().Be(remoteEpisodeHdSmallYounge);
|
||||
qualifiedReports.First().RemoteEpisode.Should().Be(remoteEpisodeSmallYoung);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_order_by_youngest()
|
||||
{
|
||||
var remoteEpisode1 = GetRemoteEpisode(new List<Episode> { GetEpisode(1) }, new QualityModel(Quality.HDTV720p), Age: 10);
|
||||
var remoteEpisode2 = GetRemoteEpisode(new List<Episode> { GetEpisode(1) }, new QualityModel(Quality.HDTV720p), Age: 5);
|
||||
var remoteEpisode1 = GivenRemoteEpisode(new List<Episode> { GivenEpisode(1) }, new QualityModel(Quality.HDTV720p), age: 10);
|
||||
var remoteEpisode2 = GivenRemoteEpisode(new List<Episode> { GivenEpisode(1) }, new QualityModel(Quality.HDTV720p), age: 5);
|
||||
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
|
@ -134,5 +134,20 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
var qualifiedReports = Subject.PrioritizeDecisions(decisions);
|
||||
qualifiedReports.First().RemoteEpisode.Should().Be(remoteEpisode2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_throw_if_no_episodes_are_found()
|
||||
{
|
||||
var remoteEpisode1 = GivenRemoteEpisode(new List<Episode> { GivenEpisode(1) }, new QualityModel(Quality.HDTV720p), size: 500.Megabytes());
|
||||
var remoteEpisode2 = GivenRemoteEpisode(new List<Episode> { GivenEpisode(1) }, new QualityModel(Quality.HDTV720p), size: 500.Megabytes());
|
||||
|
||||
remoteEpisode1.Episodes = new List<Episode>();
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteEpisode1));
|
||||
decisions.Add(new DownloadDecision(remoteEpisode2));
|
||||
|
||||
Subject.PrioritizeDecisions(decisions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ using Marr.Data;
|
|||
using NUnit.Framework;
|
||||
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.Test.Framework;
|
||||
|
@ -35,7 +36,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
public void Setup()
|
||||
{
|
||||
var fakeSeries = Builder<Series>.CreateNew()
|
||||
.With(c => c.QualityProfile = (LazyLoaded<QualityProfile>)new QualityProfile { Cutoff = Quality.Bluray1080p })
|
||||
.With(c => c.Profile = (LazyLoaded<Profile>)new Profile { Cutoff = Quality.Bluray1080p })
|
||||
.Build();
|
||||
|
||||
remoteEpisode = new RemoteEpisode
|
||||
|
@ -49,7 +50,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
public void should_allow_if_quality_is_defined_in_profile(Quality qualityType)
|
||||
{
|
||||
remoteEpisode.ParsedEpisodeInfo.Quality.Quality = qualityType;
|
||||
remoteEpisode.Series.QualityProfile.Value.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.DVD, Quality.HDTV720p, Quality.Bluray1080p);
|
||||
remoteEpisode.Series.Profile.Value.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.DVD, Quality.HDTV720p, Quality.Bluray1080p);
|
||||
|
||||
Subject.IsSatisfiedBy(remoteEpisode, null).Should().BeTrue();
|
||||
}
|
||||
|
@ -58,7 +59,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
public void should_not_allow_if_quality_is_not_defined_in_profile(Quality qualityType)
|
||||
{
|
||||
remoteEpisode.ParsedEpisodeInfo.Quality.Quality = qualityType;
|
||||
remoteEpisode.Series.QualityProfile.Value.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.DVD, Quality.HDTV720p, Quality.Bluray1080p);
|
||||
remoteEpisode.Series.Profile.Value.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.DVD, Quality.HDTV720p, Quality.Bluray1080p);
|
||||
|
||||
Subject.IsSatisfiedBy(remoteEpisode, null).Should().BeFalse();
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Profiles;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
|
@ -43,9 +44,9 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
{
|
||||
GivenAutoDownloadPropers(true);
|
||||
|
||||
var qualityProfile = new QualityProfile { Items = Qualities.QualityFixture.GetDefaultQualities() };
|
||||
var profile = new Profile { Items = Qualities.QualityFixture.GetDefaultQualities() };
|
||||
|
||||
Subject.IsUpgradable(qualityProfile, new QualityModel(current, currentProper), new QualityModel(newQuality, newProper))
|
||||
Subject.IsUpgradable(profile, new QualityModel(current, currentProper), new QualityModel(newQuality, newProper))
|
||||
.Should().Be(expected);
|
||||
}
|
||||
|
||||
|
@ -54,9 +55,9 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
{
|
||||
GivenAutoDownloadPropers(false);
|
||||
|
||||
var qualityProfile = new QualityProfile { Items = Qualities.QualityFixture.GetDefaultQualities() };
|
||||
var profile = new Profile { Items = Qualities.QualityFixture.GetDefaultQualities() };
|
||||
|
||||
Subject.IsUpgradable(qualityProfile, new QualityModel(Quality.DVD, true), new QualityModel(Quality.DVD, false))
|
||||
Subject.IsUpgradable(profile, new QualityModel(Quality.DVD, true), new QualityModel(Quality.DVD, false))
|
||||
.Should().BeFalse();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,253 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Marr.Data;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications.RssSync;
|
||||
using NzbDrone.Core.Download.Pending;
|
||||
using NzbDrone.Core.History;
|
||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Profiles;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
||||
{
|
||||
[TestFixture]
|
||||
public class DelaySpecificationFixture : CoreTest<DelaySpecification>
|
||||
{
|
||||
private Profile _profile;
|
||||
private RemoteEpisode _remoteEpisode;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_profile = Builder<Profile>.CreateNew()
|
||||
.Build();
|
||||
|
||||
var series = Builder<Series>.CreateNew()
|
||||
.With(s => s.Profile = _profile)
|
||||
.Build();
|
||||
|
||||
_remoteEpisode = Builder<RemoteEpisode>.CreateNew()
|
||||
.With(r => r.Series = series)
|
||||
.Build();
|
||||
|
||||
_profile.Items = new List<ProfileQualityItem>();
|
||||
_profile.Items.Add(new ProfileQualityItem { Allowed = true, Quality = Quality.HDTV720p });
|
||||
_profile.Items.Add(new ProfileQualityItem { Allowed = true, Quality = Quality.WEBDL720p });
|
||||
_profile.Items.Add(new ProfileQualityItem { Allowed = true, Quality = Quality.Bluray720p });
|
||||
|
||||
_profile.Cutoff = Quality.WEBDL720p;
|
||||
|
||||
_profile.GrabDelayMode = GrabDelayMode.Always;
|
||||
|
||||
_remoteEpisode.ParsedEpisodeInfo = new ParsedEpisodeInfo();
|
||||
_remoteEpisode.Release = new ReleaseInfo();
|
||||
|
||||
_remoteEpisode.Episodes = Builder<Episode>.CreateListOfSize(1).Build().ToList();
|
||||
}
|
||||
|
||||
private void GivenExistingFile(QualityModel quality)
|
||||
{
|
||||
_remoteEpisode.Episodes[0].EpisodeFile = new LazyLoaded<EpisodeFile>(new EpisodeFile
|
||||
{
|
||||
Quality = quality
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_true_when_search()
|
||||
{
|
||||
Subject.IsSatisfiedBy(new RemoteEpisode(), new SingleEpisodeSearchCriteria()).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_true_when_profile_does_not_have_a_delay()
|
||||
{
|
||||
_profile.GrabDelay = 0;
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_true_when_quality_is_last_allowed_in_profile()
|
||||
{
|
||||
_remoteEpisode.ParsedEpisodeInfo.Quality = new QualityModel(Quality.Bluray720p);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_true_when_release_is_older_than_delay()
|
||||
{
|
||||
_remoteEpisode.ParsedEpisodeInfo.Quality = new QualityModel(Quality.HDTV720p);
|
||||
_remoteEpisode.Release.PublishDate = DateTime.UtcNow.AddHours(-10);
|
||||
|
||||
_profile.GrabDelay = 1;
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_false_when_release_is_younger_than_delay()
|
||||
{
|
||||
_remoteEpisode.ParsedEpisodeInfo.Quality = new QualityModel(Quality.SDTV);
|
||||
_remoteEpisode.Release.PublishDate = DateTime.UtcNow;
|
||||
|
||||
_profile.GrabDelay = 12;
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_true_when_release_is_proper_for_existing_episode()
|
||||
{
|
||||
_remoteEpisode.ParsedEpisodeInfo.Quality = new QualityModel(Quality.HDTV720p, true);
|
||||
_remoteEpisode.Release.PublishDate = DateTime.UtcNow;
|
||||
|
||||
GivenExistingFile(new QualityModel(Quality.HDTV720p));
|
||||
|
||||
_profile.GrabDelay = 12;
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_false_when_release_is_proper_and_no_existing_episode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_true_when_release_meets_cutoff_and_mode_is_cutoff()
|
||||
{
|
||||
_profile.GrabDelayMode = GrabDelayMode.Cutoff;
|
||||
_remoteEpisode.ParsedEpisodeInfo.Quality = new QualityModel(Quality.WEBDL720p);
|
||||
_remoteEpisode.Release.PublishDate = DateTime.UtcNow;
|
||||
|
||||
_profile.GrabDelay = 12;
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_true_when_release_exceeds_cutoff_and_mode_is_cutoff()
|
||||
{
|
||||
_profile.GrabDelayMode = GrabDelayMode.Cutoff;
|
||||
_remoteEpisode.ParsedEpisodeInfo.Quality = new QualityModel(Quality.Bluray720p);
|
||||
_remoteEpisode.Release.PublishDate = DateTime.UtcNow;
|
||||
|
||||
_profile.GrabDelay = 12;
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_false_when_release_is_below_cutoff_and_mode_is_cutoff()
|
||||
{
|
||||
_profile.GrabDelayMode = GrabDelayMode.Cutoff;
|
||||
_remoteEpisode.ParsedEpisodeInfo.Quality = new QualityModel(Quality.HDTV720p);
|
||||
_remoteEpisode.Release.PublishDate = DateTime.UtcNow;
|
||||
|
||||
_profile.GrabDelay = 12;
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_false_when_release_is_proper_for_existing_episode_of_different_quality()
|
||||
{
|
||||
_remoteEpisode.ParsedEpisodeInfo.Quality = new QualityModel(Quality.HDTV720p, true);
|
||||
_remoteEpisode.Release.PublishDate = DateTime.UtcNow;
|
||||
|
||||
GivenExistingFile(new QualityModel(Quality.SDTV));
|
||||
|
||||
_profile.GrabDelay = 12;
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_false_when_release_is_first_detected_and_mode_is_first()
|
||||
{
|
||||
_profile.GrabDelayMode = GrabDelayMode.First;
|
||||
_remoteEpisode.ParsedEpisodeInfo.Quality = new QualityModel(Quality.HDTV720p);
|
||||
_remoteEpisode.Release.PublishDate = DateTime.UtcNow;
|
||||
|
||||
_profile.GrabDelay = 12;
|
||||
|
||||
Mocker.GetMock<IPendingReleaseService>()
|
||||
.Setup(s => s.GetPendingRemoteEpisodes(It.IsAny<Int32>()))
|
||||
.Returns(new List<RemoteEpisode>());
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_false_when_release_is_not_first_but_oldest_has_not_expired_and_type_is_first()
|
||||
{
|
||||
_profile.GrabDelayMode = GrabDelayMode.First;
|
||||
_remoteEpisode.ParsedEpisodeInfo.Quality = new QualityModel(Quality.HDTV720p);
|
||||
_remoteEpisode.Release.PublishDate = DateTime.UtcNow;
|
||||
|
||||
_profile.GrabDelay = 12;
|
||||
|
||||
var pendingRemoteEpisode = _remoteEpisode.JsonClone();
|
||||
|
||||
Mocker.GetMock<IPendingReleaseService>()
|
||||
.Setup(s => s.GetPendingRemoteEpisodes(It.IsAny<Int32>()))
|
||||
.Returns(new List<RemoteEpisode> { _remoteEpisode.JsonClone() });
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_true_when_existing_pending_release_expired_and_mode_is_first()
|
||||
{
|
||||
_profile.GrabDelayMode = GrabDelayMode.First;
|
||||
|
||||
_remoteEpisode.ParsedEpisodeInfo.Quality = new QualityModel(Quality.WEBDL720p);
|
||||
_remoteEpisode.Release.PublishDate = DateTime.UtcNow;
|
||||
_profile.GrabDelay = 12;
|
||||
|
||||
var pendingRemoteEpisode = _remoteEpisode.JsonClone();
|
||||
pendingRemoteEpisode.Release.PublishDate = DateTime.UtcNow.AddHours(-15);
|
||||
|
||||
Mocker.GetMock<IPendingReleaseService>()
|
||||
.Setup(s => s.GetPendingRemoteEpisodes(It.IsAny<Int32>()))
|
||||
.Returns(new List<RemoteEpisode> { pendingRemoteEpisode });
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_true_when_one_existing_pending_release_is_expired_and_mode_is_first()
|
||||
{
|
||||
_profile.GrabDelayMode = GrabDelayMode.First;
|
||||
|
||||
_remoteEpisode.ParsedEpisodeInfo.Quality = new QualityModel(Quality.WEBDL720p);
|
||||
_remoteEpisode.Release.PublishDate = DateTime.UtcNow;
|
||||
_profile.GrabDelay = 12;
|
||||
|
||||
var pendingRemoteEpisode1 = _remoteEpisode.JsonClone();
|
||||
pendingRemoteEpisode1.Release.PublishDate = DateTime.UtcNow.AddHours(-15);
|
||||
|
||||
var pendingRemoteEpisode2 = _remoteEpisode.JsonClone();
|
||||
pendingRemoteEpisode2.Release.PublishDate = DateTime.UtcNow.AddHours(5);
|
||||
|
||||
Mocker.GetMock<IPendingReleaseService>()
|
||||
.Setup(s => s.GetPendingRemoteEpisodes(It.IsAny<Int32>()))
|
||||
.Returns(new List<RemoteEpisode> { pendingRemoteEpisode1, pendingRemoteEpisode2 });
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeTrue();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@ using NzbDrone.Core.DecisionEngine.Specifications.RssSync;
|
|||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Profiles;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
|
@ -37,7 +38,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
|||
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()
|
||||
.With(c => c.QualityProfile = new QualityProfile { Cutoff = Quality.Bluray1080p })
|
||||
.With(c => c.Profile = new Profile { Cutoff = Quality.Bluray1080p })
|
||||
.Build();
|
||||
|
||||
_parseResultMulti = new RemoteEpisode
|
||||
|
|
|
@ -6,6 +6,7 @@ using NUnit.Framework;
|
|||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Profiles;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
|
@ -38,7 +39,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
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()
|
||||
.With(c => c.QualityProfile = new QualityProfile { Cutoff = Quality.Bluray1080p, Items = Qualities.QualityFixture.GetDefaultQualities() })
|
||||
.With(c => c.Profile = new Profile { Cutoff = Quality.Bluray1080p, Items = Qualities.QualityFixture.GetDefaultQualities() })
|
||||
.Build();
|
||||
|
||||
_parseResultMulti = new RemoteEpisode
|
||||
|
|
|
@ -4,19 +4,20 @@ using FizzWare.NBuilder;
|
|||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.Download.Pending;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Profiles;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Test.Common;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
|
||||
namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class DownloadApprovedFixture : CoreTest<DownloadApprovedReports>
|
||||
public class DownloadApprovedFixture : CoreTest<ProcessDownloadDecisions>
|
||||
{
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
|
@ -47,7 +48,7 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests
|
|||
remoteEpisode.Release.PublishDate = DateTime.UtcNow;
|
||||
|
||||
remoteEpisode.Series = Builder<Series>.CreateNew()
|
||||
.With(e => e.QualityProfile = new QualityProfile { Items = Qualities.QualityFixture.GetDefaultQualities() })
|
||||
.With(e => e.Profile = new Profile { Items = Qualities.QualityFixture.GetDefaultQualities() })
|
||||
.Build();
|
||||
|
||||
return remoteEpisode;
|
||||
|
@ -62,7 +63,7 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests
|
|||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteEpisode));
|
||||
|
||||
Subject.DownloadApproved(decisions);
|
||||
Subject.ProcessDecisions(decisions);
|
||||
Mocker.GetMock<IDownloadService>().Verify(v => v.DownloadReport(It.IsAny<RemoteEpisode>()), Times.Once());
|
||||
}
|
||||
|
||||
|
@ -76,7 +77,7 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests
|
|||
decisions.Add(new DownloadDecision(remoteEpisode));
|
||||
decisions.Add(new DownloadDecision(remoteEpisode));
|
||||
|
||||
Subject.DownloadApproved(decisions);
|
||||
Subject.ProcessDecisions(decisions);
|
||||
Mocker.GetMock<IDownloadService>().Verify(v => v.DownloadReport(It.IsAny<RemoteEpisode>()), Times.Once());
|
||||
}
|
||||
|
||||
|
@ -97,7 +98,7 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests
|
|||
decisions.Add(new DownloadDecision(remoteEpisode1));
|
||||
decisions.Add(new DownloadDecision(remoteEpisode2));
|
||||
|
||||
Subject.DownloadApproved(decisions);
|
||||
Subject.ProcessDecisions(decisions);
|
||||
Mocker.GetMock<IDownloadService>().Verify(v => v.DownloadReport(It.IsAny<RemoteEpisode>()), Times.Once());
|
||||
}
|
||||
|
||||
|
@ -110,7 +111,7 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests
|
|||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteEpisode));
|
||||
|
||||
Subject.DownloadApproved(decisions).Should().HaveCount(1);
|
||||
Subject.ProcessDecisions(decisions).Grabbed.Should().HaveCount(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -130,7 +131,7 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests
|
|||
decisions.Add(new DownloadDecision(remoteEpisode1));
|
||||
decisions.Add(new DownloadDecision(remoteEpisode2));
|
||||
|
||||
Subject.DownloadApproved(decisions).Should().HaveCount(2);
|
||||
Subject.ProcessDecisions(decisions).Grabbed.Should().HaveCount(2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -156,7 +157,7 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests
|
|||
decisions.Add(new DownloadDecision(remoteEpisode2));
|
||||
decisions.Add(new DownloadDecision(remoteEpisode3));
|
||||
|
||||
Subject.DownloadApproved(decisions).Should().HaveCount(2);
|
||||
Subject.ProcessDecisions(decisions).Grabbed.Should().HaveCount(2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -169,7 +170,7 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests
|
|||
decisions.Add(new DownloadDecision(remoteEpisode));
|
||||
|
||||
Mocker.GetMock<IDownloadService>().Setup(s => s.DownloadReport(It.IsAny<RemoteEpisode>())).Throws(new Exception());
|
||||
Subject.DownloadApproved(decisions).Should().BeEmpty();
|
||||
Subject.ProcessDecisions(decisions).Grabbed.Should().BeEmpty();
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
}
|
||||
|
||||
|
@ -177,10 +178,52 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests
|
|||
public void should_return_an_empty_list_when_none_are_appproved()
|
||||
{
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(null, "Failure!"));
|
||||
decisions.Add(new DownloadDecision(null, "Failure!"));
|
||||
decisions.Add(new DownloadDecision(null, new Rejection("Failure!")));
|
||||
decisions.Add(new DownloadDecision(null, new Rejection("Failure!")));
|
||||
|
||||
Subject.GetQualifiedReports(decisions).Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_grab_if_pending()
|
||||
{
|
||||
var episodes = new List<Episode> { GetEpisode(1) };
|
||||
var remoteEpisode = GetRemoteEpisode(episodes, new QualityModel(Quality.HDTV720p));
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteEpisode, new Rejection("Failure!", RejectionType.Temporary)));
|
||||
decisions.Add(new DownloadDecision(remoteEpisode));
|
||||
|
||||
Subject.ProcessDecisions(decisions);
|
||||
Mocker.GetMock<IDownloadService>().Verify(v => v.DownloadReport(It.IsAny<RemoteEpisode>()), Times.Never());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_add_to_pending_if_episode_was_grabbed()
|
||||
{
|
||||
var episodes = new List<Episode> { GetEpisode(1) };
|
||||
var remoteEpisode = GetRemoteEpisode(episodes, new QualityModel(Quality.HDTV720p));
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteEpisode));
|
||||
decisions.Add(new DownloadDecision(remoteEpisode, new Rejection("Failure!", RejectionType.Temporary)));
|
||||
|
||||
Subject.ProcessDecisions(decisions);
|
||||
Mocker.GetMock<IPendingReleaseService>().Verify(v => v.Add(It.IsAny<DownloadDecision>()), Times.Never());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_add_to_pending_even_if_already_added_to_pending()
|
||||
{
|
||||
var episodes = new List<Episode> { GetEpisode(1) };
|
||||
var remoteEpisode = GetRemoteEpisode(episodes, new QualityModel(Quality.HDTV720p));
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteEpisode, new Rejection("Failure!", RejectionType.Temporary)));
|
||||
decisions.Add(new DownloadDecision(remoteEpisode, new Rejection("Failure!", RejectionType.Temporary)));
|
||||
|
||||
Subject.ProcessDecisions(decisions);
|
||||
Mocker.GetMock<IPendingReleaseService>().Verify(v => v.Add(It.IsAny<DownloadDecision>()), Times.Exactly(2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ using NzbDrone.Core.Download;
|
|||
using NzbDrone.Core.History;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.Download
|
||||
{
|
||||
|
@ -379,6 +380,30 @@ namespace NzbDrone.Core.Test.Download
|
|||
Subject.Execute(new CheckForFinishedDownloadCommand());
|
||||
|
||||
VerifyNoFailedDownloads();
|
||||
|
||||
ExceptionVerification.IgnoreWarns();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_manual_mark_all_episodes_of_release_as_failed()
|
||||
{
|
||||
var historyFailed = Builder<History.History>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(v => v.EventType == HistoryEventType.Grabbed)
|
||||
.Do(v => v.Data.Add("downloadClient", "SabnzbdClient"))
|
||||
.Do(v => v.Data.Add("downloadClientId", "test"))
|
||||
.Build()
|
||||
.ToList();
|
||||
|
||||
GivenGrabbedHistory(historyFailed);
|
||||
|
||||
Mocker.GetMock<IHistoryService>()
|
||||
.Setup(s => s.Get(It.IsAny<Int32>()))
|
||||
.Returns<Int32>(i => historyFailed.FirstOrDefault(v => v.Id == i));
|
||||
|
||||
Subject.MarkAsFailed(1);
|
||||
|
||||
VerifyFailedDownloads(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,163 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FizzWare.NBuilder;
|
||||
using Marr.Data;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
using NzbDrone.Core.Download.Pending;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Profiles;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class AddFixture : CoreTest<PendingReleaseService>
|
||||
{
|
||||
private DownloadDecision _temporarilyRejected;
|
||||
private Series _series;
|
||||
private Episode _episode;
|
||||
private Profile _profile;
|
||||
private ReleaseInfo _release;
|
||||
private ParsedEpisodeInfo _parsedEpisodeInfo;
|
||||
private RemoteEpisode _remoteEpisode;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_series = Builder<Series>.CreateNew()
|
||||
.Build();
|
||||
|
||||
_episode = Builder<Episode>.CreateNew()
|
||||
.Build();
|
||||
|
||||
_profile = new Profile
|
||||
{
|
||||
Name = "Test",
|
||||
Cutoff = Quality.HDTV720p,
|
||||
GrabDelay = 1,
|
||||
Items = new List<ProfileQualityItem>
|
||||
{
|
||||
new ProfileQualityItem { Allowed = true, Quality = Quality.HDTV720p },
|
||||
new ProfileQualityItem { Allowed = true, Quality = Quality.WEBDL720p },
|
||||
new ProfileQualityItem { Allowed = true, Quality = Quality.Bluray720p }
|
||||
},
|
||||
};
|
||||
|
||||
_series.Profile = new LazyLoaded<Profile>(_profile);
|
||||
|
||||
_release = Builder<ReleaseInfo>.CreateNew().Build();
|
||||
|
||||
_parsedEpisodeInfo = Builder<ParsedEpisodeInfo>.CreateNew().Build();
|
||||
_parsedEpisodeInfo.Quality = new QualityModel(Quality.HDTV720p);
|
||||
|
||||
_remoteEpisode = new RemoteEpisode();
|
||||
_remoteEpisode.Episodes = new List<Episode>{ _episode };
|
||||
_remoteEpisode.Series = _series;
|
||||
_remoteEpisode.ParsedEpisodeInfo = _parsedEpisodeInfo;
|
||||
_remoteEpisode.Release = _release;
|
||||
|
||||
_temporarilyRejected = new DownloadDecision(_remoteEpisode, new Rejection("Temp Rejected", RejectionType.Temporary));
|
||||
|
||||
Mocker.GetMock<IPendingReleaseRepository>()
|
||||
.Setup(s => s.All())
|
||||
.Returns(new List<PendingRelease>());
|
||||
|
||||
Mocker.GetMock<ISeriesService>()
|
||||
.Setup(s => s.GetSeries(It.IsAny<Int32>()))
|
||||
.Returns(_series);
|
||||
|
||||
Mocker.GetMock<IParsingService>()
|
||||
.Setup(s => s.GetEpisodes(It.IsAny<ParsedEpisodeInfo>(), _series, true, null))
|
||||
.Returns(new List<Episode> {_episode});
|
||||
|
||||
Mocker.GetMock<IPrioritizeDownloadDecision>()
|
||||
.Setup(s => s.PrioritizeDecisions(It.IsAny<List<DownloadDecision>>()))
|
||||
.Returns((List<DownloadDecision> d) => d);
|
||||
}
|
||||
|
||||
private void GivenHeldRelease(String title, String indexer, DateTime publishDate)
|
||||
{
|
||||
var release = _release.JsonClone();
|
||||
release.Indexer = indexer;
|
||||
release.PublishDate = publishDate;
|
||||
|
||||
|
||||
var heldReleases = Builder<PendingRelease>.CreateListOfSize(1)
|
||||
.All()
|
||||
.With(h => h.SeriesId = _series.Id)
|
||||
.With(h => h.Title = title)
|
||||
.With(h => h.Release = release)
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<IPendingReleaseRepository>()
|
||||
.Setup(s => s.All())
|
||||
.Returns(heldReleases);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_add()
|
||||
{
|
||||
Subject.Add(_temporarilyRejected);
|
||||
|
||||
VerifyInsert();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_add_if_it_is_the_same_release_from_the_same_indexer()
|
||||
{
|
||||
GivenHeldRelease(_release.Title, _release.Indexer, _release.PublishDate);
|
||||
|
||||
Subject.Add(_temporarilyRejected);
|
||||
|
||||
VerifyNoInsert();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_add_if_title_is_different()
|
||||
{
|
||||
GivenHeldRelease(_release.Title + "-RP", _release.Indexer, _release.PublishDate);
|
||||
|
||||
Subject.Add(_temporarilyRejected);
|
||||
|
||||
VerifyInsert();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_add_if_indexer_is_different()
|
||||
{
|
||||
GivenHeldRelease(_release.Title, "AnotherIndexer", _release.PublishDate);
|
||||
|
||||
Subject.Add(_temporarilyRejected);
|
||||
|
||||
VerifyInsert();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_add_if_publish_date_is_different()
|
||||
{
|
||||
GivenHeldRelease(_release.Title, _release.Indexer, _release.PublishDate.AddHours(1));
|
||||
|
||||
Subject.Add(_temporarilyRejected);
|
||||
|
||||
VerifyInsert();
|
||||
}
|
||||
|
||||
private void VerifyInsert()
|
||||
{
|
||||
Mocker.GetMock<IPendingReleaseRepository>()
|
||||
.Verify(v => v.Insert(It.IsAny<PendingRelease>()), Times.Once());
|
||||
}
|
||||
|
||||
private void VerifyNoInsert()
|
||||
{
|
||||
Mocker.GetMock<IPendingReleaseRepository>()
|
||||
.Verify(v => v.Insert(It.IsAny<PendingRelease>()), Times.Never());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,143 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FizzWare.NBuilder;
|
||||
using Marr.Data;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
using NzbDrone.Core.Download.Pending;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Profiles;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class RemoveGrabbedFixture : CoreTest<PendingReleaseService>
|
||||
{
|
||||
private DownloadDecision _temporarilyRejected;
|
||||
private Series _series;
|
||||
private Episode _episode;
|
||||
private Profile _profile;
|
||||
private ReleaseInfo _release;
|
||||
private ParsedEpisodeInfo _parsedEpisodeInfo;
|
||||
private RemoteEpisode _remoteEpisode;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_series = Builder<Series>.CreateNew()
|
||||
.Build();
|
||||
|
||||
_episode = Builder<Episode>.CreateNew()
|
||||
.Build();
|
||||
|
||||
_profile = new Profile
|
||||
{
|
||||
Name = "Test",
|
||||
Cutoff = Quality.HDTV720p,
|
||||
GrabDelay = 1,
|
||||
Items = new List<ProfileQualityItem>
|
||||
{
|
||||
new ProfileQualityItem { Allowed = true, Quality = Quality.HDTV720p },
|
||||
new ProfileQualityItem { Allowed = true, Quality = Quality.WEBDL720p },
|
||||
new ProfileQualityItem { Allowed = true, Quality = Quality.Bluray720p }
|
||||
},
|
||||
};
|
||||
|
||||
_series.Profile = new LazyLoaded<Profile>(_profile);
|
||||
|
||||
_release = Builder<ReleaseInfo>.CreateNew().Build();
|
||||
|
||||
_parsedEpisodeInfo = Builder<ParsedEpisodeInfo>.CreateNew().Build();
|
||||
_parsedEpisodeInfo.Quality = new QualityModel(Quality.HDTV720p);
|
||||
|
||||
_remoteEpisode = new RemoteEpisode();
|
||||
_remoteEpisode.Episodes = new List<Episode>{ _episode };
|
||||
_remoteEpisode.Series = _series;
|
||||
_remoteEpisode.ParsedEpisodeInfo = _parsedEpisodeInfo;
|
||||
_remoteEpisode.Release = _release;
|
||||
|
||||
_temporarilyRejected = new DownloadDecision(_remoteEpisode, new Rejection("Temp Rejected", RejectionType.Temporary));
|
||||
|
||||
Mocker.GetMock<IPendingReleaseRepository>()
|
||||
.Setup(s => s.All())
|
||||
.Returns(new List<PendingRelease>());
|
||||
|
||||
Mocker.GetMock<ISeriesService>()
|
||||
.Setup(s => s.GetSeries(It.IsAny<Int32>()))
|
||||
.Returns(_series);
|
||||
|
||||
Mocker.GetMock<IParsingService>()
|
||||
.Setup(s => s.GetEpisodes(It.IsAny<ParsedEpisodeInfo>(), _series, true, null))
|
||||
.Returns(new List<Episode> {_episode});
|
||||
|
||||
Mocker.GetMock<IPrioritizeDownloadDecision>()
|
||||
.Setup(s => s.PrioritizeDecisions(It.IsAny<List<DownloadDecision>>()))
|
||||
.Returns((List<DownloadDecision> d) => d);
|
||||
}
|
||||
|
||||
private void GivenHeldRelease(QualityModel quality)
|
||||
{
|
||||
var parsedEpisodeInfo = _parsedEpisodeInfo.JsonClone();
|
||||
parsedEpisodeInfo.Quality = quality;
|
||||
|
||||
var heldReleases = Builder<PendingRelease>.CreateListOfSize(1)
|
||||
.All()
|
||||
.With(h => h.SeriesId = _series.Id)
|
||||
.With(h => h.Release = _release.JsonClone())
|
||||
.With(h => h.ParsedEpisodeInfo = parsedEpisodeInfo)
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<IPendingReleaseRepository>()
|
||||
.Setup(s => s.All())
|
||||
.Returns(heldReleases);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_delete_if_the_grabbed_quality_is_the_same()
|
||||
{
|
||||
GivenHeldRelease(_parsedEpisodeInfo.Quality);
|
||||
|
||||
Subject.RemoveGrabbed(new List<DownloadDecision> { _temporarilyRejected });
|
||||
|
||||
VerifyDelete();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_delete_if_the_grabbed_quality_is_the_higher()
|
||||
{
|
||||
GivenHeldRelease(new QualityModel(Quality.SDTV));
|
||||
|
||||
Subject.RemoveGrabbed(new List<DownloadDecision> { _temporarilyRejected });
|
||||
|
||||
VerifyDelete();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_delete_if_the_grabbed_quality_is_the_lower()
|
||||
{
|
||||
GivenHeldRelease(new QualityModel(Quality.Bluray720p));
|
||||
|
||||
Subject.RemoveGrabbed(new List<DownloadDecision> { _temporarilyRejected });
|
||||
|
||||
VerifyNoDelete();
|
||||
}
|
||||
|
||||
private void VerifyDelete()
|
||||
{
|
||||
Mocker.GetMock<IPendingReleaseRepository>()
|
||||
.Verify(v => v.Delete(It.IsAny<PendingRelease>()), Times.Once());
|
||||
}
|
||||
|
||||
private void VerifyNoDelete()
|
||||
{
|
||||
Mocker.GetMock<IPendingReleaseRepository>()
|
||||
.Verify(v => v.Delete(It.IsAny<PendingRelease>()), Times.Never());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,155 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FizzWare.NBuilder;
|
||||
using Marr.Data;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
using NzbDrone.Core.Download.Pending;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Profiles;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class RemoveRejectedFixture : CoreTest<PendingReleaseService>
|
||||
{
|
||||
private DownloadDecision _temporarilyRejected;
|
||||
private Series _series;
|
||||
private Episode _episode;
|
||||
private Profile _profile;
|
||||
private ReleaseInfo _release;
|
||||
private ParsedEpisodeInfo _parsedEpisodeInfo;
|
||||
private RemoteEpisode _remoteEpisode;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_series = Builder<Series>.CreateNew()
|
||||
.Build();
|
||||
|
||||
_episode = Builder<Episode>.CreateNew()
|
||||
.Build();
|
||||
|
||||
_profile = new Profile
|
||||
{
|
||||
Name = "Test",
|
||||
Cutoff = Quality.HDTV720p,
|
||||
GrabDelay = 1,
|
||||
Items = new List<ProfileQualityItem>
|
||||
{
|
||||
new ProfileQualityItem { Allowed = true, Quality = Quality.HDTV720p },
|
||||
new ProfileQualityItem { Allowed = true, Quality = Quality.WEBDL720p },
|
||||
new ProfileQualityItem { Allowed = true, Quality = Quality.Bluray720p }
|
||||
},
|
||||
};
|
||||
|
||||
_series.Profile = new LazyLoaded<Profile>(_profile);
|
||||
|
||||
_release = Builder<ReleaseInfo>.CreateNew().Build();
|
||||
|
||||
_parsedEpisodeInfo = Builder<ParsedEpisodeInfo>.CreateNew().Build();
|
||||
_parsedEpisodeInfo.Quality = new QualityModel(Quality.HDTV720p);
|
||||
|
||||
_remoteEpisode = new RemoteEpisode();
|
||||
_remoteEpisode.Episodes = new List<Episode>{ _episode };
|
||||
_remoteEpisode.Series = _series;
|
||||
_remoteEpisode.ParsedEpisodeInfo = _parsedEpisodeInfo;
|
||||
_remoteEpisode.Release = _release;
|
||||
|
||||
_temporarilyRejected = new DownloadDecision(_remoteEpisode, new Rejection("Temp Rejected", RejectionType.Temporary));
|
||||
|
||||
Mocker.GetMock<IPendingReleaseRepository>()
|
||||
.Setup(s => s.All())
|
||||
.Returns(new List<PendingRelease>());
|
||||
|
||||
Mocker.GetMock<ISeriesService>()
|
||||
.Setup(s => s.GetSeries(It.IsAny<Int32>()))
|
||||
.Returns(_series);
|
||||
|
||||
Mocker.GetMock<IParsingService>()
|
||||
.Setup(s => s.GetEpisodes(It.IsAny<ParsedEpisodeInfo>(), _series, true, null))
|
||||
.Returns(new List<Episode> {_episode});
|
||||
|
||||
Mocker.GetMock<IPrioritizeDownloadDecision>()
|
||||
.Setup(s => s.PrioritizeDecisions(It.IsAny<List<DownloadDecision>>()))
|
||||
.Returns((List<DownloadDecision> d) => d);
|
||||
}
|
||||
|
||||
private void GivenHeldRelease(String title, String indexer, DateTime publishDate)
|
||||
{
|
||||
var release = _release.JsonClone();
|
||||
release.Indexer = indexer;
|
||||
release.PublishDate = publishDate;
|
||||
|
||||
|
||||
var heldReleases = Builder<PendingRelease>.CreateListOfSize(1)
|
||||
.All()
|
||||
.With(h => h.SeriesId = _series.Id)
|
||||
.With(h => h.Title = title)
|
||||
.With(h => h.Release = release)
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<IPendingReleaseRepository>()
|
||||
.Setup(s => s.All())
|
||||
.Returns(heldReleases);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_remove_if_it_is_the_same_release_from_the_same_indexer()
|
||||
{
|
||||
GivenHeldRelease(_release.Title, _release.Indexer, _release.PublishDate);
|
||||
|
||||
Subject.RemoveRejected(new List<DownloadDecision> { _temporarilyRejected });
|
||||
|
||||
VerifyDelete();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_remove_if_title_is_different()
|
||||
{
|
||||
GivenHeldRelease(_release.Title + "-RP", _release.Indexer, _release.PublishDate);
|
||||
|
||||
Subject.RemoveRejected(new List<DownloadDecision> { _temporarilyRejected });
|
||||
|
||||
VerifyNoDelete();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_remove_if_indexer_is_different()
|
||||
{
|
||||
GivenHeldRelease(_release.Title, "AnotherIndexer", _release.PublishDate);
|
||||
|
||||
Subject.RemoveRejected(new List<DownloadDecision> { _temporarilyRejected });
|
||||
|
||||
VerifyNoDelete();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_remove_if_publish_date_is_different()
|
||||
{
|
||||
GivenHeldRelease(_release.Title, _release.Indexer, _release.PublishDate.AddHours(1));
|
||||
|
||||
Subject.RemoveRejected(new List<DownloadDecision> { _temporarilyRejected });
|
||||
|
||||
VerifyNoDelete();
|
||||
}
|
||||
|
||||
private void VerifyDelete()
|
||||
{
|
||||
Mocker.GetMock<IPendingReleaseRepository>()
|
||||
.Verify(v => v.Delete(It.IsAny<PendingRelease>()), Times.Once());
|
||||
}
|
||||
|
||||
private void VerifyNoDelete()
|
||||
{
|
||||
Mocker.GetMock<IPendingReleaseRepository>()
|
||||
.Verify(v => v.Delete(It.IsAny<PendingRelease>()), Times.Never());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Processes;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Core.HealthCheck.Checks;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
|
@ -18,16 +17,9 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
|
|||
|
||||
private void GivenOutput(string version)
|
||||
{
|
||||
Mocker.GetMock<IProcessProvider>()
|
||||
.Setup(s => s.StartAndCapture("mono", "--version"))
|
||||
.Returns(new ProcessOutput
|
||||
{
|
||||
Standard = new List<string>
|
||||
{
|
||||
String.Format("Mono JIT compiler version {0} (Debian {0}-8)", version),
|
||||
"Copyright (C) 2002-2011 Novell, Inc, Xamarin, Inc and Contributors. www.mono-project.com"
|
||||
}
|
||||
});
|
||||
Mocker.GetMock<IRuntimeInfo>()
|
||||
.SetupGet(s => s.RuntimeVersion)
|
||||
.Returns(String.Format("{0} (tarball Wed Sep 25 16:35:44 CDT 2013)", version));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -46,6 +38,14 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
|
|||
Subject.Check().ShouldBeWarning();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_warning_when_mono_2_10_2()
|
||||
{
|
||||
GivenOutput("2.10.2");
|
||||
|
||||
Subject.Check().ShouldBeWarning();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_ok_when_mono_3_2()
|
||||
{
|
||||
|
@ -85,22 +85,5 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
|
|||
|
||||
Subject.Check().ShouldBeOk();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_ok_when_mono_3_6_1_with_custom_output()
|
||||
{
|
||||
Mocker.GetMock<IProcessProvider>()
|
||||
.Setup(s => s.StartAndCapture("mono", "--version"))
|
||||
.Returns(new ProcessOutput
|
||||
{
|
||||
Standard = new List<string>
|
||||
{
|
||||
"Mono JIT compiler version 3.6.1 (master/fce3972 Fri Jul 4 01:12:43 CEST 2014)",
|
||||
"Copyright (C) 2002-2011 Novell, Inc, Xamarin, Inc and Contributors. www.mono-project.com"
|
||||
}
|
||||
});
|
||||
|
||||
Subject.Check().ShouldBeOk();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ using FluentAssertions;
|
|||
using NUnit.Framework;
|
||||
using NzbDrone.Core.History;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Qualities;
|
||||
|
||||
namespace NzbDrone.Core.Test.HistoryTests
|
||||
{
|
||||
|
@ -15,7 +16,8 @@ namespace NzbDrone.Core.Test.HistoryTests
|
|||
{
|
||||
var historyItem = Builder<History.History>.CreateListOfSize(30)
|
||||
.All()
|
||||
.With(c=>c.Id = 0)
|
||||
.With(c => c.Id = 0)
|
||||
.With(c => c.Quality = new QualityModel())
|
||||
.TheFirst(10).With(c => c.Date = DateTime.Now)
|
||||
.TheNext(20).With(c => c.Date = DateTime.Now.AddDays(-31))
|
||||
.Build();
|
||||
|
@ -32,7 +34,9 @@ namespace NzbDrone.Core.Test.HistoryTests
|
|||
[Test]
|
||||
public void should_read_write_dictionary()
|
||||
{
|
||||
var history = Builder<History.History>.CreateNew().BuildNew();
|
||||
var history = Builder<History.History>.CreateNew()
|
||||
.With(c => c.Quality = new QualityModel())
|
||||
.BuildNew();
|
||||
|
||||
history.Data.Add("key1","value1");
|
||||
history.Data.Add("key2","value2");
|
||||
|
@ -48,6 +52,7 @@ namespace NzbDrone.Core.Test.HistoryTests
|
|||
var history = Builder<History.History>
|
||||
.CreateListOfSize(5)
|
||||
.All()
|
||||
.With(c => c.Quality = new QualityModel())
|
||||
.With(c => c.EventType = HistoryEventType.Unknown)
|
||||
.Random(3)
|
||||
.With(c => c.EventType = HistoryEventType.Grabbed)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Profiles;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.History;
|
||||
using NzbDrone.Core.Qualities;
|
||||
|
@ -10,14 +11,14 @@ namespace NzbDrone.Core.Test.HistoryTests
|
|||
{
|
||||
public class HistoryServiceFixture : CoreTest<HistoryService>
|
||||
{
|
||||
private QualityProfile _profile;
|
||||
private QualityProfile _profileCustom;
|
||||
private Profile _profile;
|
||||
private Profile _profileCustom;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_profile = new QualityProfile { Cutoff = Quality.WEBDL720p, Items = QualityFixture.GetDefaultQualities() };
|
||||
_profileCustom = new QualityProfile { Cutoff = Quality.WEBDL720p, Items = QualityFixture.GetDefaultQualities(Quality.DVD) };
|
||||
_profile = new Profile { Cutoff = Quality.WEBDL720p, Items = QualityFixture.GetDefaultQualities() };
|
||||
_profileCustom = new Profile { Cutoff = Quality.WEBDL720p, Items = QualityFixture.GetDefaultQualities(Quality.DVD) };
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
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 System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NzbDrone.Core.Test.Housekeeping.Housekeepers
|
||||
{
|
||||
[TestFixture]
|
||||
public class CleanupOrphanedBlacklistFixture : DbTest<CleanupOrphanedBlacklist, Blacklist>
|
||||
{
|
||||
[Test]
|
||||
public void should_delete_orphaned_blacklist_items()
|
||||
{
|
||||
var blacklist = Builder<Blacklist>.CreateNew()
|
||||
.With(h => h.EpisodeIds = new List<Int32>())
|
||||
.With(h => h.Quality = new QualityModel())
|
||||
.BuildNew();
|
||||
|
||||
Db.Insert(blacklist);
|
||||
Subject.Clean();
|
||||
AllStoredModels.Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_delete_unorphaned_blacklist_items()
|
||||
{
|
||||
var series = Builder<Series>.CreateNew().BuildNew();
|
||||
|
||||
Db.Insert(series);
|
||||
|
||||
var blacklist = Builder<Blacklist>.CreateNew()
|
||||
.With(h => h.EpisodeIds = new List<Int32>())
|
||||
.With(h => h.Quality = new QualityModel())
|
||||
.With(b => b.SeriesId = series.Id)
|
||||
.BuildNew();
|
||||
|
||||
Db.Insert(blacklist);
|
||||
|
||||
Subject.Clean();
|
||||
AllStoredModels.Should().HaveCount(1);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@ using NzbDrone.Core.Housekeeping.Housekeepers;
|
|||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Qualities;
|
||||
|
||||
namespace NzbDrone.Core.Test.Housekeeping.Housekeepers
|
||||
{
|
||||
|
@ -16,6 +17,7 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers
|
|||
public void should_delete_orphaned_episode_files()
|
||||
{
|
||||
var episodeFile = Builder<EpisodeFile>.CreateNew()
|
||||
.With(h => h.Quality = new QualityModel())
|
||||
.BuildNew();
|
||||
|
||||
Db.Insert(episodeFile);
|
||||
|
@ -27,6 +29,8 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers
|
|||
public void should_not_delete_unorphaned_episode_files()
|
||||
{
|
||||
var episodeFiles = Builder<EpisodeFile>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(h => h.Quality = new QualityModel())
|
||||
.BuildListOfNew();
|
||||
|
||||
Db.InsertMany(episodeFiles);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Housekeeping.Housekeepers;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
|
@ -39,6 +40,7 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers
|
|||
GivenEpisode();
|
||||
|
||||
var history = Builder<History.History>.CreateNew()
|
||||
.With(h => h.Quality = new QualityModel())
|
||||
.With(h => h.EpisodeId = _episode.Id)
|
||||
.BuildNew();
|
||||
Db.Insert(history);
|
||||
|
@ -53,6 +55,7 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers
|
|||
GivenSeries();
|
||||
|
||||
var history = Builder<History.History>.CreateNew()
|
||||
.With(h => h.Quality = new QualityModel())
|
||||
.With(h => h.SeriesId = _series.Id)
|
||||
.BuildNew();
|
||||
Db.Insert(history);
|
||||
|
@ -69,6 +72,7 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers
|
|||
|
||||
var history = Builder<History.History>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(h => h.Quality = new QualityModel())
|
||||
.With(h => h.EpisodeId = _episode.Id)
|
||||
.TheFirst(1)
|
||||
.With(h => h.SeriesId = _series.Id)
|
||||
|
@ -89,6 +93,7 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers
|
|||
|
||||
var history = Builder<History.History>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(h => h.Quality = new QualityModel())
|
||||
.With(h => h.SeriesId = _series.Id)
|
||||
.TheFirst(1)
|
||||
.With(h => h.EpisodeId = _episode.Id)
|
||||
|
|
|
@ -5,6 +5,7 @@ using NzbDrone.Core.Housekeeping.Housekeepers;
|
|||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Metadata;
|
||||
using NzbDrone.Core.Metadata.Files;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
|
@ -68,6 +69,7 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers
|
|||
.BuildNew();
|
||||
|
||||
var episodeFile = Builder<EpisodeFile>.CreateNew()
|
||||
.With(h => h.Quality = new QualityModel())
|
||||
.BuildNew();
|
||||
|
||||
Db.Insert(series);
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Download.Pending;
|
||||
using NzbDrone.Core.Housekeeping.Housekeepers;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.Test.Housekeeping.Housekeepers
|
||||
{
|
||||
[TestFixture]
|
||||
public class CleanupOrphanedPendingReleasesFixture : DbTest<CleanupOrphanedPendingReleases, PendingRelease>
|
||||
{
|
||||
[Test]
|
||||
public void should_delete_orphaned_pending_items()
|
||||
{
|
||||
var pendingRelease = Builder<PendingRelease>.CreateNew()
|
||||
.With(h => h.ParsedEpisodeInfo = new ParsedEpisodeInfo())
|
||||
.With(h => h.Release = new ReleaseInfo())
|
||||
.BuildNew();
|
||||
|
||||
Db.Insert(pendingRelease);
|
||||
Subject.Clean();
|
||||
AllStoredModels.Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_delete_unorphaned_pending_items()
|
||||
{
|
||||
var series = Builder<Series>.CreateNew().BuildNew();
|
||||
|
||||
Db.Insert(series);
|
||||
|
||||
var pendingRelease = Builder<PendingRelease>.CreateNew()
|
||||
.With(h => h.SeriesId = series.Id)
|
||||
.With(h => h.ParsedEpisodeInfo = new ParsedEpisodeInfo())
|
||||
.With(h => h.Release = new ReleaseInfo())
|
||||
.BuildNew();
|
||||
|
||||
Db.Insert(pendingRelease);
|
||||
|
||||
Subject.Clean();
|
||||
AllStoredModels.Should().HaveCount(1);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
using NzbDrone.Core.DataAugmentation.Scene;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
using NzbDrone.Core.DataAugmentation.Scene;
|
||||
using NzbDrone.Core.IndexerSearch;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using FizzWare.NBuilder;
|
||||
|
@ -30,9 +31,9 @@ namespace NzbDrone.Core.Test.IndexerSearchTests
|
|||
.Setup(s => s.GetAvailableProviders())
|
||||
.Returns(new List<IIndexer> { indexer.Object });
|
||||
|
||||
Mocker.GetMock<DecisionEngine.IMakeDownloadDecision>()
|
||||
Mocker.GetMock<IMakeDownloadDecision>()
|
||||
.Setup(s => s.GetSearchDecision(It.IsAny<List<Parser.Model.ReleaseInfo>>(), It.IsAny<SearchCriteriaBase>()))
|
||||
.Returns(new List<DecisionEngine.Specifications.DownloadDecision>());
|
||||
.Returns(new List<DownloadDecision>());
|
||||
|
||||
_xemSeries = Builder<Series>.CreateNew()
|
||||
.With(v => v.UseSceneNumbering = true)
|
||||
|
|
|
@ -102,9 +102,9 @@ namespace NzbDrone.Core.Test.InstrumentationTests
|
|||
public void null_string_as_arg_should_not_fail()
|
||||
{
|
||||
var epFile = new EpisodeFile();
|
||||
_logger.Debug("File {0} no longer exists on disk. removing from database.", epFile.Path);
|
||||
_logger.Debug("File {0} no longer exists on disk. removing from database.", epFile.RelativePath);
|
||||
|
||||
epFile.Path.Should().BeNull();
|
||||
epFile.RelativePath.Should().BeNull();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using FizzWare.NBuilder;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.MediaFiles.Commands;
|
||||
using NzbDrone.Core.Messaging.Commands;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class ScanFixture : CoreTest<DiskScanService>
|
||||
{
|
||||
private Series _series;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_series = Builder<Series>.CreateNew()
|
||||
.With(s => s.Path = @"C:\Test\TV\Series")
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(s => s.GetParentFolder(It.IsAny<String>()))
|
||||
.Returns((String path) => Directory.GetParent(path).FullName);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_scan_if_series_root_folder_does_not_exist()
|
||||
{
|
||||
Subject.Scan(_series);
|
||||
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
|
||||
Mocker.GetMock<ICommandExecutor>()
|
||||
.Verify(v => v.PublishCommand(It.IsAny<CleanMediaFileDb>()), Times.Never());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -95,7 +95,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
Subject.Execute(new DownloadedEpisodesScanCommand());
|
||||
|
||||
Mocker.GetMock<IMakeImportDecision>()
|
||||
.Verify(c => c.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Series>(), It.IsAny<bool>(), It.IsAny<Core.Qualities.QualityModel>()),
|
||||
.Verify(c => c.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Series>(), It.IsAny<bool>(), It.IsAny<QualityModel>()),
|
||||
Times.Never());
|
||||
|
||||
VerifyNoImport();
|
||||
|
|
|
@ -30,7 +30,8 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeFileMovingServiceTests
|
|||
.Build();
|
||||
|
||||
_episodeFile = Builder<EpisodeFile>.CreateNew()
|
||||
.With(f => f.Path = @"C:\Test\File.avi")
|
||||
.With(f => f.Path = null)
|
||||
.With(f => f.RelativePath = @"Season 1\File.avi")
|
||||
.Build();
|
||||
|
||||
_localEpisode = Builder<LocalEpisode>.CreateNew()
|
||||
|
@ -39,12 +40,12 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeFileMovingServiceTests
|
|||
.Build();
|
||||
|
||||
Mocker.GetMock<IBuildFileNames>()
|
||||
.Setup(s => s.BuildFilename(It.IsAny<List<Episode>>(), It.IsAny<Series>(), It.IsAny<EpisodeFile>()))
|
||||
.Setup(s => s.BuildFileName(It.IsAny<List<Episode>>(), It.IsAny<Series>(), It.IsAny<EpisodeFile>(), null))
|
||||
.Returns("File Name");
|
||||
|
||||
Mocker.GetMock<IBuildFileNames>()
|
||||
.Setup(s => s.BuildFilePath(It.IsAny<Series>(), It.IsAny<Int32>(), It.IsAny<String>(), It.IsAny<String>()))
|
||||
.Returns(@"C:\Test\File Name.avi");
|
||||
.Returns(@"C:\Test\TV\Series\File Name.avi");
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(s => s.FileExists(It.IsAny<String>()))
|
||||
|
|
|
@ -9,6 +9,7 @@ using NzbDrone.Core.MediaFiles;
|
|||
using NzbDrone.Core.MediaFiles.EpisodeImport;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Profiles;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
@ -65,7 +66,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
|
|||
|
||||
_videoFiles = new List<string> { @"C:\Test\Unsorted\The.Office.S03E115.DVDRip.XviD-OSiTV.avi" };
|
||||
_series = Builder<Series>.CreateNew()
|
||||
.With(e => e.QualityProfile = new QualityProfile { Items = Qualities.QualityFixture.GetDefaultQualities() })
|
||||
.With(e => e.Profile = new Profile { Items = Qualities.QualityFixture.GetDefaultQualities() })
|
||||
.Build();
|
||||
|
||||
_quality = new QualityModel(Quality.DVD);
|
||||
|
@ -82,7 +83,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
|
|||
|
||||
|
||||
Mocker.GetMock<IMediaFileService>()
|
||||
.Setup(c => c.FilterExistingFiles(_videoFiles, It.IsAny<int>()))
|
||||
.Setup(c => c.FilterExistingFiles(_videoFiles, It.IsAny<Series>()))
|
||||
.Returns(_videoFiles);
|
||||
}
|
||||
|
||||
|
@ -162,7 +163,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
|
|||
|
||||
|
||||
Mocker.GetMock<IMediaFileService>()
|
||||
.Setup(c => c.FilterExistingFiles(_videoFiles, It.IsAny<int>()))
|
||||
.Setup(c => c.FilterExistingFiles(_videoFiles, It.IsAny<Series>()))
|
||||
.Returns(_videoFiles);
|
||||
|
||||
Subject.GetImportDecisions(_videoFiles, _series, false);
|
||||
|
|
|
@ -6,6 +6,7 @@ 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;
|
||||
|
@ -22,8 +23,8 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications
|
|||
public void Setup()
|
||||
{
|
||||
_series = Builder<Series>.CreateNew()
|
||||
.With(s => s.SeriesType = SeriesTypes.Standard)
|
||||
.With(e => e.QualityProfile = new QualityProfile { Items = Qualities.QualityFixture.GetDefaultQualities() })
|
||||
.With(s => s.SeriesType = SeriesTypes.Standard)
|
||||
.With(e => e.Profile = new Profile { Items = Qualities.QualityFixture.GetDefaultQualities() })
|
||||
.Build();
|
||||
|
||||
_localEpisode = new LocalEpisode
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
|
@ -9,6 +10,7 @@ using NzbDrone.Core.MediaFiles.EpisodeImport;
|
|||
using NzbDrone.Core.MediaFiles.Events;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Profiles;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
@ -29,7 +31,8 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
_approvedDecisions = new List<ImportDecision>();
|
||||
|
||||
var series = Builder<Series>.CreateNew()
|
||||
.With(e => e.QualityProfile = new QualityProfile { Items = Qualities.QualityFixture.GetDefaultQualities() })
|
||||
.With(e => e.Profile = new Profile { Items = Qualities.QualityFixture.GetDefaultQualities() })
|
||||
.With(s => s.Path = @"C:\Test\TV\30 Rock".AsOsAgnostic())
|
||||
.Build();
|
||||
|
||||
var episodes = Builder<Episode>.CreateListOfSize(5)
|
||||
|
@ -47,7 +50,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
{
|
||||
Series = series,
|
||||
Episodes = new List<Episode> {episode},
|
||||
Path = @"C:\Test\TV\30 Rock\30 Rock - S01E01 - Pilot.avi".AsOsAgnostic(),
|
||||
Path = Path.Combine(series.Path, "30 Rock - S01E01 - Pilot.avi"),
|
||||
Quality = new QualityModel(Quality.Bluray720p),
|
||||
ParsedEpisodeInfo = new ParsedEpisodeInfo
|
||||
{
|
||||
|
|
|
@ -4,7 +4,6 @@ using NUnit.Framework;
|
|||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.Test.MediaFiles
|
||||
{
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
|
@ -6,20 +7,24 @@ using NUnit.Framework;
|
|||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Organizer;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.MediaFiles
|
||||
namespace NzbDrone.Core.Test.MediaFiles.MediaFileServiceTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class MediaFileServiceTest : CoreTest<MediaFileService>
|
||||
public class FilterFixture : CoreTest<MediaFileService>
|
||||
{
|
||||
private Series _series;
|
||||
|
||||
[Test]
|
||||
[TestCase("Law & Order: Criminal Intent - S10E07 - Icarus [HDTV-720p]",
|
||||
"Law & Order- Criminal Intent - S10E07 - Icarus [HDTV-720p]")]
|
||||
public void CleanFileName(string name, string expectedName)
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
FileNameBuilder.CleanFilename(name).Should().Be(expectedName);
|
||||
_series = new Series
|
||||
{
|
||||
Id = 10,
|
||||
Path = @"C:\".AsOsAgnostic()
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -27,9 +32,9 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
{
|
||||
var files = new List<string>()
|
||||
{
|
||||
"c:\\file1.avi".AsOsAgnostic(),
|
||||
"c:\\file2.avi".AsOsAgnostic(),
|
||||
"c:\\file3.avi".AsOsAgnostic()
|
||||
"C:\\file1.avi".AsOsAgnostic(),
|
||||
"C:\\file2.avi".AsOsAgnostic(),
|
||||
"C:\\file3.avi".AsOsAgnostic()
|
||||
};
|
||||
|
||||
Mocker.GetMock<IMediaFileRepository>()
|
||||
|
@ -37,26 +42,25 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
.Returns(new List<EpisodeFile>());
|
||||
|
||||
|
||||
Subject.FilterExistingFiles(files, 10).Should().BeEquivalentTo(files);
|
||||
Subject.FilterExistingFiles(files, _series).Should().BeEquivalentTo(files);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void filter_should_return_none_if_all_files_exist()
|
||||
{
|
||||
var files = new List<string>()
|
||||
{
|
||||
"c:\\file1.avi".AsOsAgnostic(),
|
||||
"c:\\file2.avi".AsOsAgnostic(),
|
||||
"c:\\file3.avi".AsOsAgnostic()
|
||||
"C:\\file1.avi".AsOsAgnostic(),
|
||||
"C:\\file2.avi".AsOsAgnostic(),
|
||||
"C:\\file3.avi".AsOsAgnostic()
|
||||
};
|
||||
|
||||
Mocker.GetMock<IMediaFileRepository>()
|
||||
.Setup(c => c.GetFilesBySeries(It.IsAny<int>()))
|
||||
.Returns(files.Select(f => new EpisodeFile { Path = f }).ToList());
|
||||
.Returns(files.Select(f => new EpisodeFile { RelativePath = Path.GetFileName(f) }).ToList());
|
||||
|
||||
|
||||
Subject.FilterExistingFiles(files, 10).Should().BeEmpty();
|
||||
Subject.FilterExistingFiles(files, _series).Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -64,21 +68,21 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
{
|
||||
var files = new List<string>()
|
||||
{
|
||||
"c:\\file1.avi".AsOsAgnostic(),
|
||||
"c:\\file2.avi".AsOsAgnostic(),
|
||||
"c:\\file3.avi".AsOsAgnostic()
|
||||
"C:\\file1.avi".AsOsAgnostic(),
|
||||
"C:\\file2.avi".AsOsAgnostic(),
|
||||
"C:\\file3.avi".AsOsAgnostic()
|
||||
};
|
||||
|
||||
Mocker.GetMock<IMediaFileRepository>()
|
||||
.Setup(c => c.GetFilesBySeries(It.IsAny<int>()))
|
||||
.Returns(new List<EpisodeFile>
|
||||
{
|
||||
new EpisodeFile{Path = "c:\\file2.avi".AsOsAgnostic()}
|
||||
new EpisodeFile{ RelativePath = "file2.avi".AsOsAgnostic()}
|
||||
});
|
||||
|
||||
|
||||
Subject.FilterExistingFiles(files, 10).Should().HaveCount(2);
|
||||
Subject.FilterExistingFiles(files, 10).Should().NotContain("c:\\file2.avi".AsOsAgnostic());
|
||||
Subject.FilterExistingFiles(files, _series).Should().HaveCount(2);
|
||||
Subject.FilterExistingFiles(files, _series).Should().NotContain("C:\\file2.avi".AsOsAgnostic());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -88,21 +92,21 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
|
||||
var files = new List<string>()
|
||||
{
|
||||
"c:\\file1.avi".AsOsAgnostic(),
|
||||
"c:\\FILE2.avi".AsOsAgnostic(),
|
||||
"c:\\file3.avi".AsOsAgnostic()
|
||||
"C:\\file1.avi".AsOsAgnostic(),
|
||||
"C:\\FILE2.avi".AsOsAgnostic(),
|
||||
"C:\\file3.avi".AsOsAgnostic()
|
||||
};
|
||||
|
||||
Mocker.GetMock<IMediaFileRepository>()
|
||||
.Setup(c => c.GetFilesBySeries(It.IsAny<int>()))
|
||||
.Returns(new List<EpisodeFile>
|
||||
{
|
||||
new EpisodeFile{Path = "c:\\file2.avi".AsOsAgnostic()}
|
||||
new EpisodeFile{ RelativePath = "file2.avi".AsOsAgnostic()}
|
||||
});
|
||||
|
||||
|
||||
Subject.FilterExistingFiles(files, 10).Should().HaveCount(2);
|
||||
Subject.FilterExistingFiles(files, 10).Should().NotContain("c:\\file2.avi".AsOsAgnostic());
|
||||
Subject.FilterExistingFiles(files, _series).Should().HaveCount(2);
|
||||
Subject.FilterExistingFiles(files, _series).Should().NotContain("C:\\file2.avi".AsOsAgnostic());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -112,19 +116,19 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
|
||||
var files = new List<string>()
|
||||
{
|
||||
"c:\\file1.avi".AsOsAgnostic(),
|
||||
"c:\\FILE2.avi".AsOsAgnostic(),
|
||||
"c:\\file3.avi".AsOsAgnostic()
|
||||
"C:\\file1.avi".AsOsAgnostic(),
|
||||
"C:\\FILE2.avi".AsOsAgnostic(),
|
||||
"C:\\file3.avi".AsOsAgnostic()
|
||||
};
|
||||
|
||||
Mocker.GetMock<IMediaFileRepository>()
|
||||
.Setup(c => c.GetFilesBySeries(It.IsAny<int>()))
|
||||
.Returns(new List<EpisodeFile>
|
||||
{
|
||||
new EpisodeFile{Path = "c:\\file2.avi".AsOsAgnostic()}
|
||||
new EpisodeFile{ RelativePath = "file2.avi".AsOsAgnostic()}
|
||||
});
|
||||
|
||||
Subject.FilterExistingFiles(files, 10).Should().HaveCount(3);
|
||||
Subject.FilterExistingFiles(files, _series).Should().HaveCount(3);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -132,16 +136,16 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
{
|
||||
var files = new List<string>()
|
||||
{
|
||||
"c:\\FILE1.avi".AsOsAgnostic()
|
||||
"C:\\FILE1.avi".AsOsAgnostic()
|
||||
};
|
||||
|
||||
Mocker.GetMock<IMediaFileRepository>()
|
||||
.Setup(c => c.GetFilesBySeries(It.IsAny<int>()))
|
||||
.Returns(new List<EpisodeFile>());
|
||||
|
||||
Subject.FilterExistingFiles(files, 10).Should().HaveCount(1);
|
||||
Subject.FilterExistingFiles(files, 10).Should().NotContain(files.First().ToLower());
|
||||
Subject.FilterExistingFiles(files, 10).Should().Contain(files.First());
|
||||
Subject.FilterExistingFiles(files, _series).Should().HaveCount(1);
|
||||
Subject.FilterExistingFiles(files, _series).Should().NotContain(files.First().ToLower());
|
||||
Subject.FilterExistingFiles(files, _series).Should().Contain(files.First());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -30,7 +30,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
.Returns(Builder<Series>.CreateNew().Build());
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(e => e.FileExists(It.Is<String>(c => c != DELETED_PATH)))
|
||||
.Setup(e => e.FileExists(It.Is<String>(c => !c.Contains(DELETED_PATH))))
|
||||
.Returns(true);
|
||||
|
||||
Mocker.GetMock<IEpisodeService>()
|
||||
|
@ -68,18 +68,18 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
}
|
||||
|
||||
[Test]
|
||||
public void should_delete_none_existing_files()
|
||||
public void should_delete_non_existent_files()
|
||||
{
|
||||
var episodeFiles = Builder<EpisodeFile>.CreateListOfSize(10)
|
||||
.Random(2)
|
||||
.With(c => c.Path = DELETED_PATH)
|
||||
.With(c => c.RelativePath = DELETED_PATH)
|
||||
.Build();
|
||||
|
||||
GivenEpisodeFiles(episodeFiles);
|
||||
|
||||
Subject.Execute(new CleanMediaFileDb(0));
|
||||
|
||||
Mocker.GetMock<IMediaFileService>().Verify(c => c.Delete(It.Is<EpisodeFile>(e => e.Path == DELETED_PATH), false), Times.Exactly(2));
|
||||
Mocker.GetMock<IMediaFileService>().Verify(c => c.Delete(It.Is<EpisodeFile>(e => e.RelativePath == DELETED_PATH), false), Times.Exactly(2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -87,7 +87,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
{
|
||||
var episodeFiles = Builder<EpisodeFile>.CreateListOfSize(10)
|
||||
.Random(10)
|
||||
.With(c => c.Path = "ExistingPath")
|
||||
.With(c => c.RelativePath = "ExistingPath")
|
||||
.Build();
|
||||
|
||||
GivenEpisodeFiles(episodeFiles);
|
||||
|
@ -98,21 +98,6 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
Mocker.GetMock<IMediaFileService>().Verify(c => c.Delete(It.IsAny<EpisodeFile>(), false), Times.Exactly(10));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_delete_files_that_do_not_belong_to_the_series_path()
|
||||
{
|
||||
var episodeFiles = Builder<EpisodeFile>.CreateListOfSize(10)
|
||||
.Random(10)
|
||||
.With(c => c.Path = "ExistingPath")
|
||||
.Build();
|
||||
|
||||
GivenEpisodeFiles(episodeFiles);
|
||||
|
||||
Subject.Execute(new CleanMediaFileDb(0));
|
||||
|
||||
Mocker.GetMock<IMediaFileService>().Verify(c => c.Delete(It.IsAny<EpisodeFile>(), false), Times.Exactly(10));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_unlink_episode_when_episodeFile_does_not_exist()
|
||||
{
|
||||
|
@ -128,7 +113,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
{
|
||||
var episodeFiles = Builder<EpisodeFile>.CreateListOfSize(10)
|
||||
.Random(10)
|
||||
.With(c => c.Path = "ExistingPath")
|
||||
.With(c => c.RelativePath = "ExistingPath")
|
||||
.Build();
|
||||
|
||||
GivenEpisodeFiles(episodeFiles);
|
||||
|
|
|
@ -0,0 +1,128 @@
|
|||
using System.IO;
|
||||
using FizzWare.NBuilder;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.MediaFiles.Events;
|
||||
using NzbDrone.Core.MediaFiles.MediaInfo;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Test.Common;
|
||||
using System;
|
||||
|
||||
namespace NzbDrone.Core.Test.MediaFiles.MediaInfo
|
||||
{
|
||||
[TestFixture]
|
||||
public class UpdateMediaInfoServiceFixture : CoreTest<UpdateMediaInfoService>
|
||||
{
|
||||
private Series _series;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_series = new Series
|
||||
{
|
||||
Id = 1,
|
||||
Path = @"C:\series".AsOsAgnostic()
|
||||
};
|
||||
}
|
||||
|
||||
private void GivenFileExists()
|
||||
{
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(v => v.FileExists(It.IsAny<String>()))
|
||||
.Returns(true);
|
||||
}
|
||||
|
||||
private void GivenSuccessfulScan()
|
||||
{
|
||||
Mocker.GetMock<IVideoFileInfoReader>()
|
||||
.Setup(v => v.GetMediaInfo(It.IsAny<String>()))
|
||||
.Returns(new MediaInfoModel());
|
||||
}
|
||||
|
||||
private void GivenFailedScan(String path)
|
||||
{
|
||||
Mocker.GetMock<IVideoFileInfoReader>()
|
||||
.Setup(v => v.GetMediaInfo(path))
|
||||
.Returns((MediaInfoModel)null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_get_for_existing_episodefile_on_after_series_scan()
|
||||
{
|
||||
var episodeFiles = Builder<EpisodeFile>.CreateListOfSize(3)
|
||||
.All()
|
||||
.With(v => v.RelativePath = "media.mkv")
|
||||
.TheFirst(1)
|
||||
.With(v => v.MediaInfo = new MediaInfoModel())
|
||||
.BuildList();
|
||||
|
||||
Mocker.GetMock<IMediaFileService>()
|
||||
.Setup(v => v.GetFilesBySeries(1))
|
||||
.Returns(episodeFiles);
|
||||
|
||||
GivenFileExists();
|
||||
GivenSuccessfulScan();
|
||||
|
||||
Subject.Handle(new SeriesScannedEvent(_series));
|
||||
|
||||
Mocker.GetMock<IVideoFileInfoReader>()
|
||||
.Verify(v => v.GetMediaInfo(Path.Combine(_series.Path, "media.mkv")), Times.Exactly(2));
|
||||
|
||||
Mocker.GetMock<IMediaFileService>()
|
||||
.Verify(v => v.Update(It.IsAny<EpisodeFile>()), Times.Exactly(2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_ignore_missing_files()
|
||||
{
|
||||
var episodeFiles = Builder<EpisodeFile>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(v => v.RelativePath = "media.mkv")
|
||||
.BuildList();
|
||||
|
||||
Mocker.GetMock<IMediaFileService>()
|
||||
.Setup(v => v.GetFilesBySeries(1))
|
||||
.Returns(episodeFiles);
|
||||
|
||||
GivenSuccessfulScan();
|
||||
|
||||
Subject.Handle(new SeriesScannedEvent(_series));
|
||||
|
||||
Mocker.GetMock<IVideoFileInfoReader>()
|
||||
.Verify(v => v.GetMediaInfo("media.mkv"), Times.Never());
|
||||
|
||||
Mocker.GetMock<IMediaFileService>()
|
||||
.Verify(v => v.Update(It.IsAny<EpisodeFile>()), Times.Never());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_continue_after_failure()
|
||||
{
|
||||
var episodeFiles = Builder<EpisodeFile>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(v => v.RelativePath = "media.mkv")
|
||||
.TheFirst(1)
|
||||
.With(v => v.RelativePath = "media2.mkv")
|
||||
.BuildList();
|
||||
|
||||
Mocker.GetMock<IMediaFileService>()
|
||||
.Setup(v => v.GetFilesBySeries(1))
|
||||
.Returns(episodeFiles);
|
||||
|
||||
GivenFileExists();
|
||||
GivenSuccessfulScan();
|
||||
GivenFailedScan(Path.Combine(_series.Path, "media2.mkv"));
|
||||
|
||||
Subject.Handle(new SeriesScannedEvent(_series));
|
||||
|
||||
Mocker.GetMock<IVideoFileInfoReader>()
|
||||
.Verify(v => v.GetMediaInfo(Path.Combine(_series.Path, "media.mkv")), Times.Exactly(1));
|
||||
|
||||
Mocker.GetMock<IMediaFileService>()
|
||||
.Verify(v => v.Update(It.IsAny<EpisodeFile>()), Times.Exactly(1));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@ using NzbDrone.Core.MediaFiles;
|
|||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.MediaFiles
|
||||
{
|
||||
|
@ -22,6 +23,10 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
public void Setup()
|
||||
{
|
||||
_localEpisode = new LocalEpisode();
|
||||
_localEpisode.Series = new Series
|
||||
{
|
||||
Path = @"C:\Test\TV\Series".AsOsAgnostic()
|
||||
};
|
||||
|
||||
_episodeFile = Builder<EpisodeFile>
|
||||
.CreateNew()
|
||||
|
@ -42,7 +47,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
new EpisodeFile
|
||||
{
|
||||
Id = 1,
|
||||
Path = @"C:\Test\30 Rock\Season 01\30.rock.s01e01.avi",
|
||||
RelativePath = @"Season 01\30.rock.s01e01.avi",
|
||||
}))
|
||||
.Build()
|
||||
.ToList();
|
||||
|
@ -57,7 +62,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
new EpisodeFile
|
||||
{
|
||||
Id = 1,
|
||||
Path = @"C:\Test\30 Rock\Season 01\30.rock.s01e01.avi",
|
||||
RelativePath = @"Season 01\30.rock.s01e01.avi",
|
||||
}))
|
||||
.Build()
|
||||
.ToList();
|
||||
|
@ -71,14 +76,14 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
new EpisodeFile
|
||||
{
|
||||
Id = 1,
|
||||
Path = @"C:\Test\30 Rock\Season 01\30.rock.s01e01.avi",
|
||||
RelativePath = @"Season 01\30.rock.s01e01.avi",
|
||||
}))
|
||||
.TheNext(1)
|
||||
.With(e => e.EpisodeFile = new LazyLoaded<EpisodeFile>(
|
||||
new EpisodeFile
|
||||
{
|
||||
Id = 2,
|
||||
Path = @"C:\Test\30 Rock\Season 01\30.rock.s01e02.avi",
|
||||
RelativePath = @"Season 01\30.rock.s01e02.avi",
|
||||
}))
|
||||
.Build()
|
||||
.ToList();
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
using FluentAssertions;
|
||||
using Moq;
|
||||
using System;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Notifications.Xbmc;
|
||||
using NzbDrone.Core.Notifications.Xbmc.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
@ -17,16 +16,15 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc
|
|||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_settings = new XbmcSettings
|
||||
{
|
||||
Host = "localhost",
|
||||
Port = 8080,
|
||||
Username = "xbmc",
|
||||
Password = "xbmc",
|
||||
AlwaysUpdate = false,
|
||||
CleanLibrary = false,
|
||||
UpdateLibrary = true
|
||||
};
|
||||
_settings = Builder<XbmcSettings>.CreateNew()
|
||||
.Build();
|
||||
}
|
||||
|
||||
private void GivenVersionResponse(String response)
|
||||
{
|
||||
Mocker.GetMock<IXbmcJsonApiProxy>()
|
||||
.Setup(s => s.GetJsonVersion(_settings))
|
||||
.Returns(response);
|
||||
}
|
||||
|
||||
[TestCase(3)]
|
||||
|
@ -34,11 +32,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc
|
|||
[TestCase(0)]
|
||||
public void should_get_version_from_major_only(int number)
|
||||
{
|
||||
var message = "{\"id\":10,\"jsonrpc\":\"2.0\",\"result\":{\"version\":" + number + "}}";
|
||||
|
||||
var fakeHttp = Mocker.GetMock<IHttpProvider>();
|
||||
fakeHttp.Setup(s => s.PostCommand("localhost:8080", "xbmc", "xbmc", It.IsAny<string>()))
|
||||
.Returns(message);
|
||||
GivenVersionResponse("{\"id\":10,\"jsonrpc\":\"2.0\",\"result\":{\"version\":" + number + "}}");
|
||||
|
||||
Subject.GetJsonVersion(_settings).Should().Be(new XbmcVersion(number));
|
||||
}
|
||||
|
@ -50,11 +44,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc
|
|||
[TestCase(0, 0, 0)]
|
||||
public void should_get_version_from_semantic_version(int major, int minor, int patch)
|
||||
{
|
||||
var message = "{\"id\":10,\"jsonrpc\":\"2.0\",\"result\":{\"version\":{\"major\":" + major + ",\"minor\":" + minor + ",\"patch\":" + patch + "}}}";
|
||||
|
||||
var fakeHttp = Mocker.GetMock<IHttpProvider>();
|
||||
fakeHttp.Setup(s => s.PostCommand("localhost:8080", "xbmc", "xbmc", It.IsAny<string>()))
|
||||
.Returns(message);
|
||||
GivenVersionResponse("{\"id\":10,\"jsonrpc\":\"2.0\",\"result\":{\"version\":{\"major\":" + major + ",\"minor\":" + minor + ",\"patch\":" + patch + "}}}");
|
||||
|
||||
Subject.GetJsonVersion(_settings).Should().Be(new XbmcVersion(major, minor, patch));
|
||||
}
|
||||
|
@ -62,11 +52,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc
|
|||
[Test]
|
||||
public void should_get_version_zero_when_an_error_is_received()
|
||||
{
|
||||
var message = "{\"error\":{\"code\":-32601,\"message\":\"Method not found.\"},\"id\":10,\"jsonrpc\":\"2.0\"}";
|
||||
|
||||
var fakeHttp = Mocker.GetMock<IHttpProvider>();
|
||||
fakeHttp.Setup(s => s.PostCommand("localhost:8080", "xbmc", "xbmc", It.IsAny<string>()))
|
||||
.Returns(message);
|
||||
GivenVersionResponse("{\"error\":{\"code\":-32601,\"message\":\"Method not found.\"},\"id\":10,\"jsonrpc\":\"2.0\"}");
|
||||
|
||||
Subject.GetJsonVersion(_settings).Should().Be(new XbmcVersion(0));
|
||||
}
|
||||
|
|
|
@ -1,120 +0,0 @@
|
|||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Notifications.Xbmc;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json
|
||||
{
|
||||
[TestFixture]
|
||||
public class ActivePlayersFixture : CoreTest<JsonApiProvider>
|
||||
{
|
||||
private XbmcSettings _settings;
|
||||
|
||||
private void WithNoActivePlayers()
|
||||
{
|
||||
Mocker.GetMock<IHttpProvider>()
|
||||
.Setup(s => s.PostCommand(_settings.Address, _settings.Username, _settings.Password, It.IsAny<string>()))
|
||||
.Returns("{\"id\":10,\"jsonrpc\":\"2.0\",\"result\":[]}");
|
||||
}
|
||||
|
||||
private void WithVideoPlayerActive()
|
||||
{
|
||||
Mocker.GetMock<IHttpProvider>()
|
||||
.Setup(s => s.PostCommand(_settings.Address, _settings.Username, _settings.Password, It.IsAny<string>()))
|
||||
.Returns("{\"id\":10,\"jsonrpc\":\"2.0\",\"result\":[{\"playerid\":1,\"type\":\"video\"}]}");
|
||||
}
|
||||
|
||||
private void WithAudioPlayerActive()
|
||||
{
|
||||
Mocker.GetMock<IHttpProvider>()
|
||||
.Setup(s => s.PostCommand(_settings.Address, _settings.Username, _settings.Password, It.IsAny<string>()))
|
||||
.Returns("{\"id\":10,\"jsonrpc\":\"2.0\",\"result\":[{\"playerid\":1,\"type\":\"audio\"}]}");
|
||||
}
|
||||
|
||||
private void WithPicturePlayerActive()
|
||||
{
|
||||
Mocker.GetMock<IHttpProvider>()
|
||||
.Setup(s => s.PostCommand(_settings.Address, _settings.Username, _settings.Password, It.IsAny<string>()))
|
||||
.Returns("{\"id\":10,\"jsonrpc\":\"2.0\",\"result\":[{\"playerid\":1,\"type\":\"picture\"}]}");
|
||||
}
|
||||
|
||||
private void WithAllPlayersActive()
|
||||
{
|
||||
Mocker.GetMock<IHttpProvider>()
|
||||
.Setup(s => s.PostCommand(_settings.Address, _settings.Username, _settings.Password, It.IsAny<string>()))
|
||||
.Returns("{\"id\":10,\"jsonrpc\":\"2.0\",\"result\":[{\"playerid\":1,\"type\":\"audio\"},{\"playerid\":2,\"type\":\"picture\"},{\"playerid\":3,\"type\":\"video\"}]}");
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_settings = new XbmcSettings
|
||||
{
|
||||
Host = "localhost",
|
||||
Port = 8080,
|
||||
Username = "xbmc",
|
||||
Password = "xbmc",
|
||||
AlwaysUpdate = false,
|
||||
CleanLibrary = false,
|
||||
UpdateLibrary = true
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void _should_be_empty_when_no_active_players()
|
||||
{
|
||||
WithNoActivePlayers();
|
||||
|
||||
Subject.GetActivePlayers(_settings).Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_have_active_video_player()
|
||||
{
|
||||
WithVideoPlayerActive();
|
||||
|
||||
var result = Subject.GetActivePlayers(_settings);
|
||||
|
||||
result.Should().HaveCount(1);
|
||||
result.First().Type.Should().Be("video");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_have_active_audio_player()
|
||||
{
|
||||
WithAudioPlayerActive();
|
||||
|
||||
var result = Subject.GetActivePlayers(_settings);
|
||||
|
||||
result.Should().HaveCount(1);
|
||||
result.First().Type.Should().Be("audio");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_have_active_picture_player()
|
||||
{
|
||||
WithPicturePlayerActive();
|
||||
|
||||
var result = Subject.GetActivePlayers(_settings);
|
||||
|
||||
result.Should().HaveCount(1);
|
||||
result.First().Type.Should().Be("picture");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_have_all_players_active()
|
||||
{
|
||||
WithAllPlayersActive();
|
||||
|
||||
var result = Subject.GetActivePlayers(_settings);
|
||||
|
||||
result.Should().HaveCount(3);
|
||||
result.Select(a => a.PlayerId).Distinct().Should().HaveCount(3);
|
||||
result.Select(a => a.Type).Distinct().Should().HaveCount(3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
using System;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Notifications.Xbmc;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json
|
||||
{
|
||||
[TestFixture]
|
||||
public class CheckForErrorFixture : CoreTest<JsonApiProvider>
|
||||
{
|
||||
[Test]
|
||||
public void should_be_true_when_the_response_contains_an_error()
|
||||
{
|
||||
const string response = "{\"error\":{\"code\":-32601,\"message\":\"Method not found.\"},\"id\":10,\"jsonrpc\":\"2.0\"}";
|
||||
|
||||
Subject.CheckForError(response).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void JsonError_true_empty_response()
|
||||
{
|
||||
var response = String.Empty;
|
||||
|
||||
Subject.CheckForError(response).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void JsonError_false()
|
||||
{
|
||||
const string response = "{\"id\":10,\"jsonrpc\":\"2.0\",\"result\":{\"version\":3}}";
|
||||
|
||||
Subject.CheckForError(response).Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,9 +1,14 @@
|
|||
using FluentAssertions;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Notifications.Xbmc;
|
||||
using NzbDrone.Core.Notifications.Xbmc.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
|
@ -15,42 +20,28 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json
|
|||
private XbmcSettings _settings;
|
||||
private Series _series;
|
||||
private string _response;
|
||||
private List<TvShow> _xbmcSeries;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_settings = new XbmcSettings
|
||||
{
|
||||
Host = "localhost",
|
||||
Port = 8080,
|
||||
Username = "xbmc",
|
||||
Password = "xbmc",
|
||||
AlwaysUpdate = false,
|
||||
CleanLibrary = false,
|
||||
UpdateLibrary = true
|
||||
};
|
||||
_settings = Builder<XbmcSettings>.CreateNew()
|
||||
.Build();
|
||||
|
||||
_response = "{\"id\":10,\"jsonrpc\":\"2.0\",\"result\":{\"limits\":" +
|
||||
"{\"end\":5,\"start\":0,\"total\":5},\"tvshows\":[{\"file\"" +
|
||||
":\"smb://HOMESERVER/TV/7th Heaven/\",\"imdbnumber\":\"73928\"," +
|
||||
"\"label\":\"7th Heaven\",\"tvshowid\":3},{\"file\":\"smb://HOMESERVER/TV/8 Simple Rules/\"" +
|
||||
",\"imdbnumber\":\"78461\",\"label\":\"8 Simple Rules\",\"tvshowid\":4},{\"file\":" +
|
||||
"\"smb://HOMESERVER/TV/24-7 Penguins-Capitals- Road to the NHL Winter Classic/\",\"imdbnumber\"" +
|
||||
":\"213041\",\"label\":\"24/7 Penguins/Capitals: Road to the NHL Winter Classic\",\"tvshowid\":1}," +
|
||||
"{\"file\":\"smb://HOMESERVER/TV/30 Rock/\",\"imdbnumber\":\"79488\",\"label\":\"30 Rock\",\"tvshowid\":2}" +
|
||||
",{\"file\":\"smb://HOMESERVER/TV/90210/\",\"imdbnumber\":\"82716\",\"label\":\"90210\",\"tvshowid\":5}]}}";
|
||||
_xbmcSeries = Builder<TvShow>.CreateListOfSize(3)
|
||||
.Build()
|
||||
.ToList();
|
||||
|
||||
Mocker.GetMock<IHttpProvider>()
|
||||
.Setup(
|
||||
s => s.PostCommand(_settings.Address, _settings.Username, _settings.Password, It.IsAny<string>()))
|
||||
.Returns(_response);
|
||||
Mocker.GetMock<IXbmcJsonApiProxy>()
|
||||
.Setup(s => s.GetSeries(_settings))
|
||||
.Returns(_xbmcSeries);
|
||||
}
|
||||
|
||||
private void WithMatchingTvdbId()
|
||||
{
|
||||
_series = new Series
|
||||
{
|
||||
TvdbId = 78461,
|
||||
TvdbId = _xbmcSeries.First().ImdbNumber,
|
||||
Title = "TV Show"
|
||||
};
|
||||
}
|
||||
|
@ -59,8 +50,8 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json
|
|||
{
|
||||
_series = new Series
|
||||
{
|
||||
TvdbId = 1,
|
||||
Title = "30 Rock"
|
||||
TvdbId = 1000,
|
||||
Title = _xbmcSeries.First().Label
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -68,7 +59,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json
|
|||
{
|
||||
_series = new Series
|
||||
{
|
||||
TvdbId = 1,
|
||||
TvdbId = 1000,
|
||||
Title = "Does not exist"
|
||||
};
|
||||
}
|
||||
|
@ -86,7 +77,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json
|
|||
{
|
||||
WithMatchingTvdbId();
|
||||
|
||||
Subject.GetSeriesPath(_settings, _series).Should().Be("smb://HOMESERVER/TV/8 Simple Rules/");
|
||||
Subject.GetSeriesPath(_settings, _series).Should().Be(_xbmcSeries.First().File);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -94,7 +85,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json
|
|||
{
|
||||
WithMatchingTitle();
|
||||
|
||||
Subject.GetSeriesPath(_settings, _series).Should().Be("smb://HOMESERVER/TV/30 Rock/");
|
||||
Subject.GetSeriesPath(_settings, _series).Should().Be(_xbmcSeries.First().File);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Notifications.Xbmc;
|
||||
using NzbDrone.Core.Notifications.Xbmc.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
|
@ -14,88 +15,53 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json
|
|||
public class UpdateFixture : CoreTest<JsonApiProvider>
|
||||
{
|
||||
private XbmcSettings _settings;
|
||||
const string _expectedJson = "{\"jsonrpc\":\"2.0\",\"method\":\"VideoLibrary.GetTvShows\",\"params\":{\"properties\":[\"file\",\"imdbnumber\"]},\"id\":";
|
||||
|
||||
private const string _tvshowsResponse = "{\"id\":10,\"jsonrpc\":\"2.0\",\"result\":{\"limits\":" +
|
||||
"{\"end\":5,\"start\":0,\"total\":5},\"tvshows\":[{\"file\"" +
|
||||
":\"smb://HOMESERVER/TV/7th Heaven/\",\"imdbnumber\":\"73928\"," +
|
||||
"\"label\":\"7th Heaven\",\"tvshowid\":3},{\"file\":\"smb://HOMESERVER/TV/8 Simple Rules/\"" +
|
||||
",\"imdbnumber\":\"78461\",\"label\":\"8 Simple Rules\",\"tvshowid\":4},{\"file\":" +
|
||||
"\"smb://HOMESERVER/TV/24-7 Penguins-Capitals- Road to the NHL Winter Classic/\",\"imdbnumber\"" +
|
||||
":\"213041\",\"label\":\"24/7 Penguins/Capitals: Road to the NHL Winter Classic\",\"tvshowid\":1}," +
|
||||
"{\"file\":\"smb://HOMESERVER/TV/30 Rock/\",\"imdbnumber\":\"79488\",\"label\":\"30 Rock\",\"tvshowid\":2}" +
|
||||
",{\"file\":\"smb://HOMESERVER/TV/90210/\",\"imdbnumber\":\"82716\",\"label\":\"90210\",\"tvshowid\":5}]}}";
|
||||
private Series _series;
|
||||
private List<TvShow> _xbmcSeries;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_settings = new XbmcSettings
|
||||
{
|
||||
Host = "localhost",
|
||||
Port = 8080,
|
||||
Username = "xbmc",
|
||||
Password = "xbmc",
|
||||
AlwaysUpdate = false,
|
||||
CleanLibrary = false,
|
||||
UpdateLibrary = true
|
||||
};
|
||||
_settings = Builder<XbmcSettings>.CreateNew()
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<IHttpProvider>()
|
||||
.Setup(s => s.PostCommand(_settings.Address, _settings.Username, _settings.Password,
|
||||
It.Is<string>(e => e.Replace(" ", "").Replace("\r\n", "").Replace("\t", "").Contains(_expectedJson.Replace(" ", "")))))
|
||||
.Returns(_tvshowsResponse);
|
||||
_xbmcSeries = Builder<TvShow>.CreateListOfSize(3)
|
||||
.Build()
|
||||
.ToList();
|
||||
|
||||
Mocker.GetMock<IXbmcJsonApiProxy>()
|
||||
.Setup(s => s.GetSeries(_settings))
|
||||
.Returns(_xbmcSeries);
|
||||
|
||||
Mocker.GetMock<IXbmcJsonApiProxy>()
|
||||
.Setup(s => s.GetActivePlayers(_settings))
|
||||
.Returns(new List<ActivePlayer>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_update_using_series_path()
|
||||
{
|
||||
var fakeSeries = Builder<Series>.CreateNew()
|
||||
.With(s => s.TvdbId = 79488)
|
||||
.With(s => s.Title = "30 Rock")
|
||||
.Build();
|
||||
var series = Builder<Series>.CreateNew()
|
||||
.With(s => s.TvdbId = _xbmcSeries.First().ImdbNumber)
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<IHttpProvider>()
|
||||
.Setup(s => s.PostCommand(_settings.Address, _settings.Username, _settings.Password, It.Is<String>(
|
||||
e => e.Replace(" ", "")
|
||||
.Replace("\r\n", "")
|
||||
.Replace("\t", "")
|
||||
.Contains("\"params\":{\"directory\":\"smb://HOMESERVER/TV/30Rock/\"}"))))
|
||||
.Returns("{\"id\":55,\"jsonrpc\":\"2.0\",\"result\":\"OK\"}");
|
||||
Subject.Update(_settings, series);
|
||||
|
||||
Subject.Update(_settings, fakeSeries);
|
||||
|
||||
Mocker.GetMock<IHttpProvider>()
|
||||
.Verify(s => s.PostCommand(_settings.Address, _settings.Username, _settings.Password, It.Is<String>(
|
||||
e => e.Replace(" ", "")
|
||||
.Replace("\r\n", "")
|
||||
.Replace("\t", "")
|
||||
.Contains("\"params\":{\"directory\":\"smb://HOMESERVER/TV/30Rock/\"}"))), Times.Once());
|
||||
Mocker.GetMock<IXbmcJsonApiProxy>()
|
||||
.Verify(v => v.UpdateLibrary(_settings, It.IsAny<String>()), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_update_all_paths_when_series_path_not_found()
|
||||
{
|
||||
var fakeSeries = Builder<Series>.CreateNew()
|
||||
.With(s => s.TvdbId = 1)
|
||||
.With(s => s.Title = "Not 30 Rock")
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<IHttpProvider>()
|
||||
.Setup(s => s.PostCommand(_settings.Address, _settings.Username, _settings.Password, It.Is<String>(
|
||||
e => !e.Replace(" ", "")
|
||||
.Replace("\r\n", "")
|
||||
.Replace("\t", "")
|
||||
.Contains("\"params\":{\"directory\":\"smb://HOMESERVER/TV/30Rock/\"}"))))
|
||||
.Returns("{\"id\":55,\"jsonrpc\":\"2.0\",\"result\":\"OK\"}");
|
||||
.With(s => s.TvdbId = 1000)
|
||||
.With(s => s.Title = "Not 30 Rock")
|
||||
.Build();
|
||||
|
||||
Subject.Update(_settings, fakeSeries);
|
||||
|
||||
Mocker.GetMock<IHttpProvider>()
|
||||
.Verify(s => s.PostCommand(_settings.Address, _settings.Username, _settings.Password, It.Is<String>(
|
||||
e => e.Replace(" ", "")
|
||||
.Replace("\r\n", "")
|
||||
.Replace("\t", "")
|
||||
.Contains("\"params\":{\"directory\":\"smb://HOMESERVER/TV/30Rock/\"}"))), Times.Never());
|
||||
Mocker.GetMock<IXbmcJsonApiProxy>()
|
||||
.Verify(v => v.UpdateLibrary(_settings, null), Times.Once());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,17 +40,14 @@
|
|||
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="AutoMoq">
|
||||
<HintPath>..\packages\AutoMoq.1.6.1\lib\AutoMoq.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Microsoft.Practices.Unity.Configuration">
|
||||
<HintPath>..\packages\Unity.2.1.505.2\lib\NET35\Microsoft.Practices.Unity.Configuration.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="AutoMoq">
|
||||
<HintPath>..\packages\AutoMoq.1.6.1\lib\AutoMoq.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FizzWare.NBuilder, Version=3.0.1.0, Culture=neutral, PublicKeyToken=5651b03e12e42c12">
|
||||
<HintPath>..\packages\NBuilder.3.0.1.1\lib\FizzWare.NBuilder.dll</HintPath>
|
||||
</Reference>
|
||||
|
@ -72,6 +69,9 @@
|
|||
<Reference Include="Microsoft.Practices.Unity">
|
||||
<HintPath>..\packages\Unity.2.1.505.2\lib\NET35\Microsoft.Practices.Unity.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Practices.Unity.Configuration">
|
||||
<HintPath>..\packages\Unity.2.1.505.2\lib\NET35\Microsoft.Practices.Unity.Configuration.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Moq, Version=4.0.10827.0, Culture=neutral, PublicKeyToken=69f491c39445e920">
|
||||
<HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
|
||||
</Reference>
|
||||
|
@ -92,55 +92,76 @@
|
|||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Blacklisting\BlacklistServiceFixture.cs" />
|
||||
<Compile Include="Blacklisting\BlacklistRepositoryFixture.cs" />
|
||||
<Compile Include="Blacklisting\BlacklistServiceFixture.cs" />
|
||||
<Compile Include="Configuration\ConfigCachingFixture.cs" />
|
||||
<Compile Include="Configuration\ConfigServiceFixture.cs" />
|
||||
<Compile Include="DataAugmentationFixture\Scene\SceneMappingProxyFixture.cs" />
|
||||
<Compile Include="DataAugmentationFixture\Scene\SceneMappingServiceFixture.cs" />
|
||||
<Compile Include="Datastore\MarrDataLazyLoadingFixture.cs" />
|
||||
<Compile Include="Datastore\BasicRepositoryFixture.cs" />
|
||||
<Compile Include="Datastore\Converters\ProviderSettingConverterFixture.cs" />
|
||||
<Compile Include="Datastore\DatabaseFixture.cs" />
|
||||
<Compile Include="Datastore\DatabaseRelationshipFixture.cs" />
|
||||
<Compile Include="Datastore\MappingExtentionFixture.cs" />
|
||||
<Compile Include="Datastore\MarrDataLazyLoadingFixture.cs" />
|
||||
<Compile Include="Datastore\ObjectDatabaseFixture.cs" />
|
||||
<Compile Include="Datastore\PagingSpecExtensionsTests\ToSortDirectionFixture.cs" />
|
||||
<Compile Include="Datastore\PagingSpecExtensionsTests\PagingOffsetFixture.cs" />
|
||||
<Compile Include="Datastore\PagingSpecExtensionsTests\ToSortDirectionFixture.cs" />
|
||||
<Compile Include="Datastore\ReflectionStrategyFixture\Benchmarks.cs" />
|
||||
<Compile Include="Datastore\SQLiteMigrationHelperTests\AlterFixture.cs" />
|
||||
<Compile Include="Datastore\SQLiteMigrationHelperTests\DuplicateFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\NotInQueueSpecificationFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\AcceptableSizeSpecificationFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\CutoffSpecificationFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\DownloadDecisionMakerFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\HistorySpecificationFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\LanguageSpecificationFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\MonitoredEpisodeSpecificationFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\NotInQueueSpecificationFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\NotRestrictedReleaseSpecificationFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\PrioritizeDownloadDecisionFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\QualityAllowedByProfileSpecificationFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\QualityUpgradeSpecificationFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\RetentionSpecificationFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\RssSync\DelaySpecificationFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\RssSync\ProperSpecificationFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\Search\SeriesSpecificationFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\UpgradeDiskSpecificationFixture.cs" />
|
||||
<Compile Include="Download\CompletedDownloadServiceFixture.cs" />
|
||||
<Compile Include="Download\DownloadApprovedReportsTests\DownloadApprovedFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\PrioritizeDownloadDecisionFixture.cs" />
|
||||
<Compile Include="Download\DownloadClientTests\Blackhole\UsenetBlackholeFixture.cs" />
|
||||
<Compile Include="Download\DownloadClientTests\DownloadClientFixtureBase.cs" />
|
||||
<Compile Include="Download\DownloadClientTests\NzbgetTests\NzbgetFixture.cs" />
|
||||
<Compile Include="Download\DownloadClientTests\PneumaticProviderFixture.cs" />
|
||||
<Compile Include="Download\DownloadClientTests\SabnzbdTests\SabnzbdFixture.cs" />
|
||||
<Compile Include="Download\DownloadServiceFixture.cs" />
|
||||
<Compile Include="Download\CompletedDownloadServiceFixture.cs" />
|
||||
<Compile Include="Download\FailedDownloadServiceFixture.cs" />
|
||||
<Compile Include="Download\Pending\PendingReleaseServiceTests\RemoveRejectedFixture.cs" />
|
||||
<Compile Include="Download\Pending\PendingReleaseServiceTests\RemoveGrabbedFixture.cs" />
|
||||
<Compile Include="Download\Pending\PendingReleaseServiceTests\AddFixture.cs" />
|
||||
<Compile Include="FluentTest.cs" />
|
||||
<Compile Include="Framework\CoreTest.cs" />
|
||||
<Compile Include="Framework\DbTest.cs" />
|
||||
<Compile Include="Framework\NBuilderExtensions.cs" />
|
||||
<Compile Include="Framework\TestDbHelper.cs" />
|
||||
<Compile Include="HealthCheck\Checks\AppDataLocationFixture.cs" />
|
||||
<Compile Include="HealthCheck\Checks\RootFolderCheckFixture.cs" />
|
||||
<Compile Include="HealthCheck\Checks\DownloadClientCheckFixture.cs" />
|
||||
<Compile Include="HealthCheck\Checks\ImportMechanismCheckFixture.cs" />
|
||||
<Compile Include="HealthCheck\Checks\UpdateCheckFixture.cs" />
|
||||
<Compile Include="HealthCheck\Checks\IndexerCheckFixture.cs" />
|
||||
<Compile Include="HealthCheck\Checks\DroneFactoryCheckFixture.cs" />
|
||||
<Compile Include="HealthCheck\Checks\MonoVersionCheckFixture.cs" />
|
||||
<Compile Include="HealthCheck\Checks\HealthCheckFixtureExtentions.cs" />
|
||||
<Compile Include="HealthCheck\Checks\ImportMechanismCheckFixture.cs" />
|
||||
<Compile Include="HealthCheck\Checks\IndexerCheckFixture.cs" />
|
||||
<Compile Include="HealthCheck\Checks\MonoVersionCheckFixture.cs" />
|
||||
<Compile Include="HealthCheck\Checks\RootFolderCheckFixture.cs" />
|
||||
<Compile Include="HealthCheck\Checks\UpdateCheckFixture.cs" />
|
||||
<Compile Include="HistoryTests\HistoryRepositoryFixture.cs" />
|
||||
<Compile Include="HistoryTests\HistoryServiceFixture.cs" />
|
||||
<Compile Include="Housekeeping\Housekeepers\CleanupOrphanedHistoryItemsFixture.cs" />
|
||||
<Compile Include="Housekeeping\Housekeepers\CleanupOrphanedEpisodeFilesFixture.cs" />
|
||||
<Compile Include="Housekeeping\Housekeepers\CleanupAdditionalNamingSpecsFixture.cs" />
|
||||
<Compile Include="Housekeeping\Housekeepers\CleanupOrphanedMetadataFilesFixture.cs" />
|
||||
<Compile Include="Housekeeping\Housekeepers\CleanupDuplicateMetadataFilesFixture.cs" />
|
||||
<Compile Include="Housekeeping\Housekeepers\CleanupOrphanedBlacklistFixture.cs" />
|
||||
<Compile Include="Housekeeping\Housekeepers\CleanupOrphanedEpisodeFilesFixture.cs" />
|
||||
<Compile Include="Housekeeping\Housekeepers\CleanupOrphanedEpisodesFixture.cs" />
|
||||
<Compile Include="Housekeeping\Housekeepers\CleanupOrphanedHistoryItemsFixture.cs" />
|
||||
<Compile Include="Housekeeping\Housekeepers\CleanupOrphanedMetadataFilesFixture.cs" />
|
||||
<Compile Include="Housekeeping\Housekeepers\CleanupOrphanedPendingReleasesFixture.cs" />
|
||||
<Compile Include="Housekeeping\Housekeepers\FixFutureRunScheduledTasksFixture.cs" />
|
||||
<Compile Include="IndexerSearchTests\NzbSearchServiceFixture.cs" />
|
||||
<Compile Include="IndexerSearchTests\SearchDefinitionFixture.cs" />
|
||||
|
@ -150,122 +171,108 @@
|
|||
<Compile Include="IndexerTests\NewznabTests\NewznabSettingFixture.cs" />
|
||||
<Compile Include="IndexerTests\SeasonSearchFixture.cs" />
|
||||
<Compile Include="IndexerTests\XElementExtensionsFixture.cs" />
|
||||
<Compile Include="InstrumentationTests\DatabaseTargetFixture.cs" />
|
||||
<Compile Include="JobTests\JobRepositoryFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\LanguageSpecificationFixture.cs" />
|
||||
<Compile Include="JobTests\TestJobs.cs" />
|
||||
<Compile Include="MediaCoverTests\CoverExistsSpecificationFixture.cs" />
|
||||
<Compile Include="MediaCoverTests\MediaCoverServiceFixture.cs" />
|
||||
<Compile Include="MediaFiles\DiskScanServiceTests\ScanFixture.cs" />
|
||||
<Compile Include="MediaFiles\DownloadedEpisodesImportServiceFixture.cs" />
|
||||
<Compile Include="MediaFiles\EpisodeFileMovingServiceTests\MoveEpisodeFileFixture.cs" />
|
||||
<Compile Include="MediaFiles\EpisodeImport\Specifications\FullSeasonSpecificationFixture.cs" />
|
||||
<Compile Include="MediaFiles\EpisodeImport\Specifications\FreeSpaceSpecificationFixture.cs" />
|
||||
<Compile Include="MediaFiles\EpisodeImport\ImportDecisionMakerFixture.cs" />
|
||||
<Compile Include="MediaFiles\EpisodeImport\SampleServiceFixture.cs" />
|
||||
<Compile Include="MediaFiles\EpisodeImport\Specifications\FreeSpaceSpecificationFixture.cs" />
|
||||
<Compile Include="MediaFiles\EpisodeImport\Specifications\FullSeasonSpecificationFixture.cs" />
|
||||
<Compile Include="MediaFiles\EpisodeImport\Specifications\NotSampleSpecificationFixture.cs" />
|
||||
<Compile Include="MediaFiles\EpisodeImport\Specifications\NotUnpackingSpecificationFixture.cs" />
|
||||
<Compile Include="MediaFiles\EpisodeImport\Specifications\UpgradeSpecificationFixture.cs" />
|
||||
<Compile Include="MediaFiles\ImportApprovedEpisodesFixture.cs" />
|
||||
<Compile Include="MediaFiles\MediaFileRepositoryFixture.cs" />
|
||||
<Compile Include="OrganizerTests\CleanFixture.cs" />
|
||||
<Compile Include="MediaFiles\MediaFileServiceTests\FilterFixture.cs" />
|
||||
<Compile Include="MediaFiles\MediaFileTableCleanupServiceFixture.cs" />
|
||||
<Compile Include="MediaFiles\MediaInfo\UpdateMediaInfoServiceFixture.cs" />
|
||||
<Compile Include="MediaFiles\MediaInfo\VideoFileInfoReaderFixture.cs" />
|
||||
<Compile Include="MediaFiles\RenameEpisodeFileServiceFixture.cs" />
|
||||
<Compile Include="MediaFiles\UpgradeMediaFileServiceFixture.cs" />
|
||||
<Compile Include="MediaFiles\ImportApprovedEpisodesFixture.cs" />
|
||||
<Compile Include="MediaFiles\MediaFileTableCleanupServiceFixture.cs" />
|
||||
<Compile Include="MediaFiles\MediaFileRepositoryFixture.cs" />
|
||||
<Compile Include="Messaging\Commands\CommandEqualityComparerFixture.cs" />
|
||||
<Compile Include="Messaging\Commands\CommandExecutorFixture.cs" />
|
||||
<Compile Include="Messaging\Commands\CommandFixture.cs" />
|
||||
<Compile Include="Messaging\Events\EventAggregatorFixture.cs" />
|
||||
<Compile Include="MetadataSourceTests\TvdbProxyFixture.cs" />
|
||||
<Compile Include="MetadataSourceTests\TraktProxyFixture.cs" />
|
||||
<Compile Include="Metadata\Consumers\Roksbox\FindMetadataFileFixture.cs" />
|
||||
<Compile Include="Metadata\Consumers\Wdtv\FindMetadataFileFixture.cs" />
|
||||
<Compile Include="MetadataSourceTests\TraktProxyFixture.cs" />
|
||||
<Compile Include="MetadataSourceTests\TvdbProxyFixture.cs" />
|
||||
<Compile Include="NotificationTests\PlexProviderTest.cs" />
|
||||
<Compile Include="NotificationTests\ProwlProviderTest.cs" />
|
||||
<Compile Include="NotificationTests\Xbmc\GetJsonVersionFixture.cs" />
|
||||
<Compile Include="NotificationTests\Xbmc\Http\ActivePlayersFixture.cs" />
|
||||
<Compile Include="NotificationTests\Xbmc\Http\CheckForErrorFixture.cs" />
|
||||
<Compile Include="NotificationTests\Xbmc\Http\GetSeriesPathFixture.cs" />
|
||||
<Compile Include="NotificationTests\Xbmc\Http\UpdateFixture.cs" />
|
||||
<Compile Include="NotificationTests\Xbmc\Json\ActivePlayersFixture.cs" />
|
||||
<Compile Include="NotificationTests\Xbmc\Json\CheckForErrorFixture.cs" />
|
||||
<Compile Include="NotificationTests\Xbmc\Json\GetSeriesPathFixture.cs" />
|
||||
<Compile Include="NotificationTests\Xbmc\Json\UpdateFixture.cs" />
|
||||
<Compile Include="NotificationTests\Xbmc\OnDownloadFixture.cs" />
|
||||
<Compile Include="OrganizerTests\BuildFilePathFixture.cs" />
|
||||
<Compile Include="OrganizerTests\FileNameBuilderFixture.cs" />
|
||||
<Compile Include="OrganizerTests\GetSeriesFolderFixture.cs" />
|
||||
<Compile Include="ParserTests\AbsoluteEpisodeNumberParserFixture.cs" />
|
||||
<Compile Include="ParserTests\AnimeMetadataParserFixture.cs" />
|
||||
<Compile Include="ParserTests\IsPossibleSpecialEpisodeFixture.cs" />
|
||||
<Compile Include="ParserTests\ReleaseGroupParserFixture.cs" />
|
||||
<Compile Include="ParserTests\LanguageParserFixture.cs" />
|
||||
<Compile Include="ParserTests\SeasonParserFixture.cs" />
|
||||
<Compile Include="ParserTests\NormalizeTitleFixture.cs" />
|
||||
<Compile Include="ParserTests\CrapParserFixture.cs" />
|
||||
<Compile Include="ParserTests\DailyEpisodeParserFixture.cs" />
|
||||
<Compile Include="ParserTests\HashedReleaseFixture.cs" />
|
||||
<Compile Include="ParserTests\SingleEpisodeParserFixture.cs" />
|
||||
<Compile Include="ParserTests\PathParserFixture.cs" />
|
||||
<Compile Include="ParserTests\IsPossibleSpecialEpisodeFixture.cs" />
|
||||
<Compile Include="ParserTests\LanguageParserFixture.cs" />
|
||||
<Compile Include="ParserTests\MultiEpisodeParserFixture.cs" />
|
||||
<Compile Include="ParserTests\NormalizeTitleFixture.cs" />
|
||||
<Compile Include="ParserTests\ParserFixture.cs" />
|
||||
<Compile Include="ParserTests\ParsingServiceTests\GetEpisodesFixture.cs" />
|
||||
<Compile Include="ParserTests\ParsingServiceTests\GetSeriesFixture.cs" />
|
||||
<Compile Include="ParserTests\ParsingServiceTests\MapFixture.cs" />
|
||||
<Compile Include="ParserTests\SeriesTitleInfoFixture.cs" />
|
||||
<Compile Include="Providers\XemProxyFixture.cs" />
|
||||
<Compile Include="Qualities\QualityDefinitionRepositoryFixture.cs" />
|
||||
<Compile Include="Qualities\QualityProfileRepositoryFixture.cs" />
|
||||
<Compile Include="RootFolderTests\FreeSpaceOnDrivesFixture.cs" />
|
||||
<Compile Include="Qualities\QualityFixture.cs" />
|
||||
<Compile Include="ParserTests\PathParserFixture.cs" />
|
||||
<Compile Include="ParserTests\QualityParserFixture.cs" />
|
||||
<Compile Include="Configuration\ConfigCachingFixture.cs" />
|
||||
<Compile Include="ParserTests\ReleaseGroupParserFixture.cs" />
|
||||
<Compile Include="ParserTests\SeasonParserFixture.cs" />
|
||||
<Compile Include="ParserTests\SeriesTitleInfoFixture.cs" />
|
||||
<Compile Include="ParserTests\SingleEpisodeParserFixture.cs" />
|
||||
<Compile Include="Profiles\ProfileRepositoryFixture.cs" />
|
||||
<Compile Include="Profiles\ProfileServiceFixture.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Providers\XemProxyFixture.cs" />
|
||||
<Compile Include="ProviderTests\DiskProviderTests\ArchiveProviderFixture.cs" />
|
||||
<Compile Include="ProviderTests\DiskScanProviderTests\GetVideoFilesFixture.cs" />
|
||||
<Compile Include="ProviderTests\RecycleBinProviderTests\CleanupFixture.cs" />
|
||||
<Compile Include="ProviderTests\RecycleBinProviderTests\EmptyFixture.cs" />
|
||||
<Compile Include="ProviderTests\RecycleBinProviderTests\DeleteFileFixture.cs" />
|
||||
<Compile Include="ProviderTests\RecycleBinProviderTests\DeleteDirectoryFixture.cs" />
|
||||
<Compile Include="NotificationTests\PlexProviderTest.cs" />
|
||||
<Compile Include="Housekeeping\Housekeepers\CleanupOrphanedEpisodesFixture.cs" />
|
||||
<Compile Include="ThingiProviderTests\NullConfigFixture.cs" />
|
||||
<Compile Include="ThingiProvider\ProviderBaseFixture.cs" />
|
||||
<Compile Include="TvTests\EpisodeRepositoryTests\ByAirDateFixture.cs" />
|
||||
<Compile Include="TvTests\EpisodeRepositoryTests\EpisodesWithFilesFixture.cs" />
|
||||
<Compile Include="TvTests\EpisodeRepositoryTests\EpisodesWhereCutoffUnmetFixture.cs" />
|
||||
<Compile Include="TvTests\RefreshEpisodeServiceFixture.cs" />
|
||||
<Compile Include="TvTests\EpisodeProviderTests\HandleEpisodeFileDeletedFixture.cs" />
|
||||
<Compile Include="TvTests\EpisodeRepositoryTests\FindEpisodeFixture.cs" />
|
||||
<Compile Include="TvTests\EpisodeRepositoryTests\EpisodesRepositoryReadFixture.cs" />
|
||||
<Compile Include="TvTests\EpisodeRepositoryTests\EpisodesWithoutFilesFixture.cs" />
|
||||
<Compile Include="TvTests\EpisodeRepositoryTests\EpisodesBetweenDatesFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\RetentionSpecificationFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\QualityAllowedByProfileSpecificationFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\HistorySpecificationFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\UpgradeDiskSpecificationFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\QualityUpgradeSpecificationFixture.cs" />
|
||||
<Compile Include="NotificationTests\ProwlProviderTest.cs" />
|
||||
<Compile Include="ProviderTests\DiskProviderTests\ArchiveProviderFixture.cs" />
|
||||
<Compile Include="MediaFiles\DownloadedEpisodesImportServiceFixture.cs" />
|
||||
<Compile Include="ProviderTests\RecycleBinProviderTests\DeleteFileFixture.cs" />
|
||||
<Compile Include="ProviderTests\RecycleBinProviderTests\EmptyFixture.cs" />
|
||||
<Compile Include="Qualities\QualityDefinitionRepositoryFixture.cs" />
|
||||
<Compile Include="Qualities\QualityDefinitionServiceFixture.cs" />
|
||||
<Compile Include="Qualities\QualityFixture.cs" />
|
||||
<Compile Include="Qualities\QualityModelComparerFixture.cs" />
|
||||
<Compile Include="RootFolderTests\FreeSpaceOnDrivesFixture.cs" />
|
||||
<Compile Include="RootFolderTests\RootFolderServiceFixture.cs" />
|
||||
<Compile Include="SeriesStatsTests\SeriesStatisticsFixture.cs" />
|
||||
<Compile Include="ThingiProvider\ProviderBaseFixture.cs" />
|
||||
<Compile Include="ThingiProviderTests\NullConfigFixture.cs" />
|
||||
<Compile Include="TvTests\EpisodeProviderTests\EpisodeProviderTest_GetEpisodesByParseResult.cs" />
|
||||
<Compile Include="TvTests\EpisodeProviderTests\HandleEpisodeFileDeletedFixture.cs" />
|
||||
<Compile Include="TvTests\EpisodeRepositoryTests\ByAirDateFixture.cs" />
|
||||
<Compile Include="TvTests\EpisodeRepositoryTests\EpisodesBetweenDatesFixture.cs" />
|
||||
<Compile Include="TvTests\EpisodeRepositoryTests\EpisodesRepositoryReadFixture.cs" />
|
||||
<Compile Include="TvTests\EpisodeRepositoryTests\EpisodesWhereCutoffUnmetFixture.cs" />
|
||||
<Compile Include="TvTests\EpisodeRepositoryTests\EpisodesWithFilesFixture.cs" />
|
||||
<Compile Include="TvTests\EpisodeRepositoryTests\EpisodesWithoutFilesFixture.cs" />
|
||||
<Compile Include="TvTests\EpisodeRepositoryTests\FindEpisodeFixture.cs" />
|
||||
<Compile Include="TvTests\MoveSeriesServiceFixture.cs" />
|
||||
<Compile Include="TvTests\RefreshEpisodeServiceFixture.cs" />
|
||||
<Compile Include="TvTests\RefreshSeriesServiceFixture.cs" />
|
||||
<Compile Include="TvTests\SeriesRepositoryTests\QualityProfileRepositoryFixture.cs" />
|
||||
<Compile Include="TvTests\SeriesRepositoryTests\SeriesRepositoryFixture.cs" />
|
||||
<Compile Include="TvTests\SeriesServiceTests\AddSeriesFixture.cs" />
|
||||
<Compile Include="TvTests\SeriesServiceTests\UpdateMultipleSeriesFixture.cs" />
|
||||
<Compile Include="TvTests\SeriesServiceTests\UpdateSeriesFixture.cs" />
|
||||
<Compile Include="TvTests\ShouldRefreshSeriesFixture.cs" />
|
||||
<Compile Include="UpdateTests\UpdateServiceFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\AcceptableSizeSpecificationFixture.cs" />
|
||||
<Compile Include="Qualities\QualityDefinitionServiceFixture.cs" />
|
||||
<Compile Include="TvTests\EpisodeProviderTests\EpisodeProviderTest_GetEpisodesByParseResult.cs" />
|
||||
<Compile Include="FluentTest.cs" />
|
||||
<Compile Include="InstrumentationTests\DatabaseTargetFixture.cs" />
|
||||
<Compile Include="OrganizerTests\FileNameBuilderFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\MonitoredEpisodeSpecificationFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\DownloadDecisionMakerFixture.cs" />
|
||||
<Compile Include="Qualities\QualityModelComparerFixture.cs" />
|
||||
<Compile Include="RootFolderTests\RootFolderServiceFixture.cs" />
|
||||
<Compile Include="HistoryTests\HistoryRepositoryFixture.cs" />
|
||||
<Compile Include="MediaFiles\MediaFileServiceTest.cs" />
|
||||
<Compile Include="Configuration\ConfigServiceFixture.cs" />
|
||||
<Compile Include="TvTests\EpisodeProviderTests\EpisodeProviderTest.cs" />
|
||||
<Compile Include="Framework\TestDbHelper.cs" />
|
||||
<Compile Include="ParserTests\ParserFixture.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Qualities\QualityProfileServiceFixture.cs" />
|
||||
<Compile Include="TvTests\SeriesServiceTests\AddSeriesFixture.cs" />
|
||||
<Compile Include="UpdateTests\UpdatePackageProviderFixture.cs" />
|
||||
<Compile Include="UpdateTests\UpdateServiceFixture.cs" />
|
||||
<Compile Include="XbmcVersionTests.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -295,32 +302,38 @@
|
|||
<Link>sqlite3.dll</Link>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<None Include="..\NzbDrone.Test.Common\App.config">
|
||||
<Link>App.config</Link>
|
||||
</None>
|
||||
<Content Include="Files\Indexers\Newznab\unauthorized.xml" />
|
||||
<Content Include="Files\LongOverview.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Files\Media\H264_sample.mp4">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Files\Nzbget\JsonError.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Files\Nzbget\Queue_empty.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Files\Nzbget\Queue.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Files\QueueUnknownPriority.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Files\LongOverview.txt">
|
||||
<Content Include="Files\Nzbget\Queue_empty.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Files\Queue.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<None Include="..\NzbDrone.Test.Common\App.config">
|
||||
<Link>App.config</Link>
|
||||
</None>
|
||||
<Content Include="Files\RSS\omgwtfnzbs.xml">
|
||||
<Content Include="Files\QueueEmpty.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Files\QueueUnknownPriority.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Files\RSS\filesharingtalk.xml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Files\RSS\newznab.xml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Files\RSS\nzbclub.xml">
|
||||
|
@ -329,7 +342,13 @@
|
|||
<Content Include="Files\RSS\nzbindex.xml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Files\RSS\SizeParsing\omgwtfnzbs.xml">
|
||||
<Content Include="Files\RSS\nzbsrus.xml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Files\RSS\omgwtfnzbs.xml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Files\RSS\SizeParsing\newznab.xml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Files\RSS\SizeParsing\nzbclub.xml">
|
||||
|
@ -338,42 +357,18 @@
|
|||
<Content Include="Files\RSS\SizeParsing\nzbindex.xml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Files\RSS\SizeParsing\nzbsrus.xml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Files\RSS\SizeParsing\omgwtfnzbs.xml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Files\RSS\wombles.xml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
<Content Include="Files\RSS\filesharingtalk.xml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Files\RSS\newznab.xml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Files\RSS\SizeParsing\newznab.xml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Files\RSS\SizeParsing\nzbsrus.xml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Files\RSS\nzbsrus.xml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Files\QueueEmpty.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Files\Xem\Ids.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Files\Xem\Failure.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Files\Xem\Names.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Files\Xem\Mappings.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<None Include="Files\SceneMappings.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
|
@ -383,6 +378,18 @@
|
|||
<None Include="Files\TestArchive.zip">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<Content Include="Files\Xem\Failure.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Files\Xem\Ids.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Files\Xem\Mappings.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Files\Xem\Names.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Organizer;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.OrganizerTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class CleanFixture : CoreTest
|
||||
{
|
||||
[TestCase("Law & Order: Criminal Intent - S10E07 - Icarus [HDTV-720p]",
|
||||
"Law & Order- Criminal Intent - S10E07 - Icarus [HDTV-720p]")]
|
||||
public void CleanFileName(string name, string expectedName)
|
||||
{
|
||||
FileNameBuilder.CleanFileName(name).Should().Be(expectedName);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -64,12 +64,14 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
|||
_episodeFile.Quality.Proper = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Test]
|
||||
public void should_replace_Series_space_Title()
|
||||
{
|
||||
_namingConfig.StandardEpisodeFormat = "{Series Title}";
|
||||
|
||||
Subject.BuildFilename(new List<Episode> {_episode1}, _series, _episodeFile)
|
||||
Subject.BuildFileName(new List<Episode> {_episode1}, _series, _episodeFile)
|
||||
.Should().Be("South Park");
|
||||
}
|
||||
|
||||
|
@ -78,7 +80,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
|||
{
|
||||
_namingConfig.StandardEpisodeFormat = "{Series_Title}";
|
||||
|
||||
Subject.BuildFilename(new List<Episode> {_episode1}, _series, _episodeFile)
|
||||
Subject.BuildFileName(new List<Episode> {_episode1}, _series, _episodeFile)
|
||||
.Should().Be("South_Park");
|
||||
}
|
||||
|
||||
|
@ -87,7 +89,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
|||
{
|
||||
_namingConfig.StandardEpisodeFormat = "{Series.Title}";
|
||||
|
||||
Subject.BuildFilename(new List<Episode> {_episode1}, _series, _episodeFile)
|
||||
Subject.BuildFileName(new List<Episode> {_episode1}, _series, _episodeFile)
|
||||
.Should().Be("South.Park");
|
||||
}
|
||||
|
||||
|
@ -96,7 +98,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
|||
{
|
||||
_namingConfig.StandardEpisodeFormat = "{Series-Title}";
|
||||
|
||||
Subject.BuildFilename(new List<Episode> {_episode1}, _series, _episodeFile)
|
||||
Subject.BuildFileName(new List<Episode> {_episode1}, _series, _episodeFile)
|
||||
.Should().Be("South-Park");
|
||||
}
|
||||
|
||||
|
@ -105,7 +107,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
|||
{
|
||||
_namingConfig.StandardEpisodeFormat = "{SERIES TITLE}";
|
||||
|
||||
Subject.BuildFilename(new List<Episode> {_episode1}, _series, _episodeFile)
|
||||
Subject.BuildFileName(new List<Episode> {_episode1}, _series, _episodeFile)
|
||||
.Should().Be("SOUTH PARK");
|
||||
}
|
||||
|
||||
|
@ -114,7 +116,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
|||
{
|
||||
_namingConfig.StandardEpisodeFormat = "{sErIES-tItLE}";
|
||||
|
||||
Subject.BuildFilename(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
Subject.BuildFileName(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
.Should().Be(_series.Title.Replace(' ', '-'));
|
||||
}
|
||||
|
||||
|
@ -123,16 +125,26 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
|||
{
|
||||
_namingConfig.StandardEpisodeFormat = "{series title}";
|
||||
|
||||
Subject.BuildFilename(new List<Episode> {_episode1}, _series, _episodeFile)
|
||||
Subject.BuildFileName(new List<Episode> {_episode1}, _series, _episodeFile)
|
||||
.Should().Be("south park");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_cleanup_Series_Title()
|
||||
{
|
||||
_namingConfig.StandardEpisodeFormat = "{Series.CleanTitle}";
|
||||
_series.Title = "South Park (1997)";
|
||||
|
||||
Subject.BuildFileName(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
.Should().Be("South.Park.1997");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_replace_episode_title()
|
||||
{
|
||||
_namingConfig.StandardEpisodeFormat = "{Episode Title}";
|
||||
|
||||
Subject.BuildFilename(new List<Episode> {_episode1}, _series, _episodeFile)
|
||||
Subject.BuildFileName(new List<Episode> {_episode1}, _series, _episodeFile)
|
||||
.Should().Be("City Sushi");
|
||||
}
|
||||
|
||||
|
@ -141,7 +153,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
|||
{
|
||||
_namingConfig.StandardEpisodeFormat = "{ePisOde-TitLe}";
|
||||
|
||||
Subject.BuildFilename(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
Subject.BuildFileName(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
.Should().Be("City-Sushi");
|
||||
}
|
||||
|
||||
|
@ -151,7 +163,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
|||
_episode1.SeasonNumber = 1;
|
||||
_namingConfig.StandardEpisodeFormat = "{season}x{episode}";
|
||||
|
||||
Subject.BuildFilename(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
Subject.BuildFileName(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
.Should().Be("1x6");
|
||||
}
|
||||
|
||||
|
@ -161,7 +173,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
|||
_episode1.SeasonNumber = 1;
|
||||
_namingConfig.StandardEpisodeFormat = "{season:00}x{episode}";
|
||||
|
||||
Subject.BuildFilename(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
Subject.BuildFileName(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
.Should().Be("01x6");
|
||||
}
|
||||
|
||||
|
@ -171,7 +183,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
|||
_episode1.SeasonNumber = 1;
|
||||
_namingConfig.StandardEpisodeFormat = "{season}x{episode}";
|
||||
|
||||
Subject.BuildFilename(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
Subject.BuildFileName(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
.Should().Be("1x6");
|
||||
}
|
||||
|
||||
|
@ -181,7 +193,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
|||
_episode1.SeasonNumber = 1;
|
||||
_namingConfig.StandardEpisodeFormat = "{season}x{episode:00}";
|
||||
|
||||
Subject.BuildFilename(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
Subject.BuildFileName(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
.Should().Be("1x06");
|
||||
}
|
||||
|
||||
|
@ -190,7 +202,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
|||
{
|
||||
_namingConfig.StandardEpisodeFormat = "{Quality Title}";
|
||||
|
||||
Subject.BuildFilename(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
Subject.BuildFileName(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
.Should().Be("HDTV-720p");
|
||||
}
|
||||
|
||||
|
@ -200,7 +212,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
|||
_namingConfig.StandardEpisodeFormat = "{Quality Title}";
|
||||
_episodeFile.Quality.Proper = true;
|
||||
|
||||
Subject.BuildFilename(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
Subject.BuildFileName(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
.Should().Be("HDTV-720p Proper");
|
||||
}
|
||||
|
||||
|
@ -209,7 +221,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
|||
{
|
||||
_namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title} [{Quality Title}]";
|
||||
|
||||
Subject.BuildFilename(new List<Episode> {_episode1}, _series, _episodeFile)
|
||||
Subject.BuildFileName(new List<Episode> {_episode1}, _series, _episodeFile)
|
||||
.Should().Be("South Park - S15E06 - City Sushi [HDTV-720p]");
|
||||
}
|
||||
|
||||
|
@ -217,10 +229,10 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
|||
public void use_file_name_when_sceneName_is_null()
|
||||
{
|
||||
_namingConfig.RenameEpisodes = false;
|
||||
_episodeFile.Path = @"C:\Test\TV\30 Rock - S01E01 - Test";
|
||||
_episodeFile.RelativePath = "30 Rock - S01E01 - Test";
|
||||
|
||||
Subject.BuildFilename(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
.Should().Be(Path.GetFileNameWithoutExtension(_episodeFile.Path));
|
||||
Subject.BuildFileName(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
.Should().Be(Path.GetFileNameWithoutExtension(_episodeFile.RelativePath));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -228,9 +240,9 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
|||
{
|
||||
_namingConfig.RenameEpisodes = false;
|
||||
_episodeFile.SceneName = "30.Rock.S01E01.xvid-LOL";
|
||||
_episodeFile.Path = @"C:\Test\TV\30 Rock - S01E01 - Test";
|
||||
_episodeFile.RelativePath = "30 Rock - S01E01 - Test";
|
||||
|
||||
Subject.BuildFilename(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
Subject.BuildFileName(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
.Should().Be("30.Rock.S01E01.xvid-LOL");
|
||||
}
|
||||
|
||||
|
@ -253,7 +265,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
|||
.Build();
|
||||
|
||||
|
||||
Subject.BuildFilename(new List<Episode> {episode2, episode}, new Series {Title = "30 Rock"}, _episodeFile)
|
||||
Subject.BuildFileName(new List<Episode> {episode2, episode}, new Series {Title = "30 Rock"}, _episodeFile)
|
||||
.Should().Be("30 Rock - S06E06-E07 - Hey, Baby, What's Wrong!");
|
||||
}
|
||||
|
||||
|
@ -266,7 +278,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
|||
_episode1.Title = "Hello";
|
||||
_episode2.Title = "World";
|
||||
|
||||
Subject.BuildFilename(new List<Episode> {_episode1, _episode2}, _series, _episodeFile)
|
||||
Subject.BuildFileName(new List<Episode> {_episode1, _episode2}, _series, _episodeFile)
|
||||
.Should().Be("South Park - S15E06-E07 - Hello + World");
|
||||
}
|
||||
|
||||
|
@ -281,7 +293,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
|||
_episode1.AirDate = "2012-12-13";
|
||||
_episode1.Title = "Kristen Stewart";
|
||||
|
||||
Subject.BuildFilename(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
Subject.BuildFileName(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
.Should().Be("The Daily Show with Jon Stewart - 2012-12-13 - Kristen Stewart");
|
||||
}
|
||||
|
||||
|
@ -296,7 +308,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
|||
_episode1.AirDate = null;
|
||||
_episode1.Title = "Kristen Stewart";
|
||||
|
||||
Subject.BuildFilename(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
Subject.BuildFileName(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
.Should().Be("The Daily Show with Jon Stewart - Unknown - Kristen Stewart");
|
||||
}
|
||||
|
||||
|
@ -306,7 +318,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
|||
_namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title}";
|
||||
_namingConfig.MultiEpisodeStyle = 0;
|
||||
|
||||
Subject.BuildFilename(new List<Episode> {_episode1, _episode2}, _series, _episodeFile)
|
||||
Subject.BuildFileName(new List<Episode> {_episode1, _episode2}, _series, _episodeFile)
|
||||
.Should().Be("South Park - S15E06-07 - City Sushi");
|
||||
}
|
||||
|
||||
|
@ -316,7 +328,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
|||
_namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title}";
|
||||
_namingConfig.MultiEpisodeStyle = 1;
|
||||
|
||||
Subject.BuildFilename(new List<Episode> { _episode1, _episode2 }, _series, _episodeFile)
|
||||
Subject.BuildFileName(new List<Episode> { _episode1, _episode2 }, _series, _episodeFile)
|
||||
.Should().Be("South Park - S15E06 - S15E07 - City Sushi");
|
||||
}
|
||||
|
||||
|
@ -326,7 +338,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
|||
_namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title}";
|
||||
_namingConfig.MultiEpisodeStyle = 2;
|
||||
|
||||
Subject.BuildFilename(new List<Episode> { _episode1, _episode2 }, _series, _episodeFile)
|
||||
Subject.BuildFileName(new List<Episode> { _episode1, _episode2 }, _series, _episodeFile)
|
||||
.Should().Be("South Park - S15E06E07 - City Sushi");
|
||||
}
|
||||
|
||||
|
@ -336,7 +348,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
|||
_namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title}";
|
||||
_namingConfig.MultiEpisodeStyle = 3;
|
||||
|
||||
Subject.BuildFilename(new List<Episode> { _episode1, _episode2 }, _series, _episodeFile)
|
||||
Subject.BuildFileName(new List<Episode> { _episode1, _episode2 }, _series, _episodeFile)
|
||||
.Should().Be("South Park - S15E06-E07 - City Sushi");
|
||||
}
|
||||
|
||||
|
@ -348,7 +360,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
|||
|
||||
_namingConfig.StandardEpisodeFormat = "{Episode Title}";
|
||||
|
||||
Subject.BuildFilename(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
Subject.BuildFileName(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
.Should().Be(title);
|
||||
}
|
||||
|
||||
|
@ -357,7 +369,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
|||
{
|
||||
_namingConfig.StandardEpisodeFormat = "{Release Group}";
|
||||
|
||||
Subject.BuildFilename(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
Subject.BuildFileName(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
.Should().Be(_episodeFile.ReleaseGroup);
|
||||
}
|
||||
|
||||
|
@ -368,9 +380,9 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
|||
_namingConfig.StandardEpisodeFormat = "{Series Title} - {Original Title}";
|
||||
|
||||
_episodeFile.SceneName = "30.Rock.S01E01.xvid-LOL";
|
||||
_episodeFile.Path = @"C:\Test\TV\30 Rock - S01E01 - Test";
|
||||
_episodeFile.RelativePath = "30 Rock - S01E01 - Test";
|
||||
|
||||
Subject.BuildFilename(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
Subject.BuildFileName(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
.Should().Be("30 Rock - 30.Rock.S01E01.xvid-LOL");
|
||||
}
|
||||
|
||||
|
@ -387,7 +399,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
|||
.Build();
|
||||
|
||||
|
||||
Subject.BuildFilename(new List<Episode> { episode }, new Series { Title = "30 Rock" }, _episodeFile)
|
||||
Subject.BuildFileName(new List<Episode> { episode }, new Series { Title = "30 Rock" }, _episodeFile)
|
||||
.Should().Be("30 Rock - S06E06 - Part 1");
|
||||
}
|
||||
|
||||
|
@ -404,7 +416,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
|||
.Build();
|
||||
|
||||
|
||||
Subject.BuildFilename(new List<Episode> { episode }, new Series { Title = "30 Rock" }, _episodeFile)
|
||||
Subject.BuildFileName(new List<Episode> { episode }, new Series { Title = "30 Rock" }, _episodeFile)
|
||||
.Should().Be("30 Rock - S06E06 - Part 1");
|
||||
}
|
||||
|
||||
|
@ -419,7 +431,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
|||
.With(e => e.EpisodeNumber = 6)
|
||||
.Build();
|
||||
|
||||
Subject.BuildFilename(new List<Episode> { episode }, new Series { Title = "Chicago P.D." }, _episodeFile)
|
||||
Subject.BuildFileName(new List<Episode> { episode }, new Series { Title = "Chicago P.D." }, _episodeFile)
|
||||
.Should().Be("Chicago.P.D.S06E06.Part.1");
|
||||
}
|
||||
|
||||
|
@ -434,7 +446,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
|||
.With(e => e.EpisodeNumber = 6)
|
||||
.Build();
|
||||
|
||||
Subject.BuildFilename(new List<Episode> { episode }, new Series { Title = "Chicago P.D.." }, _episodeFile)
|
||||
Subject.BuildFileName(new List<Episode> { episode }, new Series { Title = "Chicago P.D.." }, _episodeFile)
|
||||
.Should().Be("Chicago.P.D.S06E06.Part.1");
|
||||
}
|
||||
|
||||
|
@ -443,7 +455,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
|||
{
|
||||
_namingConfig.StandardEpisodeFormat = "{Series.Title}.S{season:00}E{episode:00}.{absolute:00}.{Episode.Title}";
|
||||
|
||||
Subject.BuildFilename(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
Subject.BuildFileName(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
.Should().Be("South.Park.S15E06.City.Sushi");
|
||||
}
|
||||
|
||||
|
@ -453,7 +465,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
|||
_series.SeriesType = SeriesTypes.Anime;
|
||||
_namingConfig.AnimeEpisodeFormat = "{Series.Title}.S{season:00}E{episode:00}.{absolute:00}.{Episode.Title}";
|
||||
|
||||
Subject.BuildFilename(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
Subject.BuildFileName(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
.Should().Be("South.Park.S15E06.100.City.Sushi");
|
||||
}
|
||||
|
||||
|
@ -463,7 +475,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
|||
_series.SeriesType = SeriesTypes.Anime;
|
||||
_namingConfig.AnimeEpisodeFormat = "{Series.Title}.S{season:00}E{episode:00}.{Episode.Title}";
|
||||
|
||||
Subject.BuildFilename(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
Subject.BuildFileName(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
.Should().Be("South.Park.S15E06.City.Sushi");
|
||||
}
|
||||
|
||||
|
@ -473,7 +485,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
|||
_series.SeriesType = SeriesTypes.Anime;
|
||||
_namingConfig.AnimeEpisodeFormat = "{Series.Title}.{absolute:00}.{Episode.Title}";
|
||||
|
||||
Subject.BuildFilename(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
Subject.BuildFileName(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
.Should().Be("South.Park.100.City.Sushi");
|
||||
}
|
||||
|
||||
|
@ -483,7 +495,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
|||
_series.SeriesType = SeriesTypes.Anime;
|
||||
_namingConfig.AnimeEpisodeFormat = "{Series Title} - {absolute:000} - {Episode Title}";
|
||||
|
||||
Subject.BuildFilename(new List<Episode> { _episode1, _episode2 }, _series, _episodeFile)
|
||||
Subject.BuildFileName(new List<Episode> { _episode1, _episode2 }, _series, _episodeFile)
|
||||
.Should().Be("South Park - 100-101 - City Sushi");
|
||||
}
|
||||
|
||||
|
@ -496,7 +508,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
|||
_namingConfig.StandardEpisodeFormat = "{Series Title} - {season:0}x{episode:00} - {Episode Title}";
|
||||
_namingConfig.AnimeEpisodeFormat = "{Series Title} - {absolute:000} - {Episode Title}";
|
||||
|
||||
Subject.BuildFilename(new List<Episode> { _episode1, }, _series, _episodeFile)
|
||||
Subject.BuildFileName(new List<Episode> { _episode1, }, _series, _episodeFile)
|
||||
.Should().Be("South Park - 15x06 - City Sushi");
|
||||
}
|
||||
|
||||
|
@ -507,8 +519,62 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
|||
_namingConfig.MultiEpisodeStyle = (int)MultiEpisodeStyle.Duplicate;
|
||||
_namingConfig.AnimeEpisodeFormat = "{Series Title} - {absolute:000} - {Episode Title}";
|
||||
|
||||
Subject.BuildFilename(new List<Episode> { _episode1, _episode2 }, _series, _episodeFile)
|
||||
Subject.BuildFileName(new List<Episode> { _episode1, _episode2 }, _series, _episodeFile)
|
||||
.Should().Be("South Park - 100 - 101 - City Sushi");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_include_affixes_if_value_not_empty()
|
||||
{
|
||||
_namingConfig.StandardEpisodeFormat = "{Series.Title}.S{season:00}E{episode:00}{_Episode.Title_}";
|
||||
|
||||
Subject.BuildFileName(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
.Should().Be("South.Park.S15E06_City.Sushi_");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_include_affixes_if_value_empty()
|
||||
{
|
||||
_namingConfig.StandardEpisodeFormat = "{Series.Title}.S{season:00}E{episode:00}{_Episode.Title_}";
|
||||
|
||||
_episode1.Title = "";
|
||||
|
||||
Subject.BuildFileName(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
.Should().Be("South.Park.S15E06");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_format_mediainfo_properly()
|
||||
{
|
||||
_namingConfig.StandardEpisodeFormat = "{Series.Title}.S{season:00}E{episode:00}.{Episode.Title}.{MEDIAINFO.FULL}";
|
||||
|
||||
_episodeFile.MediaInfo = new Core.MediaFiles.MediaInfo.MediaInfoModel()
|
||||
{
|
||||
VideoCodec = "AVC",
|
||||
AudioFormat = "DTS",
|
||||
AudioLanguages = "English/Spanish",
|
||||
Subtitles = "English/Spanish/Italian"
|
||||
};
|
||||
|
||||
Subject.BuildFileName(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
.Should().Be("South.Park.S15E06.City.Sushi.X264.DTS[EN+ES].[EN+ES+IT]");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_exclude_english_in_mediainfo_audio_language()
|
||||
{
|
||||
_namingConfig.StandardEpisodeFormat = "{Series.Title}.S{season:00}E{episode:00}.{Episode.Title}.{MEDIAINFO.FULL}";
|
||||
|
||||
_episodeFile.MediaInfo = new Core.MediaFiles.MediaInfo.MediaInfoModel()
|
||||
{
|
||||
VideoCodec = "AVC",
|
||||
AudioFormat = "DTS",
|
||||
AudioLanguages = "English",
|
||||
Subtitles = "English/Spanish/Italian"
|
||||
};
|
||||
|
||||
Subject.BuildFileName(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
.Should().Be("South.Park.S15E06.City.Sushi.X264.DTS.[EN+ES+IT]");
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue