diff --git a/.editorconfig b/.editorconfig
index 8eaf9a3bf..b74add49a 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -69,6 +69,7 @@ dotnet_diagnostic.SA1406.severity = suggestion
dotnet_diagnostic.SA1410.severity = suggestion
dotnet_diagnostic.SA1411.severity = suggestion
dotnet_diagnostic.SA1413.severity = none
+dotnet_diagnostic.SA1512.severity = none
dotnet_diagnostic.SA1516.severity = none
dotnet_diagnostic.SA1600.severity = none
dotnet_diagnostic.SA1601.severity = none
diff --git a/.gitignore b/.gitignore
index 073135e2e..f6462057b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -84,7 +84,6 @@ TestResults
[Tt]est[Rr]esult*
*.Cache
ClientBin
-[Ss]tyle[Cc]op.*
~$*
*.dbmdl
Generated_Code #added for RIA/Silverlight projects
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index e213bdc20..b9c4e8099 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -104,6 +104,16 @@
false
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers
+
+
+
+
diff --git a/src/NzbDrone.Api.Test/ClientSchemaTests/SchemaBuilderFixture.cs b/src/NzbDrone.Api.Test/ClientSchemaTests/SchemaBuilderFixture.cs
index 497725c65..8b675b5bf 100644
--- a/src/NzbDrone.Api.Test/ClientSchemaTests/SchemaBuilderFixture.cs
+++ b/src/NzbDrone.Api.Test/ClientSchemaTests/SchemaBuilderFixture.cs
@@ -16,7 +16,6 @@ public void should_return_field_for_every_property()
schema.Should().HaveCount(2);
}
-
[Test]
public void schema_should_have_proper_fields()
{
@@ -32,7 +31,6 @@ public void schema_should_have_proper_fields()
schema.Should().Contain(c => c.Order == 0 && c.Name == "firstName" && c.Label == "First Name" && c.HelpText == "Your First Name" && (string)c.Value == "Bob");
}
-
[Test]
public void schema_should_have_nested_fields()
{
diff --git a/src/NzbDrone.Automation.Test/AutomationTestAttribute.cs b/src/NzbDrone.Automation.Test/AutomationTestAttribute.cs
index d1cf9faec..2ed2fac7e 100644
--- a/src/NzbDrone.Automation.Test/AutomationTestAttribute.cs
+++ b/src/NzbDrone.Automation.Test/AutomationTestAttribute.cs
@@ -7,7 +7,6 @@ public class AutomationTestAttribute : CategoryAttribute
public AutomationTestAttribute()
: base("AutomationTest")
{
-
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Automation.Test/MainPagesTest.cs b/src/NzbDrone.Automation.Test/MainPagesTest.cs
index 4dcc5556a..6711bbbc3 100644
--- a/src/NzbDrone.Automation.Test/MainPagesTest.cs
+++ b/src/NzbDrone.Automation.Test/MainPagesTest.cs
@@ -1,4 +1,5 @@
-using FluentAssertions;
+using System.Reflection;
+using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Automation.Test.PageModel;
using OpenQA.Selenium;
@@ -8,73 +9,86 @@ namespace NzbDrone.Automation.Test
[TestFixture]
public class MainPagesTest : AutomationTest
{
- private PageBase page;
+ private PageBase _page;
[SetUp]
public void Setup()
{
- page = new PageBase(driver);
+ _page = new PageBase(driver);
}
[Test]
public void series_page()
{
- page.SeriesNavIcon.Click();
- page.WaitForNoSpinner();
+ _page.SeriesNavIcon.Click();
+ _page.WaitForNoSpinner();
- page.Find(By.CssSelector("div[class*='SeriesIndex']")).Should().NotBeNull();
+ var imageName = MethodBase.GetCurrentMethod().Name;
+ TakeScreenshot(imageName);
+
+ _page.Find(By.CssSelector("div[class*='SeriesIndex']")).Should().NotBeNull();
}
[Test]
public void calendar_page()
{
- page.CalendarNavIcon.Click();
- page.WaitForNoSpinner();
+ _page.CalendarNavIcon.Click();
+ _page.WaitForNoSpinner();
- page.Find(By.CssSelector("div[class*='CalendarPage']")).Should().NotBeNull();
+ var imageName = MethodBase.GetCurrentMethod().Name;
+ TakeScreenshot(imageName);
+
+ _page.Find(By.CssSelector("div[class*='CalendarPage']")).Should().NotBeNull();
}
[Test]
public void activity_page()
{
- page.ActivityNavIcon.Click();
- page.WaitForNoSpinner();
+ _page.ActivityNavIcon.Click();
+ _page.WaitForNoSpinner();
- page.Find(By.LinkText("Queue")).Should().NotBeNull();
- page.Find(By.LinkText("History")).Should().NotBeNull();
- page.Find(By.LinkText("Blocklist")).Should().NotBeNull();
+ var imageName = MethodBase.GetCurrentMethod().Name;
+ TakeScreenshot(imageName);
+
+ _page.Find(By.LinkText("Queue")).Should().NotBeNull();
+ _page.Find(By.LinkText("History")).Should().NotBeNull();
+ _page.Find(By.LinkText("Blocklist")).Should().NotBeNull();
}
[Test]
public void wanted_page()
{
- page.WantedNavIcon.Click();
- page.WaitForNoSpinner();
+ _page.WantedNavIcon.Click();
+ _page.WaitForNoSpinner();
- page.Find(By.LinkText("Missing")).Should().NotBeNull();
- page.Find(By.LinkText("Cutoff Unmet")).Should().NotBeNull();
+ _page.Find(By.LinkText("Missing")).Should().NotBeNull();
+ _page.Find(By.LinkText("Cutoff Unmet")).Should().NotBeNull();
}
[Test]
public void system_page()
{
- page.SystemNavIcon.Click();
- page.WaitForNoSpinner();
+ _page.SystemNavIcon.Click();
+ _page.WaitForNoSpinner();
- page.Find(By.CssSelector("div[class*='Health']")).Should().NotBeNull();
+ var imageName = MethodBase.GetCurrentMethod().Name;
+ TakeScreenshot(imageName);
+
+ _page.Find(By.CssSelector("div[class*='Health']")).Should().NotBeNull();
}
[Test]
public void add_series_page()
{
- page.SeriesNavIcon.Click();
- page.WaitForNoSpinner();
+ _page.SeriesNavIcon.Click();
+ _page.WaitForNoSpinner();
- page.Find(By.LinkText("Add New")).Click();
+ _page.Find(By.LinkText("Add New")).Click();
- page.WaitForNoSpinner();
+ var imageName = MethodBase.GetCurrentMethod().Name;
+ TakeScreenshot(imageName);
- page.Find(By.CssSelector("input[class*='AddNewSeries/searchInput']")).Should().NotBeNull();
+ _page.Find(By.CssSelector("input[class*='AddNewSeries-searchInput']")).Should().NotBeNull();
}
}
}
diff --git a/src/NzbDrone.Automation.Test/PageModel/PageBase.cs b/src/NzbDrone.Automation.Test/PageModel/PageBase.cs
index b030536c5..00d084f13 100644
--- a/src/NzbDrone.Automation.Test/PageModel/PageBase.cs
+++ b/src/NzbDrone.Automation.Test/PageModel/PageBase.cs
@@ -59,4 +59,4 @@ public void WaitForNoSpinner(int timeout = 30)
public IWebElement SystemNavIcon => Find(By.PartialLinkText("System"));
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Automation.Test/Sonarr.Automation.Test.csproj b/src/NzbDrone.Automation.Test/Sonarr.Automation.Test.csproj
index b5388248b..be3d4d4db 100644
--- a/src/NzbDrone.Automation.Test/Sonarr.Automation.Test.csproj
+++ b/src/NzbDrone.Automation.Test/Sonarr.Automation.Test.csproj
@@ -4,7 +4,7 @@
-
+
diff --git a/src/NzbDrone.Common.Test/CacheTests/CachedDictionaryFixture.cs b/src/NzbDrone.Common.Test/CacheTests/CachedDictionaryFixture.cs
index 23781d033..4b98d7313 100644
--- a/src/NzbDrone.Common.Test/CacheTests/CachedDictionaryFixture.cs
+++ b/src/NzbDrone.Common.Test/CacheTests/CachedDictionaryFixture.cs
@@ -99,4 +99,4 @@ public Dictionary GetDict()
return result;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Common.Test/CacheTests/CachedFixture.cs b/src/NzbDrone.Common.Test/CacheTests/CachedFixture.cs
index 54b2a0e01..7c892047d 100644
--- a/src/NzbDrone.Common.Test/CacheTests/CachedFixture.cs
+++ b/src/NzbDrone.Common.Test/CacheTests/CachedFixture.cs
@@ -26,7 +26,6 @@ public void should_call_function_once()
_cachedString.Get("Test", _worker.GetString);
_worker.HitCount.Should().Be(1);
-
}
[Test]
@@ -38,7 +37,6 @@ public void multiple_calls_should_return_same_result()
first.Should().Be(second);
}
-
[Test]
public void should_be_able_to_update_key()
{
@@ -48,7 +46,6 @@ public void should_be_able_to_update_key()
_cachedString.Find("Key").Should().Be("New");
}
-
[Test]
public void should_be_able_to_remove_key()
{
@@ -70,7 +67,6 @@ public void should_store_null()
{
int hitCount = 0;
-
for (int i = 0; i < 10; i++)
{
_cachedString.Get("key", () =>
@@ -84,6 +80,7 @@ public void should_store_null()
}
[Test]
+ [Platform(Exclude = "MacOsX")]
public void should_honor_ttl()
{
int hitCount = 0;
@@ -91,11 +88,13 @@ public void should_honor_ttl()
for (int i = 0; i < 10; i++)
{
- _cachedString.Get("key", () =>
+ _cachedString.Get("key",
+ () =>
{
hitCount++;
return null;
- }, TimeSpan.FromMilliseconds(300));
+ },
+ TimeSpan.FromMilliseconds(300));
Thread.Sleep(100);
}
@@ -114,4 +113,4 @@ public string GetString()
return "Hit count is " + HitCount;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Common.Test/CacheTests/CachedManagerFixture.cs b/src/NzbDrone.Common.Test/CacheTests/CachedManagerFixture.cs
index ec3f9de35..29d4516fb 100644
--- a/src/NzbDrone.Common.Test/CacheTests/CachedManagerFixture.cs
+++ b/src/NzbDrone.Common.Test/CacheTests/CachedManagerFixture.cs
@@ -26,4 +26,4 @@ public void multiple_calls_should_get_the_same_cache()
result1.Should().BeSameAs(result2);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Common.Test/ConfigFileProviderTest.cs b/src/NzbDrone.Common.Test/ConfigFileProviderTest.cs
index 92df06ded..9622f4e01 100644
--- a/src/NzbDrone.Common.Test/ConfigFileProviderTest.cs
+++ b/src/NzbDrone.Common.Test/ConfigFileProviderTest.cs
@@ -62,10 +62,8 @@ public void GetInt_Success()
const string key = "Port";
const int value = 8989;
-
var result = Subject.GetValueInt(key, value);
-
result.Should().Be(value);
}
@@ -75,20 +73,16 @@ public void GetBool_Success()
const string key = "LaunchBrowser";
const bool value = true;
-
var result = Subject.GetValueBoolean(key, value);
-
result.Should().BeTrue();
}
[Test]
public void GetLaunchBrowser_Success()
{
-
var result = Subject.LaunchBrowser;
-
result.Should().Be(true);
}
@@ -97,10 +91,8 @@ public void GetPort_Success()
{
const int value = 8989;
-
var result = Subject.Port;
-
result.Should().Be(value);
}
@@ -110,10 +102,8 @@ public void SetValue_bool()
const string key = "LaunchBrowser";
const bool value = false;
-
Subject.SetValue(key, value);
-
var result = Subject.LaunchBrowser;
result.Should().Be(value);
}
@@ -124,10 +114,8 @@ public void SetValue_int()
const string key = "Port";
const int value = 12345;
-
Subject.SetValue(key, value);
-
var result = Subject.Port;
result.Should().Be(value);
}
@@ -138,10 +126,8 @@ public void GetValue_New_Key()
const string key = "Hello";
const string value = "World";
-
var result = Subject.GetValue(key, value);
-
result.Should().Be(value);
}
@@ -178,7 +164,6 @@ public void SaveDictionary_should_only_save_specified_values()
dic["SslPort"] = origSslPort;
Subject.SaveConfigDictionary(dic);
-
dic = new Dictionary();
dic["SslPort"] = sslPort;
Subject.SaveConfigDictionary(dic);
@@ -213,4 +198,4 @@ public void should_throw_if_config_file_contains_invalid_xml()
Assert.Throws(() => Subject.GetValue("key", "value"));
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Common.Test/DiskTests/DirectoryLookupServiceFixture.cs b/src/NzbDrone.Common.Test/DiskTests/DirectoryLookupServiceFixture.cs
index 70b68ca0a..78aa99f7d 100644
--- a/src/NzbDrone.Common.Test/DiskTests/DirectoryLookupServiceFixture.cs
+++ b/src/NzbDrone.Common.Test/DiskTests/DirectoryLookupServiceFixture.cs
@@ -76,7 +76,7 @@ public void should_not_contain_recycling_bin_or_system_volume_information_for_ro
.Returns(_folders);
var result = Subject.LookupContents(root, false, false);
-
+
result.Directories.Should().HaveCount(_folders.Count - 3);
result.Directories.Should().NotContain(f => f.Name == RECYCLING_BIN);
diff --git a/src/NzbDrone.Common.Test/DiskTests/DiskProviderFixtureBase.cs b/src/NzbDrone.Common.Test/DiskTests/DiskProviderFixtureBase.cs
index 77f048f33..b1994d103 100644
--- a/src/NzbDrone.Common.Test/DiskTests/DiskProviderFixtureBase.cs
+++ b/src/NzbDrone.Common.Test/DiskTests/DiskProviderFixtureBase.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.IO;
using FluentAssertions;
using NUnit.Framework;
@@ -7,7 +7,8 @@
namespace NzbDrone.Common.Test.DiskTests
{
- public abstract class DiskProviderFixtureBase : TestBase where TSubject : class, IDiskProvider
+ public abstract class DiskProviderFixtureBase : TestBase
+ where TSubject : class, IDiskProvider
{
[Test]
[Retry(5)]
@@ -154,7 +155,7 @@ public void folder_should_return_correct_value_for_last_write()
public void should_return_false_for_unlocked_file()
{
var testFile = GetTempFilePath();
- Subject.WriteAllText(testFile, new Guid().ToString());
+ Subject.WriteAllText(testFile, default(Guid).ToString());
Subject.IsFileLocked(testFile).Should().BeFalse();
}
@@ -163,7 +164,7 @@ public void should_return_false_for_unlocked_file()
public void should_return_false_for_unlocked_and_readonly_file()
{
var testFile = GetTempFilePath();
- Subject.WriteAllText(testFile, new Guid().ToString());
+ Subject.WriteAllText(testFile, default(Guid).ToString());
File.SetAttributes(testFile, FileAttributes.ReadOnly);
@@ -174,7 +175,7 @@ public void should_return_false_for_unlocked_and_readonly_file()
public void should_return_true_for_unlocked_file()
{
var testFile = GetTempFilePath();
- Subject.WriteAllText(testFile, new Guid().ToString());
+ Subject.WriteAllText(testFile, default(Guid).ToString());
using (var file = File.OpenWrite(testFile))
{
@@ -186,7 +187,7 @@ public void should_return_true_for_unlocked_file()
public void should_be_able_to_set_permission_from_parrent()
{
var testFile = GetTempFilePath();
- Subject.WriteAllText(testFile, new Guid().ToString());
+ Subject.WriteAllText(testFile, default(Guid).ToString());
Subject.InheritFolderPermissions(testFile);
}
@@ -195,7 +196,7 @@ public void should_be_able_to_set_permission_from_parrent()
public void should_be_set_last_file_write()
{
var testFile = GetTempFilePath();
- Subject.WriteAllText(testFile, new Guid().ToString());
+ Subject.WriteAllText(testFile, default(Guid).ToString());
var lastWriteTime = DateTime.SpecifyKind(new DateTime(2012, 1, 2), DateTimeKind.Utc);
diff --git a/src/NzbDrone.Common.Test/DiskTests/DiskTransferServiceFixture.cs b/src/NzbDrone.Common.Test/DiskTests/DiskTransferServiceFixture.cs
index 2be842067..084bd6752 100644
--- a/src/NzbDrone.Common.Test/DiskTests/DiskTransferServiceFixture.cs
+++ b/src/NzbDrone.Common.Test/DiskTests/DiskTransferServiceFixture.cs
@@ -751,7 +751,9 @@ private void WithExistingFolder(string path, bool exists = true)
{
var dir = Path.GetDirectoryName(path);
if (exists && dir.IsNotNullOrWhiteSpace())
+ {
WithExistingFolder(dir);
+ }
Mocker.GetMock()
.Setup(v => v.FolderExists(path))
@@ -762,7 +764,9 @@ private void WithExistingFile(string path, bool exists = true, int size = 1000)
{
var dir = Path.GetDirectoryName(path);
if (exists && dir.IsNotNullOrWhiteSpace())
+ {
WithExistingFolder(dir);
+ }
Mocker.GetMock()
.Setup(v => v.FileExists(path))
@@ -816,7 +820,6 @@ private void WithEmulatedDiskProvider()
WithExistingFile(v, false);
});
-
Mocker.GetMock()
.Setup(v => v.FolderExists(It.IsAny()))
.Returns(false);
@@ -834,6 +837,7 @@ private void WithEmulatedDiskProvider()
{
WithExistingFolder(s, false);
WithExistingFolder(d);
+
// Note: Should also deal with the files.
});
@@ -842,6 +846,7 @@ private void WithEmulatedDiskProvider()
.Callback((f, r) =>
{
WithExistingFolder(f, false);
+
// Note: Should also deal with the files.
});
@@ -907,8 +912,13 @@ private void WithRealDiskProvider()
Mocker.GetMock()
.Setup(v => v.MoveFile(It.IsAny(), It.IsAny(), It.IsAny()))
- .Callback((s,d,o) => {
- if (File.Exists(d) && o) File.Delete(d);
+ .Callback((s, d, o) =>
+ {
+ if (File.Exists(d) && o)
+ {
+ File.Delete(d);
+ }
+
File.Move(s, d);
});
diff --git a/src/NzbDrone.Common.Test/DiskTests/FreeSpaceFixtureBase.cs b/src/NzbDrone.Common.Test/DiskTests/FreeSpaceFixtureBase.cs
index bf6d8ec27..2b4d356cd 100644
--- a/src/NzbDrone.Common.Test/DiskTests/FreeSpaceFixtureBase.cs
+++ b/src/NzbDrone.Common.Test/DiskTests/FreeSpaceFixtureBase.cs
@@ -7,7 +7,8 @@
namespace NzbDrone.Common.Test.DiskTests
{
- public abstract class FreeSpaceFixtureBase : TestBase where TSubject : class, IDiskProvider
+ public abstract class FreeSpaceFixtureBase : TestBase
+ where TSubject : class, IDiskProvider
{
[Test]
public void should_get_free_space_for_folder()
diff --git a/src/NzbDrone.Common.Test/EnsureTest/PathExtensionFixture.cs b/src/NzbDrone.Common.Test/EnsureTest/PathExtensionFixture.cs
index 9d51e806f..0ff119ec2 100644
--- a/src/NzbDrone.Common.Test/EnsureTest/PathExtensionFixture.cs
+++ b/src/NzbDrone.Common.Test/EnsureTest/PathExtensionFixture.cs
@@ -15,7 +15,6 @@ public void EnsureWindowsPath(string path)
Ensure.That(path, () => path).IsValidPath();
}
-
[TestCase(@"/var/user/file with, comma.mkv")]
public void EnsureLinuxPath(string path)
{
diff --git a/src/NzbDrone.Common.Test/EnvironmentProviderTest.cs b/src/NzbDrone.Common.Test/EnvironmentProviderTest.cs
index dd7e8fcf0..1d9936a8b 100644
--- a/src/NzbDrone.Common.Test/EnvironmentProviderTest.cs
+++ b/src/NzbDrone.Common.Test/EnvironmentProviderTest.cs
@@ -10,13 +10,11 @@ namespace NzbDrone.Common.Test
[TestFixture]
public class IAppDirectoryInfoTest : TestBase
{
-
[Test]
public void StartupPath_should_not_be_empty()
{
Subject.StartUpFolder.Should().NotBeNullOrWhiteSpace();
Path.IsPathRooted(Subject.StartUpFolder).Should().BeTrue("Path is not rooted");
-
}
[Test]
diff --git a/src/NzbDrone.Common.Test/EnvironmentTests/EnvironmentProviderTest.cs b/src/NzbDrone.Common.Test/EnvironmentTests/EnvironmentProviderTest.cs
index 826cf9520..a4f0bdc6d 100644
--- a/src/NzbDrone.Common.Test/EnvironmentTests/EnvironmentProviderTest.cs
+++ b/src/NzbDrone.Common.Test/EnvironmentTests/EnvironmentProviderTest.cs
@@ -9,13 +9,11 @@ namespace NzbDrone.Common.Test.EnvironmentTests
[TestFixture]
public class BuildInfoTest : TestBase
{
-
[TestCase("0.0.0.0")]
[TestCase("1.0.0.0")]
public void Application_version_should_not_be_default(string version)
{
BuildInfo.Version.Should().NotBe(new Version(version));
}
-
}
}
diff --git a/src/NzbDrone.Common.Test/EnvironmentTests/StartupArgumentsFixture.cs b/src/NzbDrone.Common.Test/EnvironmentTests/StartupArgumentsFixture.cs
index c34c0cf70..07df9c79e 100644
--- a/src/NzbDrone.Common.Test/EnvironmentTests/StartupArgumentsFixture.cs
+++ b/src/NzbDrone.Common.Test/EnvironmentTests/StartupArgumentsFixture.cs
@@ -26,7 +26,6 @@ public void should_parse_single_flag(string arg)
args.Flags.Contains("t").Should().BeTrue();
}
-
[TestCase("/key=value")]
[TestCase("/KEY=value")]
[TestCase(" /key=\"value\"")]
@@ -37,7 +36,6 @@ public void should_parse_args_with_alues(string arg)
args.Args["key"].Should().Be("value");
}
-
[TestCase("/data=test", "/data=test")]
[TestCase("/Data=/a/b/c", "/data=/a/b/c")]
public void should_preserver_data(string arg, string preserved)
@@ -55,7 +53,6 @@ public void should_preserver_no_browser(string arg, string preserved)
args.PreservedArguments.Should().Be(preserved);
}
-
[Test]
public void should_preserver_both()
{
diff --git a/src/NzbDrone.Common.Test/ExtensionTests/IEnumerableExtensionTests/ExceptByFixture.cs b/src/NzbDrone.Common.Test/ExtensionTests/IEnumerableExtensionTests/ExceptByFixture.cs
index 1688fd8c4..2b7ef935b 100644
--- a/src/NzbDrone.Common.Test/ExtensionTests/IEnumerableExtensionTests/ExceptByFixture.cs
+++ b/src/NzbDrone.Common.Test/ExtensionTests/IEnumerableExtensionTests/ExceptByFixture.cs
@@ -56,7 +56,7 @@ public void should_return_objects_that_do_not_have_a_match_in_the_second_list()
var result = first.ExceptBy(o => o.Prop1, second, o => o.Prop1, StringComparer.InvariantCultureIgnoreCase).ToList();
result.Should().HaveCount(1);
- result.First().GetType().Should().Be(typeof (Object1));
+ result.First().GetType().Should().Be(typeof(Object1));
result.First().Prop1.Should().Be("two");
}
}
diff --git a/src/NzbDrone.Common.Test/ExtensionTests/IPAddressExtensionsFixture.cs b/src/NzbDrone.Common.Test/ExtensionTests/IPAddressExtensionsFixture.cs
index 978742af3..f7ed71f94 100644
--- a/src/NzbDrone.Common.Test/ExtensionTests/IPAddressExtensionsFixture.cs
+++ b/src/NzbDrone.Common.Test/ExtensionTests/IPAddressExtensionsFixture.cs
@@ -24,7 +24,6 @@ public void should_return_true_for_local_ip_address(string ipAddress)
public void should_return_false_for_public_ip_address(string ipAddress)
{
IPAddress.Parse(ipAddress).IsLocalAddress().Should().BeFalse();
-
}
}
}
diff --git a/src/NzbDrone.Common.Test/HashUtilFixture.cs b/src/NzbDrone.Common.Test/HashUtilFixture.cs
index 02869fa24..d487b78ba 100644
--- a/src/NzbDrone.Common.Test/HashUtilFixture.cs
+++ b/src/NzbDrone.Common.Test/HashUtilFixture.cs
@@ -18,4 +18,4 @@ public void should_create_the_same_id()
HashUtil.AnonymousToken().Should().Be(HashUtil.AnonymousToken());
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Common.Test/Http/HttpClientFixture.cs b/src/NzbDrone.Common.Test/Http/HttpClientFixture.cs
index e11c6a2a6..2fa05cea4 100644
--- a/src/NzbDrone.Common.Test/Http/HttpClientFixture.cs
+++ b/src/NzbDrone.Common.Test/Http/HttpClientFixture.cs
@@ -23,7 +23,8 @@ namespace NzbDrone.Common.Test.Http
[Ignore("httpbin is bugged")]
[IntegrationTest]
[TestFixture(typeof(ManagedHttpDispatcher))]
- public class HttpClientFixture : TestBase where TDispatcher : IHttpDispatcher
+ public class HttpClientFixture : TestBase
+ where TDispatcher : IHttpDispatcher
{
private string[] _httpBinHosts;
private int _httpBinSleep;
@@ -35,6 +36,7 @@ public class HttpClientFixture : TestBase where TDispat
public void FixtureSetUp()
{
var candidates = new[] { "eu.httpbin.org", /*"httpbin.org",*/ "www.httpbin.org" };
+
// httpbin.org is broken right now, occassionally redirecting to https if it's unavailable.
_httpBinHosts = candidates.Where(IsTestSiteAvailable).ToArray();
@@ -49,7 +51,10 @@ private bool IsTestSiteAvailable(string site)
{
var req = WebRequest.Create($"http://{site}/get") as HttpWebRequest;
var res = req.GetResponse() as HttpWebResponse;
- if (res.StatusCode != HttpStatusCode.OK) return false;
+ if (res.StatusCode != HttpStatusCode.OK)
+ {
+ return false;
+ }
try
{
@@ -61,7 +66,10 @@ private bool IsTestSiteAvailable(string site)
res = ex.Response as HttpWebResponse;
}
- if (res == null || res.StatusCode != (HttpStatusCode)429) return false;
+ if (res == null || res.StatusCode != (HttpStatusCode)429)
+ {
+ return false;
+ }
return true;
}
@@ -688,7 +696,7 @@ public void should_throw_on_http429_too_many_requests()
[Test]
public void should_call_interceptor()
{
- Mocker.SetConstant>(new [] { Mocker.GetMock().Object });
+ Mocker.SetConstant>(new[] { Mocker.GetMock().Object });
Mocker.GetMock()
.Setup(v => v.PreRequest(It.IsAny()))
diff --git a/src/NzbDrone.Common.Test/Http/HttpHeaderFixture.cs b/src/NzbDrone.Common.Test/Http/HttpHeaderFixture.cs
index e0a22072e..e5221e408 100644
--- a/src/NzbDrone.Common.Test/Http/HttpHeaderFixture.cs
+++ b/src/NzbDrone.Common.Test/Http/HttpHeaderFixture.cs
@@ -1,11 +1,11 @@
-using NUnit.Framework;
-using FluentAssertions;
-using NzbDrone.Test.Common;
-using System;
-using System.Text;
-using NzbDrone.Common.Http;
+using System;
using System.Collections.Specialized;
using System.Linq;
+using System.Text;
+using FluentAssertions;
+using NUnit.Framework;
+using NzbDrone.Common.Http;
+using NzbDrone.Test.Common;
namespace NzbDrone.Common.Test.Http
{
diff --git a/src/NzbDrone.Common.Test/Http/HttpRequestBuilderFixture.cs b/src/NzbDrone.Common.Test/Http/HttpRequestBuilderFixture.cs
index 8bc2a265b..4af9bb501 100644
--- a/src/NzbDrone.Common.Test/Http/HttpRequestBuilderFixture.cs
+++ b/src/NzbDrone.Common.Test/Http/HttpRequestBuilderFixture.cs
@@ -35,7 +35,6 @@ public void should_remove_duplicated_slashes()
var request = builder.Resource("/v1/").Build();
request.Url.FullUri.Should().Be("http://domain/v1/");
-
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Common.Test/Http/HttpRequestFixture.cs b/src/NzbDrone.Common.Test/Http/HttpRequestFixture.cs
index 94b55f9f3..060504beb 100644
--- a/src/NzbDrone.Common.Test/Http/HttpRequestFixture.cs
+++ b/src/NzbDrone.Common.Test/Http/HttpRequestFixture.cs
@@ -6,4 +6,4 @@ namespace NzbDrone.Common.Test.Http
public class HttpRequestFixture
{
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Common.Test/Http/UserAgentBuilderFixture.cs b/src/NzbDrone.Common.Test/Http/UserAgentBuilderFixture.cs
index 6b99793ea..5b764c206 100644
--- a/src/NzbDrone.Common.Test/Http/UserAgentBuilderFixture.cs
+++ b/src/NzbDrone.Common.Test/Http/UserAgentBuilderFixture.cs
@@ -27,4 +27,4 @@ public void should_get_use_os_family_if_name_is_null()
Subject.GetUserAgent(false).Should().NotBeNullOrWhiteSpace();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Common.Test/InstrumentationTests/CleanseLogMessageFixture.cs b/src/NzbDrone.Common.Test/InstrumentationTests/CleanseLogMessageFixture.cs
index 35da0066b..f01a72912 100644
--- a/src/NzbDrone.Common.Test/InstrumentationTests/CleanseLogMessageFixture.cs
+++ b/src/NzbDrone.Common.Test/InstrumentationTests/CleanseLogMessageFixture.cs
@@ -1,6 +1,6 @@
-using NUnit.Framework;
-using NzbDrone.Common.Instrumentation;
using FluentAssertions;
+using NUnit.Framework;
+using NzbDrone.Common.Instrumentation;
namespace NzbDrone.Common.Test.InstrumentationTests
{
@@ -16,9 +16,11 @@ public class CleanseLogMessageFixture
[TestCase(@"https://baconbits.org/feeds.php?feed=torrents_tv&user=12345&auth=2b51db35e1910123321025a12b9933d2&passkey=mySecret&authkey=2b51db35e1910123321025a12b9933d2")]
[TestCase(@"http://127.0.0.1:9117/dl/indexername?jackett_apikey=flwjiefewklfjacketmySecretsdfldskjfsdlk&path=we0re9f0sdfbase64sfdkfjsdlfjk&file=The+Torrent+File+Name.torrent")]
[TestCase(@"http://nzb.su/getnzb/2b51db35e1912ffc138825a12b9933d2.nzb&i=37292&r=2b51db35e1910123321025a12b9933d2")]
+
// NzbGet
[TestCase(@"{ ""Name"" : ""ControlUsername"", ""Value"" : ""mySecret"" }, { ""Name"" : ""ControlPassword"", ""Value"" : ""mySecret"" }, ")]
[TestCase(@"{ ""Name"" : ""Server1.Username"", ""Value"" : ""mySecret"" }, { ""Name"" : ""Server1.Password"", ""Value"" : ""mySecret"" }, ")]
+
// Sabnzbd
[TestCase(@"http://127.0.0.1:1234/api/call?vv=1&apikey=mySecret")]
[TestCase(@"http://127.0.0.1:1234/api/call?vv=1&ma_username=mySecret&ma_password=mySecret")]
@@ -29,6 +31,7 @@ public class CleanseLogMessageFixture
[TestCase(@"""misc"":{""username"":""mySecret"",""api_key"":""mySecret"",""password"":""mySecret"",""nzb_key"":""mySecret""}")]
[TestCase(@"""servers"":[{""username"":""mySecret"",""password"":""mySecret""}]")]
[TestCase(@"""misc"":{""email_account"":""mySecret"",""email_to"":[],""email_from"":"""",""email_pwd"":""mySecret""}")]
+
// uTorrent
[TestCase(@"http://localhost:9091/gui/?token=wThmph5l0ZXfH-a6WOA4lqiLvyjCP0FpMrMeXmySecret_VXBO11HoKL751MAAAAA&list=1")]
[TestCase(@",[""boss_key"",0,""mySecret"",{""access"":""Y""}],[""boss_key_salt"",0,""mySecret"",{""access"":""W""}]")]
@@ -36,22 +39,28 @@ public class CleanseLogMessageFixture
[TestCase(@",[""webui.uconnect_username"",2,""mySecret"",{""access"":""Y""}],[""webui.uconnect_password"",2,""mySecret"",{""access"":""Y""}]")]
[TestCase(@",[""proxy.proxy"",2,""mySecret"",{""access"":""Y""}]")]
[TestCase(@",[""proxy.username"",2,""mySecret"",{""access"":""Y""}],[""proxy.password"",2,""mySecret"",{""access"":""Y""}]")]
+
// Deluge
[TestCase(@",{""download_location"": ""C:\Users\\mySecret mySecret\\Downloads""}")]
[TestCase(@",{""download_location"": ""/home/mySecret/Downloads""}")]
[TestCase(@"auth.login(""mySecret"")")]
+
// Download Station
[TestCase(@"webapi/entry.cgi?api=(removed)&version=2&method=login&account=01233210&passwd=mySecret&format=sid&session=DownloadStation")]
+
// BroadcastheNet
[TestCase(@"method: ""getTorrents"", ""params"": [ ""mySecret"",")]
[TestCase(@"getTorrents(""mySecret"", [asdfasdf], 100, 0)")]
[TestCase(@"""DownloadURL"":""https:\/\/broadcasthe.net\/torrents.php?action=download&id=123&authkey=mySecret&torrent_pass=mySecret""")]
+
// Plex
[TestCase(@" http://localhost:32400/library/metadata/12345/refresh?X-Plex-Client-Identifier=1234530f-422f-4aac-b6b3-01233210aaaa&X-Plex-Product=Sonarr&X-Plex-Platform=Windows&X-Plex-Platform-Version=7&X-Plex-Device-Name=Sonarr&X-Plex-Version=3.0.3.833&X-Plex-Token=mySecret")]
+
// Internal
[TestCase(@"OutputPath=/home/mySecret/Downloads")]
[TestCase("Hardlinking episode file: /home/mySecret/Downloads to /media/abc.mkv")]
[TestCase("Hardlink '/home/mySecret/Downloads/abs.mkv' to '/media/abc.mkv' failed.")]
+
// Announce URLs (passkeys) Magnet & Tracker
[TestCase(@"magnet_uri"":""magnet:?xt=urn:btih:9pr04sgkillroyimaveql2tyu8xyui&dn=&tr=https%3a%2f%2fxxx.yyy%2f9pr04sg601233210imaveql2tyu8xyui%2fannounce""}")]
[TestCase(@"magnet_uri"":""magnet:?xt=urn:btih:9pr04sgkillroyimaveql2tyu8xyui&dn=&tr=https%3a%2f%2fxxx.yyy%2ftracker.php%2f9pr04sg601233210imaveql2tyu8xyui%2fannounce""}")]
@@ -62,6 +71,7 @@ public class CleanseLogMessageFixture
[TestCase(@"tracker"":""https://xxx.yyy/announce/9pr04sg601233210imaveql2tyu8xyui""}")]
[TestCase(@"tracker"":""https://xxx.yyy/announce.php?passkey=9pr04sg601233210imaveql2tyu8xyui""}")]
[TestCase(@"tracker"":""http://xxx.yyy/announce.php?passkey=9pr04sg601233210imaveql2tyu8xyui"",""info"":""http://xxx.yyy/info?a=b""")]
+
// Webhooks - Notifiarr
[TestCase(@"https://xxx.yyy/api/v1/notification/sonarr/9pr04sg6-0123-3210-imav-eql2tyu8xyui")]
diff --git a/src/NzbDrone.Common.Test/InstrumentationTests/SentryTargetFixture.cs b/src/NzbDrone.Common.Test/InstrumentationTests/SentryTargetFixture.cs
index 70c701b74..75c6f0b52 100644
--- a/src/NzbDrone.Common.Test/InstrumentationTests/SentryTargetFixture.cs
+++ b/src/NzbDrone.Common.Test/InstrumentationTests/SentryTargetFixture.cs
@@ -1,24 +1,25 @@
-using NUnit.Framework;
-using FluentAssertions;
-using NzbDrone.Common.Instrumentation.Sentry;
using System;
-using NLog;
-using NzbDrone.Test.Common;
using System.Globalization;
using System.Linq;
+using FluentAssertions;
+using NLog;
+using NUnit.Framework;
+using NzbDrone.Common.Instrumentation.Sentry;
+using NzbDrone.Test.Common;
namespace NzbDrone.Common.Test.InstrumentationTests
{
[TestFixture]
public class SentryTargetFixture : TestBase
{
- private SentryTarget Subject;
+ private SentryTarget _subject;
private static LogLevel[] AllLevels = LogLevel.AllLevels.ToArray();
private static LogLevel[] SentryLevels = LogLevel.AllLevels.Where(x => x >= LogLevel.Error).ToArray();
private static LogLevel[] OtherLevels = AllLevels.Except(SentryLevels).ToArray();
- private static Exception[] FilteredExceptions = new Exception[] {
+ private static Exception[] FilteredExceptions = new Exception[]
+ {
new UnauthorizedAccessException(),
new TinyIoC.TinyIoCResolutionException(typeof(string))
};
@@ -26,7 +27,7 @@ public class SentryTargetFixture : TestBase
[SetUp]
public void Setup()
{
- Subject = new SentryTarget("https://aaaaaaaaaaaaaaaaaaaaaaaaaa@sentry.io/111111");
+ _subject = new SentryTarget("https://aaaaaaaaaaaaaaaaaaaaaaaaaa@sentry.io/111111");
}
private LogEventInfo GivenLogEvent(LogLevel level, Exception ex, string message)
@@ -34,44 +35,50 @@ private LogEventInfo GivenLogEvent(LogLevel level, Exception ex, string message)
return LogEventInfo.Create(level, "SentryTest", ex, CultureInfo.InvariantCulture, message);
}
- [Test, TestCaseSource("AllLevels")]
+ [Test]
+ [TestCaseSource("AllLevels")]
public void log_without_error_is_not_sentry_event(LogLevel level)
{
- Subject.IsSentryMessage(GivenLogEvent(level, null, "test")).Should().BeFalse();
+ _subject.IsSentryMessage(GivenLogEvent(level, null, "test")).Should().BeFalse();
}
- [Test, TestCaseSource("SentryLevels")]
+ [Test]
+ [TestCaseSource("SentryLevels")]
public void error_or_worse_with_exception_is_sentry_event(LogLevel level)
{
- Subject.IsSentryMessage(GivenLogEvent(level, new Exception(), "test")).Should().BeTrue();
+ _subject.IsSentryMessage(GivenLogEvent(level, new Exception(), "test")).Should().BeTrue();
}
- [Test, TestCaseSource("OtherLevels")]
+ [Test]
+ [TestCaseSource("OtherLevels")]
public void less_than_error_with_exception_is_not_sentry_event(LogLevel level)
{
- Subject.IsSentryMessage(GivenLogEvent(level, new Exception(), "test")).Should().BeFalse();
+ _subject.IsSentryMessage(GivenLogEvent(level, new Exception(), "test")).Should().BeFalse();
}
- [Test, TestCaseSource("FilteredExceptions")]
+ [Test]
+ [TestCaseSource("FilteredExceptions")]
public void should_filter_event_for_filtered_exception_types(Exception ex)
{
var log = GivenLogEvent(LogLevel.Error, ex, "test");
- Subject.IsSentryMessage(log).Should().BeFalse();
+ _subject.IsSentryMessage(log).Should().BeFalse();
}
- [Test, TestCaseSource("FilteredExceptions")]
+ [Test]
+ [TestCaseSource("FilteredExceptions")]
public void should_not_filter_event_for_filtered_exception_types_if_filtering_disabled(Exception ex)
{
- Subject.FilterEvents = false;
+ _subject.FilterEvents = false;
var log = GivenLogEvent(LogLevel.Error, ex, "test");
- Subject.IsSentryMessage(log).Should().BeTrue();
+ _subject.IsSentryMessage(log).Should().BeTrue();
}
- [Test, TestCaseSource(typeof(SentryTarget), "FilteredExceptionMessages")]
+ [Test]
+ [TestCaseSource(typeof(SentryTarget), "FilteredExceptionMessages")]
public void should_filter_event_for_filtered_exception_messages(string message)
{
var log = GivenLogEvent(LogLevel.Error, new Exception("aaaaaaa" + message + "bbbbbbb"), "test");
- Subject.IsSentryMessage(log).Should().BeFalse();
+ _subject.IsSentryMessage(log).Should().BeFalse();
}
[TestCase("A message that isn't filtered")]
@@ -79,7 +86,7 @@ public void should_filter_event_for_filtered_exception_messages(string message)
public void should_not_filter_event_for_exception_messages_that_are_not_filtered(string message)
{
var log = GivenLogEvent(LogLevel.Error, new Exception(message), "test");
- Subject.IsSentryMessage(log).Should().BeTrue();
+ _subject.IsSentryMessage(log).Should().BeTrue();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Common.Test/OsPathFixture.cs b/src/NzbDrone.Common.Test/OsPathFixture.cs
index 992ea11fd..c31abefc7 100644
--- a/src/NzbDrone.Common.Test/OsPathFixture.cs
+++ b/src/NzbDrone.Common.Test/OsPathFixture.cs
@@ -1,7 +1,7 @@
-using NUnit.Framework;
+using FluentAssertions;
+using NUnit.Framework;
using NzbDrone.Common.Disk;
using NzbDrone.Test.Common;
-using FluentAssertions;
namespace NzbDrone.Common.Test
{
diff --git a/src/NzbDrone.Common.Test/PathExtensionFixture.cs b/src/NzbDrone.Common.Test/PathExtensionFixture.cs
index f86bceac3..2744271fc 100644
--- a/src/NzbDrone.Common.Test/PathExtensionFixture.cs
+++ b/src/NzbDrone.Common.Test/PathExtensionFixture.cs
@@ -110,6 +110,7 @@ public void should_return_true_when_folder_is_parent_of_a_file()
_parent.IsParentPath(path).Should().BeTrue();
}
+
[TestCase(@"C:\Test\", @"C:\Test\mydir")]
[TestCase(@"C:\Test\", @"C:\Test\mydir\")]
[TestCase(@"C:\Test", @"C:\Test\30.Rock.S01E01.Pilot.avi")]
@@ -198,10 +199,9 @@ public void normalize_path_exception_null()
public void get_actual_casing_for_none_existing_file_return_partially_fixed_result()
{
WindowsOnly();
- "C:\\WINDOWS\\invalidfile.exe".GetActualCasing().Should().Be("C:\\Windows\\invalidfile.exe");
+ "C:\\WINDOWS\\invalidfile.exe".GetActualCasing().Should().Be("C:\\Windows\\invalidfile.exe");
}
-
[Test]
public void get_actual_casing_for_none_existing_folder_return_partially_fixed_result()
{
@@ -218,7 +218,6 @@ public void get_actual_casing_should_return_actual_casing_for_local_file_in_wind
path.ToLower().GetActualCasing().Should().Be(path);
}
-
[Test]
public void get_actual_casing_should_return_actual_casing_for_local_dir_in_windows()
{
diff --git a/src/NzbDrone.Common.Test/ProcessProviderFixture.cs b/src/NzbDrone.Common.Test/ProcessProviderFixture.cs
index 796f63382..dbf5d8a59 100644
--- a/src/NzbDrone.Common.Test/ProcessProviderFixture.cs
+++ b/src/NzbDrone.Common.Test/ProcessProviderFixture.cs
@@ -18,7 +18,6 @@ namespace NzbDrone.Common.Test
[TestFixture]
public class ProcessProviderFixture : TestBase
{
-
[SetUp]
public void Setup()
{
@@ -44,7 +43,6 @@ public void TearDown()
{
TestLogger.Warn(ex, "{0} when killing process", ex.Message);
}
-
});
}
@@ -134,7 +132,6 @@ public void Should_be_able_to_start_python()
}
}
-
[Test]
[Platform(Exclude = "MacOsX")]
[Retry(3)]
diff --git a/src/NzbDrone.Common.Test/ServiceFactoryFixture.cs b/src/NzbDrone.Common.Test/ServiceFactoryFixture.cs
index 1c9dbe102..9dfdde396 100644
--- a/src/NzbDrone.Common.Test/ServiceFactoryFixture.cs
+++ b/src/NzbDrone.Common.Test/ServiceFactoryFixture.cs
@@ -29,4 +29,4 @@ public void event_handlers_should_be_unique()
handlers.Should().OnlyHaveUniqueItems();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Common.Test/ServiceProviderFixture.cs b/src/NzbDrone.Common.Test/ServiceProviderFixture.cs
index 93ee3d703..fd48c49ce 100644
--- a/src/NzbDrone.Common.Test/ServiceProviderFixture.cs
+++ b/src/NzbDrone.Common.Test/ServiceProviderFixture.cs
@@ -36,7 +36,6 @@ public void TearDown()
}
}
-
private void CleanupService()
{
if (Subject.ServiceExist(TEMP_SERVICE_NAME))
@@ -62,7 +61,6 @@ public void Exists_should_not_find_random_service()
Subject.ServiceExist("random_service_name").Should().BeFalse();
}
-
[Test]
public void Service_should_be_installed_and_then_uninstalled()
{
@@ -123,7 +121,6 @@ public void should_throw_if_starting_a_running_service()
Subject.Start(ALWAYS_INSTALLED_SERVICE);
Assert.Throws(() => Subject.Start(ALWAYS_INSTALLED_SERVICE));
-
ExceptionVerification.ExpectedWarns(1);
}
@@ -133,15 +130,14 @@ public void Should_log_warn_if_on_stop_if_service_is_already_stopped()
Subject.GetService(ALWAYS_INSTALLED_SERVICE).Status
.Should().NotBe(ServiceControllerStatus.Running);
-
Subject.Stop(ALWAYS_INSTALLED_SERVICE);
-
Subject.GetService(ALWAYS_INSTALLED_SERVICE).Status
.Should().Be(ServiceControllerStatus.Stopped);
ExceptionVerification.ExpectedWarns(1);
}
+
private static bool IsAnAdministrator()
{
var principal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
diff --git a/src/NzbDrone.Common.Test/TPLTests/DebouncerFixture.cs b/src/NzbDrone.Common.Test/TPLTests/DebouncerFixture.cs
index 29e7bb7ec..c8844b2f3 100644
--- a/src/NzbDrone.Common.Test/TPLTests/DebouncerFixture.cs
+++ b/src/NzbDrone.Common.Test/TPLTests/DebouncerFixture.cs
@@ -19,7 +19,6 @@ public void Hit()
}
}
-
[Test]
[Retry(3)]
public void should_hold_the_call_for_debounce_duration()
@@ -33,11 +32,9 @@ public void should_hold_the_call_for_debounce_duration()
counter.Count.Should().Be(0);
-
Thread.Sleep(100);
counter.Count.Should().Be(1);
-
}
[Test]
@@ -53,7 +50,6 @@ public void should_throttle_calls()
counter.Count.Should().Be(0);
-
Thread.Sleep(200);
debounceFunction.Execute();
@@ -63,7 +59,6 @@ public void should_throttle_calls()
Thread.Sleep(200);
counter.Count.Should().Be(2);
-
}
[Test]
@@ -126,4 +121,4 @@ public void should_handle_pause_reentrancy()
counter.Count.Should().Be(1);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Common.Test/TPLTests/RateLimitServiceFixture.cs b/src/NzbDrone.Common.Test/TPLTests/RateLimitServiceFixture.cs
index b2ff87a06..a92eed1f1 100644
--- a/src/NzbDrone.Common.Test/TPLTests/RateLimitServiceFixture.cs
+++ b/src/NzbDrone.Common.Test/TPLTests/RateLimitServiceFixture.cs
@@ -1,11 +1,11 @@
using System;
using System.Collections.Concurrent;
using System.Diagnostics;
+using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Common.Cache;
using NzbDrone.Common.TPL;
using NzbDrone.Test.Common;
-using FluentAssertions;
namespace NzbDrone.Common.Test.TPLTests
{
diff --git a/src/NzbDrone.Common/ArchiveService.cs b/src/NzbDrone.Common/ArchiveService.cs
index 1871bd8ad..39745eb3b 100644
--- a/src/NzbDrone.Common/ArchiveService.cs
+++ b/src/NzbDrone.Common/ArchiveService.cs
@@ -73,7 +73,9 @@ private void ExtractZip(string compressedFile, string destination)
{
continue; // Ignore directories
}
+
string entryFileName = zipEntry.Name;
+
// to remove the folder from the entry:- entryFileName = Path.GetFileName(entryFileName);
// Optionally match entrynames against a selection list here to skip as desired.
// The unpacked length is available in the zipEntry.Size property.
diff --git a/src/NzbDrone.Common/Cache/CacheManager.cs b/src/NzbDrone.Common/Cache/CacheManager.cs
index 7b7f0d3e0..7d6bb128f 100644
--- a/src/NzbDrone.Common/Cache/CacheManager.cs
+++ b/src/NzbDrone.Common/Cache/CacheManager.cs
@@ -21,7 +21,6 @@ public class CacheManager : ICacheManager
public CacheManager()
{
_cache = new Cached();
-
}
public void Clear()
@@ -61,4 +60,4 @@ public ICachedDictionary GetCacheDictionary(Type host, string name, Func)_cache.Get("dict_" + host.FullName + "_" + name, () => new CachedDictionary(fetchFunc, lifeTime));
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Common/Cache/Cached.cs b/src/NzbDrone.Common/Cache/Cached.cs
index db7f8d5a3..b0dfc3eb2 100644
--- a/src/NzbDrone.Common/Cache/Cached.cs
+++ b/src/NzbDrone.Common/Cache/Cached.cs
@@ -7,7 +7,6 @@
namespace NzbDrone.Common.Cache
{
-
public class Cached : ICached
{
private class CacheItem
@@ -144,6 +143,5 @@ private bool TryRemove(string key, CacheItem value)
return collection.Remove(new KeyValuePair(key, value));
}
-
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Common/Cache/CachedDictionary.cs b/src/NzbDrone.Common/Cache/CachedDictionary.cs
index 7bbda022a..3d860f831 100644
--- a/src/NzbDrone.Common/Cache/CachedDictionary.cs
+++ b/src/NzbDrone.Common/Cache/CachedDictionary.cs
@@ -5,7 +5,6 @@
namespace NzbDrone.Common.Cache
{
-
public class CachedDictionary : ICachedDictionary
{
private readonly Func> _fetchFunc;
diff --git a/src/NzbDrone.Common/Cache/ICached.cs b/src/NzbDrone.Common/Cache/ICached.cs
index 179491a4f..e64b1637c 100644
--- a/src/NzbDrone.Common/Cache/ICached.cs
+++ b/src/NzbDrone.Common/Cache/ICached.cs
@@ -19,4 +19,4 @@ public interface ICached : ICached
ICollection Values { get; }
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Common/Composition/Container.cs b/src/NzbDrone.Common/Composition/Container.cs
index 3b9b2c8fe..6ae1e4bfa 100644
--- a/src/NzbDrone.Common/Composition/Container.cs
+++ b/src/NzbDrone.Common/Composition/Container.cs
@@ -24,12 +24,14 @@ public void Register()
_container.Register();
}
- public void Register(T instance) where T : class
+ public void Register(T instance)
+ where T : class
{
_container.Register(instance);
}
- public T Resolve() where T : class
+ public T Resolve()
+ where T : class
{
return _container.Resolve();
}
@@ -44,7 +46,8 @@ public void Register(Type serviceType, Type implementationType)
_container.Register(serviceType, implementationType);
}
- public void Register(Func factory) where TService : class
+ public void Register(Func factory)
+ where TService : class
{
_container.Register((c, n) => factory(this));
}
@@ -67,7 +70,8 @@ public void RegisterSingleton(Type service, Type implementation)
});
}
- public IEnumerable ResolveAll() where T : class
+ public IEnumerable ResolveAll()
+ where T : class
{
return _container.ResolveAll();
}
@@ -103,8 +107,7 @@ public IEnumerable GetImplementations(Type contractType)
.Where(implementation =>
contractType.IsAssignableFrom(implementation) &&
!implementation.IsInterface &&
- !implementation.IsAbstract
- );
+ !implementation.IsAbstract);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Common/Composition/ContainerBuilderBase.cs b/src/NzbDrone.Common/Composition/ContainerBuilderBase.cs
index 009b356ef..c3ce47940 100644
--- a/src/NzbDrone.Common/Composition/ContainerBuilderBase.cs
+++ b/src/NzbDrone.Common/Composition/ContainerBuilderBase.cs
@@ -121,6 +121,7 @@ private void AutoRegisterImplementations(Type contractType)
{
return;
}
+
if (implementations.Count == 1)
{
var impl = implementations.Single();
diff --git a/src/NzbDrone.Common/Composition/IContainer.cs b/src/NzbDrone.Common/Composition/IContainer.cs
index 87d076842..9e7402017 100644
--- a/src/NzbDrone.Common/Composition/IContainer.cs
+++ b/src/NzbDrone.Common/Composition/IContainer.cs
@@ -5,20 +5,24 @@ namespace NzbDrone.Common.Composition
{
public interface IContainer
{
- void Register(T instance) where T : class;
+ void Register(T instance)
+ where T : class;
void Register()
where TImplementation : class, TService
where TService : class;
- T Resolve() where T : class;
+ T Resolve()
+ where T : class;
object Resolve(Type type);
void Register(Type serviceType, Type implementationType);
- void Register(Func factory) where TService : class;
+ void Register(Func factory)
+ where TService : class;
void RegisterSingleton(Type service, Type implementation);
- IEnumerable ResolveAll() where T : class;
+ IEnumerable ResolveAll()
+ where T : class;
void RegisterAllAsSingleton(Type registrationType, IEnumerable implementationList);
bool IsTypeRegistered(Type type);
IEnumerable GetImplementations(Type contractType);
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Common/Crypto/HashProvider.cs b/src/NzbDrone.Common/Crypto/HashProvider.cs
index 04868cb8c..10a09f359 100644
--- a/src/NzbDrone.Common/Crypto/HashProvider.cs
+++ b/src/NzbDrone.Common/Crypto/HashProvider.cs
@@ -28,4 +28,4 @@ public byte[] ComputeMd5(string path)
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Common/Disk/DestinationAlreadyExistsException.cs b/src/NzbDrone.Common/Disk/DestinationAlreadyExistsException.cs
index 986413742..ffdc36e0e 100644
--- a/src/NzbDrone.Common/Disk/DestinationAlreadyExistsException.cs
+++ b/src/NzbDrone.Common/Disk/DestinationAlreadyExistsException.cs
@@ -10,19 +10,23 @@ public DestinationAlreadyExistsException()
{
}
- public DestinationAlreadyExistsException(string message) : base(message)
+ public DestinationAlreadyExistsException(string message)
+ : base(message)
{
}
- public DestinationAlreadyExistsException(string message, int hresult) : base(message, hresult)
+ public DestinationAlreadyExistsException(string message, int hresult)
+ : base(message, hresult)
{
}
- public DestinationAlreadyExistsException(string message, Exception innerException) : base(message, innerException)
+ public DestinationAlreadyExistsException(string message, Exception innerException)
+ : base(message, innerException)
{
}
- protected DestinationAlreadyExistsException(SerializationInfo info, StreamingContext context) : base(info, context)
+ protected DestinationAlreadyExistsException(SerializationInfo info, StreamingContext context)
+ : base(info, context)
{
}
}
diff --git a/src/NzbDrone.Common/Disk/DiskProviderBase.cs b/src/NzbDrone.Common/Disk/DiskProviderBase.cs
index e2dd26586..23f35981d 100644
--- a/src/NzbDrone.Common/Disk/DiskProviderBase.cs
+++ b/src/NzbDrone.Common/Disk/DiskProviderBase.cs
@@ -117,6 +117,7 @@ public bool FileExists(string path, StringComparison stringComparison)
{
return File.Exists(path) && path == path.GetActualCasing();
}
+
default:
{
return File.Exists(path);
@@ -367,7 +368,7 @@ private static void RemoveReadOnly(string path)
if (attributes.HasFlag(FileAttributes.ReadOnly))
{
- var newAttributes = attributes & ~(FileAttributes.ReadOnly);
+ var newAttributes = attributes & ~FileAttributes.ReadOnly;
File.SetAttributes(path, newAttributes);
}
}
diff --git a/src/NzbDrone.Common/Disk/DiskTransferService.cs b/src/NzbDrone.Common/Disk/DiskTransferService.cs
index 42e672e8a..44d28a9df 100644
--- a/src/NzbDrone.Common/Disk/DiskTransferService.cs
+++ b/src/NzbDrone.Common/Disk/DiskTransferService.cs
@@ -14,7 +14,7 @@ public interface IDiskTransferService
TransferMode TransferFile(string sourcePath, string targetPath, TransferMode mode, bool overwrite = false);
int MirrorFolder(string sourcePath, string targetPath);
}
-
+
public class DiskTransferService : IDiskTransferService
{
private readonly IDiskProvider _diskProvider;
@@ -40,7 +40,7 @@ private string ResolveRealParentPath(string path)
return realParentPath + partialChildPath;
}
-
+
public TransferMode TransferFolder(string sourcePath, string targetPath, TransferMode mode)
{
Ensure.That(sourcePath, () => sourcePath).IsValidPath();
@@ -101,14 +101,20 @@ public TransferMode TransferFolder(string sourcePath, string targetPath, Transfe
foreach (var subDir in _diskProvider.GetDirectoryInfos(sourcePath))
{
- if (ShouldIgnore(subDir)) continue;
+ if (ShouldIgnore(subDir))
+ {
+ continue;
+ }
result &= TransferFolder(subDir.FullName, Path.Combine(targetPath, subDir.Name), mode);
}
foreach (var sourceFile in _diskProvider.GetFileInfos(sourcePath))
{
- if (ShouldIgnore(sourceFile)) continue;
+ if (ShouldIgnore(sourceFile))
+ {
+ continue;
+ }
var destFile = Path.Combine(targetPath, sourceFile.Name);
@@ -152,14 +158,20 @@ public int MirrorFolder(string sourcePath, string targetPath)
foreach (var subDir in targetFolders.Where(v => !sourceFolders.Any(d => d.Name == v.Name)))
{
- if (ShouldIgnore(subDir)) continue;
+ if (ShouldIgnore(subDir))
+ {
+ continue;
+ }
_diskProvider.DeleteFolder(subDir.FullName, true);
}
foreach (var subDir in sourceFolders)
{
- if (ShouldIgnore(subDir)) continue;
+ if (ShouldIgnore(subDir))
+ {
+ continue;
+ }
filesCopied += MirrorFolder(subDir.FullName, Path.Combine(targetPath, subDir.Name));
}
@@ -169,14 +181,20 @@ public int MirrorFolder(string sourcePath, string targetPath)
foreach (var targetFile in targetFiles.Where(v => !sourceFiles.Any(d => d.Name == v.Name)))
{
- if (ShouldIgnore(targetFile)) continue;
+ if (ShouldIgnore(targetFile))
+ {
+ continue;
+ }
_diskProvider.DeleteFile(targetFile.FullName);
}
foreach (var sourceFile in sourceFiles)
{
- if (ShouldIgnore(sourceFile)) continue;
+ if (ShouldIgnore(sourceFile))
+ {
+ continue;
+ }
var targetFile = Path.Combine(targetPath, sourceFile.Name);
@@ -305,6 +323,7 @@ public TransferMode TransferFile(string sourcePath, string targetPath, TransferM
{
return TransferMode.HardLink;
}
+
if (!mode.HasFlag(TransferMode.Copy))
{
throw new IOException("Hardlinking from '" + sourcePath + "' to '" + targetPath + "' failed.");
@@ -315,14 +334,14 @@ public TransferMode TransferFile(string sourcePath, string targetPath, TransferM
var sourceMount = _diskProvider.GetMount(sourcePath);
var targetMount = _diskProvider.GetMount(targetPath);
- var isSameMount = (sourceMount != null && targetMount != null && sourceMount.RootDirectory == targetMount.RootDirectory);
+ var isSameMount = sourceMount != null && targetMount != null && sourceMount.RootDirectory == targetMount.RootDirectory;
var sourceDriveFormat = sourceMount?.DriveFormat ?? string.Empty;
var targetDriveFormat = targetMount?.DriveFormat ?? string.Empty;
var isCifs = targetDriveFormat == "cifs";
var isBtrfs = sourceDriveFormat == "btrfs" && targetDriveFormat == "btrfs";
-
+
if (mode.HasFlag(TransferMode.Copy))
{
if (isBtrfs)
@@ -363,7 +382,7 @@ public TransferMode TransferFile(string sourcePath, string targetPath, TransferM
_diskProvider.DeleteFile(sourcePath);
return TransferMode.Move;
}
-
+
TryMoveFileVerified(sourcePath, targetPath, originalSize);
return TransferMode.Move;
}
diff --git a/src/NzbDrone.Common/Disk/FileAlreadyExistsException.cs b/src/NzbDrone.Common/Disk/FileAlreadyExistsException.cs
index 6a987444d..69acb4cd7 100644
--- a/src/NzbDrone.Common/Disk/FileAlreadyExistsException.cs
+++ b/src/NzbDrone.Common/Disk/FileAlreadyExistsException.cs
@@ -6,7 +6,8 @@ public class FileAlreadyExistsException : Exception
{
public string Filename { get; set; }
- public FileAlreadyExistsException(string message, string filename) : base(message)
+ public FileAlreadyExistsException(string message, string filename)
+ : base(message)
{
Filename = filename;
}
diff --git a/src/NzbDrone.Common/Disk/FileSystemLookupService.cs b/src/NzbDrone.Common/Disk/FileSystemLookupService.cs
index 40f7adfb0..63529697e 100644
--- a/src/NzbDrone.Common/Disk/FileSystemLookupService.cs
+++ b/src/NzbDrone.Common/Disk/FileSystemLookupService.cs
@@ -125,7 +125,6 @@ private FileSystemResult GetResult(string path, bool includeFiles)
result.Files = GetFiles(path);
}
}
-
catch (DirectoryNotFoundException)
{
return new FileSystemResult { Parent = GetParent(path) };
diff --git a/src/NzbDrone.Common/Disk/LongPathSupport.cs b/src/NzbDrone.Common/Disk/LongPathSupport.cs
index 7336bb1d6..8d10f78d6 100644
--- a/src/NzbDrone.Common/Disk/LongPathSupport.cs
+++ b/src/NzbDrone.Common/Disk/LongPathSupport.cs
@@ -54,7 +54,11 @@ public static int MaxFilePathLength
{
get
{
- if (MAX_PATH == 0) DetectLongPathLimits();
+ if (MAX_PATH == 0)
+ {
+ DetectLongPathLimits();
+ }
+
return MAX_PATH;
}
}
@@ -63,7 +67,11 @@ public static int MaxFileNameLength
{
get
{
- if (MAX_NAME == 0) DetectLongPathLimits();
+ if (MAX_NAME == 0)
+ {
+ DetectLongPathLimits();
+ }
+
return MAX_NAME;
}
}
diff --git a/src/NzbDrone.Common/Disk/NotParentException.cs b/src/NzbDrone.Common/Disk/NotParentException.cs
index 0ae384722..4859c29be 100644
--- a/src/NzbDrone.Common/Disk/NotParentException.cs
+++ b/src/NzbDrone.Common/Disk/NotParentException.cs
@@ -4,11 +4,13 @@ namespace NzbDrone.Common.Disk
{
public class NotParentException : NzbDroneException
{
- public NotParentException(string message, params object[] args) : base(message, args)
+ public NotParentException(string message, params object[] args)
+ : base(message, args)
{
}
- public NotParentException(string message) : base(message)
+ public NotParentException(string message)
+ : base(message)
{
}
}
diff --git a/src/NzbDrone.Common/Disk/OsPath.cs b/src/NzbDrone.Common/Disk/OsPath.cs
index 9028ec1f7..c4327ddeb 100644
--- a/src/NzbDrone.Common/Disk/OsPath.cs
+++ b/src/NzbDrone.Common/Disk/OsPath.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Common.Extensions;
@@ -44,22 +44,36 @@ private static OsPathKind DetectPathKind(string path)
{
return OsPathKind.Unix;
}
+
if (HasWindowsDriveLetter(path) || path.Contains('\\'))
{
return OsPathKind.Windows;
}
+
if (path.Contains('/'))
{
return OsPathKind.Unix;
}
+
return OsPathKind.Unknown;
}
private static bool HasWindowsDriveLetter(string path)
{
- if (path.Length < 2) return false;
- if (!char.IsLetter(path[0]) || path[1] != ':') return false;
- if (path.Length > 2 && path[2] != '\\' && path[2] != '/') return false;
+ if (path.Length < 2)
+ {
+ return false;
+ }
+
+ if (!char.IsLetter(path[0]) || path[1] != ':')
+ {
+ return false;
+ }
+
+ if (path.Length > 2 && path[2] != '\\' && path[2] != '/')
+ {
+ return false;
+ }
return true;
}
@@ -76,6 +90,7 @@ private static string FixSlashes(string path, OsPathKind kind)
{
path = path.Replace("//", "/");
}
+
return path;
}
@@ -98,11 +113,12 @@ public bool IsRooted
{
return _path.StartsWith(@"\\") || HasWindowsDriveLetter(_path);
}
+
if (IsUnixPath)
{
return _path.StartsWith("/");
}
-
+
return false;
}
}
@@ -117,7 +133,7 @@ public OsPath Directory
{
return new OsPath(null);
}
-
+
return new OsPath(_path.Substring(0, index), _kind).AsDirectory();
}
}
@@ -141,7 +157,7 @@ public string FileName
return path;
}
-
+
return _path.Substring(index).Trim('\\', '/');
}
}
@@ -196,10 +212,12 @@ public override bool Equals(object obj)
{
return Equals((OsPath)obj);
}
+
if (obj is string)
{
return Equals(new OsPath(obj as string));
}
+
return false;
}
@@ -217,6 +235,7 @@ public OsPath AsDirectory()
case OsPathKind.Unix:
return new OsPath(_path.TrimEnd('/') + "/", _kind);
}
+
return this;
}
@@ -250,7 +269,10 @@ public bool Contains(OsPath other)
public bool Equals(OsPath other)
{
- if (ReferenceEquals(other, null)) return false;
+ if (ReferenceEquals(other, null))
+ {
+ return false;
+ }
if (_path == other._path)
{
@@ -264,19 +286,26 @@ public bool Equals(OsPath other)
{
return string.Equals(left, right, StringComparison.InvariantCultureIgnoreCase);
}
+
return string.Equals(left, right, StringComparison.InvariantCulture);
}
public static bool operator ==(OsPath left, OsPath right)
{
- if (ReferenceEquals(left, null)) return ReferenceEquals(right, null);
+ if (ReferenceEquals(left, null))
+ {
+ return ReferenceEquals(right, null);
+ }
return left.Equals(right);
}
public static bool operator !=(OsPath left, OsPath right)
{
- if (ReferenceEquals(left, null)) return !ReferenceEquals(right, null);
+ if (ReferenceEquals(left, null))
+ {
+ return !ReferenceEquals(right, null);
+ }
return !left.Equals(right);
}
@@ -302,10 +331,12 @@ public bool Equals(OsPath other)
{
return new OsPath(string.Join("\\", left._path.TrimEnd('\\'), right._path.TrimStart('\\')), OsPathKind.Windows);
}
+
if (left.Kind == OsPathKind.Unix || right.Kind == OsPathKind.Unix)
{
return new OsPath(string.Join("/", left._path.TrimEnd('/'), right._path), OsPathKind.Unix);
}
+
return new OsPath(string.Join("/", left._path, right._path), OsPathKind.Unknown);
}
@@ -361,6 +392,7 @@ public bool Equals(OsPath other)
{
return new OsPath(string.Join("\\", newFragments), OsPathKind.Unknown);
}
+
return new OsPath(string.Join("/", newFragments), OsPathKind.Unknown);
}
}
diff --git a/src/NzbDrone.Common/EnsureThat/Ensure.cs b/src/NzbDrone.Common/EnsureThat/Ensure.cs
index d918d0e66..cb63dd14c 100644
--- a/src/NzbDrone.Common/EnsureThat/Ensure.cs
+++ b/src/NzbDrone.Common/EnsureThat/Ensure.cs
@@ -20,4 +20,4 @@ public static TypeParam ThatTypeFor(T value, string name = Param.DefaultName)
return new TypeParam(name, value.GetType());
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Common/EnsureThat/EnsureBoolExtensions.cs b/src/NzbDrone.Common/EnsureThat/EnsureBoolExtensions.cs
index de18bb06c..a393d556c 100644
--- a/src/NzbDrone.Common/EnsureThat/EnsureBoolExtensions.cs
+++ b/src/NzbDrone.Common/EnsureThat/EnsureBoolExtensions.cs
@@ -9,7 +9,9 @@ public static class EnsureBoolExtensions
public static Param IsTrue(this Param param)
{
if (!param.Value)
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotTrue);
+ }
return param;
}
@@ -18,9 +20,11 @@ public static Param IsTrue(this Param param)
public static Param IsFalse(this Param param)
{
if (param.Value)
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotFalse);
+ }
return param;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Common/EnsureThat/EnsureCollectionExtensions.cs b/src/NzbDrone.Common/EnsureThat/EnsureCollectionExtensions.cs
index 34565f8a0..cf0392487 100644
--- a/src/NzbDrone.Common/EnsureThat/EnsureCollectionExtensions.cs
+++ b/src/NzbDrone.Common/EnsureThat/EnsureCollectionExtensions.cs
@@ -10,10 +10,13 @@ namespace NzbDrone.Common.EnsureThat
public static class EnsureCollectionExtensions
{
[DebuggerStepThrough]
- public static Param HasItems(this Param param) where T : class, ICollection
+ public static Param HasItems(this Param param)
+ where T : class, ICollection
{
if (param.Value == null || param.Value.Count < 1)
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsEmptyCollection);
+ }
return param;
}
@@ -22,7 +25,9 @@ public static Param HasItems(this Param param) where T : class, ICollec
public static Param> HasItems(this Param> param)
{
if (param.Value == null || param.Value.Count < 1)
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsEmptyCollection);
+ }
return param;
}
@@ -31,7 +36,9 @@ public static Param> HasItems(this Param> param)
public static Param> HasItems(this Param> param)
{
if (param.Value == null || !param.Value.Any())
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsEmptyCollection);
+ }
return param;
}
@@ -40,7 +47,9 @@ public static Param> HasItems(this Param> param
public static Param HasItems(this Param param)
{
if (param.Value == null || param.Value.Length < 1)
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsEmptyCollection);
+ }
return param;
}
@@ -49,19 +58,22 @@ public static Param HasItems(this Param param)
public static Param> HasItems(this Param> param)
{
if (param.Value == null || param.Value.Count < 1)
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsEmptyCollection);
+ }
return param;
}
-
[DebuggerStepThrough]
public static Param> HasItems(this Param> param)
{
if (param.Value == null || param.Value.Count < 1)
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsEmptyCollection);
+ }
return param;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Common/EnsureThat/EnsureDateTimeExtensions.cs b/src/NzbDrone.Common/EnsureThat/EnsureDateTimeExtensions.cs
index 8586c4ddf..97d9f58ee 100644
--- a/src/NzbDrone.Common/EnsureThat/EnsureDateTimeExtensions.cs
+++ b/src/NzbDrone.Common/EnsureThat/EnsureDateTimeExtensions.cs
@@ -7,14 +7,15 @@ namespace NzbDrone.Common.EnsureThat
{
public static class EnsureDateTimeExtensions
{
-
private static readonly DateTime _minTime = new DateTime(1960, 1, 1);
[DebuggerStepThrough]
public static Param IsLt(this Param param, DateTime limit)
{
if (param.Value >= limit)
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotLt.Inject(param.Value, limit));
+ }
return param;
}
@@ -23,7 +24,9 @@ public static Param IsLt(this Param param, DateTime limit)
public static Param IsLte(this Param param, DateTime limit)
{
if (!(param.Value <= limit))
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotLte.Inject(param.Value, limit));
+ }
return param;
}
@@ -32,7 +35,9 @@ public static Param IsLte(this Param param, DateTime limit)
public static Param IsGt(this Param param, DateTime limit)
{
if (param.Value <= limit)
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotGt.Inject(param.Value, limit));
+ }
return param;
}
@@ -41,7 +46,9 @@ public static Param IsGt(this Param param, DateTime limit)
public static Param IsGte(this Param param, DateTime limit)
{
if (!(param.Value >= limit))
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotGte.Inject(param.Value, limit));
+ }
return param;
}
@@ -50,10 +57,14 @@ public static Param IsGte(this Param param, DateTime limit)
public static Param IsInRange(this Param param, DateTime min, DateTime max)
{
if (param.Value < min)
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotInRange_ToLow.Inject(param.Value, min));
+ }
if (param.Value > max)
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotInRange_ToHigh.Inject(param.Value, max));
+ }
return param;
}
@@ -62,15 +73,17 @@ public static Param IsInRange(this Param param, DateTime min
public static Param IsUtc(this Param param)
{
if (param.Value.Kind != DateTimeKind.Utc)
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, "Excepted time to be in UTC but was [{0}]".Inject(param.Value.Kind));
+ }
+
return param;
}
-
[DebuggerStepThrough]
public static Param IsValid(this Param param)
{
return IsGt(param, _minTime);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Common/EnsureThat/EnsureDecimalExtensions.cs b/src/NzbDrone.Common/EnsureThat/EnsureDecimalExtensions.cs
index 5fa967337..e1bf3ba6d 100644
--- a/src/NzbDrone.Common/EnsureThat/EnsureDecimalExtensions.cs
+++ b/src/NzbDrone.Common/EnsureThat/EnsureDecimalExtensions.cs
@@ -10,7 +10,9 @@ public static class EnsureDecimalExtensions
public static Param IsLt(this Param param, decimal limit)
{
if (param.Value >= limit)
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotLt.Inject(param.Value, limit));
+ }
return param;
}
@@ -19,7 +21,9 @@ public static Param IsLt(this Param param, decimal limit)
public static Param IsLte(this Param param, decimal limit)
{
if (!(param.Value <= limit))
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotLte.Inject(param.Value, limit));
+ }
return param;
}
@@ -28,7 +32,9 @@ public static Param IsLte(this Param param, decimal limit)
public static Param IsGt(this Param param, decimal limit)
{
if (param.Value <= limit)
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotGt.Inject(param.Value, limit));
+ }
return param;
}
@@ -37,7 +43,9 @@ public static Param IsGt(this Param param, decimal limit)
public static Param IsGte(this Param param, decimal limit)
{
if (!(param.Value >= limit))
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotGte.Inject(param.Value, limit));
+ }
return param;
}
@@ -46,12 +54,16 @@ public static Param IsGte(this Param param, decimal limit)
public static Param IsInRange(this Param param, decimal min, decimal max)
{
if (param.Value < min)
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotInRange_ToLow.Inject(param.Value, min));
+ }
if (param.Value > max)
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotInRange_ToHigh.Inject(param.Value, max));
+ }
return param;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Common/EnsureThat/EnsureDoubleExtensions.cs b/src/NzbDrone.Common/EnsureThat/EnsureDoubleExtensions.cs
index 7c91f41b4..d67abe512 100644
--- a/src/NzbDrone.Common/EnsureThat/EnsureDoubleExtensions.cs
+++ b/src/NzbDrone.Common/EnsureThat/EnsureDoubleExtensions.cs
@@ -10,7 +10,9 @@ public static class EnsureDoubleExtensions
public static Param IsLt(this Param param, double limit)
{
if (param.Value >= limit)
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotLt.Inject(param.Value, limit));
+ }
return param;
}
@@ -19,7 +21,9 @@ public static Param IsLt(this Param param, double limit)
public static Param IsLte(this Param param, double limit)
{
if (!(param.Value <= limit))
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotLte.Inject(param.Value, limit));
+ }
return param;
}
@@ -28,7 +32,9 @@ public static Param IsLte(this Param param, double limit)
public static Param IsGt(this Param param, double limit)
{
if (param.Value <= limit)
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotGt.Inject(param.Value, limit));
+ }
return param;
}
@@ -37,7 +43,9 @@ public static Param IsGt(this Param param, double limit)
public static Param IsGte(this Param param, double limit)
{
if (!(param.Value >= limit))
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotGte.Inject(param.Value, limit));
+ }
return param;
}
@@ -46,12 +54,16 @@ public static Param IsGte(this Param param, double limit)
public static Param IsInRange(this Param param, double min, double max)
{
if (param.Value < min)
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotInRange_ToLow.Inject(param.Value, min));
+ }
if (param.Value > max)
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotInRange_ToHigh.Inject(param.Value, max));
+ }
return param;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Common/EnsureThat/EnsureGuidExtensions.cs b/src/NzbDrone.Common/EnsureThat/EnsureGuidExtensions.cs
index 77a7be433..a9d6190b3 100644
--- a/src/NzbDrone.Common/EnsureThat/EnsureGuidExtensions.cs
+++ b/src/NzbDrone.Common/EnsureThat/EnsureGuidExtensions.cs
@@ -10,9 +10,11 @@ public static class EnsureGuidExtensions
public static Param IsNotEmpty(this Param param)
{
if (Guid.Empty.Equals(param.Value))
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsEmptyGuid);
+ }
return param;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Common/EnsureThat/EnsureIntExtensions.cs b/src/NzbDrone.Common/EnsureThat/EnsureIntExtensions.cs
index ecbdb0e3f..77ecaf669 100644
--- a/src/NzbDrone.Common/EnsureThat/EnsureIntExtensions.cs
+++ b/src/NzbDrone.Common/EnsureThat/EnsureIntExtensions.cs
@@ -10,7 +10,9 @@ public static class EnsureIntExtensions
public static Param IsLessThan(this Param param, int limit)
{
if (param.Value >= limit)
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotLt.Inject(param.Value, limit));
+ }
return param;
}
@@ -19,7 +21,9 @@ public static Param IsLessThan(this Param param, int limit)
public static Param IsLessThanOrEqualTo(this Param param, int limit)
{
if (!(param.Value <= limit))
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotLte.Inject(param.Value, limit));
+ }
return param;
}
@@ -28,7 +32,9 @@ public static Param IsLessThanOrEqualTo(this Param param, int limit)
public static Param IsGreaterThan(this Param param, int limit)
{
if (param.Value <= limit)
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotGt.Inject(param.Value, limit));
+ }
return param;
}
@@ -37,7 +43,9 @@ public static Param IsGreaterThan(this Param param, int limit)
public static Param IsGreaterThanZero(this Param param)
{
if (param.Value <= 0)
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotGt.Inject(param.Value, 0));
+ }
return param;
}
@@ -46,7 +54,9 @@ public static Param IsGreaterThanZero(this Param param)
public static Param IsGreaterOrEqualTo(this Param param, int limit)
{
if (!(param.Value >= limit))
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotGte.Inject(param.Value, limit));
+ }
return param;
}
@@ -55,12 +65,16 @@ public static Param IsGreaterOrEqualTo(this Param param, int limit)
public static Param IsInRange(this Param param, int min, int max)
{
if (param.Value < min)
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotInRange_ToLow.Inject(param.Value, min));
+ }
if (param.Value > max)
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotInRange_ToHigh.Inject(param.Value, max));
+ }
return param;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Common/EnsureThat/EnsureLongExtensions.cs b/src/NzbDrone.Common/EnsureThat/EnsureLongExtensions.cs
index 066c78c2f..568fefb5a 100644
--- a/src/NzbDrone.Common/EnsureThat/EnsureLongExtensions.cs
+++ b/src/NzbDrone.Common/EnsureThat/EnsureLongExtensions.cs
@@ -10,7 +10,9 @@ public static class EnsureLongExtensions
public static Param IsLt(this Param param, long limit)
{
if (param.Value >= limit)
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotLt.Inject(param.Value, limit));
+ }
return param;
}
@@ -19,7 +21,9 @@ public static Param IsLt(this Param param, long limit)
public static Param IsLte(this Param param, long limit)
{
if (!(param.Value <= limit))
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotLte.Inject(param.Value, limit));
+ }
return param;
}
@@ -28,7 +32,9 @@ public static Param IsLte(this Param param, long limit)
public static Param IsGt(this Param param, long limit)
{
if (param.Value <= limit)
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotGt.Inject(param.Value, limit));
+ }
return param;
}
@@ -37,7 +43,9 @@ public static Param IsGt(this Param param, long limit)
public static Param IsGte(this Param param, long limit)
{
if (!(param.Value >= limit))
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotGte.Inject(param.Value, limit));
+ }
return param;
}
@@ -46,12 +54,16 @@ public static Param IsGte(this Param param, long limit)
public static Param IsInRange(this Param param, long min, long max)
{
if (param.Value < min)
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotInRange_ToLow.Inject(param.Value, min));
+ }
if (param.Value > max)
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotInRange_ToHigh.Inject(param.Value, max));
+ }
return param;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Common/EnsureThat/EnsureNullableValueTypeExtensions.cs b/src/NzbDrone.Common/EnsureThat/EnsureNullableValueTypeExtensions.cs
index 54d5af7ad..3603da257 100644
--- a/src/NzbDrone.Common/EnsureThat/EnsureNullableValueTypeExtensions.cs
+++ b/src/NzbDrone.Common/EnsureThat/EnsureNullableValueTypeExtensions.cs
@@ -6,12 +6,15 @@ namespace NzbDrone.Common.EnsureThat
public static class EnsureNullableValueTypeExtensions
{
[DebuggerStepThrough]
- public static Param IsNotNull(this Param param) where T : struct
+ public static Param IsNotNull(this Param param)
+ where T : struct
{
if (param.Value == null || !param.Value.HasValue)
+ {
throw ExceptionFactory.CreateForParamNullValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotNull);
+ }
return param;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Common/EnsureThat/EnsureObjectExtensions.cs b/src/NzbDrone.Common/EnsureThat/EnsureObjectExtensions.cs
index a5fe6a23f..7833d02e5 100644
--- a/src/NzbDrone.Common/EnsureThat/EnsureObjectExtensions.cs
+++ b/src/NzbDrone.Common/EnsureThat/EnsureObjectExtensions.cs
@@ -6,12 +6,15 @@ namespace NzbDrone.Common.EnsureThat
public static class EnsureObjectExtensions
{
[DebuggerStepThrough]
- public static Param IsNotNull(this Param param) where T : class
+ public static Param IsNotNull(this Param param)
+ where T : class
{
if (param.Value == null)
+ {
throw ExceptionFactory.CreateForParamNullValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotNull);
+ }
return param;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Common/EnsureThat/EnsureShortExtensions.cs b/src/NzbDrone.Common/EnsureThat/EnsureShortExtensions.cs
index 425494d43..54f082b8f 100644
--- a/src/NzbDrone.Common/EnsureThat/EnsureShortExtensions.cs
+++ b/src/NzbDrone.Common/EnsureThat/EnsureShortExtensions.cs
@@ -10,7 +10,9 @@ public static class EnsureShortExtensions
public static Param IsLt(this Param param, short limit)
{
if (param.Value >= limit)
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotLt.Inject(param.Value, limit));
+ }
return param;
}
@@ -19,7 +21,9 @@ public static Param IsLt(this Param param, short limit)
public static Param IsLte(this Param param, short limit)
{
if (!(param.Value <= limit))
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotLte.Inject(param.Value, limit));
+ }
return param;
}
@@ -28,7 +32,9 @@ public static Param IsLte(this Param param, short limit)
public static Param IsGt(this Param param, short limit)
{
if (param.Value <= limit)
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotGt.Inject(param.Value, limit));
+ }
return param;
}
@@ -37,7 +43,9 @@ public static Param IsGt(this Param param, short limit)
public static Param IsGte(this Param param, short limit)
{
if (!(param.Value >= limit))
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotGte.Inject(param.Value, limit));
+ }
return param;
}
@@ -46,12 +54,16 @@ public static Param IsGte(this Param param, short limit)
public static Param