Compare commits

...

3 Commits

Author SHA1 Message Date
Keivan Beigi 2855ffff66
Upgrade CurlSharp 2017-01-14 11:41:49 -08:00
Keivan Beigi 5abcf887b0
cleanup 2017-01-14 11:30:33 -08:00
Keivan Beigi c13fff1358 Use nameof 2017-01-07 09:59:59 -08:00
21 changed files with 57 additions and 59 deletions

Binary file not shown.

View File

@ -94,7 +94,7 @@
<Compile Include="LevenshteinDistanceFixture.cs" /> <Compile Include="LevenshteinDistanceFixture.cs" />
<Compile Include="OsPathFixture.cs" /> <Compile Include="OsPathFixture.cs" />
<Compile Include="PathExtensionFixture.cs" /> <Compile Include="PathExtensionFixture.cs" />
<Compile Include="ProcessProviderTests.cs" /> <Compile Include="Processes\ProcessProviderFixture.cs" />
<Compile Include="ReflectionExtensions.cs" /> <Compile Include="ReflectionExtensions.cs" />
<Compile Include="ReflectionTests\ReflectionExtensionFixture.cs" /> <Compile Include="ReflectionTests\ReflectionExtensionFixture.cs" />
<Compile Include="ServiceFactoryFixture.cs" /> <Compile Include="ServiceFactoryFixture.cs" />

View File

@ -10,20 +10,20 @@ using NzbDrone.Common.Processes;
using NzbDrone.Test.Common; using NzbDrone.Test.Common;
using NzbDrone.Test.Dummy; using NzbDrone.Test.Dummy;
namespace NzbDrone.Common.Test namespace NzbDrone.Common.Test.Processes
{ {
[TestFixture] [TestFixture]
public class ProcessProviderTests : TestBase<ProcessProvider> public class ProcessProviderFixture : TestBase<ProcessProvider>
{ {
[SetUp] [SetUp]
public void Setup() public void Setup()
{ {
Process.GetProcessesByName(DummyApp.DUMMY_PROCCESS_NAME).ToList().ForEach(c => Process.GetProcessesByName(DummyApp.DUMMY_PROCCESS_NAME).ToList().ForEach(c =>
{ {
c.Kill(); c.Kill();
c.WaitForExit(); c.WaitForExit();
}); });
Process.GetProcessesByName(DummyApp.DUMMY_PROCCESS_NAME).Should().BeEmpty(); Process.GetProcessesByName(DummyApp.DUMMY_PROCCESS_NAME).Should().BeEmpty();
} }
@ -101,5 +101,11 @@ namespace NzbDrone.Common.Test
Console.WriteLine(new ProcessInfo().ToString()); Console.WriteLine(new ProcessInfo().ToString());
ExceptionVerification.MarkInconclusive(typeof(Win32Exception)); ExceptionVerification.MarkInconclusive(typeof(Win32Exception));
} }
[Test]
public void should_find_process_by_name()
{
Subject.FindProcessByName(Process.GetCurrentProcess().ProcessName).Should().NotBeNull();
}
} }
} }

View File

