1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2026-03-13 15:34:28 -04:00

Compare commits

..

1 Commits

Author SHA1 Message Date
Taloth Saldono
a19776553e WIP: Statistics API endpoint. 2016-01-31 15:33:13 +01:00
268 changed files with 7516 additions and 3222 deletions

View File

@@ -1,6 +1,6 @@
# How to Contribute #
We're always looking for people to help make Sonarr even better, there are a number of ways to contribute.
We're always looking for people to help make Sonarr even better, there are a number of ways to contribute. To get started, <a href="http://www.clahub.com/agreements/NzbDrone/NzbDrone">sign the Contributor License Agreement</a>.
## Documentation ##
Setup guides, FAQ, the more information we have on the wiki the better.

View File

@@ -296,7 +296,7 @@ namespace LogentriesCore
WriteDebugMessages("HostName parameter is not defined - trying to get it from System.Environment.MachineName");
m_HostName = "HostName=" + System.Environment.MachineName + " ";
}
catch (InvalidOperationException)
catch (InvalidOperationException ex)
{
// Cannot get host name automatically, so assume that HostName is not used
// and log message is sent without it.

View File

@@ -51,9 +51,8 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.2.3\lib\net40\NLog.dll</HintPath>
<Private>True</Private>
<Reference Include="NLog">
<HintPath>..\packages\NLog.2.1.0\lib\net40\NLog.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
@@ -80,7 +79,6 @@
</ItemGroup>
<ItemGroup>
<None Include="fastJSON\license.txt" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NLog" version="4.2.3" targetFramework="net40" />
</packages>
<package id="NLog" version="2.1.0" targetFramework="net40" />
</packages>

View File

@@ -774,8 +774,7 @@ namespace MonoTorrent
break;
case ("nodes"):
if (keypair.Value.ToString().Length != 0)
this.nodes = (BEncodedList)keypair.Value;
this.nodes = (BEncodedList)keypair.Value;
break;
case ("comment.utf-8"):

View File

@@ -26,7 +26,7 @@ namespace NzbDrone.Api.ErrorManagement
if (apiException != null)
{
_logger.Warn(apiException, "API Error");
_logger.WarnException("API Error", apiException);
return apiException.ToErrorResponse();
}
@@ -65,10 +65,10 @@ namespace NzbDrone.Api.ErrorManagement
var sqlErrorMessage = string.Format("[{0} {1}]", context.Request.Method, context.Request.Path);
_logger.Error(sqLiteException, sqlErrorMessage);
_logger.ErrorException(sqlErrorMessage, sqLiteException);
}
_logger.Fatal(exception, "Request Failed");
_logger.FatalException("Request Failed", exception);
return new ErrorModel
{

View File

@@ -60,7 +60,7 @@ namespace NzbDrone.Api.Extensions.Pipelines
catch (Exception ex)
{
_logger.Error(ex, "Unable to gzip response");
_logger.ErrorException("Unable to gzip response", ex);
throw;
}
}

View File

@@ -68,7 +68,7 @@ namespace NzbDrone.Api.Indexers
}
catch (ReleaseDownloadException ex)
{
_logger.Error(ex, ex.Message);
_logger.ErrorException(ex.Message, ex);
throw new NzbDroneClientException(HttpStatusCode.Conflict, "Getting release from indexer failed");
}
@@ -96,7 +96,7 @@ namespace NzbDrone.Api.Indexers
}
catch (Exception ex)
{
_logger.Error(ex, "Episode search failed: " + ex.Message);
_logger.ErrorException("Episode search failed: " + ex.Message, ex);
}
return new List<ReleaseResource>();

View File

@@ -9,7 +9,6 @@ using NzbDrone.Core.Parser.Model;
using NzbDrone.Api.Mapping;
using NzbDrone.Api.Extensions;
using NLog;
using NzbDrone.Core.Indexers;
namespace NzbDrone.Api.Indexers
{
@@ -31,7 +30,7 @@ namespace NzbDrone.Api.Indexers
PostValidator.RuleFor(s => s.Title).NotEmpty();
PostValidator.RuleFor(s => s.DownloadUrl).NotEmpty();
PostValidator.RuleFor(s => s.Protocol).NotEmpty();
PostValidator.RuleFor(s => s.DownloadProtocol).NotEmpty();
PostValidator.RuleFor(s => s.PublishDate).NotEmpty();
}
@@ -39,14 +38,11 @@ namespace NzbDrone.Api.Indexers
{
_logger.Info("Release pushed: {0} - {1}", release.Title, release.DownloadUrl);
var info = release.Protocol == DownloadProtocol.Usenet ?
release.InjectTo<ReleaseInfo>() :
release.InjectTo<TorrentInfo>();
var info = release.InjectTo<ReleaseInfo>();
info.Guid = "PUSH-" + info.DownloadUrl;
var decisions = _downloadDecisionMaker.GetRssDecision(new List<ReleaseInfo> { info });
_downloadDecisionProcessor.ProcessDecisions(decisions);
var processed = _downloadDecisionProcessor.ProcessDecisions(decisions);
return MapDecisions(decisions).First().AsResponse();
}

View File

@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using NzbDrone.Api.REST;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Qualities;
@@ -49,25 +48,8 @@ namespace NzbDrone.Api.Indexers
public int? Leechers { get; set; }
public DownloadProtocol Protocol { get; set; }
// TODO: Remove in v3
// Used to support the original Release Push implementation
// JsonIgnore so we don't serialize it, but can still parse it
[JsonIgnore]
public DownloadProtocol DownloadProtocol
{
get
{
return Protocol;
}
set
{
if (value > 0 && Protocol == 0)
{
Protocol = value;
}
}
}
//TODO: besides a test I don't think this is used...
public DownloadProtocol DownloadProtocol { get; set; }
public bool IsDaily { get; set; }
public bool IsAbsoluteNumbering { get; set; }

View File

@@ -40,8 +40,8 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="FluentValidation, Version=6.2.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\FluentValidation.6.2.1.0\lib\portable-net40+sl50+wp80+win8+wpa81\FluentValidation.dll</HintPath>
<Reference Include="FluentValidation, Version=6.0.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\FluentValidation.6.0.2.0\lib\portable-net40+sl50+wp80+win8+wpa81\FluentValidation.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Nancy, Version=0.23.2.0, Culture=neutral, processorArchitecture=MSIL">
@@ -59,10 +59,6 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.6.0.6\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.2.3\lib\net40\NLog.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
@@ -70,6 +66,9 @@
<Reference Include="DDay.iCal">
<HintPath>..\packages\DDay.iCal.1.0.2.575\lib\DDay.iCal.dll</HintPath>
</Reference>
<Reference Include="NLog">
<HintPath>..\packages\NLog.2.1.0\lib\net40\NLog.dll</HintPath>
</Reference>
<Reference Include="Omu.ValueInjecter">
<HintPath>..\packages\ValueInjecter.2.3.3\lib\net35\Omu.ValueInjecter.dll</HintPath>
</Reference>
@@ -231,6 +230,7 @@
<Compile Include="Series\SeasonStatisticsResource.cs" />
<Compile Include="System\Backup\BackupModule.cs" />
<Compile Include="System\Backup\BackupResource.cs" />
<Compile Include="System\Statistics\StatisticsModule.cs" />
<Compile Include="System\Tasks\TaskModule.cs" />
<Compile Include="System\Tasks\TaskResource.cs" />
<Compile Include="System\SystemModule.cs" />

View File

@@ -0,0 +1,62 @@
using System;
using System.Linq;
using Nancy;
using Nancy.Routing;
using NLog;
using NzbDrone.Api.Extensions;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.History;
using NzbDrone.Core.Lifecycle;
using NzbDrone.Core.Statistics;
namespace NzbDrone.Api.System
{
public class StatisticsModule : NzbDroneApiModule
{
private readonly IStatisticsService _statisticsService;
private readonly Logger _logger;
public StatisticsModule(IStatisticsService statisticsService, Logger logger)
: base("system/statistics")
{
_statisticsService = statisticsService;
_logger = logger;
Get["/"] = x => GetGlobalStatistics();
Get["/indexer"] = x => GetIndexerStatistics();
}
private Response GetGlobalStatistics()
{
return new
{
Generated = DateTime.UtcNow,
Uptime = GetUpTime(),
History = _statisticsService.GetGlobalStatistics()
}.AsResponse();
}
private Response GetIndexerStatistics()
{
var stats = _statisticsService.GetIndexerStatistics();
return stats.AsResponse();
}
private TimeSpan? GetUpTime()
{
try
{
return DateTime.Now - global::System.Diagnostics.Process.GetCurrentProcess().StartTime;
}
catch (Exception ex)
{
_logger.DebugException("Failed to get uptime", ex);
return null;
}
}
}
}

View File

@@ -93,6 +93,7 @@ namespace NzbDrone.Api
break;
case Lifetime.PerRequest:
throw new InvalidOperationException("Unable to directly register a per request lifetime.");
break;
default:
throw new ArgumentOutOfRangeException();
}
@@ -119,6 +120,7 @@ namespace NzbDrone.Api
break;
case Lifetime.PerRequest:
throw new InvalidOperationException("Unable to directly register a per request lifetime.");
break;
default:
throw new ArgumentOutOfRangeException();
}

View File

@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="DDay.iCal" version="1.0.2.575" targetFramework="net40" />
<package id="FluentValidation" version="6.2.1.0" targetFramework="net40" />
<package id="FluentValidation" version="6.0.2.0" targetFramework="net40" />
<package id="Nancy" version="0.23.2" targetFramework="net40" />
<package id="Nancy.Authentication.Basic" version="0.23.2" targetFramework="net40" />
<package id="Nancy.Authentication.Forms" version="0.23.2" targetFramework="net40" />
<package id="Newtonsoft.Json" version="6.0.6" targetFramework="net40" />
<package id="NLog" version="4.2.3" targetFramework="net40" />
<package id="NLog" version="2.1.0" targetFramework="net40" />
<package id="ValueInjecter" version="2.3.3" targetFramework="net40" />
</packages>

View File

@@ -45,10 +45,6 @@
<HintPath>..\packages\FluentAssertions.4.2.1\lib\net40\FluentAssertions.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.2.3\lib\net40\NLog.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="nunit.framework, Version=2.6.3.13283, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
@@ -64,6 +60,9 @@
<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>
</ItemGroup>
<ItemGroup>
<Compile Include="ContainerFixture.cs" />

View File

@@ -3,6 +3,6 @@
<package id="FluentAssertions" version="4.2.1" targetFramework="net40" />
<package id="Moq" version="4.0.10827" />
<package id="NBuilder" version="3.0.1.1" />
<package id="NLog" version="4.2.3" targetFramework="net40" />
<package id="NLog" version="2.1.0" targetFramework="net40" />
<package id="NUnit" version="2.6.3" targetFramework="net40" />
</packages>

View File

@@ -46,10 +46,6 @@
<HintPath>..\packages\FluentAssertions.4.2.1\lib\net40\FluentAssertions.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.2.3\lib\net40\NLog.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="nunit.framework, Version=2.6.3.13283, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
@@ -62,6 +58,9 @@
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="NLog">
<HintPath>..\packages\NLog.2.1.0\lib\net40\NLog.dll</HintPath>
</Reference>
<Reference Include="WebDriver, Version=2.48.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Selenium.WebDriver.2.48.0\lib\net40\WebDriver.dll</HintPath>
@@ -103,4 +102,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="FluentAssertions" version="4.2.1" targetFramework="net40" />
<package id="NLog" version="4.2.3" targetFramework="net40" />
<package id="NLog" version="2.1.0" targetFramework="net40" />
<package id="NUnit" version="2.6.3" targetFramework="net40" />
<package id="Selenium.Support" version="2.48.0" targetFramework="net40" />
<package id="Selenium.WebDriver" version="2.48.0" targetFramework="net40" />

View File

@@ -1,102 +0,0 @@
using System;
using System.Collections.Generic;
using System.Threading;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Common.Cache;
namespace NzbDrone.Common.Test.CacheTests
{
[TestFixture]
public class CachedDictionaryFixture
{
private CachedDictionary<string> _cachedString;
private DictionaryWorker _worker;
[SetUp]
public void SetUp()
{
_worker = new DictionaryWorker();
_cachedString = new CachedDictionary<string>(_worker.GetDict, TimeSpan.FromMilliseconds(100));
}
[Test]
public void should_not_fetch_on_create()
{
_worker.HitCount.Should().Be(0);
}
[Test]
public void should_fetch_on_first_call()
{
var result = _cachedString.Get("Hi");
_worker.HitCount.Should().Be(1);
result.Should().Be("Value");
}
[Test]
public void should_fetch_once()
{
var result1 = _cachedString.Get("Hi");
var result2 = _cachedString.Get("HitCount");
_worker.HitCount.Should().Be(1);
}
[Test]
public void should_auto_refresh_after_lifetime()
{
var result1 = _cachedString.Get("Hi");
Thread.Sleep(200);
var result2 = _cachedString.Get("Hi");
_worker.HitCount.Should().Be(2);
}
[Test]
public void should_refresh_early_if_requested()
{
var result1 = _cachedString.Get("Hi");
Thread.Sleep(10);
_cachedString.RefreshIfExpired(TimeSpan.FromMilliseconds(1));
var result2 = _cachedString.Get("Hi");
_worker.HitCount.Should().Be(2);
}
[Test]
public void should_not_refresh_early_if_not_expired()
{
var result1 = _cachedString.Get("Hi");
_cachedString.RefreshIfExpired(TimeSpan.FromMilliseconds(50));
var result2 = _cachedString.Get("Hi");
_worker.HitCount.Should().Be(1);
}
}
public class DictionaryWorker
{
public int HitCount { get; private set; }
public Dictionary<string, string> GetDict()
{
HitCount++;
var result = new Dictionary<string, string>();
result["Hi"] = "Value";
result["HitCount"] = "Hit count is " + HitCount;
return result;
}
}
}

View File

@@ -24,10 +24,6 @@ namespace NzbDrone.Common.Test.DiskTests
{
Mocker.GetMock<IDiskProvider>(MockBehavior.Strict);
Mocker.GetMock<IDiskProvider>()
.Setup(v => v.GetMount(It.IsAny<string>()))
.Returns((IMount)null);
WithEmulatedDiskProvider();
WithExistingFile(_sourcePath);

View File

@@ -45,10 +45,6 @@
<HintPath>..\packages\FluentAssertions.4.2.1\lib\net40\FluentAssertions.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.2.3\lib\net40\NLog.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="nunit.framework, Version=2.6.3.13283, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
@@ -64,9 +60,11 @@
<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>
</ItemGroup>
<ItemGroup>
<Compile Include="CacheTests\CachedDictionaryFixture.cs" />
<Compile Include="CacheTests\CachedFixture.cs" />
<Compile Include="CacheTests\CachedManagerFixture.cs" />
<Compile Include="ConfigFileProviderTest.cs" />
@@ -153,4 +151,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>

View File

@@ -2,6 +2,6 @@
<packages>
<package id="FluentAssertions" version="4.2.1" targetFramework="net40" />
<package id="Moq" version="4.0.10827" />
<package id="NLog" version="4.2.3" targetFramework="net40" />
<package id="NLog" version="2.1.0" targetFramework="net40" />
<package id="NUnit" version="2.6.3" targetFramework="net40" />
</packages>

View File

@@ -6,9 +6,8 @@ namespace NzbDrone.Common.Cache
{
public interface ICacheManager
{
ICached<T> GetCache<T>(Type host);
ICached<T> GetCache<T>(Type host, string name);
ICachedDictionary<T> GetCacheDictionary<T>(Type host, string name, Func<IDictionary<string, T>> fetchFunc = null, TimeSpan? lifeTime = null);
ICached<T> GetCache<T>(Type host);
void Clear();
ICollection<ICached> Caches { get; }
}
@@ -23,6 +22,12 @@ namespace NzbDrone.Common.Cache
}
public ICached<T> GetCache<T>(Type host)
{
Ensure.That(host, () => host).IsNotNull();
return GetCache<T>(host, host.FullName);
}
public void Clear()
{
_cache.Clear();
@@ -30,12 +35,6 @@ namespace NzbDrone.Common.Cache
public ICollection<ICached> Caches { get { return _cache.Values; } }
public ICached<T> GetCache<T>(Type host)
{
Ensure.That(host, () => host).IsNotNull();
return GetCache<T>(host, host.FullName);
}
public ICached<T> GetCache<T>(Type host, string name)
{
Ensure.That(host, () => host).IsNotNull();
@@ -43,13 +42,5 @@ namespace NzbDrone.Common.Cache
return (ICached<T>)_cache.Get(host.FullName + "_" + name, () => new Cached<T>());
}
public ICachedDictionary<T> GetCacheDictionary<T>(Type host, string name, Func<IDictionary<string, T>> fetchFunc = null, TimeSpan? lifeTime = null)
{
Ensure.That(host, () => host).IsNotNull();
Ensure.That(name, () => name).IsNotNullOrWhiteSpace();
return (ICachedDictionary<T>)_cache.Get("dict_" + host.FullName + "_" + name, () => new CachedDictionary<T>(fetchFunc, lifeTime));
}
}
}

View File

@@ -1,137 +0,0 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
namespace NzbDrone.Common.Cache
{
public class CachedDictionary<TValue> : ICachedDictionary<TValue>
{
private readonly Func<IDictionary<string, TValue>> _fetchFunc;
private readonly TimeSpan? _ttl;
private DateTime _lastRefreshed = DateTime.MinValue;
private ConcurrentDictionary<string, TValue> _items = new ConcurrentDictionary<string, TValue>();
public CachedDictionary(Func<IDictionary<string, TValue>> fetchFunc = null, TimeSpan? ttl = null)
{
_fetchFunc = fetchFunc;
_ttl = ttl;
}
public bool IsExpired(TimeSpan ttl)
{
return _lastRefreshed.Add(ttl) < DateTime.UtcNow;
}
public void RefreshIfExpired()
{
if (_ttl.HasValue && _fetchFunc != null)
{
RefreshIfExpired(_ttl.Value);
}
}
public void RefreshIfExpired(TimeSpan ttl)
{
if (IsExpired(ttl))
{
Refresh();
}
}
public void Refresh()
{
if (_fetchFunc == null)
{
throw new InvalidOperationException("Cannot update cache without data source.");
}
Update(_fetchFunc());
ExtendTTL();
}
public void Update(IDictionary<string, TValue> items)
{
_items = new ConcurrentDictionary<string, TValue>(items);
ExtendTTL();
}
public void ExtendTTL()
{
_lastRefreshed = DateTime.UtcNow;
}
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public ICollection<TValue> Values
{
get
{
RefreshIfExpired();
return _items.Values;
}
}
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public int Count
{
get
{
RefreshIfExpired();
return _items.Count;
}
}
public TValue Get(string key)
{
RefreshIfExpired();
TValue result;
if (!_items.TryGetValue(key, out result))
{
throw new KeyNotFoundException(string.Format("Item {0} not found in cache.", key));
}
return result;
}
public TValue Find(string key)
{
RefreshIfExpired();
TValue result;
_items.TryGetValue(key, out result);
return result;
}
public void Clear()
{
_items.Clear();
_lastRefreshed = DateTime.MinValue;
}
public void ClearExpired()
{
if (!_ttl.HasValue)
{
throw new InvalidOperationException("Checking expiry without ttl not possible.");
}
if (IsExpired(_ttl.Value))
{
Clear();
}
}
public void Remove(string key)
{
TValue item;
_items.TryRemove(key, out item);
}
}
}

