Use nameof

This commit is contained in:
Keivan Beigi 2017-01-07 09:59:59 -08:00
parent ced7a7dce2
commit cea6469ab8
No known key found for this signature in database
GPG Key ID: C536675AC49003C0
11 changed files with 16 additions and 16 deletions

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

@ -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

@ -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

@ -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
@ -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);