@ -14,8 +14,8 @@ namespace NzbDrone.Common.Extensions
public static Dictionary<T1, T2> Merge<T1, T2>(this Dictionary<T1, T2> first, Dictionary<T1, T2> second) public static Dictionary<T1, T2> Merge<T1, T2>(this Dictionary<T1, T2> first, Dictionary<T1, T2> second)
{ {
if (first == null) throw new ArgumentNullException("first"); if (first == null) throw new ArgumentNullException(nameof(first));
if (second == null) throw new ArgumentNullException("second"); if (second == null) throw new ArgumentNullException(nameof(second));
var merged = new Dictionary<T1, T2>(); var merged = new Dictionary<T1, T2>();
first.ToList().ForEach(kv => merged[kv.Key] = kv.Value); first.ToList().ForEach(kv => merged[kv.Key] = kv.Value);

View File

@ -33,22 +33,21 @@ namespace NzbDrone.Common.Instrumentation.Sentry
public SentryTarget(string dsn) public SentryTarget(string dsn)
{ {
_debounce = new SentryDebounce();
_client = new RavenClient(new Dsn(dsn), new SonarrJsonPacketFactory(), new SentryRequestFactory(), new MachineNameUserFactory()) _client = new RavenClient(new Dsn(dsn), new SonarrJsonPacketFactory(), new SentryRequestFactory(), new MachineNameUserFactory())
{ {
Compression = true, Compression = true,
Environment = RuntimeInfo.IsProduction ? "production" : "development", Release = BuildInfo.Release,
Release = BuildInfo.Release ErrorOnCapture = OnError,
Timeout = TimeSpan.FromSeconds(1)
}; };
_client.ErrorOnCapture = OnError;
_client.Tags.Add("osfamily", OsInfo.Os.ToString()); _client.Tags.Add("osfamily", OsInfo.Os.ToString());
_client.Tags.Add("runtime", PlatformInfo.Platform.ToString().ToLower()); _client.Tags.Add("runtime", PlatformInfo.Platform.ToString().ToLower());
_client.Tags.Add("culture", Thread.CurrentThread.CurrentCulture.Name); _client.Tags.Add("culture", Thread.CurrentThread.CurrentCulture.Name);
_client.Tags.Add("branch", BuildInfo.Branch); _client.Tags.Add("branch", BuildInfo.Branch);
_client.Tags.Add("version", BuildInfo.Version.ToString()); _client.Tags.Add("version", BuildInfo.Version.ToString());
_debounce = new SentryDebounce();
} }
private void OnError(Exception ex) private void OnError(Exception ex)

View File

@ -39,6 +39,10 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="CurlSharp, Version=1.0.6216.18898, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Libraries\CurlSharp\CurlSharp.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net40\Newtonsoft.Json.dll</HintPath> <HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net40\Newtonsoft.Json.dll</HintPath>
<Private>True</Private> <Private>True</Private>
@ -233,10 +237,6 @@
<Content Include="Expansive\license.txt" /> <Content Include="Expansive\license.txt" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\ExternalModules\CurlSharp\CurlSharp\CurlSharp.csproj">
<Project>{74420a79-cc16-442c-8b1e-7c1b913844f0}</Project>
<Name>CurlSharp</Name>
</ProjectReference>
<ProjectReference Include="..\LogentriesNLog\LogentriesNLog.csproj"> <ProjectReference Include="..\LogentriesNLog\LogentriesNLog.csproj">
<Project>{9DC31DE3-79FF-47A8-96B4-6BA18F6BB1CB}</Project> <Project>{9DC31DE3-79FF-47A8-96B4-6BA18F6BB1CB}</Project>
<Name>LogentriesNLog</Name> <Name>LogentriesNLog</Name>

View File

@ -25,7 +25,7 @@ namespace NzbDrone.Common.TPL
/// <param name="maxDegreeOfParallelism">The maximum degree of parallelism provided by this scheduler.</param> /// <param name="maxDegreeOfParallelism">The maximum degree of parallelism provided by this scheduler.</param>
public LimitedConcurrencyLevelTaskScheduler(int maxDegreeOfParallelism) public LimitedConcurrencyLevelTaskScheduler(int maxDegreeOfParallelism)
{ {
if (maxDegreeOfParallelism < 1) throw new ArgumentOutOfRangeException("maxDegreeOfParallelism"); if (maxDegreeOfParallelism < 1) throw new ArgumentOutOfRangeException(nameof(maxDegreeOfParallelism));
_maxDegreeOfParallelism = maxDegreeOfParallelism; _maxDegreeOfParallelism = maxDegreeOfParallelism;
} }

View File

@ -45,7 +45,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
}; };
} }
[Test, TestCaseSource("AllowedTestCases")] [Test, TestCaseSource(nameof(AllowedTestCases))]
public void should_allow_if_quality_is_defined_in_profile(Quality qualityType) public void should_allow_if_quality_is_defined_in_profile(Quality qualityType)
{ {
remoteEpisode.ParsedEpisodeInfo.Quality.Quality = qualityType; remoteEpisode.ParsedEpisodeInfo.Quality.Quality = qualityType;
@ -54,7 +54,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
Subject.IsSatisfiedBy(remoteEpisode, null).Accepted.Should().BeTrue(); Subject.IsSatisfiedBy(remoteEpisode, null).Accepted.Should().BeTrue();
} }
[Test, TestCaseSource("DeniedTestCases")] [Test, TestCaseSource(nameof(DeniedTestCases))]
public void should_not_allow_if_quality_is_not_defined_in_profile(Quality qualityType) public void should_not_allow_if_quality_is_not_defined_in_profile(Quality qualityType)
{ {
remoteEpisode.ParsedEpisodeInfo.Quality.Quality = qualityType; remoteEpisode.ParsedEpisodeInfo.Quality.Quality = qualityType;

View File

@ -36,7 +36,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
.Returns(autoDownloadPropers); .Returns(autoDownloadPropers);
} }
[Test, TestCaseSource("IsUpgradeTestCases")] [Test, TestCaseSource(nameof(IsUpgradeTestCases))]
public void IsUpgradeTest(Quality current, int currentVersion, Quality newQuality, int newVersion, Quality cutoff, bool expected) public void IsUpgradeTest(Quality current, int currentVersion, Quality newQuality, int newVersion, Quality cutoff, bool expected)
{ {
GivenAutoDownloadPropers(true); GivenAutoDownloadPropers(true);

View File

@ -83,7 +83,7 @@ namespace NzbDrone.Core.Test.ParserTests
} }
}; };
[Test, TestCaseSource("HashedReleaseParserCases")] [Test, TestCaseSource(nameof(HashedReleaseParserCases))]
public void should_properly_parse_hashed_releases(string path, string title, Quality quality, string releaseGroup) public void should_properly_parse_hashed_releases(string path, string title, Quality quality, string releaseGroup)
{ {
var result = Parser.Parser.ParsePath(path); var result = Parser.Parser.ParsePath(path);

View File

@ -238,7 +238,7 @@ namespace NzbDrone.Core.Test.ParserTests
ParseAndVerifyQuality(title, Quality.Unknown, proper); ParseAndVerifyQuality(title, Quality.Unknown, proper);
} }
[Test, TestCaseSource("SelfQualityParserCases")] [Test, TestCaseSource(nameof(SelfQualityParserCases))]
public void parsing_our_own_quality_enum_name(Quality quality) public void parsing_our_own_quality_enum_name(Quality quality)
{ {
var fileName = string.Format("My series S01E01 [{0}]", quality.Name); var fileName = string.Format("My series S01E01 [{0}]", quality.Name);
@ -246,7 +246,7 @@ namespace NzbDrone.Core.Test.ParserTests
result.Quality.Should().Be(quality); result.Quality.Should().Be(quality);
} }
[Test, TestCaseSource("OtherSourceQualityParserCases")] [Test, TestCaseSource(nameof(OtherSourceQualityParserCases))]
public void should_parse_quality_from_other_source(string qualityString, Quality quality) public void should_parse_quality_from_other_source(string qualityString, Quality quality)
{ {
foreach (var c in new char[] { '-', '.', ' ', '_' }) foreach (var c in new char[] { '-', '.', ' ', '_' })

View File

@ -47,14 +47,14 @@ namespace NzbDrone.Core.Test.Qualities
new object[] {Quality.Bluray2160p, 19}, new object[] {Quality.Bluray2160p, 19},
}; };
[Test, TestCaseSource("FromIntCases")] [Test, TestCaseSource(nameof(FromIntCases))]
public void should_be_able_to_convert_int_to_qualityTypes(int source, Quality expected) public void should_be_able_to_convert_int_to_qualityTypes(int source, Quality expected)
{ {
var quality = (Quality)source; var quality = (Quality)source;
quality.Should().Be(expected); quality.Should().Be(expected);
} }
[Test, TestCaseSource("ToIntCases")] [Test, TestCaseSource(nameof(ToIntCases))]
public void should_be_able_to_convert_qualityTypes_to_int(Quality source, int expected) public void should_be_able_to_convert_qualityTypes_to_int(Quality source, int expected)
{ {
var i = (int)source; var i = (int)source;

View File

@ -43,7 +43,7 @@ namespace NzbDrone.Core.Download.Clients.Hadouken
} }
catch (DownloadClientException ex) catch (DownloadClientException ex)
{ {
_logger.ErrorException(ex.Message, ex); _logger.Error(ex);
return Enumerable.Empty<DownloadClientItem>(); return Enumerable.Empty<DownloadClientItem>();
} }
@ -175,7 +175,7 @@ namespace NzbDrone.Core.Download.Clients.Hadouken
} }
catch (DownloadClientAuthenticationException ex) catch (DownloadClientAuthenticationException ex)
{ {
_logger.ErrorException(ex.Message, ex); _logger.Error(ex);
return new NzbDroneValidationFailure("Password", "Authentication failed"); return new NzbDroneValidationFailure("Password", "Authentication failed");
} }
@ -191,7 +191,7 @@ namespace NzbDrone.Core.Download.Clients.Hadouken
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.ErrorException(ex.Message, ex); _logger.Error(ex);
return new NzbDroneValidationFailure(String.Empty, "Failed to get the list of torrents: " + ex.Message); return new NzbDroneValidationFailure(String.Empty, "Failed to get the list of torrents: " + ex.Message);
} }