View File

@@ -1,18 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace NzbDrone.Common.Cache
{
public interface ICachedDictionary<TValue> : ICached
{
void RefreshIfExpired();
void RefreshIfExpired(TimeSpan ttl);
void Refresh();
void Update(IDictionary<string, TValue> items);
void ExtendTTL();
TValue Get(string key);
TValue Find(string key);
bool IsExpired(TimeSpan ttl);
}
}

View File

@@ -304,7 +304,7 @@ namespace NzbDrone.Common.Disk
}
catch (Exception e)
{
Logger.Warn(e, string.Format("Couldn't set permission for {0}. account:{1} rights:{2} accessControlType:{3}", filename, accountSid, rights, controlType));
Logger.WarnException(string.Format("Couldn't set permission for {0}. account:{1} rights:{2} accessControlType:{3}", filename, accountSid, rights, controlType), e);
throw;
}
@@ -346,12 +346,12 @@ namespace NzbDrone.Common.Disk
public string[] GetFixedDrives()
{
return GetMounts().Where(x => x.DriveType == DriveType.Fixed).Select(x => x.RootDirectory).ToArray();
return (DriveInfo.GetDrives().Where(x => x.DriveType == DriveType.Fixed).Select(x => x.Name)).ToArray();
}
public string GetVolumeLabel(string path)
{
var driveInfo = GetMounts().SingleOrDefault(d => d.RootDirectory.PathEquals(path));
var driveInfo = DriveInfo.GetDrives().SingleOrDefault(d => d.Name == path);
if (driveInfo == null)
{
@@ -376,36 +376,11 @@ namespace NzbDrone.Common.Disk
return new FileStream(path, FileMode.Create);
}
public virtual List<IMount> GetMounts()
{
return GetDriveInfoMounts();
}
public virtual IMount GetMount(string path)
{
try
{
var mounts = GetMounts();
return mounts.Where(drive => drive.RootDirectory.PathEquals(path) ||
drive.RootDirectory.IsParentPath(path))
.OrderByDescending(drive => drive.RootDirectory.Length)
.FirstOrDefault();
}
catch (Exception ex)
{
Logger.Debug(ex, string.Format("Failed to get mount for path {0}", path));
return null;
}
}
protected List<IMount> GetDriveInfoMounts()
public List<DriveInfo> GetDrives()
{
return DriveInfo.GetDrives()
.Where(d => d.DriveType == DriveType.Fixed || d.DriveType == DriveType.Network || d.DriveType == DriveType.Removable)
.Where(d => d.DriveType == DriveType.Fixed || d.DriveType == DriveType.Network)
.Where(d => d.IsReady)
.Select(d => new DriveInfoMount(d))
.Cast<IMount>()
.ToList();
}
@@ -426,19 +401,5 @@ namespace NzbDrone.Common.Disk
return di.GetFiles().ToList();
}
public void RemoveEmptySubfolders(string path)
{
var subfolders = GetDirectories(path);
var files = GetFiles(path, SearchOption.AllDirectories);
foreach (var subfolder in subfolders)
{
if (files.None(f => subfolder.IsParentPath(f)))
{
DeleteFolder(subfolder, false);
}
}
}
}
}

View File

@@ -45,13 +45,6 @@ namespace NzbDrone.Common.Disk
}
public TransferMode TransferFolder(string sourcePath, string targetPath, TransferMode mode, bool verified = true)
{
var verificationMode = verified ? VerificationMode : DiskTransferVerificationMode.VerifyOnly;
return TransferFolder(sourcePath, targetPath, mode, verificationMode);
}
public TransferMode TransferFolder(string sourcePath, string targetPath, TransferMode mode, DiskTransferVerificationMode verificationMode)
{
Ensure.That(sourcePath, () => sourcePath).IsValidPath();
Ensure.That(targetPath, () => targetPath).IsValidPath();
@@ -65,14 +58,14 @@ namespace NzbDrone.Common.Disk
foreach (var subDir in _diskProvider.GetDirectoryInfos(sourcePath))
{
result &= TransferFolder(subDir.FullName, Path.Combine(targetPath, subDir.Name), mode, verificationMode);
result &= TransferFolder(subDir.FullName, Path.Combine(targetPath, subDir.Name), mode, verified);
}
foreach (var sourceFile in _diskProvider.GetFileInfos(sourcePath))
{
var destFile = Path.Combine(targetPath, sourceFile.Name);
result &= TransferFile(sourceFile.FullName, destFile, mode, true, verificationMode);
result &= TransferFile(sourceFile.FullName, destFile, mode, true, verified);
}
if (mode.HasFlag(TransferMode.Move))
@@ -84,17 +77,15 @@ namespace NzbDrone.Common.Disk
}
public TransferMode TransferFile(string sourcePath, string targetPath, TransferMode mode, bool overwrite = false, bool verified = true)
{
var verificationMode = verified ? VerificationMode : DiskTransferVerificationMode.None;
return TransferFile(sourcePath, targetPath, mode, overwrite, verificationMode);
}
public TransferMode TransferFile(string sourcePath, string targetPath, TransferMode mode, bool overwrite, DiskTransferVerificationMode verificationMode)
{
Ensure.That(sourcePath, () => sourcePath).IsValidPath();
Ensure.That(targetPath, () => targetPath).IsValidPath();
if (VerificationMode != DiskTransferVerificationMode.Transactional && VerificationMode != DiskTransferVerificationMode.TryTransactional)
{
verified = false;
}
_logger.Debug("{0} [{1}] > [{2}]", mode, sourcePath, targetPath);
var originalSize = _diskProvider.GetFileSize(sourcePath);
@@ -163,59 +154,49 @@ namespace NzbDrone.Common.Disk
}
}
// We force a transactional transfer if the transfer occurs between mounts and one of the mounts is cifs, it would be a copy anyway.
if (verificationMode == DiskTransferVerificationMode.TryTransactional && OsInfo.IsNotWindows)
if (verified)
{
var sourceMount = _diskProvider.GetMount(sourcePath);
var targetMount = _diskProvider.GetMount(targetPath);
if (sourceMount != null && targetMount != null && sourceMount.RootDirectory != targetMount.RootDirectory &&
(sourceMount.DriveFormat == "cifs" || targetMount.DriveFormat == "cifs"))
{
verificationMode = DiskTransferVerificationMode.Transactional;
}
}
if (mode.HasFlag(TransferMode.Copy))
{
if (verificationMode == DiskTransferVerificationMode.Transactional || verificationMode == DiskTransferVerificationMode.TryTransactional)
if (mode.HasFlag(TransferMode.Copy))
{
if (TryCopyFileTransactional(sourcePath, targetPath, originalSize))
{
return TransferMode.Copy;
}
throw new IOException(string.Format("Failed to completely transfer [{0}] to [{1}], aborting.", sourcePath, targetPath));
}
else if (verificationMode == DiskTransferVerificationMode.VerifyOnly)
if (mode.HasFlag(TransferMode.Move))
{
if (TryMoveFileTransactional(sourcePath, targetPath, originalSize))
{
return TransferMode.Move;
}
}
throw new IOException(string.Format("Failed to completely transfer [{0}] to [{1}], aborting.", sourcePath, targetPath));
}
else if (VerificationMode != DiskTransferVerificationMode.None)
{
if (mode.HasFlag(TransferMode.Copy))
{
TryCopyFileVerified(sourcePath, targetPath, originalSize);
return TransferMode.Copy;
}
else
{
_diskProvider.CopyFile(sourcePath, targetPath);
return TransferMode.Copy;
}
}
if (mode.HasFlag(TransferMode.Move))
{
if (verificationMode == DiskTransferVerificationMode.Transactional || verificationMode == DiskTransferVerificationMode.TryTransactional)
{
if (TryMoveFileTransactional(sourcePath, targetPath, originalSize, verificationMode))
{
return TransferMode.Move;
}
throw new IOException(string.Format("Failed to completely transfer [{0}] to [{1}], aborting.", sourcePath, targetPath));
}
else if (verificationMode == DiskTransferVerificationMode.VerifyOnly)
if (mode.HasFlag(TransferMode.Move))
{
TryMoveFileVerified(sourcePath, targetPath, originalSize);
return TransferMode.Move;
}
else
}
else
{
if (mode.HasFlag(TransferMode.Copy))
{
_diskProvider.CopyFile(sourcePath, targetPath);
return TransferMode.Copy;
}
if (mode.HasFlag(TransferMode.Move))
{
_diskProvider.MoveFile(sourcePath, targetPath);
return TransferMode.Move;
@@ -259,7 +240,7 @@ namespace NzbDrone.Common.Disk
}
catch (Exception ex)
{
_logger.Error(ex, string.Format("Failed to properly rollback the file move [{0}] to [{1}], incomplete file may be left in target path.", sourcePath, targetPath));
_logger.ErrorException(string.Format("Failed to properly rollback the file move [{0}] to [{1}], incomplete file may be left in target path.", sourcePath, targetPath), ex);
}
}
@@ -275,7 +256,7 @@ namespace NzbDrone.Common.Disk
}
catch (Exception ex)
{
_logger.Error(ex, string.Format("Failed to properly rollback the file move [{0}] to [{1}], file may be left in target path.", sourcePath, targetPath));
_logger.ErrorException(string.Format("Failed to properly rollback the file move [{0}] to [{1}], file may be left in target path.", sourcePath, targetPath), ex);
}
}
@@ -294,7 +275,7 @@ namespace NzbDrone.Common.Disk
}
catch (Exception ex)
{
_logger.Error(ex, string.Format("Failed to properly rollback the file copy [{0}] to [{1}], file may be left in target path.", sourcePath, targetPath));
_logger.ErrorException(string.Format("Failed to properly rollback the file copy [{0}] to [{1}], file may be left in target path.", sourcePath, targetPath), ex);
}
}
@@ -359,7 +340,7 @@ namespace NzbDrone.Common.Disk
return false;
}
private bool TryMoveFileTransactional(string sourcePath, string targetPath, long originalSize, DiskTransferVerificationMode verificationMode)
private bool TryMoveFileTransactional(string sourcePath, string targetPath, long originalSize)
{
var backupPath = sourcePath + ".backup~";
var tempTargetPath = targetPath + ".partial~";
@@ -413,7 +394,7 @@ namespace NzbDrone.Common.Disk
}
}
if (verificationMode == DiskTransferVerificationMode.Transactional)
if (VerificationMode == DiskTransferVerificationMode.Transactional)
{
_logger.Trace("Hardlink move failed, reverting to copy.");
if (TryCopyFileTransactional(sourcePath, targetPath, originalSize))

View File

@@ -1,76 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using NzbDrone.Common.Extensions;
namespace NzbDrone.Common.Disk
{
public class DriveInfoMount : IMount
{
private readonly DriveInfo _driveInfo;
public DriveInfoMount(DriveInfo driveInfo)
{
_driveInfo = driveInfo;
}
public long AvailableFreeSpace
{
get { return _driveInfo.AvailableFreeSpace; }
}
public string DriveFormat
{
get { return _driveInfo.DriveFormat; }
}
public DriveType DriveType
{
get { return _driveInfo.DriveType; }
}
public bool IsReady
{
get { return _driveInfo.IsReady; }
}
public string Name
{
get { return _driveInfo.Name; }
}
public string RootDirectory
{
get { return _driveInfo.RootDirectory.FullName; }
}
public long TotalFreeSpace
{
get { return _driveInfo.TotalFreeSpace; }
}
public long TotalSize
{
get { return _driveInfo.TotalSize; }
}
public string VolumeLabel
{
get { return _driveInfo.VolumeLabel; }
}
public string VolumeName
{
get
{
if (VolumeLabel.IsNullOrWhiteSpace())
{
return Name;
}
return string.Format("{0} ({1})", Name, VolumeLabel);
}
}
}
}

View File

@@ -103,12 +103,12 @@ namespace NzbDrone.Common.Disk
private List<FileSystemModel> GetDrives()
{
return _diskProvider.GetMounts()
return _diskProvider.GetDrives()
.Select(d => new FileSystemModel
{
Type = FileSystemEntityType.Drive,
Name = d.VolumeLabel,
Path = d.RootDirectory,
Name = GetVolumeName(d),
Path = d.Name,
LastModified = null
})
.ToList();
@@ -157,6 +157,16 @@ namespace NzbDrone.Common.Disk
return path;
}
private string GetVolumeName(DriveInfo driveInfo)
{
if (driveInfo.VolumeLabel.IsNullOrWhiteSpace())
{
return driveInfo.Name;
}
return string.Format("{0} ({1})", driveInfo.Name, driveInfo.VolumeLabel);
}
private string GetParent(string path)
{

View File

@@ -40,13 +40,12 @@ namespace NzbDrone.Common.Disk
void SetPermissions(string filename, WellKnownSidType accountSid, FileSystemRights rights, AccessControlType controlType);
FileAttributes GetFileAttributes(string path);
void EmptyFolder(string path);
string[] GetFixedDrives();
string GetVolumeLabel(string path);
FileStream OpenReadStream(string path);
FileStream OpenWriteStream(string path);
List<IMount> GetMounts();
IMount GetMount(string path);
List<DriveInfo> GetDrives();
List<DirectoryInfo> GetDirectoryInfos(string path);
List<FileInfo> GetFileInfos(string path);
void RemoveEmptySubfolders(string path);
}
}

View File

@@ -1,21 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace NzbDrone.Common.Disk
{
public interface IMount
{
long AvailableFreeSpace { get; }
string DriveFormat { get; }
DriveType DriveType { get; }
bool IsReady { get; }
string Name { get; }
string RootDirectory { get; }
long TotalFreeSpace { get; }
long TotalSize { get; }
string VolumeLabel { get; }
}
}

View File

@@ -43,7 +43,7 @@ namespace NzbDrone.Common.EnvironmentInfo
}
catch (Exception ex)
{
_logger.Warn(ex, "Coudn't set app folder permission");
_logger.WarnException("Coudn't set app folder permission", ex);
}
}
}

View File

@@ -60,7 +60,7 @@ namespace NzbDrone.Common.EnvironmentInfo
}
catch (Exception ex)
{
_logger.Warn(ex, "Error checking if the current user is an administrator.");
_logger.WarnException("Error checking if the current user is an administrator.", ex);
return false;
}
}

View File

@@ -73,14 +73,8 @@ namespace NzbDrone.Common.Extensions
public static bool IsParentPath(this string parentPath, string childPath)
{
if (parentPath != "/")
{
parentPath = parentPath.TrimEnd(Path.DirectorySeparatorChar);
}
if (childPath != "/")
{
childPath = childPath.TrimEnd(Path.DirectorySeparatorChar);
}
parentPath = parentPath.TrimEnd(Path.DirectorySeparatorChar);
childPath = childPath.TrimEnd(Path.DirectorySeparatorChar);
var parent = new DirectoryInfo(parentPath);
var child = new DirectoryInfo(childPath);

View File

@@ -29,7 +29,7 @@ namespace NzbDrone.Common.Http.Dispatchers
}
catch (Exception ex)
{
_logger.Trace(ex, "Initializing curl failed");
_logger.TraceException("Initializing curl failed", ex);
return false;
}
}
@@ -112,15 +112,7 @@ namespace NzbDrone.Common.Http.Dispatchers
if (result != CurlCode.Ok)
{
switch (result)
{
case CurlCode.SslCaCert:
case (CurlCode)77:
throw new WebException(string.Format("Curl Error {0} for Url {1}, issues with your operating system SSL Root Certificate Bundle (ca-bundle).", result, curlEasy.Url));
default:
throw new WebException(string.Format("Curl Error {0} for Url {1}", result, curlEasy.Url));
}
throw new WebException(string.Format("Curl Error {0} for Url {1}", result, curlEasy.Url));
}
}

View File

@@ -100,6 +100,7 @@ namespace NzbDrone.Common.Http.Dispatchers
break;
case "Range":
throw new NotImplementedException();
break;
case "Referer":
webRequest.Referer = header.Value.ToString();
break;
@@ -110,6 +111,7 @@ namespace NzbDrone.Common.Http.Dispatchers
throw new NotSupportedException("User-Agent other than Sonarr not allowed.");
case "Proxy-Connection":
throw new NotImplementedException();
break;
default:
webRequest.Headers.Add(header.Key, header.Value.ToString());
break;

View File

@@ -28,6 +28,7 @@ namespace NzbDrone.Common.Http
private readonly Logger _logger;
private readonly IRateLimitService _rateLimitService;
private readonly ICached<CookieContainer> _cookieContainerCache;
private readonly ICached<bool> _curlTLSFallbackCache;
private readonly List<IHttpRequestInterceptor> _requestInterceptors;
private readonly IHttpDispatcher _httpDispatcher;
@@ -176,7 +177,7 @@ namespace NzbDrone.Common.Http
}
catch (Exception e)
{
_logger.Warn(e, "Failed to get response from: " + url);
_logger.WarnException("Failed to get response from: " + url, e);
throw;
}
}

View File

@@ -53,7 +53,7 @@ namespace NzbDrone.Common.Http
}
catch (Exception e)
{
_logger.Warn(e, "Failed to get response from: " + url);
_logger.WarnException("Failed to get response from: " + url, e);
throw;
}
}

View File

@@ -50,7 +50,7 @@ namespace NzbDrone.Common.Instrumentation
var value = m.Value;
foreach (var capture in m.Groups["secret"].Captures.OfType<Capture>().Reverse())
{
value = value.Replace(capture.Index - m.Index, capture.Length, "(removed)");
value = value.Replace(capture.Index - m.Index, capture.Length, "<removed>");
}
return value;

View File

