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="OsPathFixture.cs" />
<Compile Include="PathExtensionFixture.cs" />
<Compile Include="ProcessProviderTests.cs" />
<Compile Include="Processes\ProcessProviderFixture.cs" />
<Compile Include="ReflectionExtensions.cs" />
<Compile Include="ReflectionTests\ReflectionExtensionFixture.cs" />
<Compile Include="ServiceFactoryFixture.cs" />

View File

@ -10,20 +10,20 @@ using NzbDrone.Common.Processes;
using NzbDrone.Test.Common;
using NzbDrone.Test.Dummy;
namespace NzbDrone.Common.Test
namespace NzbDrone.Common.Test.Processes
{
[TestFixture]
public class ProcessProviderTests : TestBase<ProcessProvider>
public class ProcessProviderFixture : TestBase<ProcessProvider>
{
[SetUp]
public void Setup()
{
Process.GetProcessesByName(DummyApp.DUMMY_PROCCESS_NAME).ToList().ForEach(c =>
{
c.Kill();
c.WaitForExit();
});
{
c.Kill();
c.WaitForExit();
});
Process.GetProcessesByName(DummyApp.DUMMY_PROCCESS_NAME).Should().BeEmpty();
}
@ -41,7 +41,7 @@ namespace NzbDrone.Common.Test
{
TestLogger.Warn(ex, "{0} when killing process", ex.Message);
}
});
}
@ -101,5 +101,11 @@ namespace NzbDrone.Common.Test
Console.WriteLine(new ProcessInfo().ToString());
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)
{
if (first == null) throw new ArgumentNullException("first");
if (second == null) throw new ArgumentNullException("second");
if (first == null) throw new ArgumentNullException(nameof(first));
if (second == null) throw new ArgumentNullException(nameof(second));
var merged = new Dictionary<T1, T2>();
first.ToList().ForEach(kv => merged[kv.Key] = kv.Value);

View File

@ -33,22 +33,21 @@ namespace NzbDrone.Common.Instrumentation.Sentry
public SentryTarget(string dsn)
{
_debounce = new SentryDebounce();
_client = new RavenClient(new Dsn(dsn), new SonarrJsonPacketFactory(), new SentryRequestFactory(), new MachineNameUserFactory())
{
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("runtime", PlatformInfo.Platform.ToString().ToLower());
_client.Tags.Add("culture", Thread.CurrentThread.CurrentCulture.Name);
_client.Tags.Add("branch", BuildInfo.Branch);
_client.Tags.Add("version", BuildInfo.Version.ToString());
_debounce = new SentryDebounce();
}
private void OnError(Exception ex)

View File

@ -39,6 +39,10 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<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">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net40\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
@ -233,10 +237,6 @@
<Content Include="Expansive\license.txt" />
</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">
<Project>{9DC31DE3-79FF-47A8-96B4-6BA18F6BB1CB}</Project>
<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>
public LimitedConcurrencyLevelTaskScheduler(int maxDegreeOfParallelism)
{
if (maxDegreeOfParallelism < 1) throw new ArgumentOutOfRangeException("maxDegreeOfParallelism");
if (maxDegreeOfParallelism < 1) throw new ArgumentOutOfRangeException(nameof(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)
{
remoteEpisode.ParsedEpisodeInfo.Quality.Quality = qualityType;
@ -54,7 +54,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
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)
{
remoteEpisode.ParsedEpisodeInfo.Quality.Quality = qualityType;

View File

@ -36,7 +36,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
.Returns(autoDownloadPropers);
}
[Test, TestCaseSource("IsUpgradeTestCases")]
[Test, TestCaseSource(nameof(IsUpgradeTestCases))]
public void IsUpgradeTest(Quality current, int currentVersion, Quality newQuality, int newVersion, Quality cutoff, bool expected)
{
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)
{
var result = Parser.Parser.ParsePath(path);

View File

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

View File

@ -47,14 +47,14 @@ namespace NzbDrone.Core.Test.Qualities
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)
{
var quality = (Quality)source;
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)
{
var i = (int)source;

View File

@ -43,7 +43,7 @@ namespace NzbDrone.Core.Download.Clients.Hadouken
}
catch (DownloadClientException ex)
{
_logger.ErrorException(ex.Message, ex);
_logger.Error(ex);
return Enumerable.Empty<DownloadClientItem>();
}
@ -170,12 +170,12 @@ namespace NzbDrone.Core.Download.Clients.Hadouken
if (version < new Version("5.1"))
{
return new ValidationFailure(string.Empty, "Old Hadouken client with unsupported API, need 5.1 or higher");
return new ValidationFailure(string.Empty, "Old Hadouken client with unsupported API, need 5.1 or higher");
}
}
catch (DownloadClientAuthenticationException ex)
{
_logger.ErrorException(ex.Message, ex);
_logger.Error(ex);
return new NzbDroneValidationFailure("Password", "Authentication failed");
}
@ -191,7 +191,7 @@ namespace NzbDrone.Core.Download.Clients.Hadouken
}
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);
}