View File

@ -125,9 +125,9 @@ namespace NzbDrone.Core.Parser
Logger.Debug("Unable to parse langauge from subtitle file: {0}", fileName); Logger.Debug("Unable to parse langauge from subtitle file: {0}", fileName);
} }
catch (Exception ex) catch (Exception e)
{ {
Logger.Debug("Failed parsing langauge from subtitle file: {0}", fileName); Logger.Debug(e, "Failed parsing langauge from subtitle file: {0}", fileName);
} }
return Language.Unknown; return Language.Unknown;

View File

@ -134,7 +134,7 @@ namespace NzbDrone.Core.Qualities
var quality = AllLookup[id]; var quality = AllLookup[id];
if (quality == null) if (quality == null)
throw new ArgumentException("ID does not match a known quality", "id"); throw new ArgumentException("ID does not match a known quality", nameof(id));
return quality; return quality;
} }

View File

@ -132,7 +132,7 @@ namespace NzbDrone.Core.RootFolders
{ {
_logger.Debug("Generating list of unmapped folders"); _logger.Debug("Generating list of unmapped folders");
if (string.IsNullOrEmpty(path)) if (string.IsNullOrEmpty(path))
throw new ArgumentException("Invalid path provided", "path"); throw new ArgumentException("Invalid path provided", nameof(path));
var results = new List<UnmappedFolder>(); var results = new List<UnmappedFolder>();
var series = _seriesRepository.All().ToList(); var series = _seriesRepository.All().ToList();

View File

@ -50,7 +50,7 @@ namespace NzbDrone.Core.Update
{ {
if (configFileProvider == null) if (configFileProvider == null)
{ {
throw new ArgumentNullException("configFileProvider"); throw new ArgumentNullException(nameof(configFileProvider));
} }
_checkUpdateService = checkUpdateService; _checkUpdateService = checkUpdateService;
_appFolderInfo = appFolderInfo; _appFolderInfo = appFolderInfo;

View File

@ -20,7 +20,7 @@ namespace NzbDrone.Test.Common
if (LogManager.Configuration == null || LogManager.Configuration.AllTargets.None(c => c is ExceptionVerification)) if (LogManager.Configuration == null || LogManager.Configuration.AllTargets.None(c => c is ExceptionVerification))
{ {
LogManager.Configuration = new LoggingConfiguration(); LogManager.Configuration = new LoggingConfiguration();
var consoleTarget = new ConsoleTarget { Layout = "${level}: ${message} ${exception}" }; var consoleTarget = new ConsoleTarget { Layout = "${level}: ${message} ${exception:format=toString}" };
LogManager.Configuration.AddTarget(consoleTarget.GetType().Name, consoleTarget); LogManager.Configuration.AddTarget(consoleTarget.GetType().Name, consoleTarget);
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Trace, consoleTarget)); LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Trace, consoleTarget));

View File

@ -57,7 +57,7 @@ namespace NzbDrone.Test.Common
Assert.Fail("Process has exited"); Assert.Fail("Process has exited");
} }
SetApiKey(); GetApiKey();
var request = new RestRequest("system/status"); var request = new RestRequest("system/status");
request.AddHeader("Authorization", ApiKey); request.AddHeader("Authorization", ApiKey);
@ -71,7 +71,7 @@ namespace NzbDrone.Test.Common
return; return;
} }
Console.WriteLine("Waiting for NzbDrone to start. Response Status : {0} [{1}] {2}", statusCall.ResponseStatus, statusCall.StatusDescription, statusCall.ErrorException); Console.WriteLine("Waiting for NzbDrone to start. Response Status : {0} [{1}]", statusCall.ResponseStatus, statusCall.StatusDescription);
Thread.Sleep(500); Thread.Sleep(500);
} }
@ -105,22 +105,22 @@ namespace NzbDrone.Test.Common
} }
} }
private void SetApiKey() private void GetApiKey()
{ {
var configFile = Path.Combine(AppData, "config.xml"); var configFile = Path.Combine(AppData, "config.xml");
var attempts = 0; var attempts = 0;
while (ApiKey == null && attempts < 50) while (ApiKey == null && attempts < 30)
{ {
try try
{ {
if (File.Exists(configFile)) if (File.Exists(configFile))
{ {
var apiKeyElement = XDocument.Load(configFile) var apiKeyElement = XDocument.Load(configFile).XPathSelectElement("Config/ApiKey");
.XPathSelectElement("Config/ApiKey");
if (apiKeyElement != null) if (apiKeyElement != null)
{ {
ApiKey = apiKeyElement.Value; ApiKey = apiKeyElement.Value;
return;
} }
} }
} }
@ -132,6 +132,8 @@ namespace NzbDrone.Test.Common
attempts++; attempts++;
Thread.Sleep(1000); Thread.Sleep(1000);
} }
Assert.Fail("Couldn't get API key in time.");
} }
} }
} }