@@ -19,7 +19,7 @@ namespace NzbDrone.Common.Instrumentation
var exception = e.Exception;
Console.WriteLine("Task Error: {0}", exception);
Logger.Error(exception, "Task Error: " + exception.Message);
Logger.Error("Task Error: " + exception.Message, exception);
}
private static void HandleAppDomainException(object sender, UnhandledExceptionEventArgs e)
@@ -40,13 +40,13 @@ namespace NzbDrone.Common.Instrumentation
if (exception is TypeInitializationException && exception.InnerException is DllNotFoundException ||
exception is DllNotFoundException)
{
Logger.Debug(exception, "Minor Fail: " + exception.Message);
Logger.DebugException("Minor Fail: " + exception.Message, exception);
return;
}
}
Console.WriteLine("EPIC FAIL: {0}", exception);
Logger.Fatal(exception, "EPIC FAIL: " + exception.Message);
Logger.FatalException("EPIC FAIL: " + exception.Message, exception);
}
}
}

View File

@@ -76,7 +76,7 @@ namespace NzbDrone.Common.Instrumentation
{
DebuggerTarget target = new DebuggerTarget();
target.Name = "debuggerLogger";
target.Layout = "[${level}] [${threadid}] ${logger}: ${message} ${onexception:inner=${newline}${newline}[v${assembly-version}] ${exception:format=ToString}${newline}}";
target.Layout = "[${level}] [${threadid}] ${logger}: ${message} ${onexception:inner=${newline}${newline}${exception:format=ToString}${newline}}";
var loggingRule = new LoggingRule("*", LogLevel.Trace, target);
LogManager.Configuration.AddTarget("debugger", target);
@@ -91,7 +91,7 @@ namespace NzbDrone.Common.Instrumentation
var coloredConsoleTarget = new ColoredConsoleTarget();
coloredConsoleTarget.Name = "consoleLogger";
coloredConsoleTarget.Layout = "[${level}] ${logger}: ${message} ${onexception:inner=${newline}${newline}[v${assembly-version}] ${exception:format=ToString}${newline}}";
coloredConsoleTarget.Layout = "[${level}] ${logger}: ${message} ${onexception:inner=${newline}${newline}${exception:format=ToString}${newline}}";
var loggingRule = new LoggingRule("*", level, coloredConsoleTarget);
@@ -99,38 +99,29 @@ namespace NzbDrone.Common.Instrumentation
LogManager.Configuration.LoggingRules.Add(loggingRule);
}
const string FILE_LOG_LAYOUT = @"${date:format=yy-M-d HH\:mm\:ss.f}|${level}|${logger}|${message}${onexception:inner=${newline}${newline}[v${assembly-version}] ${exception:format=ToString}${newline}}";
const string FILE_LOG_LAYOUT = @"${date:format=yy-M-d HH\:mm\:ss.f}|${level}|${logger}|${message}${onexception:inner=${newline}${newline}${exception:format=ToString}${newline}}";
private static void RegisterAppFile(IAppFolderInfo appFolderInfo)
{
RegisterAppFile(appFolderInfo, "appFileInfo", "sonarr.txt", 5);
RegisterAppFile(appFolderInfo, "appFileDebug", "sonarr.debug.txt", 50);
RegisterAppFile(appFolderInfo, "appFileTrace", "sonarr.trace.txt", 50);
}
private static LoggingRule RegisterAppFile(IAppFolderInfo appFolderInfo, string name, string fileName, int maxArchiveFiles)
{
var fileTarget = new NzbDroneFileTarget();
fileTarget.Name = name;
fileTarget.FileName = Path.Combine(appFolderInfo.GetLogFolder(), fileName);
fileTarget.Name = "rollingFileLogger";
fileTarget.FileName = Path.Combine(appFolderInfo.GetLogFolder(), "nzbdrone.txt");
fileTarget.AutoFlush = true;
fileTarget.KeepFileOpen = false;
fileTarget.ConcurrentWrites = false;
fileTarget.ConcurrentWriteAttemptDelay = 50;
fileTarget.ConcurrentWriteAttempts = 10;
fileTarget.ArchiveAboveSize = 1024000;
fileTarget.MaxArchiveFiles = maxArchiveFiles;
fileTarget.MaxArchiveFiles = 5;
fileTarget.EnableFileDelete = true;
fileTarget.ArchiveNumbering = ArchiveNumberingMode.Rolling;
fileTarget.Layout = FILE_LOG_LAYOUT;
var loggingRule = new LoggingRule("*", LogLevel.Trace, fileTarget);
LogManager.Configuration.AddTarget(name, fileTarget);
LogManager.Configuration.AddTarget("appfile", fileTarget);
LogManager.Configuration.LoggingRules.Add(loggingRule);
return loggingRule;
}
private static void RegisterUpdateFile(IAppFolderInfo appFolderInfo)

View File

@@ -43,10 +43,6 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.6.0.6\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.2.3\lib\net40\NLog.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Configuration.Install" />
@@ -57,6 +53,9 @@
<Reference Include="ICSharpCode.SharpZipLib">
<HintPath>..\packages\ICSharpCode.SharpZipLib.Patched.0.86.5\lib\net20\ICSharpCode.SharpZipLib.dll</HintPath>
</Reference>
<Reference Include="NLog">
<HintPath>..\packages\NLog.2.1.0\lib\net40\NLog.dll</HintPath>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>
@@ -64,9 +63,7 @@
<Compile Include="ArchiveService.cs" />
<Compile Include="Cache\Cached.cs" />
<Compile Include="Cache\CacheManager.cs" />
<Compile Include="Cache\CachedDictionary.cs" />
<Compile Include="Cache\ICached.cs" />
<Compile Include="Cache\ICachedDictionary.cs" />
<Compile Include="Cloud\CloudClient.cs" />
<Compile Include="Composition\Container.cs" />
<Compile Include="Composition\ContainerBuilderBase.cs" />
@@ -75,8 +72,6 @@
<Compile Include="ConvertBase32.cs" />
<Compile Include="Crypto\HashProvider.cs" />
<Compile Include="Disk\FileSystemLookupService.cs" />
<Compile Include="Disk\DriveInfoMount.cs" />
<Compile Include="Disk\IMount.cs" />
<Compile Include="Disk\RelativeFileSystemModel.cs" />
<Compile Include="Disk\FileSystemModel.cs" />
<Compile Include="Disk\FileSystemResult.cs" />

View File

@@ -37,7 +37,7 @@ namespace NzbDrone.Common.Processes
}
catch (Exception ex)
{
_logger.Error(ex, "Unable to write PID file: " + filename);
_logger.Error("Unable to write PID file: " + filename, ex);
throw;
}
}

View File

@@ -292,7 +292,7 @@ namespace NzbDrone.Common.Processes
}
catch (Win32Exception e)
{
_logger.Warn(e, "Couldn't get process info for " + process.ProcessName);
_logger.WarnException("Couldn't get process info for " + process.ProcessName, e);
}
return processInfo;

View File

@@ -17,7 +17,7 @@ namespace NzbDrone.Common.TPL
var aggregateException = t.Exception.Flatten();
foreach (var exception in aggregateException.InnerExceptions)
{
Logger.Error(exception, "Task Error");
Logger.ErrorException("Task Error", exception);
}
}
}, TaskContinuationOptions.OnlyOnFaulted);

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="ICSharpCode.SharpZipLib.Patched" version="0.86.5" targetFramework="net40" />
<package id="Newtonsoft.Json" version="6.0.6" targetFramework="net40" />
<package id="NLog" version="4.2.3" targetFramework="net40" />
<package id="NLog" version="2.1.0" targetFramework="net40" />
<package id="ICSharpCode.SharpZipLib.Patched" version="0.86.5" targetFramework="net40" />
</packages>

View File