View File

@ -125,11 +125,11 @@ namespace NzbDrone.Core.Parser
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;
}
}

View File

@ -134,7 +134,7 @@ namespace NzbDrone.Core.Qualities
var quality = AllLookup[id];
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;
}

View File

@ -132,7 +132,7 @@ namespace NzbDrone.Core.RootFolders
{
_logger.Debug("Generating list of unmapped folders");
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 series = _seriesRepository.All().ToList();

View File

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

View File

@ -20,7 +20,7 @@ namespace NzbDrone.Test.Common
if (LogManager.Configuration == null || LogManager.Configuration.AllTargets.None(c => c is ExceptionVerification))
{
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.LoggingRules.Add(new LoggingRule("*", LogLevel.Trace, consoleTarget));

View File

@ -57,7 +57,7 @@ namespace NzbDrone.Test.Common
Assert.Fail("Process has exited");
}
SetApiKey();
GetApiKey();
var request = new RestRequest("system/status");
request.AddHeader("Authorization", ApiKey);
@ -71,7 +71,7 @@ namespace NzbDrone.Test.Common
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);
}
@ -81,7 +81,7 @@ namespace NzbDrone.Test.Common
{
if (_nzbDroneProcess != null)
{
_processProvider.Kill(_nzbDroneProcess.Id);
_processProvider.Kill(_nzbDroneProcess.Id);
}
_processProvider.KillAll(ProcessProvider.NZB_DRONE_CONSOLE_PROCESS_NAME);
@ -105,22 +105,22 @@ namespace NzbDrone.Test.Common
}
}
private void SetApiKey()
private void GetApiKey()
{
var configFile = Path.Combine(AppData, "config.xml");
var attempts = 0;
while (ApiKey == null && attempts < 50)
while (ApiKey == null && attempts < 30)
{
try
{
if (File.Exists(configFile))
{
var apiKeyElement = XDocument.Load(configFile)
.XPathSelectElement("Config/ApiKey");
var apiKeyElement = XDocument.Load(configFile).XPathSelectElement("Config/ApiKey");
if (apiKeyElement != null)
{
ApiKey = apiKeyElement.Value;
return;
}
}
}
@ -132,6 +132,8 @@ namespace NzbDrone.Test.Common
attempts++;
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())
{
throw new ArgumentOutOfRangeException("args", "args must be specified");
throw new ArgumentOutOfRangeException(nameof(args), "args must be specified");
}
var startupContext = new UpdateStartupContext
@ -72,7 +72,7 @@ namespace NzbDrone.Update
if (OsInfo.IsNotWindows)
{
switch (args.Count())
switch (args.Length)
{
case 1:
return startupContext;
@ -101,7 +101,7 @@ namespace NzbDrone.Update
int id;
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);

View File

@ -88,8 +88,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LogentriesNLog", "Logentrie
{90D6E9FC-7B88-4E1B-B018-8FA742274558} = {90D6E9FC-7B88-4E1B-B018-8FA742274558}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CurlSharp", "ExternalModules\CurlSharp\CurlSharp\CurlSharp.csproj", "{74420A79-CC16-442C-8B1E-7C1B913844F0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
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}.Release|x86.ActiveCfg = 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
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -308,7 +300,6 @@ Global
{411A9E0E-FDC6-4E25-828A-0C2CD1CD96F8} = {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}
{74420A79-CC16-442C-8B1E-7C1B913844F0} = {F6E3A728-AE77-4D02-BAC8-82FBC1402DDA}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EnterpriseLibraryConfigurationToolBinariesPath = packages\Unity.2.1.505.0\lib\NET35;packages\Unity.2.1.505.2\lib\NET35