View File

@ -62,7 +62,7 @@ namespace NzbDrone.Update
{ {
if (args == null || !args.Any()) if (args == null || !args.Any())
{ {
throw new ArgumentOutOfRangeException("args", "args must be specified"); throw new ArgumentOutOfRangeException(nameof(args), "args must be specified");
} }
var startupContext = new UpdateStartupContext var startupContext = new UpdateStartupContext
@ -72,7 +72,7 @@ namespace NzbDrone.Update
if (OsInfo.IsNotWindows) if (OsInfo.IsNotWindows)
{ {
switch (args.Count()) switch (args.Length)
{ {
case 1: case 1:
return startupContext; return startupContext;
@ -101,7 +101,7 @@ namespace NzbDrone.Update
int id; int id;
if (!int.TryParse(arg, out id) || id <= 0) if (!int.TryParse(arg, out id) || id <= 0)
{ {
throw new ArgumentOutOfRangeException("arg", "Invalid process ID"); throw new ArgumentOutOfRangeException(nameof(arg), "Invalid process ID");
} }
Logger.Debug("NzbDrone process ID: {0}", id); Logger.Debug("NzbDrone process ID: {0}", id);

View File

@ -88,8 +88,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LogentriesNLog", "Logentrie
{90D6E9FC-7B88-4E1B-B018-8FA742274558} = {90D6E9FC-7B88-4E1B-B018-8FA742274558} {90D6E9FC-7B88-4E1B-B018-8FA742274558} = {90D6E9FC-7B88-4E1B-B018-8FA742274558}
EndProjectSection EndProjectSection
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CurlSharp", "ExternalModules\CurlSharp\CurlSharp\CurlSharp.csproj", "{74420A79-CC16-442C-8B1E-7C1B913844F0}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86 Debug|x86 = Debug|x86
@ -270,12 +268,6 @@ Global
{9DC31DE3-79FF-47A8-96B4-6BA18F6BB1CB}.Mono|x86.Build.0 = Release|x86 {9DC31DE3-79FF-47A8-96B4-6BA18F6BB1CB}.Mono|x86.Build.0 = Release|x86
{9DC31DE3-79FF-47A8-96B4-6BA18F6BB1CB}.Release|x86.ActiveCfg = Release|x86 {9DC31DE3-79FF-47A8-96B4-6BA18F6BB1CB}.Release|x86.ActiveCfg = Release|x86
{9DC31DE3-79FF-47A8-96B4-6BA18F6BB1CB}.Release|x86.Build.0 = Release|x86 {9DC31DE3-79FF-47A8-96B4-6BA18F6BB1CB}.Release|x86.Build.0 = Release|x86
{74420A79-CC16-442C-8B1E-7C1B913844F0}.Debug|x86.ActiveCfg = Debug|Any CPU
{74420A79-CC16-442C-8B1E-7C1B913844F0}.Debug|x86.Build.0 = Debug|Any CPU
{74420A79-CC16-442C-8B1E-7C1B913844F0}.Mono|x86.ActiveCfg = Release|Any CPU
{74420A79-CC16-442C-8B1E-7C1B913844F0}.Mono|x86.Build.0 = Release|Any CPU
{74420A79-CC16-442C-8B1E-7C1B913844F0}.Release|x86.ActiveCfg = Release|Any CPU
{74420A79-CC16-442C-8B1E-7C1B913844F0}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -308,7 +300,6 @@ Global
{411A9E0E-FDC6-4E25-828A-0C2CD1CD96F8} = {F6E3A728-AE77-4D02-BAC8-82FBC1402DDA} {411A9E0E-FDC6-4E25-828A-0C2CD1CD96F8} = {F6E3A728-AE77-4D02-BAC8-82FBC1402DDA}
{90D6E9FC-7B88-4E1B-B018-8FA742274558} = {F6E3A728-AE77-4D02-BAC8-82FBC1402DDA} {90D6E9FC-7B88-4E1B-B018-8FA742274558} = {F6E3A728-AE77-4D02-BAC8-82FBC1402DDA}
{9DC31DE3-79FF-47A8-96B4-6BA18F6BB1CB} = {F6E3A728-AE77-4D02-BAC8-82FBC1402DDA} {9DC31DE3-79FF-47A8-96B4-6BA18F6BB1CB} = {F6E3A728-AE77-4D02-BAC8-82FBC1402DDA}
{74420A79-CC16-442C-8B1E-7C1B913844F0} = {F6E3A728-AE77-4D02-BAC8-82FBC1402DDA}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
EnterpriseLibraryConfigurationToolBinariesPath = packages\Unity.2.1.505.0\lib\NET35;packages\Unity.2.1.505.2\lib\NET35 EnterpriseLibraryConfigurationToolBinariesPath = packages\Unity.2.1.505.0\lib\NET35;packages\Unity.2.1.505.2\lib\NET35