@@ -32,7 +32,7 @@ namespace NzbDrone.Console
{
System.Console.WriteLine("");
System.Console.WriteLine("");
Logger.Fatal(e, "EPIC FAIL!");
Logger.FatalException("EPIC FAIL!", e);
System.Console.WriteLine("Press any key to exit...");
System.Console.ReadLine();
Environment.Exit(1);

View File

@@ -75,12 +75,11 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.6.0.6\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.2.3\lib\net40\NLog.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="NLog">
<HintPath>..\packages\NLog.2.1.0\lib\net40\NLog.dll</HintPath>
</Reference>
<Reference Include="Owin">
<HintPath>..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
</Reference>
@@ -151,4 +150,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>

View File

@@ -3,6 +3,6 @@
<package id="Microsoft.Owin" version="2.1.0" targetFramework="net40" />
<package id="Microsoft.Owin.Hosting" version="2.1.0" targetFramework="net40" />
<package id="Newtonsoft.Json" version="6.0.6" targetFramework="net40" />
<package id="NLog" version="4.2.3" targetFramework="net40" />
<package id="NLog" version="2.1.0" targetFramework="net40" />
<package id="Owin" version="1.0" targetFramework="net40" />
</packages>
</packages>

View File

@@ -124,7 +124,7 @@ namespace NzbDrone.Core.Test.DataAugmentation.Scene
.Returns(Builder<SceneMapping>.CreateListOfSize(1).Build());
Subject.Execute(new UpdateSceneMappingCommand());
Subject.HandleAsync(new ApplicationStartedEvent());
Mocker.GetMock<ISceneMappingRepository>()
.Verify(v => v.All(), Times.Once());

View File

@@ -11,7 +11,6 @@ using NzbDrone.Core.DataAugmentation.Xem.Model;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Tv.Events;
using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.DataAugmentation.SceneNumbering
{
@@ -145,25 +144,6 @@ namespace NzbDrone.Core.Test.DataAugmentation.SceneNumbering
Mocker.GetMock<ISeriesService>()
.Verify(v => v.UpdateSeries(It.IsAny<Series>()), Times.Never());
ExceptionVerification.ExpectedWarns(1);
}
[Test]
public void should_not_clear_scenenumbering_if_thexem_throws()
{
GivenExistingMapping();
Mocker.GetMock<IXemProxy>()
.Setup(v => v.GetXemSeriesIds())
.Throws(new InvalidOperationException());
Subject.Handle(new SeriesUpdatedEvent(_series));
Mocker.GetMock<ISeriesService>()
.Verify(v => v.UpdateSeries(It.IsAny<Series>()), Times.Never());
ExceptionVerification.ExpectedWarns(1);
}
[Test]

View File

@@ -2,7 +2,11 @@
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Datastore.Migration;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Profiles.Delay;
using NzbDrone.Core.Tags;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv;
namespace NzbDrone.Core.Test.Datastore.Migration
{
@@ -12,7 +16,7 @@ namespace NzbDrone.Core.Test.Datastore.Migration
[Test]
public void should_migrate_old_delays()
{
var db = WithMigrationTestDb(c =>
WithTestDb(c =>
{
c.Insert.IntoTable("Profiles").Row(new
{
@@ -31,10 +35,10 @@ namespace NzbDrone.Core.Test.Datastore.Migration
});
});
var allProfiles = db.Query<DelayProfile70>("SELECT * FROM DelayProfiles");
var allProfiles = Mocker.Resolve<DelayProfileRepository>().All().ToList();
allProfiles.Should().HaveCount(3);
allProfiles.Should().OnlyContain(c => c.PreferredProtocol == 1);
allProfiles.Should().OnlyContain(c => c.PreferredProtocol == DownloadProtocol.Usenet);
allProfiles.Should().OnlyContain(c => c.TorrentDelay == 0);
allProfiles.Should().Contain(c => c.UsenetDelay == 60);
allProfiles.Should().Contain(c => c.UsenetDelay == 120);
@@ -43,18 +47,17 @@ namespace NzbDrone.Core.Test.Datastore.Migration
[Test]
public void should_create_tag_for_delay_profile()
{
var db = WithMigrationTestDb(c =>
{
WithTestDb(c =>
c.Insert.IntoTable("Profiles").Row(new
{
GrabDelay = 1,
Name = "OneHour",
Cutoff = 0,
Items = "[]"
});
});
})
);
var tags = db.Query<Tag69>("SELECT * FROM Tags");
var tags = Mocker.Resolve<TagRepository>().All().ToList();
tags.Should().HaveCount(1);
tags.First().Label.Should().Be("delay-60");
@@ -63,7 +66,7 @@ namespace NzbDrone.Core.Test.Datastore.Migration
[Test]
public void should_add_tag_to_series_that_had_a_profile_with_delay_attached()
{
var db = WithMigrationTestDb(c =>
WithTestDb(c =>
{
c.Insert.IntoTable("Profiles").Row(new
{
@@ -92,11 +95,12 @@ namespace NzbDrone.Core.Test.Datastore.Migration
});
});
var tag = db.Query<Tag69>("SELECT Id, Label FROM Tags").Single();
var series = db.Query<Series69>("SELECT Tags FROM Series");
var tag = Mocker.Resolve<TagRepository>().All().ToList().First();
var series = Mocker.Resolve<SeriesRepository>().All().ToList();
series.Should().HaveCount(1);
series.First().Tags.Should().BeEquivalentTo(tag.Id);
series.First().Tags.Should().HaveCount(1);
series.First().Tags.First().Should().Be(tag.Id);
}
}
}

View File

@@ -2,7 +2,12 @@
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Datastore.Migration;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Profiles;
using NzbDrone.Core.Profiles.Delay;
using NzbDrone.Core.Tags;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv;
namespace NzbDrone.Core.Test.Datastore.Migration
{
@@ -12,11 +17,10 @@ namespace NzbDrone.Core.Test.Datastore.Migration
[Test]
public void should_add_unknown_to_old_profile()
{
var db = WithMigrationTestDb(c =>
WithTestDb(c =>
{
c.Insert.IntoTable("Profiles").Row(new
{
Id = 0,
Name = "SDTV",
Cutoff = 1,
Items = "[ { \"quality\": 1, \"allowed\": true } ]",
@@ -24,12 +28,11 @@ namespace NzbDrone.Core.Test.Datastore.Migration
});
});
var profiles = db.Query<Profile70>("SELECT Items FROM Profiles LIMIT 1");
var allProfiles = Mocker.Resolve<ProfileRepository>().All().ToList();
var items = profiles.First().Items;
items.Should().HaveCount(2);
items.First().Quality.Should().Be(0);
items.First().Allowed.Should().Be(false);
allProfiles.Should().HaveCount(1);
allProfiles.First().Items.Should().HaveCount(2);
allProfiles.First().Items.Should().Contain(i => i.Quality.Id == 0 && i.Allowed == false);
}
}
}

View File

@@ -6,6 +6,7 @@ using FluentMigrator;
using NUnit.Framework;
using NzbDrone.Common.Serializer;
using NzbDrone.Core.Datastore.Migration;
using NzbDrone.Core.History;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.Datastore.Migration
@@ -16,7 +17,7 @@ namespace NzbDrone.Core.Test.Datastore.Migration
[Test]
public void should_move_grab_id_from_date_to_columns()
{
var db = WithMigrationTestDb(c =>
WithTestDb(c =>
{
InsertHistory(c, new Dictionary<string, string>
{
@@ -32,19 +33,19 @@ namespace NzbDrone.Core.Test.Datastore.Migration
});
var history = db.Query<History72>("SELECT DownloadId, Data FROM History");
var allProfiles = Mocker.Resolve<HistoryRepository>().All().ToList();
history.Should().HaveCount(2);
history.Should().NotContain(c => c.Data.ContainsKey("downloadClientId"));
history.Should().Contain(c => c.DownloadId == "123");
history.Should().Contain(c => c.DownloadId == "abc");
allProfiles.Should().HaveCount(2);
allProfiles.Should().NotContain(c => c.Data.ContainsKey("downloadClientId"));
allProfiles.Should().Contain(c => c.DownloadId == "123");
allProfiles.Should().Contain(c => c.DownloadId == "abc");
}
[Test]
public void should_leave_items_with_no_grabid()
{
var db = WithMigrationTestDb(c =>
WithTestDb(c =>
{
InsertHistory(c, new Dictionary<string, string>
{
@@ -59,18 +60,18 @@ namespace NzbDrone.Core.Test.Datastore.Migration
});
var history = db.Query<History72>("SELECT DownloadId, Data FROM History");
var allProfiles = Mocker.Resolve<HistoryRepository>().All().ToList();
history.Should().HaveCount(2);
history.Should().NotContain(c => c.Data.ContainsKey("downloadClientId"));
history.Should().Contain(c => c.DownloadId == "123");
history.Should().Contain(c => c.DownloadId == null);
allProfiles.Should().HaveCount(2);
allProfiles.Should().NotContain(c => c.Data.ContainsKey("downloadClientId"));
allProfiles.Should().Contain(c => c.DownloadId == "123");
allProfiles.Should().Contain(c => c.DownloadId == null);
}
[Test]
public void should_leave_other_data()
{
var db = WithMigrationTestDb(c =>
WithTestDb(c =>
{
InsertHistory(c, new Dictionary<string, string>
{
@@ -80,15 +81,16 @@ namespace NzbDrone.Core.Test.Datastore.Migration
});
});
var history = db.Query<History72>("SELECT DownloadId, Data FROM History").Single();
var allProfiles = Mocker.Resolve<HistoryRepository>().All().Single();
history.Data.Should().NotContainKey("downloadClientId");
history.Data.Should().Contain(new KeyValuePair<string, string>("indexer", "test"));
history.Data.Should().Contain(new KeyValuePair<string, string>("group", "test2"));
allProfiles.Data.Should().NotContainKey("downloadClientId");
allProfiles.Data.Should().Contain(new KeyValuePair<string, string>("indexer", "test"));
allProfiles.Data.Should().Contain(new KeyValuePair<string, string>("group", "test2"));
history.DownloadId.Should().Be("123");
allProfiles.DownloadId.Should().Be("123");
}
private void InsertHistory(MigrationBase migrationBase, Dictionary<string, string> data)
{
migrationBase.Insert.IntoTable("History").Row(new

View File

@@ -1,28 +1,29 @@
using System.Linq;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Jobs;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Datastore.Migration;
using NzbDrone.Core.Tv;
namespace NzbDrone.Core.Test.Datastore.Migration
{
[TestFixture]
public class force_lib_updateFixture : MigrationTest<force_lib_update>
public class force_lib_updateFixture : MigrationTest<Core.Datastore.Migration.force_lib_update>
{
[Test]
public void should_not_fail_on_empty_db()
{
var db = WithMigrationTestDb();
WithTestDb(c => { });
db.Query("SELECT * FROM ScheduledTasks").Should().BeEmpty();
db.Query("SELECT * FROM Series").Should().BeEmpty();
Mocker.Resolve<ScheduledTaskRepository>().All().Should().BeEmpty();
Mocker.Resolve<SeriesRepository>().All().Should().BeEmpty();
}
[Test]
public void should_reset_job_last_execution_time()
{
var db = WithMigrationTestDb(c =>
WithTestDb(c =>
{
c.Insert.IntoTable("ScheduledTasks").Row(new
{
@@ -39,7 +40,7 @@ namespace NzbDrone.Core.Test.Datastore.Migration
});
});
var jobs = db.Query<ScheduledTasks75>("SELECT TypeName, LastExecution FROM ScheduledTasks");
var jobs = Mocker.Resolve<ScheduledTaskRepository>().All().ToList();
jobs.Single(c => c.TypeName == "NzbDrone.Core.Tv.Commands.RefreshSeriesCommand")
.LastExecution.Year.Should()
@@ -50,10 +51,11 @@ namespace NzbDrone.Core.Test.Datastore.Migration
.Be(2000);
}
[Test]
public void should_reset_series_last_sync_time()
{
var db = WithMigrationTestDb(c =>
WithTestDb(c =>
{
c.Insert.IntoTable("Series").Row(new
{
@@ -90,9 +92,9 @@ namespace NzbDrone.Core.Test.Datastore.Migration
});
});
var series = db.Query<Series69>("SELECT LastInfoSync FROM Series");
var jobs = Mocker.Resolve<SeriesRepository>().All().ToList();
series.Should().OnlyContain(c => c.LastInfoSync.Value.Year == 2014);
jobs.Should().OnlyContain(c => c.LastInfoSync.Value.Year == 2014);
}
}
}

View File

@@ -1,18 +1,21 @@
using System.Linq;
using System;
using System.Linq;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Datastore.Migration;
using NzbDrone.Core.Jobs;
using NzbDrone.Core.Tags;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv;
namespace NzbDrone.Core.Test.Datastore.Migration
{
[TestFixture]
public class dedupe_tagsFixture : MigrationTest<dedupe_tags>
public class dedupe_tagsFixture : MigrationTest<Core.Datastore.Migration.dedupe_tags>
{
[Test]
public void should_not_fail_if_series_tags_are_null()
{
var db = WithMigrationTestDb(c =>
WithTestDb(c =>
{
c.Insert.IntoTable("Series").Row(new
{
@@ -37,14 +40,13 @@ namespace NzbDrone.Core.Test.Datastore.Migration
});
});
var tags = db.Query<Tag69>("SELECT * FROM Tags");
tags.Should().HaveCount(1);
Mocker.Resolve<TagRepository>().All().Should().HaveCount(1);
}
[Test]
public void should_not_fail_if_series_tags_are_empty()
{
var db = WithMigrationTestDb(c =>
WithTestDb(c =>
{
c.Insert.IntoTable("Series").Row(new
{
@@ -70,14 +72,13 @@ namespace NzbDrone.Core.Test.Datastore.Migration
});
});
var tags = db.Query<Tag69>("SELECT * FROM Tags");
tags.Should().HaveCount(1);
Mocker.Resolve<TagRepository>().All().Should().HaveCount(1);
}
[Test]
public void should_remove_duplicate_labels_from_tags()
{
var db = WithMigrationTestDb(c =>
WithTestDb(c =>
{
c.Insert.IntoTable("Tags").Row(new
{
@@ -90,14 +91,13 @@ namespace NzbDrone.Core.Test.Datastore.Migration
});
});
var tags = db.Query<Tag69>("SELECT * FROM Tags");
tags.Should().HaveCount(1);
Mocker.Resolve<TagRepository>().All().Should().HaveCount(1);
}
[Test]
public void should_not_allow_duplicate_tag_to_be_inserted()
{
var db = WithMigrationTestDb(c =>
WithTestDb(c =>
{
c.Insert.IntoTable("Tags").Row(new
{
@@ -105,13 +105,13 @@ namespace NzbDrone.Core.Test.Datastore.Migration
});
});
Assert.That(() => db.Query("INSERT INTO Tags (Label) VALUES ('test')"), Throws.Exception);
Assert.That(() => Mocker.Resolve<TagRepository>().Insert(new Tag { Label = "test" }), Throws.Exception);
}
[Test]
public void should_replace_duplicated_tag_with_proper_tag()
{
var db = WithMigrationTestDb(c =>
WithTestDb(c =>
{
c.Insert.IntoTable("Series").Row(new
{
@@ -142,14 +142,13 @@ namespace NzbDrone.Core.Test.Datastore.Migration
});
});
var series = db.Query<Series69>("SELECT Tags FROM Series WHERE Id = 1").Single();
series.Tags.First().Should().Be(1);
Mocker.Resolve<SeriesRepository>().Get(1).Tags.First().Should().Be(1);
}
[Test]
public void should_only_update_affected_series()
{
var db = WithMigrationTestDb(c =>
WithTestDb(c =>
{
c.Insert.IntoTable("Series").Row(new
{
@@ -198,8 +197,7 @@ namespace NzbDrone.Core.Test.Datastore.Migration
});
});
var series = db.Query<Series69>("SELECT Tags FROM Series WHERE Id = 2").Single();
series.Tags.Should().BeEmpty();
Mocker.Resolve<SeriesRepository>().Get(2).Tags.Should().BeEmpty();
}
}
}

View File

@@ -3,25 +3,27 @@ using System.Linq;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Common.Serializer;
using NzbDrone.Core.Download;
using NzbDrone.Core.Download.Clients.Sabnzbd;
using NzbDrone.Core.Download.Clients.Transmission;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Datastore.Migration;
namespace NzbDrone.Core.Test.Datastore.Migration
{
[TestFixture]
public class move_dot_prefix_to_transmission_categoryFixture : MigrationTest<move_dot_prefix_to_transmission_category>
public class move_dot_prefix_to_transmission_categoryFixture : MigrationTest<Core.Datastore.Migration.move_dot_prefix_to_transmission_category>
{
[Test]
public void should_not_fail_if_no_transmission()
{
var db = WithMigrationTestDb(c =>
WithTestDb(c =>
{
c.Insert.IntoTable("DownloadClients").Row(new
c.Insert.IntoTable("DownloadClients").Row(new
{
Enable = 1,
Name = "Sab",
Implementation = "Sabnzbd",
Settings = new
Settings = new SabnzbdSettings
{
Host = "127.0.0.1",
TvCategory = "abc"
@@ -30,23 +32,24 @@ namespace NzbDrone.Core.Test.Datastore.Migration
});
});
var downloadClients = db.Query<DownloadClientDefinition81>("SELECT Settings FROM DownloadClients");
var items = Mocker.Resolve<DownloadClientRepository>().All();
downloadClients.Should().HaveCount(1);
downloadClients.First().Settings.ToObject<SabnzbdSettings81>().TvCategory.Should().Be("abc");
items.Should().HaveCount(1);
items.First().Settings.As<SabnzbdSettings>().TvCategory.Should().Be("abc");
}
[Test]
public void should_be_updated_for_transmission()
{
var db = WithMigrationTestDb(c =>
WithTestDb(c =>
{
c.Insert.IntoTable("DownloadClients").Row(new
{
Enable = 1,
Name = "Trans",
Implementation = "Transmission",
Settings = new
Settings = new TransmissionSettings
{
Host = "127.0.0.1",
TvCategory = "abc"
@@ -55,23 +58,24 @@ namespace NzbDrone.Core.Test.Datastore.Migration
});
});
var downloadClients = db.Query<DownloadClientDefinition81>("SELECT Settings FROM DownloadClients");
var items = Mocker.Resolve<DownloadClientRepository>().All();
downloadClients.Should().HaveCount(1);
downloadClients.First().Settings.ToObject<TransmissionSettings81>().TvCategory.Should().Be(".abc");
items.Should().HaveCount(1);
items.First().Settings.As<TransmissionSettings>().TvCategory.Should().Be(".abc");
}
[Test]
public void should_leave_empty_category_untouched()
{
var db = WithMigrationTestDb(c =>
WithTestDb(c =>
{
c.Insert.IntoTable("DownloadClients").Row(new
{
Enable = 1,
Name = "Trans",
Implementation = "Transmission",
Settings = new
Settings = new TransmissionSettings
{
Host = "127.0.0.1",
TvCategory = ""
@@ -80,10 +84,11 @@ namespace NzbDrone.Core.Test.Datastore.Migration
});
});
var downloadClients = db.Query<DownloadClientDefinition81>("SELECT Settings FROM DownloadClients");
var items = Mocker.Resolve<DownloadClientRepository>().All();
downloadClients.Should().HaveCount(1);
downloadClients.First().Settings.ToObject<TransmissionSettings81>().TvCategory.Should().Be("");
items.Should().HaveCount(1);
items.First().Settings.As<TransmissionSettings>().TvCategory.Should().Be("");
}
}
}

View File

@@ -1,28 +1,32 @@
using System.Linq;
using System;
using System.Linq;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Datastore.Migration;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.Datastore.Migration
{
[TestFixture]
public class update_quality_minmax_sizeFixture : MigrationTest<update_quality_minmax_size>
public class update_quality_minmax_sizeFixture : MigrationTest<Core.Datastore.Migration.update_quality_minmax_size>
{
[Test]
public void should_not_fail_if_empty()
{
var db = WithMigrationTestDb();
WithTestDb(c =>
{
var qualityDefinitions = db.Query<QualityDefinition84>("SELECT * FROM QualityDefinitions");
});
qualityDefinitions.Should().BeEmpty();
var items = Mocker.Resolve<QualityDefinitionRepository>().All();
items.Should().HaveCount(0);
}
[Test]
public void should_set_rawhd_to_null()
{
var db = WithMigrationTestDb(c =>
WithTestDb(c =>
{
c.Insert.IntoTable("QualityDefinitions").Row(new
{
@@ -40,16 +44,17 @@ namespace NzbDrone.Core.Test.Datastore.Migration
});
});
var qualityDefinitions = db.Query<QualityDefinition84>("SELECT * FROM QualityDefinitions");
var items = Mocker.Resolve<QualityDefinitionRepository>().All();
qualityDefinitions.Should().HaveCount(2);
qualityDefinitions.First(v => v.Quality == 10).MaxSize.Should().NotHaveValue();
items.Should().HaveCount(2);
items.First(v => v.Quality.Id == 10).MaxSize.Should().NotHaveValue();
}
[Test]
public void should_set_zero_maxsize_to_null()
{
var db = WithMigrationTestDb(c =>
WithTestDb(c =>
{
c.Insert.IntoTable("QualityDefinitions").Row(new
{
@@ -60,16 +65,17 @@ namespace NzbDrone.Core.Test.Datastore.Migration
});
});
var qualityDefinitions = db.Query<QualityDefinition84>("SELECT * FROM QualityDefinitions");
var items = Mocker.Resolve<QualityDefinitionRepository>().All();
qualityDefinitions.Should().HaveCount(1);
qualityDefinitions.First(v => v.Quality == 1).MaxSize.Should().NotHaveValue();
items.Should().HaveCount(1);
items.First(v => v.Quality.Id == 1).MaxSize.Should().NotHaveValue();
}
[Test]
public void should_preserve_values()
{
var db = WithMigrationTestDb(c =>
WithTestDb(c =>
{
c.Insert.IntoTable("QualityDefinitions").Row(new
{
@@ -87,10 +93,11 @@ namespace NzbDrone.Core.Test.Datastore.Migration
});
});
var qualityDefinitions = db.Query<QualityDefinition84>("SELECT * FROM QualityDefinitions");
var items = Mocker.Resolve<QualityDefinitionRepository>().All();
qualityDefinitions.Should().HaveCount(2);
qualityDefinitions.First(v => v.Quality == 1).MaxSize.Should().Be(100);
items.Should().HaveCount(2);
items.First(v => v.Quality.Id == 1).MaxSize.Should().Be(100);
}
}
}

View File

@@ -1,26 +1,30 @@
using System.Linq;
using System;
using System.Linq;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Common.Serializer;
using NzbDrone.Core.Datastore.Migration;
using NzbDrone.Core.Download;
using NzbDrone.Core.Download.Clients.Deluge;
using NzbDrone.Core.Download.Clients.Sabnzbd;
using NzbDrone.Core.Download.Clients.Transmission;
using NzbDrone.Core.Test.Framework;
using System.Drawing;
namespace NzbDrone.Core.Test.Datastore.Migration
{
[TestFixture]
public class expand_transmission_urlbaseFixture : MigrationTest<expand_transmission_urlbase>
public class expand_transmission_urlbaseFixture : MigrationTest<Core.Datastore.Migration.expand_transmission_urlbase>
{
[Test]
public void should_not_fail_if_no_transmission()
{
var db = WithMigrationTestDb(c =>
WithTestDb(c =>
{
c.Insert.IntoTable("DownloadClients").Row(new
{
Enable = 1,
Name = "Deluge",
Implementation = "Deluge",
Settings = new DelugeSettings85
Settings = new DelugeSettings
{
Host = "127.0.0.1",
TvCategory = "abc",
@@ -30,48 +34,51 @@ namespace NzbDrone.Core.Test.Datastore.Migration
});
});
var items = db.Query<DownloadClientDefinition81>("SELECT * FROM DownloadClients");
var items = Mocker.Resolve<DownloadClientRepository>().All();
items.Should().HaveCount(1);
items.First().Settings.ToObject<DelugeSettings85>().UrlBase.Should().Be("/my/");
items.First().Settings.As<DelugeSettings>().UrlBase.Should().Be("/my/");
}
[Test]
public void should_be_updated_for_transmission()
{
var db = WithMigrationTestDb(c =>
WithTestDb(c =>
{
c.Insert.IntoTable("DownloadClients").Row(new
{
Enable = 1,
Name = "Trans",
Implementation = "Transmission",
Settings = new TransmissionSettings81
Settings = new TransmissionSettings
{
Host = "127.0.0.1",
TvCategory = "abc"
TvCategory = "abc",
UrlBase = null
}.ToJson(),
ConfigContract = "TransmissionSettings"
});
});
var items = db.Query<DownloadClientDefinition81>("SELECT * FROM DownloadClients");
var items = Mocker.Resolve<DownloadClientRepository>().All();
items.Should().HaveCount(1);
items.First().Settings.ToObject<TransmissionSettings81>().UrlBase.Should().Be("/transmission/");
items.First().Settings.As<TransmissionSettings>().UrlBase.Should().Be("/transmission/");
}
[Test]
public void should_be_append_to_existing_urlbase()
{
var db = WithMigrationTestDb(c =>
WithTestDb(c =>
{
c.Insert.IntoTable("DownloadClients").Row(new
{
Enable = 1,
Name = "Trans",
Implementation = "Transmission",
Settings = new TransmissionSettings81
Settings = new TransmissionSettings
{
Host = "127.0.0.1",
TvCategory = "abc",
@@ -81,10 +88,11 @@ namespace NzbDrone.Core.Test.Datastore.Migration
});
});
var items = db.Query<DownloadClientDefinition81>("SELECT * FROM DownloadClients");
var items = Mocker.Resolve<DownloadClientRepository>().All();
items.Should().HaveCount(1);
items.First().Settings.ToObject<TransmissionSettings81>().UrlBase.Should().Be("/my/url/transmission/");
items.First().Settings.As<TransmissionSettings>().UrlBase.Should().Be("/my/url/transmission/");
}
}
}

View File

@@ -2,18 +2,19 @@
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Common.Serializer;
using NzbDrone.Core.Datastore.Migration;
using NzbDrone.Core.Notifications;
using NzbDrone.Core.Notifications.PushBullet;
using NzbDrone.Core.Notifications.Pushover;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.Datastore.Migration
{
[TestFixture]
public class pushbullet_device_idsFixture : MigrationTest<pushbullet_device_ids>
public class pushbullet_device_idsFixture : MigrationTest<Core.Datastore.Migration.pushbullet_device_ids>
{
[Test]
public void should_not_fail_if_no_pushbullet()
{
var db = WithMigrationTestDb(c =>
WithTestDb(c =>
{
c.Insert.IntoTable("Notifications").Row(new
{
@@ -22,12 +23,12 @@ namespace NzbDrone.Core.Test.Datastore.Migration
OnUpgrade = false,
Name = "Pushover",
Implementation = "Pushover",
Settings = "{}",
Settings = new PushoverSettings().ToJson(),
ConfigContract = "PushoverSettings"
});
});
var items = db.Query<Notification86>("SELECT * FROM Notifications");
var items = Mocker.Resolve<NotificationRepository>().All();
items.Should().HaveCount(1);
}
@@ -35,7 +36,7 @@ namespace NzbDrone.Core.Test.Datastore.Migration
[Test]
public void should_not_fail_if_deviceId_is_not_set()
{
var db = WithMigrationTestDb(c =>
WithTestDb(c =>
{
c.Insert.IntoTable("Notifications").Row(new
{
@@ -46,13 +47,13 @@ namespace NzbDrone.Core.Test.Datastore.Migration
Implementation = "PushBullet",
Settings = new
{
ApiKey = "my_api_key"
ApiKey = "my_api_key",
}.ToJson(),
ConfigContract = "PushBulletSettings"
});
});
var items = db.Query<Notification86>("SELECT * FROM Notifications");
var items = Mocker.Resolve<NotificationRepository>().All();
items.Should().HaveCount(1);
}
@@ -62,7 +63,7 @@ namespace NzbDrone.Core.Test.Datastore.Migration
{
var deviceId = "device_id";
var db = WithMigrationTestDb(c =>
WithTestDb(c =>
{
c.Insert.IntoTable("Notifications").Row(new
{
@@ -80,10 +81,10 @@ namespace NzbDrone.Core.Test.Datastore.Migration
});
});
var items = db.Query<Notification86>("SELECT * FROM Notifications");
var items = Mocker.Resolve<NotificationRepository>().All();
items.Should().HaveCount(1);
items.First().Settings.ToObject<PushBulletSettings86>().DeviceIds.First().Should().Be(deviceId);
items.First().Settings.As<PushBulletSettings>().DeviceIds.First().Should().Be(deviceId);
}
}
}

View File

@@ -2,18 +2,21 @@
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Common.Serializer;
using NzbDrone.Core.Datastore.Migration;
using NzbDrone.Core.Notifications;
using NzbDrone.Core.Notifications.PushBullet;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.Datastore.Migration
{
[TestFixture]
public class pushbullet_devices_channels_listFixture : MigrationTest<pushbullet_devices_channels_list>
public class pushbullet_devices_channels : MigrationTest<Core.Datastore.Migration.pushbullet_devices_channels_list>
{
[Test]
public void should_convert_comma_separted_string_to_list()
{
var db = WithMigrationTestDb(c =>
var deviceId = "device_id";
WithTestDb(c =>
{
c.Insert.IntoTable("Notifications").Row(new
{
@@ -31,10 +34,11 @@ namespace NzbDrone.Core.Test.Datastore.Migration
});
});
var items = db.Query<Notification86>("SELECT * FROM Notifications");
var items = Mocker.Resolve<NotificationRepository>().All();
items.Should().HaveCount(1);
items.First().Settings.ToObject<PushBulletSettings88>().ChannelTags.Should().HaveCount(2);
var settings = items.First().Settings.As<PushBulletSettings>();
settings.ChannelTags.Should().HaveCount(2);
}
}
}

View File

@@ -3,6 +3,8 @@ using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Common.Serializer;
using NzbDrone.Core.Datastore.Migration;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Indexers.KickassTorrents;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.Datastore.Migration
@@ -18,13 +20,13 @@ namespace NzbDrone.Core.Test.Datastore.Migration
// [TestCase("HTTP://KICKASS.SO")] Not sure if there is an easy way to do this, not sure if worth it.
public void should_replace_old_url(string oldUrl)
{
var db = WithMigrationTestDb(c =>
WithTestDb(c =>
{
c.Insert.IntoTable("Indexers").Row(new
{
Name = "Kickass_wrong_url",
Implementation = "KickassTorrents",
Settings = new KickassTorrentsSettings90
Settings = new KickassTorrentsSettings
{
BaseUrl = oldUrl
}.ToJson(),
@@ -32,22 +34,22 @@ namespace NzbDrone.Core.Test.Datastore.Migration
});
});
var items = db.Query<IndexerDefinition90>("SELECT * FROM Indexers");
var items = Mocker.Resolve<IndexerRepository>().All().ToList();
items.Should().HaveCount(1);
items.First().Settings.ToObject<KickassTorrentsSettings90>().BaseUrl.Should().Be("https://kat.cr");
items.First().Settings.As<KickassTorrentsSettings>().BaseUrl.Should().Be("https://kat.cr");
}
[Test]
public void should_not_replace_other_indexers()
{
var db = WithMigrationTestDb(c =>
WithTestDb(c =>
{
c.Insert.IntoTable("Indexers").Row(new
{
Name = "not_kickass",
Implementation = "NotKickassTorrents",
Settings = new KickassTorrentsSettings90
Settings = new KickassTorrentsSettings
{
BaseUrl = "kickass.so",
}.ToJson(),
@@ -55,10 +57,10 @@ namespace NzbDrone.Core.Test.Datastore.Migration
});
});
var items = db.Query<IndexerDefinition90>("SELECT * FROM Indexers");
var items = Mocker.Resolve<IndexerRepository>().All().ToList();
items.Should().HaveCount(1);
items.First().Settings.ToObject<KickassTorrentsSettings90>().BaseUrl.Should().Be("kickass.so");
items.First().Settings.As<KickassTorrentsSettings>().BaseUrl.Should().Be("kickass.so");
}
}
}

View File

@@ -1,35 +0,0 @@
using System.Linq;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Datastore.Migration;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.Datastore.Migration
{
[TestFixture]
public class add_ultrahd_quality_in_profilesFixture : MigrationTest<add_ultrahd_quality_in_profiles>
{
[Test]
public void should_add_ultrahd_to_old_profile()
{
var db = WithMigrationTestDb(c =>
{
c.Insert.IntoTable("Profiles").Row(new
{
Id = 0,
Name = "SDTV",
Cutoff = 1,
Items = "[ { \"quality\": 1, \"allowed\": true } ]",
Language = 1
});
});
var profiles = db.Query<Profile70>("SELECT Items FROM Profiles LIMIT 1");
var items = profiles.First().Items;
items.Should().HaveCount(4);
items.Select(v => v.Quality).Should().BeEquivalentTo(1, 16, 18, 19);
items.Select(v => v.Allowed).Should().BeEquivalentTo(true, false, false, false);
}
}
}

View File

@@ -396,22 +396,5 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests
result.OutputRootFolders.Should().NotBeNull();
result.OutputRootFolders.First().Should().Be(@"O:\mymount".AsOsAgnostic());
}
[TestCase("0.6.9", false)]
[TestCase("0.7.0", true)]
[TestCase("0.8.0", true)]
[TestCase("1.0.0", true)]
[TestCase("1.0.0RC1", true)]
[TestCase("1.1.x", true)]
public void should_test_version(string version, bool expected)
{
Mocker.GetMock<ISabnzbdProxy>()
.Setup(v => v.GetVersion(It.IsAny<SabnzbdSettings>()))
.Returns(version);
var error = Subject.Test();
error.IsValid.Should().Be(expected);
}
}
}

View File

@@ -1,93 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:torrent="http://xmlns.ezrss.it/0.1/">
<channel>
<title>tv torrents RSS feed - KickassTorrents</title>
<link>http://kickass.to/</link>
<description>tv torrents RSS feed</description>
<item>
<title>Doctor Strang&eacute;r.E03.140512.HDTV.H264.720p-iPOP.avi [CTRG]</title>
<category>TV</category>
<author>http://kickass.to/user/2NE1/</author>
<link>http://kickass.to/doctor-stranger-e03-140512-hdtv-h264-720p-ipop-avi-ctrg-t9100648.html</link>
<guid>http://kickass.to/doctor-stranger-e03-140512-hdtv-h264-720p-ipop-avi-ctrg-t9100648.html</guid>
<pubDate>Mon, 12 May 2014 16:16:49 +0000</pubDate>
<torrent:contentLength>1205364736</torrent:contentLength>
<torrent:infoHash>208C4F7866612CC88BFEBC7C496FA72C2368D1C0</torrent:infoHash>
<torrent:magnetURI><![CDATA[magnet:?xt=urn:btih:208C4F7866612CC88BFEBC7C496FA72C2368D1C0&dn=doctor+stranger+e03+140512+hdtv+h264+720p+ipop+avi+ctrg&tr=udp%3A%2F%2Fopen.demonii.com%3A1337%2Fannounce]]></torrent:magnetURI>
<torrent:seeds>206</torrent:seeds>
<torrent:peers>311</torrent:peers>
<torrent:verified>1</torrent:verified>
<torrent:fileName>doctor.stranger.e03.140512.hdtv.h264.720p.ipop.avi.ctrg.torrent</torrent:fileName>
<enclosure url="http://torcache.net/torrent/208C4F7866612CC88BFEBC7C496FA72C2368D1C0.torrent?title=%5Bkickass.to%5Ddoctor.stranger.e03.140512.hdtv.h264.720p.ipop.avi.ctrg" length="1205364736" type="application/x-bittorrent" />
</item>
<item>
<title>Triangle.E03.140512.HDTV.XViD-iPOP.avi [CTRG]</title>
<category>TV</category>
<author>http://kickass.to/user/2NE1/</author>
<link>http://kickass.to/triangle-e03-140512-hdtv-xvid-ipop-avi-ctrg-t9100647.html</link>
<guid>http://kickass.to/triangle-e03-140512-hdtv-xvid-ipop-avi-ctrg-t9100647.html</guid>
<pubDate>Mon, 12 May 2014 16:16:31 +0000</pubDate>
<torrent:contentLength>677543936</torrent:contentLength>
<torrent:infoHash>BF22A53C9889A7D325F2A3D904E566B7DF4074EB</torrent:infoHash>
<torrent:magnetURI><![CDATA[magnet:?xt=urn:btih:BF22A53C9889A7D325F2A3D904E566B7DF4074EB&dn=triangle+e03+140512+hdtv+xvid+ipop+avi+ctrg&tr=udp%3A%2F%2Fopen.demonii.com%3A1337%2Fannounce]]></torrent:magnetURI>
<torrent:seeds>242</torrent:seeds>
<torrent:peers>374</torrent:peers>
<torrent:verified>1</torrent:verified>
<torrent:fileName>triangle.e03.140512.hdtv.xvid.ipop.avi.ctrg.torrent</torrent:fileName>
<enclosure url="http://torcache.net/torrent/BF22A53C9889A7D325F2A3D904E566B7DF4074EB.torrent?title=%5Bkickass.to%5Dtriangle.e03.140512.hdtv.xvid.ipop.avi.ctrg" length="677543936" type="application/x-bittorrent" />
</item>
<item>
<title>Triangle.E03.140512.HDTV.H264.720p-iPOP.avi [CTRG]</title>
<category>TV</category>
<author>http://kickass.to/user/2NE1/</author>
<link>http://kickass.to/triangle-e03-140512-hdtv-h264-720p-ipop-avi-ctrg-t9100646.html</link>
<guid>http://kickass.to/triangle-e03-140512-hdtv-h264-720p-ipop-avi-ctrg-t9100646.html</guid>
<pubDate>Mon, 12 May 2014 16:16:10 +0000</pubDate>
<torrent:contentLength>1196869632</torrent:contentLength>
<torrent:infoHash>8427BFB8884B8228364EBB9B3EA7D8B77E03A7BC</torrent:infoHash>
<torrent:magnetURI><![CDATA[magnet:?xt=urn:btih:8427BFB8884B8228364EBB9B3EA7D8B77E03A7BC&dn=triangle+e03+140512+hdtv+h264+720p+ipop+avi+ctrg&tr=udp%3A%2F%2Fopen.demonii.com%3A1337%2Fannounce]]></torrent:magnetURI>
<torrent:seeds>177</torrent:seeds>
<torrent:peers>268</torrent:peers>
<torrent:verified>1</torrent:verified>
<torrent:fileName>triangle.e03.140512.hdtv.h264.720p.ipop.avi.ctrg.torrent</torrent:fileName>
<enclosure url="http://torcache.net/torrent/8427BFB8884B8228364EBB9B3EA7D8B77E03A7BC.torrent?title=%5Bkickass.to%5Dtriangle.e03.140512.hdtv.h264.720p.ipop.avi.ctrg" length="1196869632" type="application/x-bittorrent" />
</item>
<item>
<title>Triangle.E03.140512.HDTV.X264.720p-BarosG_.avi [CTRG]</title>
<category>TV</category>
<author>http://kickass.to/user/2NE1/</author>
<link>http://kickass.to/triangle-e03-140512-hdtv-x264-720p-barosg-avi-ctrg-t9100644.html</link>
<guid>http://kickass.to/triangle-e03-140512-hdtv-x264-720p-barosg-avi-ctrg-t9100644.html</guid>
<pubDate>Mon, 12 May 2014 16:15:52 +0000</pubDate>
<torrent:contentLength>1418906266</torrent:contentLength>
<torrent:infoHash>5556B773893DB55287ECEC581E850B853163DB11</torrent:infoHash>
<torrent:magnetURI><![CDATA[magnet:?xt=urn:btih:5556B773893DB55287ECEC581E850B853163DB11&dn=triangle+e03+140512+hdtv+x264+720p+barosg+avi+ctrg&tr=udp%3A%2F%2Fopen.demonii.com%3A1337%2Fannounce]]></torrent:magnetURI>
<torrent:seeds>522</torrent:seeds>
<torrent:peers>785</torrent:peers>
<torrent:verified>1</torrent:verified>
<torrent:fileName>triangle.e03.140512.hdtv.x264.720p.barosg.avi.ctrg.torrent</torrent:fileName>
<enclosure url="http://torcache.net/torrent/5556B773893DB55287ECEC581E850B853163DB11.torrent?title=%5Bkickass.to%5Dtriangle.e03.140512.hdtv.x264.720p.barosg.avi.ctrg" length="1418906266" type="application/x-bittorrent" />
</item>
<item>
<title>Battlestar Galactica 1978 Dvd3 e09 e10 e11 e12 [NL] [FR] [ENG] Sub</title>
<description>
<![CDATA[In een afgelegen zonnestelsel leeft een mensenras op twaalf koloniewerelden. Ze zijn al eeuwen in oorlog met de Cylons, gevechtsrobots die ooit werden gemaakt door een allang verdwenen buitenaards reptielachtig ras. Met de hulp van de menselijke verrader Baltar zijn de Cylons erin geslaagd de mensheid vrijwel uit te roeien. Slechts een oorlogsschip kan aan de vernietiging ontkomen: de Battlestar Galactica van commandant Adama.
Met een vloot burgerschepen vol vluchtelingen vlucht de Galactica voor de Cylons. Adama besluit op zoek te gaan naar de legendarische 13e en laatste kolonie, genaamd Aarde. Tijdens de lange en gevaarlijke reis worden ze voortdurend bedreigd door de achtervolgende Cylons en andere gevaren.]]>
</description>
<category>TV</category>
<author>http://kickass.to/user/hendriknl/</author>
<link>http://kickass.to/battlestar-galactica-1978-dvd3-e09-e10-e11-e12-nl-fr-eng-sub-t9100642.html</link>
<guid>http://kickass.to/battlestar-galactica-1978-dvd3-e09-e10-e11-e12-nl-fr-eng-sub-t9100642.html</guid>
<pubDate>Mon, 12 May 2014 16:15:46 +0000</pubDate>
<torrent:contentLength>4680841216</torrent:contentLength>
<torrent:infoHash>3D293CAFEDAC595F6E55F9C284DD76862FE254F6</torrent:infoHash>
<torrent:magnetURI><![CDATA[magnet:?xt=urn:btih:3D293CAFEDAC595F6E55F9C284DD76862FE254F6&dn=battlestar+galactica+1978+dvd3+e09+e10+e11+e12+nl+fr+eng+sub&tr=udp%3A%2F%2Fopen.demonii.com%3A1337%2Fannounce]]></torrent:magnetURI>
<torrent:seeds>2</torrent:seeds>
<torrent:peers>5</torrent:peers>
<torrent:verified>0</torrent:verified>
<torrent:fileName>battlestar.galactica.1978.dvd3.e09.e10.e11.e12.nl.fr.eng.sub.torrent</torrent:fileName>
<enclosure url="http://torcache.net/torrent/3D293CAFEDAC595F6E55F9C284DD76862FE254F6.torrent?title=%5Bkickass.to%5Dbattlestar.galactica.1978.dvd3.e09.e10.e11.e12.nl.fr.eng.sub" length="4680841216" type="application/x-bittorrent" />
</item>
</channel>
</rss>

View File

@@ -1,31 +0,0 @@
<caps>
<server appversion="" version="0.1" />
<limits max="60" default="25"/>
<registration available="yes" open="no"/>
<searching>
<search available="yes"/>
<tv-search available="yes"/>
<movie-search available="yes"/>
<audio-search available="yes"/>
</searching>
<categories>
<category id="5000" name="TV">
<subcat id="5070" name="Anime"/>
<subcat id="5080" name="Documentary"/>
<subcat id="5020" name="Foreign"/>
<subcat id="5040" name="HD"/>
<subcat id="5050" name="Other"/>
<subcat id="5030" name="SD"/>
<subcat id="5060" name="Sport"/>
<subcat id="5010" name="WEB-DL"/>
</category>
<category id="7000" name="Other">
<subcat id="7010" name="Misc"/>
</category>
<category id="8000" name="Books">
<subcat id="8020" name="Comics"/>
</category>
</categories>
<groups></groups>
<genres></genres>
</caps>

View File

@@ -1,204 +0,0 @@
<?xml version='1.0' encoding='utf-8' ?>
<rss version='2.0'>
<channel>
<title><![CDATA[RSS ac.me, Category: TV. Torrents type: Most Downloaded. The World's Largest BitTorrent System]]></title>
<link>http://ac.me/</link>
<description>RSS ac.me The World's Largest BitTorrent System. Any torrents for download. Download music, movies, games, software, iPod, anime, porn, adult, books, pictures and other torrents.</description>
<language>en-us</language>
<category>All</category>
<webMaster>extratorr@gmail.com</webMaster>
<image>
<title>ac.me</title>
<url>http://ac.me/images/logo.gif</url>
<link>http://ac.me</link>
</image>
<item>
<title><![CDATA[One.Piece.E334.D ED.720p.HDTV.x264-W4F-={SPARROW}=-]]></title>
<pubDate>Sun, 21 Feb 2016 09:51:54 +0000</pubDate>
<category>TV</category>
<link>http://ac.me/torrent/4722030/One.Piece.E334.D+ED.720p.HDTV.x264-W4F-%3D%7BSPARROW%7D%3D-.html</link>
<enclosure url="http://ac.me/download/4722030/One.Piece.E334.D+ED.720p.HDTV.x264-W4F-%3D%7BSPARROW%7D%3D-.torrent" length="562386947" type="application/x-bittorrent" />
<guid isPermaLink="true">http://ac.me/torrent/4722030/One.Piece.E334.D+ED.720p.HDTV.x264-W4F-%3D%7BSPARROW%7D%3D-.html</guid>
<description>
<![CDATA[ <br />
<div class="bbcode_center" style="text-align:center"><br />
One.Piece.E334.DUBBED.720p.HDTV.x264-W4F-={SPARROW}=-<br /><br />
<br /><br />
<a href='http://www.sparrowpics.com/image/LwB' target='_blank' rel='nofollow' ><img src='http://www.sparrowpics.com/images/2015/12/10/Info.png' alt='Info.png' title='Info.png' border='0' /></a><br /><br />
<br /><br />
<span style="color:green"><br /><br />
one.piece.e334.720p.hdtv.x264-w4f-={SPARROW}=-.mkv<br /><br />
<br /><br />
File type: mkv<br /><br />
Duration: 00:21:14<br /><br />
Video size: 1280x720<br /><br />
Frame rate: 23.98<br /><br />
Bitrate: 3529 kb/s<br /><br />
Video codec: h264<br /><br />
Audio codec: ac3,<br /><br />
Audio type: 5.1(side) </span><br /><br />
<br /><br />
<a href='http://www.sparrowpics.com/image/UYe' target='_blank' rel='nofollow' ><img src='http://www.sparrowpics.com/images/2015/12/10/Screens.png' alt='Screens.png' title='Screens.png' border='0' /></a><br /><br />
<br /><br />
<span style="color:red">Click Image To View Full Size</span><br /><br />
<br /><br />
<a href='http://www.sparrowpics.com/image/FR1EP'... ]]>
</description>
<size>562386947</size>
<seeders>---</seeders>
<leechers>---</leechers>
<info_hash>c1b7641c4fd5fd4c248a7aee7c2ad0a4267a371c</info_hash>
</item>
<item>
<title><![CDATA[One Piece E334 D ED 720p HDTV x264-W4F]]></title>
<pubDate>Sun, 21 Feb 2016 09:44:21 +0000</pubDate>
<category>TV</category>
<link>http://ac.me/torrent/4722015/One+Piece+E334+D+ED+720p+HDTV+x264-W4F.html</link>
<enclosure url="http://ac.me/download/4722015/One+Piece+E334+D+ED+720p+HDTV+x264-W4F.torrent" length="562392556" type="application/x-bittorrent" />
<guid isPermaLink="true">http://ac.me/torrent/4722015/One+Piece+E334+D+ED+720p+HDTV+x264-W4F.html</guid>
<description>
<![CDATA[ <b></b><br /><br />
<br /><br />
<br /><br />
<br /><br />
<br /><br />
<b>one.piece.e334.720p.hdtv.x264-w4f.mkv</b><br /><br />
<br /><br />
<b>SIZE:</b> 562386319 bytes (536.33 MiB),<br /><br />
<br /><br />
<b>DURATION:</b> 00:21:14,<br /><br />
<br /><br />
<b>AVG-BITRATE:</b> 3531 kb/s<br /><br />
<br /><br />
<b>AUDIO:</b> ac3, 48000 Hz, 5:1 (eng)<br /><br />
<br /><br />
<b>VIDEO:</b> h264, yuv420p, 1280x720, 23.98 fps(r)<br /><br />
Subtitles: eng<br /><br />
<br /><br />
<br /><br />
<br /><br />
<br /><br />
<br /><br />
<b>SCREENS:</b><br /><br />
<a href='http://vivaex.com/img-56c986f4020e8.html' target='_blank' rel='nofollow' ><img src='http://vivaex.com/upload/small/2016/02/21/56c986f4020ae.jpg' alt='56c986f4020ae.jpg' title='56c986f4020ae.jpg' border='0' /></a><br /><br />
<br /><br />
<a href='http://vivaex.com/img-56c986f40a4b0.html' target='_blank' rel='nofollow' ><b>Large Runtime Screen</b></a><br /><br />
<br /><br />
<a href='http://vivaex.com/img-56c986f41229f.html' target='_blank' rel='nofollow' ><b>Large Runtime Screen</b></a> ]]>
</description>
<size>562392556</size>
<seeders>---</seeders>
<leechers>---</leechers>
<info_hash>1a69f565b531594e4f75b0fd4db153dce3e5186e</info_hash>
</item>
<item>
<title><![CDATA[Shadowhunters.S01E06.Of.Men.and.Angels.720p.HDTV.DD5.1.MPEG2-JiTB-={SPARROW}=-]]></title>
<pubDate>Sun, 21 Feb 2016 09:33:00 +0000</pubDate>
<category>TV</category>
<link>http://ac.me/torrent/4721983/Shadowhunters.S01E06.Of.Men.and.Angels.720p.HDTV.DD5.1.MPEG2-JiTB-%3D%7BSPARROW%7D%3D-.html</link>
<enclosure url="http://ac.me/download/4721983/Shadowhunters.S01E06.Of.Men.and.Angels.720p.HDTV.DD5.1.MPEG2-JiTB-%3D%7BSPARROW%7D%3D-.torrent" length="2826689668" type="application/x-bittorrent" />
<guid isPermaLink="true">http://ac.me/torrent/4721983/Shadowhunters.S01E06.Of.Men.and.Angels.720p.HDTV.DD5.1.MPEG2-JiTB-%3D%7BSPARROW%7D%3D-.html</guid>
<description>
<![CDATA[ <br />
<div class="bbcode_center" style="text-align:center"><br />
Shadowhunters.S01E06.Of.Men.and.Angels.720p.HDTV.DD5.1.MPEG2-JiTB-={SPARROW}=-<br /><br />
<br /><br />
<a href='http://www.sparrowpics.com/image/LwB' target='_blank' rel='nofollow' ><img src='http://www.sparrowpics.com/images/2015/12/10/Info.png' alt='Info.png' title='Info.png' border='0' /></a><br /><br />
<br /><br />
<span style="color:green"><br /><br />
Shadowhunters.S01E06.Of.Men.and.Angels.720p.HDTV.DD5.1.MPEG2-JiTB.ts<br /><br />
<br /><br />
File type: ts<br /><br />
Duration: 00:41:17<br /><br />
Video size: 1280x720<br /><br />
Frame rate: 59.94<br /><br />
Bitrate: 9126 kb/s<br /><br />
Video codec: mpeg2video<br /><br />
Audio codec: ac3<br /><br />
Audio type: 5.1(side) </span><br /><br />
<br /><br />
<a href='http://www.sparrowpics.com/image/UYe' target='_blank' rel='nofollow' ><img src='http://www.sparrowpics.com/images/2015/12/10/Screens.png' alt='Screens.png' title='Screens.png' border='0' /></a><br /><br />
<br /><br />
<span style="color:red">Click Image To View Full Size</span><br /><br />
<br /><br />
<a... ]]>
</description>
<size>2826689668</size>
<seeders>---</seeders>
<leechers>---</leechers>
<info_hash>e7b26a23c8cc7e8b2d7da35baaa5933a51586c90</info_hash>
</item>
<item>
<title><![CDATA[Shadowhunters.S01E05.Moo.Shu.to.Go.720p.HDTV.DD5.1.MPEG2-JiTB-={SPARROW}=-]]></title>
<pubDate>Sun, 21 Feb 2016 09:32:51 +0000</pubDate>
<category>TV</category>
<link>http://ac.me/torrent/4721982/Shadowhunters.S01E05.Moo.Shu.to.Go.720p.HDTV.DD5.1.MPEG2-JiTB-%3D%7BSPARROW%7D%3D-.html</link>
<enclosure url="http://ac.me/download/4721982/Shadowhunters.S01E05.Moo.Shu.to.Go.720p.HDTV.DD5.1.MPEG2-JiTB-%3D%7BSPARROW%7D%3D-.torrent" length="2823160720" type="application/x-bittorrent" />
<guid isPermaLink="true">http://ac.me/torrent/4721982/Shadowhunters.S01E05.Moo.Shu.to.Go.720p.HDTV.DD5.1.MPEG2-JiTB-%3D%7BSPARROW%7D%3D-.html</guid>
<description>
<![CDATA[ <br />
<div class="bbcode_center" style="text-align:center"><br />
Shadowhunters.S01E05.Moo.Shu.to.Go.720p.HDTV.DD5.1.MPEG2-JiTB-={SPARROW}=-<br /><br />
<br /><br />
<a href='http://www.sparrowpics.com/image/LwB' target='_blank' rel='nofollow' ><img src='http://www.sparrowpics.com/images/2015/12/10/Info.png' alt='Info.png' title='Info.png' border='0' /></a><br /><br />
<br /><br />
<span style="color:green"><br /><br />
Shadowhunters.S01E05.Moo.Shu.to.Go.720p.HDTV.DD5.1.MPEG2-JiTB.ts<br /><br />
<br /><br />
File type: ts<br /><br />
Duration: 00:41:18<br /><br />
Video size: 1280x720<br /><br />
Frame rate: 59.94<br /><br />
Bitrate: 9112 kb/s<br /><br />
Video codec: mpeg2video<br /><br />
Audio codec: ac3<br /><br />
Audio type: 5.1(side) </span><br /><br />
<br /><br />
<a href='http://www.sparrowpics.com/image/UYe' target='_blank' rel='nofollow' ><img src='http://www.sparrowpics.com/images/2015/12/10/Screens.png' alt='Screens.png' title='Screens.png' border='0' /></a><br /><br />
<br /><br />
<span style="color:red">Click Image To View Full Size</span><br /><br />
<br /><br />
<a... ]]>
</description>
<size>2823160720</size>
<seeders>---</seeders>
<leechers>---</leechers>
<info_hash>77faae6a126854fceb0a9a6fbdc229f68d3e3d03</info_hash>
</item>
<item>
<title><![CDATA[Second.Chance.2016.S01E05.Scratch.That.Glitch.720p.HDTV.DD5.1.MPEG2-JiTB-={SPARROW}=-]]></title>
<pubDate>Sun, 21 Feb 2016 09:32:47 +0000</pubDate>
<category>TV</category>
<link>http://ac.me/torrent/4721981/Second.Chance.2016.S01E05.Scratch.That.Glitch.720p.HDTV.DD5.1.MPEG2-JiTB-%3D%7BSPARROW%7D%3D-.html</link>
<enclosure url="http://ac.me/download/4721981/Second.Chance.2016.S01E05.Scratch.That.Glitch.720p.HDTV.DD5.1.MPEG2-JiTB-%3D%7BSPARROW%7D%3D-.torrent" length="4745525204" type="application/x-bittorrent" />
<guid isPermaLink="true">http://ac.me/torrent/4721981/Second.Chance.2016.S01E05.Scratch.That.Glitch.720p.HDTV.DD5.1.MPEG2-JiTB-%3D%7BSPARROW%7D%3D-.html</guid>
<description>
<![CDATA[ <br />
<div class="bbcode_center" style="text-align:center"><br />
Second.Chance.2016.S01E05.Scratch.That.Glitch.720p.HDTV.DD5.1.MPEG2-JiTB-={SPARROW}=-<br /><br />
<br /><br />
<a href='http://www.sparrowpics.com/image/LwB' target='_blank' rel='nofollow' ><img src='http://www.sparrowpics.com/images/2015/12/10/Info.png' alt='Info.png' title='Info.png' border='0' /></a><br /><br />
<br /><br />
<span style="color:green"><br /><br />
Second.Chance.2016.S01E05.Scratch.That.Glitch.720p.HDTV.DD5.1.MPEG2-JiTB.ts<br /><br />
<br /><br />
File type: ts<br /><br />
Duration: 00:42:01<br /><br />
Video size: 1280x720<br /><br />
Frame rate: 59.94<br /><br />
Bitrate: 15055 kb/s<br /><br />
Video codec: mpeg2video<br /><br />
Audio codec: ac3 ac3<br /><br />
Audio type: 5.1(side) stereo </span><br /><br />
<br /><br />
<a href='http://www.sparrowpics.com/image/UYe' target='_blank' rel='nofollow' ><img src='http://www.sparrowpics.com/images/2015/12/10/Screens.png' alt='Screens.png' title='Screens.png' border='0' /></a><br /><br />
<br /><br />
<span style="color:red">Click Image To View Full... ]]>
</description>
<size>4745525204</size>
<seeders>---</seeders>
<leechers>---</leechers>
<info_hash>0c341bbdadbc3c985304eb13893cc0731121e333</info_hash>
</item>
</channel>
</rss>

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using FluentMigrator;
@@ -8,11 +7,11 @@ using FluentMigrator.Runner;
using Marr.Data;
using Moq;
using NUnit.Framework;
using NzbDrone.Common.Serializer;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Datastore.Migration.Framework;
using NzbDrone.Core.Messaging.Events;
namespace NzbDrone.Core.Test.Framework
{
public abstract class DbTest<TSubject, TModel> : DbTest
@@ -71,6 +70,7 @@ namespace NzbDrone.Core.Test.Framework
get
{
return MigrationType.Main;
}
}
@@ -85,10 +85,10 @@ namespace NzbDrone.Core.Test.Framework
}
}
protected virtual ITestDatabase WithTestDb(MigrationContext migrationContext)
protected virtual TestDatabase WithTestDb(Action<MigrationBase> beforeMigration)
{
var factory = Mocker.Resolve<DbFactory>();
var database = factory.Create(migrationContext);
var database = factory.Create(MigrationType, beforeMigration);
Mocker.SetConstant(database);
switch (MigrationType)
@@ -118,6 +118,7 @@ namespace NzbDrone.Core.Test.Framework
return testDb;
}
protected void SetupContainer()
{
WithTempAsAppPath();
@@ -133,7 +134,7 @@ namespace NzbDrone.Core.Test.Framework
public virtual void SetupDb()
{
SetupContainer();
_db = WithTestDb(new MigrationContext(MigrationType));
_db = WithTestDb(null);
}
[TearDown]
@@ -157,4 +158,57 @@ namespace NzbDrone.Core.Test.Framework
}
}
}
public interface ITestDatabase
{
void InsertMany<T>(IEnumerable<T> items) where T : ModelBase, new();
T Insert<T>(T item) where T : ModelBase, new();
List<T> All<T>() where T : ModelBase, new();
T Single<T>() where T : ModelBase, new();
void Update<T>(T childModel) where T : ModelBase, new();
void Delete<T>(T childModel) where T : ModelBase, new();
}
public class TestDatabase : ITestDatabase
{
private readonly IDatabase _dbConnection;
private IEventAggregator _eventAggregator;
public TestDatabase(IDatabase dbConnection)
{
_eventAggregator = new Mock<IEventAggregator>().Object;
_dbConnection = dbConnection;
}
public void InsertMany<T>(IEnumerable<T> items) where T : ModelBase, new()
{
new BasicRepository<T>(_dbConnection, _eventAggregator).InsertMany(items.ToList());
}
public T Insert<T>(T item) where T : ModelBase, new()
{
return new BasicRepository<T>(_dbConnection, _eventAggregator).Insert(item);
}
public List<T> All<T>() where T : ModelBase, new()
{
return new BasicRepository<T>(_dbConnection, _eventAggregator).All().ToList();
}
public T Single<T>() where T : ModelBase, new()
{
return All<T>().SingleOrDefault();
}
public void Update<T>(T childModel) where T : ModelBase, new()
{
new BasicRepository<T>(_dbConnection, _eventAggregator).Update(childModel);
}
public void Delete<T>(T childModel) where T : ModelBase, new()
{
new BasicRepository<T>(_dbConnection, _eventAggregator).Delete(childModel);
}
}
}

View File

@@ -1,130 +0,0 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq;
using NzbDrone.Common.Serializer;
using NzbDrone.Core.Datastore;
namespace NzbDrone.Core.Test.Framework
{
public interface IDirectDataMapper
{
List<Dictionary<string, object>> Query(string sql);
List<T> Query<T>(string sql) where T : new();
}
public class DirectDataMapper : IDirectDataMapper
{
private readonly DbProviderFactory _providerFactory;
private readonly string _connectionString;
public DirectDataMapper(IDatabase database)
{
var dataMapper = database.GetDataMapper();
_providerFactory = dataMapper.ProviderFactory;
_connectionString = dataMapper.ConnectionString;
}
private DbConnection OpenConnection()
{
var connection = _providerFactory.CreateConnection();
connection.ConnectionString = _connectionString;
connection.Open();
return connection;
}
public DataTable GetDataTable(string sql)
{
using (var connection = OpenConnection())
{
using (var cmd = connection.CreateCommand())
{
var dataTable = new DataTable();
cmd.CommandText = sql;
dataTable.Load(cmd.ExecuteReader());
return dataTable;
}
}
}
public List<Dictionary<string, object>> Query(string sql)
{
var dataTable = GetDataTable(sql);
return dataTable.Rows.Cast<DataRow>().Select(MapToDictionary).ToList();
}
public List<T> Query<T>(string sql) where T : new()
{
var dataTable = GetDataTable(sql);
return dataTable.Rows.Cast<DataRow>().Select(MapToObject<T>).ToList();
}
protected Dictionary<string, object> MapToDictionary(DataRow dataRow)
{
var item = new Dictionary<string, object>();
for (var i = 0; i < dataRow.Table.Columns.Count; i++)
{
var columnName = dataRow.Table.Columns[i].ColumnName;
object value;
if (dataRow.ItemArray[i] == DBNull.Value)
{
value = null;
}
else
{
value = dataRow.ItemArray[i];
}
item[columnName] = dataRow.ItemArray[i];
}
return item;
}
protected T MapToObject<T>(DataRow dataRow) where T : new()
{
var item = new T();
for (var i = 0; i < dataRow.Table.Columns.Count; i++)
{
var columnName = dataRow.Table.Columns[i].ColumnName;
var propertyInfo = typeof(T).GetProperty(columnName);
if (propertyInfo == null)
{
throw new Exception(string.Format("Column {0} doesn't exist on type {1}.", columnName, typeof(T)));
}
var propertyType = propertyInfo.PropertyType;
if (propertyType.IsGenericType && propertyType.GetGenericTypeDefinition() == typeof(Nullable<>))
{
propertyType = propertyType.GetGenericArguments()[0];
}
object value;
if (dataRow.ItemArray[i] == DBNull.Value)
{
value = null;
}
else if (dataRow.Table.Columns[i].DataType == typeof(string) && propertyType != typeof(string))
{
value = Json.Deserialize((string)dataRow.ItemArray[i], propertyType);
}
else
{
value = Convert.ChangeType(dataRow.ItemArray[i], propertyType);
}
propertyInfo.SetValue(item, value, null);
}
return item;
}
}
}

View File

@@ -1,41 +1,23 @@
using System;
using System.Data;
using FluentMigrator;
using NUnit.Framework;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Datastore.Migration.Framework;
using NzbDrone.Test.Common.AutoMoq;
namespace NzbDrone.Core.Test.Framework
{
[Category("DbMigrationTest")]
[Category("DbTest")]
public abstract class MigrationTest<TMigration> : DbTest where TMigration : NzbDroneMigrationBase
public abstract class MigrationTest<TMigration> : DbTest where TMigration : MigrationBase
{
protected long MigrationVersion
protected override TestDatabase WithTestDb(Action<MigrationBase> beforeMigration)
{
get
return base.WithTestDb(m =>
{
var attrib = (MigrationAttribute)Attribute.GetCustomAttribute(typeof(TMigration), typeof(MigrationAttribute));
return attrib.Version;
}
}
protected virtual IDirectDataMapper WithMigrationTestDb(Action<TMigration> beforeMigration = null)
{
var db = WithTestDb(new MigrationContext(MigrationType, MigrationVersion)
{
BeforeMigration = m =>
if (m.GetType() == typeof(TMigration))
{
var migration = m as TMigration;
if (beforeMigration != null && migration is TMigration)
{
beforeMigration(migration);
}
beforeMigration(m);
}
});
return db.GetDirectDataMapper();
}
[SetUp]
@@ -43,11 +25,5 @@ namespace NzbDrone.Core.Test.Framework
{
SetupContainer();
}
[Obsolete("Don't use Mocker/Repositories in MigrationTests, query the DB.", true)]
public new AutoMoqer Mocker
{
get { return base.Mocker; }
}
}
}

View File

@@ -1,69 +0,0 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using Moq;
using NzbDrone.Common.Serializer;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Messaging.Events;
namespace NzbDrone.Core.Test.Framework
{
public interface ITestDatabase
{
void InsertMany<T>(IEnumerable<T> items) where T : ModelBase, new();
T Insert<T>(T item) where T : ModelBase, new();
List<T> All<T>() where T : ModelBase, new();
T Single<T>() where T : ModelBase, new();
void Update<T>(T childModel) where T : ModelBase, new();
void Delete<T>(T childModel) where T : ModelBase, new();
IDirectDataMapper GetDirectDataMapper();
}
public class TestDatabase : ITestDatabase
{
private readonly IDatabase _dbConnection;
private readonly IEventAggregator _eventAggregator;
public TestDatabase(IDatabase dbConnection)
{
_eventAggregator = new Mock<IEventAggregator>().Object;
_dbConnection = dbConnection;
}
public void InsertMany<T>(IEnumerable<T> items) where T : ModelBase, new()
{
new BasicRepository<T>(_dbConnection, _eventAggregator).InsertMany(items.ToList());
}
public T Insert<T>(T item) where T : ModelBase, new()
{
return new BasicRepository<T>(_dbConnection, _eventAggregator).Insert(item);
}
public List<T> All<T>() where T : ModelBase, new()
{
return new BasicRepository<T>(_dbConnection, _eventAggregator).All().ToList();
}
public T Single<T>() where T : ModelBase, new()
{
return All<T>().SingleOrDefault();
}
public void Update<T>(T childModel) where T : ModelBase, new()
{
new BasicRepository<T>(_dbConnection, _eventAggregator).Update(childModel);
}
public void Delete<T>(T childModel) where T : ModelBase, new()
{
new BasicRepository<T>(_dbConnection, _eventAggregator).Delete(childModel);
}
public IDirectDataMapper GetDirectDataMapper()
{
return new DirectDataMapper(_dbConnection);
}
}
}

View File

@@ -0,0 +1,7 @@
namespace NzbDrone.Core.Test.Framework
{
internal static class TestDbHelper
{
}
}

View File

@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.HealthCheck.Checks;
using NzbDrone.Core.Indexers;
@@ -11,17 +10,17 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
[TestFixture]
public class IndexerCheckFixture : CoreTest<IndexerCheck>
{
private Mock<IIndexer> _indexerMock;
private IIndexer _indexer;
private void GivenIndexer(bool supportsRss, bool supportsSearch)
{
_indexerMock = Mocker.GetMock<IIndexer>();
_indexerMock.SetupGet(s => s.SupportsRss).Returns(supportsRss);
_indexerMock.SetupGet(s => s.SupportsSearch).Returns(supportsSearch);
var _indexer = Mocker.GetMock<IIndexer>();
_indexer.SetupGet(s => s.SupportsRss).Returns(supportsRss);
_indexer.SetupGet(s => s.SupportsSearch).Returns(supportsSearch);
Mocker.GetMock<IIndexerFactory>()
.Setup(s => s.GetAvailableProviders())
.Returns(new List<IIndexer> { _indexerMock.Object });
.Returns(new List<IIndexer> { _indexer.Object });
Mocker.GetMock<IIndexerFactory>()
.Setup(s => s.RssEnabled())
@@ -36,14 +35,14 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
{
Mocker.GetMock<IIndexerFactory>()
.Setup(s => s.RssEnabled())
.Returns(new List<IIndexer> { _indexerMock.Object });
.Returns(new List<IIndexer> { _indexer });
}
private void GivenSearchEnabled()
{
Mocker.GetMock<IIndexerFactory>()
.Setup(s => s.SearchEnabled())
.Returns(new List<IIndexer> { _indexerMock.Object });
.Returns(new List<IIndexer> { _indexer });
}
[Test]

View File

@@ -226,7 +226,7 @@ namespace NzbDrone.Core.Test.IndexerSearchTests
var seasonNumber = 1;
var allCriteria = WatchForSearchCriteria();
Subject.SeasonSearch(_xemSeries.Id, seasonNumber, false);
Subject.SeasonSearch(_xemSeries.Id, seasonNumber, true);
var criteria = allCriteria.OfType<AnimeEpisodeSearchCriteria>().ToList();

View File

@@ -154,20 +154,5 @@ namespace NzbDrone.Core.Test.IndexerTests.KickassTorrentsTests
torrentInfo.Peers.Should().Be(0);
torrentInfo.Seeders.Should().Be(0);
}
[Test]
public void should_handle_xml_with_html_accents()
{
var recentFeed = ReadAllText(@"Files/Indexers/KickassTorrents/KickassTorrents_accents.xml");
Mocker.GetMock<IHttpClient>()
.Setup(o => o.Execute(It.Is<HttpRequest>(v => v.Method == HttpMethod.GET)))
.Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), recentFeed));
var releases = Subject.FetchRecent();
releases.Should().HaveCount(5);
}
}
}

View File

@@ -1,68 +0,0 @@
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common.Http;
using NzbDrone.Core.Indexers.Newznab;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
{
[TestFixture]
public class NewznabCapabilitiesProviderFixture : CoreTest<NewznabCapabilitiesProvider>
{
private NewznabSettings _settings;
private string _caps;
[SetUp]
public void SetUp()
{
_settings = new NewznabSettings()
{
Url = "http://indxer.local"
};
_caps = ReadAllText("Files", "Indexers", "Newznab", "newznab_caps.xml");
}
private void GivenCapsResponse(string caps)
{
Mocker.GetMock<IHttpClient>()
.Setup(o => o.Get(It.IsAny<HttpRequest>()))
.Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), caps));
}
[Test]
public void should_not_request_same_caps_twice()
{
GivenCapsResponse(_caps);
Subject.GetCapabilities(_settings);
Subject.GetCapabilities(_settings);
Mocker.GetMock<IHttpClient>()
.Verify(o => o.Get(It.IsAny<HttpRequest>()), Times.Once());
}
[Test]
public void should_report_pagesize()
{
GivenCapsResponse(_caps);
var caps = Subject.GetCapabilities(_settings);
caps.DefaultPageSize.Should().Be(25);
caps.MaxPageSize.Should().Be(60);
}
[Test]
public void should_use_default_pagesize_if_missing()
{
GivenCapsResponse(_caps.Replace("<limits", "<abclimits"));
var caps = Subject.GetCapabilities(_settings);
caps.DefaultPageSize.Should().Be(100);
caps.MaxPageSize.Should().Be(100);
}
}
}

View File

@@ -14,8 +14,6 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
[TestFixture]
public class NewznabFixture : CoreTest<Newznab>
{
private NewznabCapabilities _caps;
[SetUp]
public void Setup()
{
@@ -30,10 +28,9 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
}
};
_caps = new NewznabCapabilities();
Mocker.GetMock<INewznabCapabilitiesProvider>()
.Setup(v => v.GetCapabilities(It.IsAny<NewznabSettings>()))
.Returns(_caps);
.Returns(new NewznabCapabilities());
}
[Test]
@@ -61,14 +58,5 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
releaseInfo.PublishDate.Should().Be(DateTime.Parse("2012/02/27 16:09:39"));
releaseInfo.Size.Should().Be(1183105773);
}
[Test]
public void should_use_pagesize_reported_by_caps()
{
_caps.MaxPageSize = 30;
_caps.DefaultPageSize = 25;
Subject.PageSize.Should().Be(25);
}
}
}

View File

@@ -151,31 +151,5 @@ namespace NzbDrone.Core.Test.IndexerTests.TorrentRssIndexerTests
torrentInfo.Peers.Should().NotHaveValue();
torrentInfo.Seeders.Should().NotHaveValue();
}
[Test]
public void should_parse_recent_feed_from_ExtraTorrents()
{
GivenRecentFeedResponse("TorrentRss/ExtraTorrents.xml");
var releases = Subject.FetchRecent();
releases.Should().HaveCount(5);
releases.First().Should().BeOfType<TorrentInfo>();
var torrentInfo = releases.First() as TorrentInfo;
torrentInfo.Title.Should().Be("One.Piece.E334.D ED.720p.HDTV.x264-W4F-={SPARROW}=-");
torrentInfo.DownloadProtocol.Should().Be(DownloadProtocol.Torrent);
torrentInfo.DownloadUrl.Should().Be("http://ac.me/download/4722030/One.Piece.E334.D+ED.720p.HDTV.x264-W4F-%3D%7BSPARROW%7D%3D-.torrent");
torrentInfo.InfoUrl.Should().BeNullOrEmpty();
torrentInfo.CommentUrl.Should().BeNullOrEmpty();
torrentInfo.Indexer.Should().Be(Subject.Definition.Name);
torrentInfo.PublishDate.Should().Be(DateTime.Parse("Sun, 21 Feb 2016 09:51:54 +0000").ToUniversalTime());
torrentInfo.Size.Should().Be(562386947);
torrentInfo.InfoHash.Should().BeNull();
torrentInfo.MagnetUrl.Should().BeNull();
torrentInfo.Peers.Should().NotHaveValue();
torrentInfo.Seeders.Should().NotHaveValue();
}
}
}

View File

@@ -163,26 +163,6 @@ namespace NzbDrone.Core.Test.IndexerTests.TorrentRssIndexerTests
});
}
[Test]
public void should_detect_rss_settings_for_ExtraTorrents()
{
_indexerSettings.AllowZeroSize = true;
GivenRecentFeedResponse("TorrentRss/ExtraTorrents.xml");
var settings = Subject.Detect(_indexerSettings);
settings.ShouldBeEquivalentTo(new TorrentRssIndexerParserSettings
{
UseEZTVFormat = false,
UseEnclosureUrl = true,
UseEnclosureLength = true,
ParseSizeInDescription = false,
ParseSeedersInDescription = false,
SizeElementName = null
});
}
[Test]
[Ignore("Cannot reliably reject unparseable titles")]
public void should_reject_rss_settings_for_AwesomeHD()
@@ -237,6 +217,7 @@ namespace NzbDrone.Core.Test.IndexerTests.TorrentRssIndexerTests
}
[TestCase("Torrentleech/Torrentleech.xml")]
[TestCase("Wombles/wombles.xml")]
[TestCase("TorrentRss/invalid/Eztv_InvalidSize.xml")]
[TestCase("TorrentRss/invalid/ImmortalSeed_InvalidSize.xml")]
[TestCase("TorrentRss/Doki.xml")]

View File

@@ -15,8 +15,6 @@ namespace NzbDrone.Core.Test.IndexerTests.TorznabTests
[TestFixture]
public class TorznabFixture : CoreTest<Torznab>
{
private NewznabCapabilities _caps;
[SetUp]
public void Setup()
{
@@ -30,10 +28,9 @@ namespace NzbDrone.Core.Test.IndexerTests.TorznabTests
}
};
_caps = new NewznabCapabilities();
Mocker.GetMock<INewznabCapabilitiesProvider>()
.Setup(v => v.GetCapabilities(It.IsAny<NewznabSettings>()))
.Returns(_caps);
.Returns(new NewznabCapabilities());
}
[Test]
@@ -96,14 +93,5 @@ namespace NzbDrone.Core.Test.IndexerTests.TorznabTests
releaseInfo.Seeders.Should().Be(34128);
releaseInfo.Peers.Should().Be(36724);
}
[Test]
public void should_use_pagesize_reported_by_caps()
{
_caps.MaxPageSize = 30;
_caps.DefaultPageSize = 25;
Subject.PageSize.Should().Be(25);
}
}
}

View File

@@ -1,64 +0,0 @@
using System;
using System.Linq;
using FluentAssertions;
using Moq;
using NLog;
using NUnit.Framework;
using NzbDrone.Common.Cache;
using NzbDrone.Common.Http;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Indexers.TorrentRss;
using NzbDrone.Core.Indexers.Wombles;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.IndexerTests.WomblesTests
{
[TestFixture]
public class TorrentRssIndexerFixture : CoreTest<Wombles>
{
[SetUp]
public void Setup()
{
Subject.Definition = new IndexerDefinition()
{
Name = "Wombles",
Settings = new NullConfig(),
};
}
private void GivenRecentFeedResponse(string rssXmlFile)
{
var recentFeed = ReadAllText(@"Files/Indexers/" + rssXmlFile);
Mocker.GetMock<IHttpClient>()
.Setup(o => o.Execute(It.IsAny<HttpRequest>()))
.Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), recentFeed));
}
[Test]
public void should_parse_recent_feed_from_wombles()
{
GivenRecentFeedResponse("Wombles/wombles.xml");
var releases = Subject.FetchRecent();
releases.Should().HaveCount(5);
var releaseInfo = releases.First();
releaseInfo.Title.Should().Be("One.Child.S01E01.720p.HDTV.x264-TLA");
releaseInfo.DownloadProtocol.Should().Be(DownloadProtocol.Usenet);
releaseInfo.DownloadUrl.Should().Be("http://indexer.local/nzb/bb4/One.Child.S01E01.720p.HDTV.x264-TLA.nzb");
releaseInfo.InfoUrl.Should().BeNullOrEmpty();
releaseInfo.CommentUrl.Should().BeNullOrEmpty();
releaseInfo.Indexer.Should().Be(Subject.Definition.Name);
releaseInfo.PublishDate.Should().Be(DateTime.Parse("2016-02-17 23:03:52 +0000").ToUniversalTime());
releaseInfo.Size.Should().Be(956*1024*1024);
}
}
}

View File

@@ -83,7 +83,7 @@ namespace NzbDrone.Core.Test.InstrumentationTests
{
var ex = new InvalidOperationException("Fake Exception");
_logger.Error(ex, _uniqueMessage);
_logger.ErrorException(_uniqueMessage, ex);
VerifyLog(StoredModel, LogLevel.Error);
@@ -102,7 +102,7 @@ namespace NzbDrone.Core.Test.InstrumentationTests
_uniqueMessage = string.Empty;
_logger.Error(ex, _uniqueMessage);
_logger.ErrorException(_uniqueMessage, ex);
StoredModel.Message.Should().Be(ex.Message);

View File

@@ -22,13 +22,15 @@ namespace NzbDrone.Core.Test.MediaFiles
{
private string _droneFactory = "c:\\drop\\".AsOsAgnostic();
private string _downloadFolder = "c:\\drop_other\\Show.S01E01\\".AsOsAgnostic();
private string _downloadFile = "c:\\drop_other\\Show.S01E01.mkv".AsOsAgnostic();
private TrackedDownload _trackedDownload;
[SetUp]
public void Setup()
{
Mocker.GetMock<IDiskProvider>().Setup(c => c.FolderExists(It.IsAny<string>()))
.Returns(true);
Mocker.GetMock<IConfigService>().SetupGet(c => c.DownloadedEpisodesFolder)
.Returns(_droneFactory);
@@ -57,18 +59,6 @@ namespace NzbDrone.Core.Test.MediaFiles
};
}
private void GivenExistingFolder(string path)
{
Mocker.GetMock<IDiskProvider>().Setup(c => c.FolderExists(It.IsAny<string>()))
.Returns(true);
}
private void GivenExistingFile(string path)
{
Mocker.GetMock<IDiskProvider>().Setup(c => c.FileExists(It.IsAny<string>()))
.Returns(true);
}
private void GivenValidQueueItem()
{
Mocker.GetMock<ITrackedDownloadService>()
@@ -79,8 +69,6 @@ namespace NzbDrone.Core.Test.MediaFiles
[Test]
public void should_process_dronefactory_if_path_is_not_specified()
{
GivenExistingFolder(_droneFactory);
Subject.Execute(new DownloadedEpisodesScanCommand());
Mocker.GetMock<IDownloadedEpisodesImportService>().Verify(c => c.ProcessRootFolder(It.IsAny<DirectoryInfo>()), Times.Once());
@@ -89,6 +77,8 @@ namespace NzbDrone.Core.Test.MediaFiles
[Test]
public void should_skip_import_if_dronefactory_doesnt_exist()
{
Mocker.GetMock<IDiskProvider>().Setup(c => c.FolderExists(It.IsAny<string>())).Returns(false);
Subject.Execute(new DownloadedEpisodesScanCommand());
Mocker.GetMock<IDownloadedEpisodesImportService>().Verify(c => c.ProcessRootFolder(It.IsAny<DirectoryInfo>()), Times.Never());
@@ -99,8 +89,6 @@ namespace NzbDrone.Core.Test.MediaFiles
[Test]
public void should_ignore_downloadclientid_if_path_is_not_specified()
{
GivenExistingFolder(_droneFactory);
Subject.Execute(new DownloadedEpisodesScanCommand() { DownloadClientId = "sab1" });
Mocker.GetMock<IDownloadedEpisodesImportService>().Verify(c => c.ProcessRootFolder(It.IsAny<DirectoryInfo>()), Times.Once());
@@ -109,27 +97,14 @@ namespace NzbDrone.Core.Test.MediaFiles
[Test]
public void should_process_folder_if_downloadclientid_is_not_specified()
{
GivenExistingFolder(_downloadFolder);
Subject.Execute(new DownloadedEpisodesScanCommand() { Path = _downloadFolder });
Mocker.GetMock<IDownloadedEpisodesImportService>().Verify(c => c.ProcessPath(It.IsAny<string>(), null, null), Times.Once());
}
[Test]
public void should_process_file_if_downloadclientid_is_not_specified()
{
GivenExistingFile(_downloadFile);
Subject.Execute(new DownloadedEpisodesScanCommand() { Path = _downloadFile });
Mocker.GetMock<IDownloadedEpisodesImportService>().Verify(c => c.ProcessPath(It.IsAny<string>(), null, null), Times.Once());
}
[Test]
public void should_process_folder_with_downloadclientitem_if_available()
{
GivenExistingFolder(_downloadFolder);
GivenValidQueueItem();
Subject.Execute(new DownloadedEpisodesScanCommand() { Path = _downloadFolder, DownloadClientId = "sab1" });
@@ -140,23 +115,11 @@ namespace NzbDrone.Core.Test.MediaFiles
[Test]
public void should_process_folder_without_downloadclientitem_if_not_available()
{
GivenExistingFolder(_downloadFolder);
Subject.Execute(new DownloadedEpisodesScanCommand() { Path = _downloadFolder, DownloadClientId = "sab1" });
Mocker.GetMock<IDownloadedEpisodesImportService>().Verify(c => c.ProcessPath(_downloadFolder, null, null), Times.Once());
ExceptionVerification.ExpectedWarns(1);
}
[Test]
public void should_warn_if_neither_folder_or_file_exists()
{
Subject.Execute(new DownloadedEpisodesScanCommand() { Path = _downloadFolder });
Mocker.GetMock<IDownloadedEpisodesImportService>().Verify(c => c.ProcessPath(It.IsAny<string>(), null, null), Times.Never());
ExceptionVerification.ExpectedWarns(1);
}
}
}

View File

@@ -167,7 +167,7 @@ namespace NzbDrone.Core.Test.MediaFiles
It.IsAny<QualityModel>(),
It.IsAny<string>(),
It.IsAny<long>(),
It.IsAny<bool>()))
It.IsAny<int>()))
.Returns(true);
Subject.ProcessRootFolder(new DirectoryInfo(_droneFactory));
@@ -239,7 +239,7 @@ namespace NzbDrone.Core.Test.MediaFiles
It.IsAny<QualityModel>(),
It.IsAny<string>(),
It.IsAny<long>(),
It.IsAny<bool>()))
It.IsAny<int>()))
.Returns(true);
Mocker.GetMock<IDiskProvider>()
@@ -350,7 +350,7 @@ namespace NzbDrone.Core.Test.MediaFiles
It.IsAny<QualityModel>(),
It.IsAny<string>(),
It.IsAny<long>(),
It.IsAny<bool>()))
It.IsAny<int>()))
.Returns(true);
Mocker.GetMock<IDiskProvider>()

View File

@@ -332,7 +332,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
GivenVideoFiles(videoFiles.ToList());
Mocker.GetMock<IDetectSample>()
.Setup(s => s.IsSample(_series, It.IsAny<QualityModel>(), It.Is<string>(c => c.Contains("sample")), It.IsAny<long>(), It.IsAny<bool>()))
.Setup(s => s.IsSample(_series, It.IsAny<QualityModel>(), It.Is<string>(c => c.Contains("sample")), It.IsAny<long>(), It.IsAny<int>()))
.Returns(true);
var folderInfo = Parser.Parser.ParseTitle("Series.Title.S01E01");

View File

@@ -91,7 +91,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
_localEpisode.Quality,
_localEpisode.Path,
_localEpisode.Size,
_localEpisode.IsSpecial);
_localEpisode.SeasonNumber);
Mocker.GetMock<IVideoFileInfoReader>().Verify(v => v.GetRunTime(It.IsAny<string>()), Times.Once());
}
@@ -144,7 +144,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
}
[Test]
public void should_return_false_for_anime_special()
public void should_return_false_for_anime_speical()
{
_series.SeriesType = SeriesTypes.Anime;
_localEpisode.Episodes[0].SeasonNumber = 0;
@@ -158,7 +158,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
_localEpisode.Quality,
_localEpisode.Path,
_localEpisode.Size,
_localEpisode.IsSpecial).Should().BeTrue();
_localEpisode.SeasonNumber).Should().BeTrue();
}
private void ShouldBeFalse()
@@ -167,7 +167,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
_localEpisode.Quality,
_localEpisode.Path,
_localEpisode.Size,
_localEpisode.IsSpecial).Should().BeFalse();
_localEpisode.SeasonNumber).Should().BeFalse();
}
}
}

View File

@@ -16,6 +16,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json
private const int TVDB_ID = 5;
private XbmcSettings _settings;
private Series _series;
private string _response;
private List<TvShow> _xbmcSeries;
[SetUp]

View File

@@ -16,6 +16,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json
{
private const int TVDB_ID = 5;
private XbmcSettings _settings;
private Series _series;
private List<TvShow> _xbmcSeries;
[SetUp]

View File

@@ -60,18 +60,14 @@
<HintPath>..\packages\FluentMigrator.Runner.1.6.1\lib\40\FluentMigrator.Runner.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="FluentValidation, Version=6.2.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\FluentValidation.6.2.1.0\lib\portable-net40+sl50+wp80+win8+wpa81\FluentValidation.dll</HintPath>
<Reference Include="FluentValidation, Version=6.0.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\FluentValidation.6.0.2.0\lib\portable-net40+sl50+wp80+win8+wpa81\FluentValidation.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.6.0.6\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.2.3\lib\net40\NLog.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="nunit.framework, Version=2.6.3.13283, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
@@ -100,6 +96,9 @@
<Reference Include="NCrunch.Framework">
<HintPath>..\packages\NCrunch.Framework.1.46.0.9\lib\net35\NCrunch.Framework.dll</HintPath>
</Reference>
<Reference Include="NLog">
<HintPath>..\packages\NLog.2.1.0\lib\net40\NLog.dll</HintPath>
</Reference>
<Reference Include="Prowlin">
<HintPath>..\packages\Prowlin.0.9.4456.26422\lib\net40\Prowlin.dll</HintPath>
</Reference>
@@ -119,11 +118,10 @@
<Compile Include="Datastore\DatabaseRelationshipFixture.cs" />
<Compile Include="Datastore\MappingExtentionFixture.cs" />
<Compile Include="Datastore\MarrDataLazyLoadingFixture.cs" />
<Compile Include="Datastore\Migration\101_add_ultrahd_quality_in_profilesFixture.cs" />
<Compile Include="Datastore\Migration\071_unknown_quality_in_profileFixture.cs" />
<Compile Include="Datastore\Migration\072_history_downloadIdFixture.cs" />
<Compile Include="Datastore\Migration\072_history_grabIdFixture.cs" />
<Compile Include="Datastore\Migration\070_delay_profileFixture.cs" />
<Compile Include="Datastore\Migration\088_pushbullet_devices_channels_listFixture.cs" />
<Compile Include="Datastore\Migration\088_pushbullet_devices_channels.cs" />
<Compile Include="Datastore\Migration\086_pushbullet_device_idsFixture.cs" />
<Compile Include="Datastore\Migration\085_expand_transmission_urlbaseFixture.cs" />
<Compile Include="Datastore\Migration\084_update_quality_minmax_sizeFixture.cs" />
@@ -187,10 +185,9 @@
<Compile Include="FluentTest.cs" />
<Compile Include="Framework\CoreTest.cs" />
<Compile Include="Framework\DbTest.cs" />
<Compile Include="Framework\DirectDataMapper.cs" />
<Compile Include="Framework\MigrationTest.cs" />
<Compile Include="Framework\NBuilderExtensions.cs" />
<Compile Include="Framework\TestDatabase.cs" />
<Compile Include="Framework\TestDbHelper.cs" />
<Compile Include="HealthCheck\Checks\DeleteBadMediaCovers.cs" />
<Compile Include="HealthCheck\Checks\AppDataLocationFixture.cs" />
<Compile Include="HealthCheck\Checks\DownloadClientCheckFixture.cs" />
@@ -226,7 +223,6 @@
<Compile Include="IndexerTests\IndexerServiceFixture.cs" />
<Compile Include="IndexerTests\IndexerStatusServiceFixture.cs" />
<Compile Include="IndexerTests\IntegrationTests\IndexerIntegrationTests.cs" />
<Compile Include="IndexerTests\NewznabTests\NewznabCapabilitiesProviderFixture.cs" />
<Compile Include="IndexerTests\RarbgTests\RarbgFixture.cs" />
<Compile Include="IndexerTests\TorrentRssIndexerTests\TorrentRssParserFactoryFixture.cs" />
<Compile Include="IndexerTests\TorrentRssIndexerTests\TorrentRssSettingsDetectorFixture.cs" />
@@ -245,7 +241,6 @@
<Compile Include="IndexerTests\TorrentleechTests\TorrentleechFixture.cs" />
<Compile Include="IndexerTests\TorrentRssIndexerTests\TorrentRssIndexerFixture.cs" />
<Compile Include="IndexerTests\TorrentRssIndexerTests\TestTorrentRssIndexer.cs" />
<Compile Include="IndexerTests\WomblesTests\WomblesFixture.cs" />
<Compile Include="IndexerTests\XElementExtensionsFixture.cs" />
<Compile Include="InstrumentationTests\DatabaseTargetFixture.cs" />
<Compile Include="JobTests\JobRepositoryFixture.cs" />
@@ -408,18 +403,9 @@
<Content Include="Files\emptyfile.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Files\Indexers\KickassTorrents\KickassTorrents_accents.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Files\Indexers\Newznab\newznab_caps.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Files\Indexers\relative_urls.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Files\Indexers\TorrentRss\ExtraTorrents.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Files\Indexers\TorrentRss\Doki.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
@@ -565,4 +551,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>

View File

@@ -97,17 +97,5 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests
Subject.BuildFileName(new List<Episode> { _episode1, _episode2 }, _series, _episodeFile)
.Should().Be("South Park - S15E06-E07 - Hello + World");
}
[Test]
public void should_not_collaspe_when_result_is_empty()
{
_namingConfig.StandardEpisodeFormat = "{Episode Title}";
_episode1.Title = "Part 1";
_episode2.Title = "Part 2";
Subject.BuildFileName(new List<Episode> { _episode1, _episode2 }, _series, _episodeFile)
.Should().Be("Part 1 + Part 2");
}
}
}

View File

@@ -712,18 +712,6 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests
.Should().Be("Sonarr");
}
[TestCase("{Episode Title}{-Release Group}", "City Sushi")]
[TestCase("{Episode Title}{ Release Group}", "City Sushi")]
[TestCase("{Episode Title}{ [Release Group]}", "City Sushi")]
public void should_not_use_Sonarr_as_release_group_if_pattern_has_separator(string pattern, string expectedFileName)
{
_episodeFile.ReleaseGroup = null;
_namingConfig.StandardEpisodeFormat = pattern;
Subject.BuildFileName(new List<Episode> { _episode1 }, _series, _episodeFile)
.Should().Be(expectedFileName);
}
[TestCase("0SEC")]
[TestCase("2HD")]
[TestCase("IMMERSE")]

View File

@@ -28,7 +28,6 @@ namespace NzbDrone.Core.Test.ParserTests
[TestCase("At_Midnight_140722_720p_HDTV_x264-YesTV", "At Midnight", 2014, 07, 22)]
//[TestCase("Corrie.07.01.15", "Corrie", 2015, 1, 7)]
[TestCase("The Nightly Show with Larry Wilmore 2015 02 09 WEBRIP s01e13", "The Nightly Show with Larry Wilmore", 2015, 2, 9)]
[TestCase("Judge Judy 2016 02 10 S20E121", "Judge Judy", 2016, 2, 10)]
//[TestCase("", "", 0, 0, 0)]
public void should_parse_daily_episode(string postTitle, string title, int year, int month, int day)
{

View File

@@ -24,6 +24,7 @@ namespace NzbDrone.Core.Test.ParserTests
[TestCase("The Real Housewives of Some Place - S01E01 - Why are we doing this?", 0)]
public void should_parse_reality_from_title(string title, int reality)
{
//TODO: re-enable this when we have a reliable way to determine real
QualityParser.ParseQuality(title).Revision.Real.Should().Be(reality);
}
@@ -40,9 +41,6 @@ namespace NzbDrone.Core.Test.ParserTests
[TestCase("[Hatsuyuki] Tokyo Ghoul - 07 [v2][848x480][23D8F455].avi", 2)]
[TestCase("[DeadFish] Barakamon - 01v3 [720p][AAC]", 3)]
[TestCase("[DeadFish] Momo Kyun Sword - 01v4 [720p][AAC]", 4)]
[TestCase("[Vivid-Asenshi] Akame ga Kill - 04v2 [266EE983]", 2)]
[TestCase("[Vivid-Asenshi] Akame ga Kill - 03v2 [66A05817]", 2)]
[TestCase("[Vivid-Asenshi] Akame ga Kill - 02v2 [1F67AB55]", 2)]
public void should_parse_version_from_title(string title, int version)
{
QualityParser.ParseQuality(title).Revision.Version.Should().Be(version);

View File

@@ -1,4 +1,5 @@
using FluentAssertions;
using System;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Qualities;
@@ -17,13 +18,10 @@ namespace NzbDrone.Core.Test.ParserTests
new object[] { Quality.WEBDL480p },
new object[] { Quality.HDTV720p },
new object[] { Quality.HDTV1080p },
new object[] { Quality.HDTV2160p },
new object[] { Quality.WEBDL720p },
new object[] { Quality.WEBDL1080p },
new object[] { Quality.WEBDL2160p },
new object[] { Quality.Bluray720p },
new object[] { Quality.Bluray1080p },
new object[] { Quality.Bluray2160p },
new object[] { Quality.Bluray1080p }
};
public static object[] OtherSourceQualityParserCases =
@@ -33,13 +31,10 @@ namespace NzbDrone.Core.Test.ParserTests
new object[] { "480p WEB-DL", Quality.WEBDL480p },
new object[] { "HD TV", Quality.HDTV720p },
new object[] { "1080p HD TV", Quality.HDTV1080p },
new object[] { "2160p HD TV", Quality.HDTV2160p },
new object[] { "720p WEB-DL", Quality.WEBDL720p },
new object[] { "1080p WEB-DL", Quality.WEBDL1080p },
new object[] { "2160p WEB-DL", Quality.WEBDL2160p },
new object[] { "720p BluRay", Quality.Bluray720p },
new object[] { "1080p BluRay", Quality.Bluray1080p },
new object[] { "2160p BluRay", Quality.Bluray2160p },
new object[] { "1080p BluRay", Quality.Bluray1080p }
};
[TestCase("S07E23 .avi ", false)]
@@ -162,15 +157,6 @@ namespace NzbDrone.Core.Test.ParserTests
ParseAndVerifyQuality(title, Quality.WEBDL1080p, proper);
}
[TestCase("CASANOVA S01E01.2160P AMZN WEBRIP DD2.0 HI10P X264-TROLLUHD", false)]
[TestCase("JUST ADD MAGIC S01E01.2160P AMZN WEBRIP DD2.0 X264-TROLLUHD", false)]
[TestCase("The.Man.In.The.High.Castle.S01E01.2160p.AMZN.WEBRip.DD2.0.Hi10p.X264-TrollUHD", false)]
[TestCase("The Man In the High Castle S01E01 2160p AMZN WEBRip DD2.0 Hi10P x264-TrollUHD", false)]
public void should_parse_webdl2160p_quality(string title, bool proper)
{
ParseAndVerifyQuality(title, Quality.WEBDL2160p, proper);
}
[TestCase("WEEDS.S03E01-06.DUAL.Bluray.AC3.-HELLYWOOD.avi", false)]
[TestCase("Chuck - S01E03 - Come Fly With Me - 720p BluRay.mkv", false)]
[TestCase("The Big Bang Theory.S03E01.The Electric Can Opener Fluctuation.m2ts", false)]

View File

@@ -41,8 +41,6 @@ namespace NzbDrone.Core.Test.ParserTests
}
[TestCase("The.Longest.Mystery.S02E04.720p.WEB-DL.AAC2.0.H.264-EVL-RP", "EVL")]
[TestCase("The.Longest.Mystery.S02E04.720p.WEB-DL.AAC2.0.H.264-EVL-RP-RP", "EVL")]
[TestCase("The.Longest.Mystery.S02E04.720p.WEB-DL.AAC2.0.H.264-EVL-Obfuscated", "EVL")]
[TestCase("Lost.S04E04.720p.BluRay.x264-xHD-NZBgeek", "xHD")]
[TestCase("Blue.Bloods.S05E11.720p.HDTV.X264-DIMENSION-NZBgeek", "DIMENSION")]
[TestCase("Lost.S04E04.720p.BluRay.x264-xHD-1", "xHD")]

View File

@@ -19,7 +19,7 @@ namespace NzbDrone.Core.Test.Profiles
Subject.Handle(new ApplicationStartedEvent());
Mocker.GetMock<IProfileRepository>()
.Verify(v => v.Insert(It.IsAny<Profile>()), Times.Exactly(6));
.Verify(v => v.Insert(It.IsAny<Profile>()), Times.Exactly(5));
}
[Test]

View File

@@ -27,6 +27,20 @@ namespace NzbDrone.Core.Test.Providers
ids.Should().Contain(i => i == 73141);
}
[Test]
[Ignore("XEM's data is not clean")]
public void get_mapping_for_all_series()
{
var ids = Subject.GetXemSeriesIds();
var randomIds = ids.OrderBy(x => Guid.NewGuid()).Take(5);
foreach (var randomId in randomIds)
{
Subject.GetSceneTvdbMappings(randomId).Should().NotBeEmpty();
}
}
[TestCase(12345, Description = "invalid id")]
[TestCase(279042, Description = "no single connection")]
public void should_return_empty_when_known_error(int id)

View File

@@ -13,38 +13,22 @@ namespace NzbDrone.Core.Test.Qualities
{
public static object[] FromIntCases =
{
new object[] {0, Quality.Unknown},
new object[] {1, Quality.SDTV},
new object[] {2, Quality.DVD},
new object[] {3, Quality.WEBDL1080p},
new object[] {4, Quality.HDTV720p},
new object[] {5, Quality.WEBDL720p},
new object[] {6, Quality.Bluray720p},
new object[] {7, Quality.Bluray1080p},
new object[] {8, Quality.WEBDL480p},
new object[] {9, Quality.HDTV1080p},
new object[] {10, Quality.RAWHD},
new object[] {16, Quality.HDTV2160p},
new object[] {18, Quality.WEBDL2160p},
new object[] {19, Quality.Bluray2160p},
new object[] {7, Quality.Bluray1080p}
};
public static object[] ToIntCases =
{
new object[] {Quality.Unknown, 0},
new object[] {Quality.SDTV, 1},
new object[] {Quality.DVD, 2},
new object[] {Quality.WEBDL1080p, 3},
new object[] {Quality.HDTV720p, 4},
new object[] {Quality.WEBDL720p, 5},
new object[] {Quality.Bluray720p, 6},
new object[] {Quality.Bluray1080p, 7},
new object[] {Quality.WEBDL480p, 8},
new object[] {Quality.HDTV1080p, 9},
new object[] {Quality.RAWHD, 10},
new object[] {Quality.HDTV2160p, 16},
new object[] {Quality.WEBDL2160p, 18},
new object[] {Quality.Bluray2160p, 19},
new object[] {Quality.Bluray1080p, 7}
};
[Test, TestCaseSource("FromIntCases")]
@@ -65,20 +49,16 @@ namespace NzbDrone.Core.Test.Qualities
{
var qualities = new List<Quality>
{
Quality.Unknown,
Quality.SDTV,
Quality.WEBDL480p,
Quality.DVD,
Quality.HDTV720p,
Quality.HDTV1080p,
Quality.HDTV2160p,
Quality.RAWHD,
Quality.WEBDL720p,
Quality.WEBDL1080p,
Quality.WEBDL2160p,
Quality.Bluray720p,
Quality.Bluray1080p,
Quality.Bluray2160p,
Quality.WEBDL1080p,
Quality.Bluray1080p
};
if (allowed.Length == 0)

View File

@@ -365,33 +365,5 @@ namespace NzbDrone.Core.Test.TvTests
_insertedEpisodes.Should().OnlyContain(e => e.AirDateUtc.Value.ToString("s") == episodes.First().AirDateUtc.Value.ToString("s"));
}
[Test]
public void should_prefer_regular_season_when_absolute_numbers_conflict()
{
var episodes = Builder<Episode>.CreateListOfSize(2)
.Build()
.ToList();
episodes[0].AbsoluteEpisodeNumber = episodes[1].AbsoluteEpisodeNumber;
episodes[0].SeasonNumber = 0;
episodes[0].EpisodeNumber.Should().NotBe(episodes[1].EpisodeNumber);
var existingEpisode = new Episode
{
SeasonNumber = episodes[0].SeasonNumber,
EpisodeNumber = episodes[0].EpisodeNumber,
AbsoluteEpisodeNumber = episodes[1].AbsoluteEpisodeNumber
};
Mocker.GetMock<IEpisodeService>().Setup(c => c.GetEpisodeBySeries(It.IsAny<int>()))
.Returns(new List<Episode> { existingEpisode });
Subject.RefreshEpisodeInfo(GetAnimeSeries(), episodes);
_updatedEpisodes.First().SeasonNumber.Should().Be(episodes[1].SeasonNumber);
_updatedEpisodes.First().EpisodeNumber.Should().Be(episodes[1].EpisodeNumber);
_updatedEpisodes.First().AbsoluteEpisodeNumber.Should().Be(episodes[1].AbsoluteEpisodeNumber);
}
}
}

Some files were not shown because too many files have changed in this diff Show More