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 @@ namespace NzbDrone.Api.Test.ClientSchemaTests
schema.Should().HaveCount(2);
}
-
[Test]
public void schema_should_have_proper_fields()
{
@@ -32,7 +31,6 @@ namespace NzbDrone.Api.Test.ClientSchemaTests
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 @@ namespace NzbDrone.Automation.Test
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 @@ namespace NzbDrone.Automation.Test.PageModel
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 @@ namespace NzbDrone.Common.Test.CacheTests
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 @@ namespace NzbDrone.Common.Test.CacheTests
_cachedString.Get("Test", _worker.GetString);
_worker.HitCount.Should().Be(1);
-
}
[Test]
@@ -38,7 +37,6 @@ namespace NzbDrone.Common.Test.CacheTests
first.Should().Be(second);
}
-
[Test]
public void should_be_able_to_update_key()
{
@@ -48,7 +46,6 @@ namespace NzbDrone.Common.Test.CacheTests
_cachedString.Find("Key").Should().Be("New");
}
-
[Test]
public void should_be_able_to_remove_key()
{
@@ -70,7 +67,6 @@ namespace NzbDrone.Common.Test.CacheTests
{
int hitCount = 0;
-
for (int i = 0; i < 10; i++)
{
_cachedString.Get("key", () =>
@@ -84,6 +80,7 @@ namespace NzbDrone.Common.Test.CacheTests
}
[Test]
+ [Platform(Exclude = "MacOsX")]
public void should_honor_ttl()
{
int hitCount = 0;
@@ -91,11 +88,13 @@ namespace NzbDrone.Common.Test.CacheTests
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 @@ namespace NzbDrone.Common.Test.CacheTests
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 @@ namespace NzbDrone.Common.Test.CacheTests
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 @@ namespace NzbDrone.Common.Test
const string key = "Port";
const int value = 8989;
-
var result = Subject.GetValueInt(key, value);
-
result.Should().Be(value);
}
@@ -75,20 +73,16 @@ namespace NzbDrone.Common.Test
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 @@ namespace NzbDrone.Common.Test
{
const int value = 8989;
-
var result = Subject.Port;
-
result.Should().Be(value);
}
@@ -110,10 +102,8 @@ namespace NzbDrone.Common.Test
const string key = "LaunchBrowser";
const bool value = false;
-
Subject.SetValue(key, value);
-
var result = Subject.LaunchBrowser;
result.Should().Be(value);
}
@@ -124,10 +114,8 @@ namespace NzbDrone.Common.Test
const string key = "Port";
const int value = 12345;
-
Subject.SetValue(key, value);
-
var result = Subject.Port;
result.Should().Be(value);
}
@@ -138,10 +126,8 @@ namespace NzbDrone.Common.Test
const string key = "Hello";
const string value = "World";
-
var result = Subject.GetValue(key, value);
-
result.Should().Be(value);
}
@@ -178,7 +164,6 @@ namespace NzbDrone.Common.Test
dic["SslPort"] = origSslPort;
Subject.SaveConfigDictionary(dic);
-
dic = new Dictionary();
dic["SslPort"] = sslPort;
Subject.SaveConfigDictionary(dic);
@@ -213,4 +198,4 @@ namespace NzbDrone.Common.Test
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 @@ namespace NzbDrone.Common.Test.DiskTests
.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 @@ using NzbDrone.Test.Common;
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 @@ namespace NzbDrone.Common.Test.DiskTests
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 @@ namespace NzbDrone.Common.Test.DiskTests
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 @@ namespace NzbDrone.Common.Test.DiskTests
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 @@ namespace NzbDrone.Common.Test.DiskTests
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 @@ namespace NzbDrone.Common.Test.DiskTests
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 @@ namespace NzbDrone.Common.Test.DiskTests
{
var dir = Path.GetDirectoryName(path);
if (exists && dir.IsNotNullOrWhiteSpace())
+ {
WithExistingFolder(dir);
+ }
Mocker.GetMock()
.Setup(v => v.FolderExists(path))
@@ -762,7 +764,9 @@ namespace NzbDrone.Common.Test.DiskTests
{
var dir = Path.GetDirectoryName(path);
if (exists && dir.IsNotNullOrWhiteSpace())
+ {
WithExistingFolder(dir);
+ }
Mocker.GetMock()
.Setup(v => v.FileExists(path))
@@ -816,7 +820,6 @@ namespace NzbDrone.Common.Test.DiskTests
WithExistingFile(v, false);
});
-
Mocker.GetMock()
.Setup(v => v.FolderExists(It.IsAny()))
.Returns(false);
@@ -834,6 +837,7 @@ namespace NzbDrone.Common.Test.DiskTests
{
WithExistingFolder(s, false);
WithExistingFolder(d);
+
// Note: Should also deal with the files.
});
@@ -842,6 +846,7 @@ namespace NzbDrone.Common.Test.DiskTests
.Callback((f, r) =>
{
WithExistingFolder(f, false);
+
// Note: Should also deal with the files.
});
@@ -907,8 +912,13 @@ namespace NzbDrone.Common.Test.DiskTests
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 @@ using NzbDrone.Test.Common;
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 @@ namespace NzbDrone.Common.Test.EnsureTest
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 @@ namespace NzbDrone.Common.Test.EnvironmentTests
args.Flags.Contains("t").Should().BeTrue();
}
-
[TestCase("/key=value")]
[TestCase("/KEY=value")]
[TestCase(" /key=\"value\"")]
@@ -37,7 +36,6 @@ namespace NzbDrone.Common.Test.EnvironmentTests
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 @@ namespace NzbDrone.Common.Test.EnvironmentTests
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 @@ namespace NzbDrone.Common.Test.ExtensionTests.IEnumerableExtensionTests
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 @@ namespace NzbDrone.Common.Test.ExtensionTests
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 @@ namespace NzbDrone.Common.Test
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 @@ namespace NzbDrone.Common.Test.Http
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 @@ namespace NzbDrone.Common.Test.Http
{
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 @@ namespace NzbDrone.Common.Test.Http
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 @@ namespace NzbDrone.Common.Test.Http
[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 @@ namespace NzbDrone.Common.Test.Http
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 @@ namespace NzbDrone.Common.Test.Http
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 @@ namespace NzbDrone.Common.Test.InstrumentationTests
[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 @@ namespace NzbDrone.Common.Test.InstrumentationTests
[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 @@ namespace NzbDrone.Common.Test.InstrumentationTests
[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 @@ namespace NzbDrone.Common.Test.InstrumentationTests
[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 @@ namespace NzbDrone.Common.Test.InstrumentationTests
[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 @@ namespace NzbDrone.Common.Test.InstrumentationTests
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 @@ namespace NzbDrone.Common.Test.InstrumentationTests
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 @@ namespace NzbDrone.Common.Test
_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 @@ namespace NzbDrone.Common.Test
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 @@ namespace NzbDrone.Common.Test
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 @@ namespace NzbDrone.Common.Test
{
TestLogger.Warn(ex, "{0} when killing process", ex.Message);
}
-
});
}
@@ -134,7 +132,6 @@ namespace NzbDrone.Common.Test
}
}
-
[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 @@ namespace NzbDrone.Common.Test
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 @@ namespace NzbDrone.Common.Test
}
}
-
private void CleanupService()
{
if (Subject.ServiceExist(TEMP_SERVICE_NAME))
@@ -62,7 +61,6 @@ namespace NzbDrone.Common.Test
Subject.ServiceExist("random_service_name").Should().BeFalse();
}
-
[Test]
public void Service_should_be_installed_and_then_uninstalled()
{
@@ -123,7 +121,6 @@ namespace NzbDrone.Common.Test
Subject.Start(ALWAYS_INSTALLED_SERVICE);
Assert.Throws(() => Subject.Start(ALWAYS_INSTALLED_SERVICE));
-
ExceptionVerification.ExpectedWarns(1);
}
@@ -133,15 +130,14 @@ namespace NzbDrone.Common.Test
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 @@ namespace NzbDrone.Common.Test.TPLTests
}
}
-
[Test]
[Retry(3)]
public void should_hold_the_call_for_debounce_duration()
@@ -33,11 +32,9 @@ namespace NzbDrone.Common.Test.TPLTests
counter.Count.Should().Be(0);
-
Thread.Sleep(100);
counter.Count.Should().Be(1);
-
}
[Test]
@@ -53,7 +50,6 @@ namespace NzbDrone.Common.Test.TPLTests
counter.Count.Should().Be(0);
-
Thread.Sleep(200);
debounceFunction.Execute();
@@ -63,7 +59,6 @@ namespace NzbDrone.Common.Test.TPLTests
Thread.Sleep(200);
counter.Count.Should().Be(2);
-
}
[Test]
@@ -126,4 +121,4 @@ namespace NzbDrone.Common.Test.TPLTests
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 @@ namespace NzbDrone.Common
{
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 @@ namespace NzbDrone.Common.Cache
public CacheManager()
{
_cache = new Cached();
-
}
public void Clear()
@@ -61,4 +60,4 @@ namespace NzbDrone.Common.Cache
return (ICachedDictionary)_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 @@ using NzbDrone.Common.Extensions;
namespace NzbDrone.Common.Cache
{
-
public class Cached : ICached
{
private class CacheItem
@@ -144,6 +143,5 @@ namespace NzbDrone.Common.Cache
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 @@ using System.Diagnostics;
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 @@ namespace NzbDrone.Common.Cache
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 @@ namespace NzbDrone.Common.Composition
_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 @@ namespace NzbDrone.Common.Composition
_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 @@ namespace NzbDrone.Common.Composition
});
}
- public IEnumerable ResolveAll() where T : class
+ public IEnumerable ResolveAll()
+ where T : class
{
return _container.ResolveAll();
}
@@ -103,8 +107,7 @@ namespace NzbDrone.Common.Composition
.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 @@ namespace NzbDrone.Common.Composition
{
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 @@ namespace NzbDrone.Common.Crypto
}
}
}
-}
\ 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 @@ namespace NzbDrone.Common.Disk
{
}
- 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 @@ namespace NzbDrone.Common.Disk
{
return File.Exists(path) && path == path.GetActualCasing();
}
+
default:
{
return File.Exists(path);
@@ -367,7 +368,7 @@ namespace NzbDrone.Common.Disk
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 @@ namespace NzbDrone.Common.Disk
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 @@ namespace NzbDrone.Common.Disk
return realParentPath + partialChildPath;
}
-
+
public TransferMode TransferFolder(string sourcePath, string targetPath, TransferMode mode)
{
Ensure.That(sourcePath, () => sourcePath).IsValidPath();
@@ -101,14 +101,20 @@ namespace NzbDrone.Common.Disk
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 @@ namespace NzbDrone.Common.Disk
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 @@ namespace NzbDrone.Common.Disk
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 @@ namespace NzbDrone.Common.Disk
{
return TransferMode.HardLink;
}
+
if (!mode.HasFlag(TransferMode.Copy))
{
throw new IOException("Hardlinking from '" + sourcePath + "' to '" + targetPath + "' failed.");
@@ -315,14 +334,14 @@ namespace NzbDrone.Common.Disk
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 @@ namespace NzbDrone.Common.Disk
_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 @@ namespace NzbDrone.Common.Disk
{
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 @@ namespace NzbDrone.Common.Disk
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 @@ namespace NzbDrone.Common.Disk
{
get
{
- if (MAX_PATH == 0) DetectLongPathLimits();
+ if (MAX_PATH == 0)
+ {
+ DetectLongPathLimits();
+ }
+
return MAX_PATH;
}
}
@@ -63,7 +67,11 @@ namespace NzbDrone.Common.Disk
{
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 @@ namespace NzbDrone.Common.Disk
{
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 @@ namespace NzbDrone.Common.Disk
{
path = path.Replace("//", "/");
}
+
return path;
}
@@ -98,11 +113,12 @@ namespace NzbDrone.Common.Disk
{
return _path.StartsWith(@"\\") || HasWindowsDriveLetter(_path);
}
+
if (IsUnixPath)
{
return _path.StartsWith("/");
}
-
+
return false;
}
}
@@ -117,7 +133,7 @@ namespace NzbDrone.Common.Disk
{
return new OsPath(null);
}
-
+
return new OsPath(_path.Substring(0, index), _kind).AsDirectory();
}
}
@@ -141,7 +157,7 @@ namespace NzbDrone.Common.Disk
return path;
}
-
+
return _path.Substring(index).Trim('\\', '/');
}
}
@@ -196,10 +212,12 @@ namespace NzbDrone.Common.Disk
{
return Equals((OsPath)obj);
}
+
if (obj is string)
{
return Equals(new OsPath(obj as string));
}
+
return false;
}
@@ -217,6 +235,7 @@ namespace NzbDrone.Common.Disk
case OsPathKind.Unix:
return new OsPath(_path.TrimEnd('/') + "/", _kind);
}
+
return this;
}
@@ -250,7 +269,10 @@ namespace NzbDrone.Common.Disk
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 @@ namespace NzbDrone.Common.Disk
{
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 @@ namespace NzbDrone.Common.Disk
{
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 @@ namespace NzbDrone.Common.Disk
{
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 @@ namespace NzbDrone.Common.EnsureThat
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 @@ namespace NzbDrone.Common.EnsureThat
public static Param IsTrue(this Param param)
{
if (!param.Value)
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotTrue);
+ }
return param;
}
@@ -18,9 +20,11 @@ namespace NzbDrone.Common.EnsureThat
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 @@ namespace NzbDrone.Common.EnsureThat
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 @@ namespace NzbDrone.Common.EnsureThat
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 @@ namespace NzbDrone.Common.EnsureThat
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 @@ namespace NzbDrone.Common.EnsureThat
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 @@ namespace NzbDrone.Common.EnsureThat
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 @@ namespace NzbDrone.Common.EnsureThat
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 @@ namespace NzbDrone.Common.EnsureThat
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 @@ namespace NzbDrone.Common.EnsureThat
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 @@ namespace NzbDrone.Common.EnsureThat
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 @@ namespace NzbDrone.Common.EnsureThat
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 @@ namespace NzbDrone.Common.EnsureThat
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 @@ namespace NzbDrone.Common.EnsureThat
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 @@ namespace NzbDrone.Common.EnsureThat
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 @@ namespace NzbDrone.Common.EnsureThat
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 @@ namespace NzbDrone.Common.EnsureThat
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 @@ namespace NzbDrone.Common.EnsureThat
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 @@ namespace NzbDrone.Common.EnsureThat
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 @@ namespace NzbDrone.Common.EnsureThat
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 @@ namespace NzbDrone.Common.EnsureThat
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 @@ namespace NzbDrone.Common.EnsureThat
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 @@ namespace NzbDrone.Common.EnsureThat
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 @@ namespace NzbDrone.Common.EnsureThat
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 @@ namespace NzbDrone.Common.EnsureThat
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 @@ namespace NzbDrone.Common.EnsureThat
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 @@ namespace NzbDrone.Common.EnsureThat
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 @@ namespace NzbDrone.Common.EnsureThat
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 @@ namespace NzbDrone.Common.EnsureThat
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 @@ namespace NzbDrone.Common.EnsureThat
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 @@ namespace NzbDrone.Common.EnsureThat
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 @@ namespace NzbDrone.Common.EnsureThat
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 @@ namespace NzbDrone.Common.EnsureThat
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 @@ namespace NzbDrone.Common.EnsureThat
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 @@ namespace NzbDrone.Common.EnsureThat
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 @@ namespace NzbDrone.Common.EnsureThat
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 @@ namespace NzbDrone.Common.EnsureThat
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 @@ namespace NzbDrone.Common.EnsureThat
public static Param IsInRange(this Param param, short min, short 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/EnsureStringExtensions.cs b/src/NzbDrone.Common/EnsureThat/EnsureStringExtensions.cs
index 99f348667..1c10c9f28 100644
--- a/src/NzbDrone.Common/EnsureThat/EnsureStringExtensions.cs
+++ b/src/NzbDrone.Common/EnsureThat/EnsureStringExtensions.cs
@@ -13,7 +13,9 @@ namespace NzbDrone.Common.EnsureThat
public static Param IsNotNullOrWhiteSpace(this Param param)
{
if (string.IsNullOrWhiteSpace(param.Value))
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotNullOrWhiteSpace);
+ }
return param;
}
@@ -22,7 +24,9 @@ namespace NzbDrone.Common.EnsureThat
public static Param IsNotNullOrEmpty(this Param param)
{
if (string.IsNullOrEmpty(param.Value))
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotNullOrEmpty);
+ }
return param;
}
@@ -31,15 +35,21 @@ namespace NzbDrone.Common.EnsureThat
public static Param HasLengthBetween(this Param param, int minLength, int maxLength)
{
if (string.IsNullOrEmpty(param.Value))
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotNullOrEmpty);
+ }
var length = param.Value.Length;
if (length < minLength)
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotInRange_ToShort.Inject(minLength, maxLength, length));
+ }
if (length > maxLength)
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotInRange_ToLong.Inject(minLength, maxLength, length));
+ }
return param;
}
@@ -48,12 +58,16 @@ namespace NzbDrone.Common.EnsureThat
public static Param IsLongerThan(this Param param, int minLength)
{
if (string.IsNullOrEmpty(param.Value))
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotNullOrEmpty);
+ }
var length = param.Value.Length;
if (length < minLength)
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, "The string is not long enough. Must be at least '{0}' but was '{1}' characters long.".Inject(minLength, length));
+ }
return param;
}
@@ -71,6 +85,7 @@ namespace NzbDrone.Common.EnsureThat
{
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_NoMatch.Inject(param.Value, match));
}
+
return param;
}
@@ -78,7 +93,9 @@ namespace NzbDrone.Common.EnsureThat
public static Param IsRelativePath(this Param param)
{
if (string.IsNullOrWhiteSpace(param.Value))
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotNullOrWhiteSpace);
+ }
if (!param.Value.EndsWith("\\"))
{
@@ -97,9 +114,14 @@ namespace NzbDrone.Common.EnsureThat
public static Param IsValidPath(this Param param)
{
if (string.IsNullOrWhiteSpace(param.Value))
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotNullOrWhiteSpace);
+ }
- if (param.Value.IsPathValid()) return param;
+ if (param.Value.IsPathValid())
+ {
+ return param;
+ }
if (OsInfo.IsWindows)
{
diff --git a/src/NzbDrone.Common/EnsureThat/EnsureTypeExtensions.cs b/src/NzbDrone.Common/EnsureThat/EnsureTypeExtensions.cs
index 74f4246fb..00c1b4dc2 100644
--- a/src/NzbDrone.Common/EnsureThat/EnsureTypeExtensions.cs
+++ b/src/NzbDrone.Common/EnsureThat/EnsureTypeExtensions.cs
@@ -9,7 +9,7 @@ namespace NzbDrone.Common.EnsureThat
{
private static class Types
{
- internal static readonly Type IntType = typeof (int);
+ internal static readonly Type IntType = typeof(int);
internal static readonly Type ShortType = typeof(short);
@@ -78,10 +78,12 @@ namespace NzbDrone.Common.EnsureThat
public static TypeParam IsOfType(this TypeParam param, Type type)
{
if (!param.Type.Equals(type))
+ {
throw ExceptionFactory.CreateForParamValidation(param.Name,
ExceptionMessages.EnsureExtensions_IsNotOfType.Inject(param.Type.FullName));
+ }
return param;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Common/EnsureThat/ExceptionFactory.cs b/src/NzbDrone.Common/EnsureThat/ExceptionFactory.cs
index 42bbb1b5c..d3f24a43f 100644
--- a/src/NzbDrone.Common/EnsureThat/ExceptionFactory.cs
+++ b/src/NzbDrone.Common/EnsureThat/ExceptionFactory.cs
@@ -19,4 +19,4 @@ namespace NzbDrone.Common.EnsureThat
return new ArgumentNullException(paramName, message);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Common/EnsureThat/ExpressionExtensions.cs b/src/NzbDrone.Common/EnsureThat/ExpressionExtensions.cs
index 7e72fe4ed..baea52fcb 100644
--- a/src/NzbDrone.Common/EnsureThat/ExpressionExtensions.cs
+++ b/src/NzbDrone.Common/EnsureThat/ExpressionExtensions.cs
@@ -9,7 +9,9 @@ namespace NzbDrone.Common.EnsureThat
var path = "";
if (e.Expression is MemberExpression parent)
+ {
path = parent.ToPath() + ".";
+ }
return path + e.Member.Name;
}
@@ -22,17 +24,23 @@ namespace NzbDrone.Common.EnsureThat
private static MemberExpression GetRightMostMember(Expression e)
{
if (e is LambdaExpression)
+ {
return GetRightMostMember(((LambdaExpression)e).Body);
+ }
if (e is MemberExpression)
+ {
return (MemberExpression)e;
+ }
if (e is MethodCallExpression)
{
var callExpression = (MethodCallExpression)e;
if (callExpression.Object is MethodCallExpression || callExpression.Object is MemberExpression)
+ {
return GetRightMostMember(callExpression.Object);
+ }
var member = callExpression.Arguments.Count > 0 ? callExpression.Arguments[0] : callExpression.Object;
return GetRightMostMember(member);
@@ -47,4 +55,4 @@ namespace NzbDrone.Common.EnsureThat
return null;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Common/EnsureThat/Param.cs b/src/NzbDrone.Common/EnsureThat/Param.cs
index c1ff3c963..1eea2851d 100644
--- a/src/NzbDrone.Common/EnsureThat/Param.cs
+++ b/src/NzbDrone.Common/EnsureThat/Param.cs
@@ -16,9 +16,10 @@ namespace NzbDrone.Common.EnsureThat
{
public readonly T Value;
- internal Param(string name, T value) : base(name)
+ internal Param(string name, T value)
+ : base(name)
{
Value = value;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Common/EnsureThat/TypeParam.cs b/src/NzbDrone.Common/EnsureThat/TypeParam.cs
index 202dacf87..09788e446 100644
--- a/src/NzbDrone.Common/EnsureThat/TypeParam.cs
+++ b/src/NzbDrone.Common/EnsureThat/TypeParam.cs
@@ -12,4 +12,4 @@ namespace NzbDrone.Common.EnsureThat
Type = type;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Common/EnvironmentInfo/AppFolderFactory.cs b/src/NzbDrone.Common/EnvironmentInfo/AppFolderFactory.cs
index b48110a52..1995dcb47 100644
--- a/src/NzbDrone.Common/EnvironmentInfo/AppFolderFactory.cs
+++ b/src/NzbDrone.Common/EnvironmentInfo/AppFolderFactory.cs
@@ -95,9 +95,20 @@ namespace NzbDrone.Common.EnvironmentInfo
RemovePidFile();
}
- if (_appFolderInfo.LegacyAppDataFolder.IsNullOrWhiteSpace()) return;
- if (_diskProvider.FileExists(_appFolderInfo.GetDatabase()) || _diskProvider.FileExists(_appFolderInfo.GetConfigPath())) return;
- if (!_diskProvider.FolderExists(_appFolderInfo.LegacyAppDataFolder)) return;
+ if (_appFolderInfo.LegacyAppDataFolder.IsNullOrWhiteSpace())
+ {
+ return;
+ }
+
+ if (_diskProvider.FileExists(_appFolderInfo.GetDatabase()) || _diskProvider.FileExists(_appFolderInfo.GetConfigPath()))
+ {
+ return;
+ }
+
+ if (!_diskProvider.FolderExists(_appFolderInfo.LegacyAppDataFolder))
+ {
+ return;
+ }
// Delete the bin folder on Windows
var binFolder = Path.Combine(_appFolderInfo.LegacyAppDataFolder, "bin");
diff --git a/src/NzbDrone.Common/EnvironmentInfo/IOsVersionAdapter.cs b/src/NzbDrone.Common/EnvironmentInfo/IOsVersionAdapter.cs
index 25a3cbf1f..b844a29c2 100644
--- a/src/NzbDrone.Common/EnvironmentInfo/IOsVersionAdapter.cs
+++ b/src/NzbDrone.Common/EnvironmentInfo/IOsVersionAdapter.cs
@@ -1,6 +1,5 @@
namespace NzbDrone.Common.EnvironmentInfo
{
-
public interface IOsVersionAdapter
{
bool Enabled { get; }
diff --git a/src/NzbDrone.Common/EnvironmentInfo/OsInfo.cs b/src/NzbDrone.Common/EnvironmentInfo/OsInfo.cs
index 2c9bf896a..bb94ec267 100644
--- a/src/NzbDrone.Common/EnvironmentInfo/OsInfo.cs
+++ b/src/NzbDrone.Common/EnvironmentInfo/OsInfo.cs
@@ -34,6 +34,7 @@ namespace NzbDrone.Common.EnvironmentInfo
Os = Os.Windows;
break;
}
+
case PlatformID.MacOSX:
case PlatformID.Unix:
{
diff --git a/src/NzbDrone.Common/EnvironmentInfo/OsVersionModel.cs b/src/NzbDrone.Common/EnvironmentInfo/OsVersionModel.cs
index c20865813..f5e8074fc 100644
--- a/src/NzbDrone.Common/EnvironmentInfo/OsVersionModel.cs
+++ b/src/NzbDrone.Common/EnvironmentInfo/OsVersionModel.cs
@@ -2,8 +2,6 @@ namespace NzbDrone.Common.EnvironmentInfo
{
public class OsVersionModel
{
-
-
public OsVersionModel(string name, string version, string fullName = null)
{
Name = Trim(name);
diff --git a/src/NzbDrone.Common/EnvironmentInfo/PlatformInfo.cs b/src/NzbDrone.Common/EnvironmentInfo/PlatformInfo.cs
index 23fcc00b1..76f323652 100644
--- a/src/NzbDrone.Common/EnvironmentInfo/PlatformInfo.cs
+++ b/src/NzbDrone.Common/EnvironmentInfo/PlatformInfo.cs
@@ -2,7 +2,6 @@ using System;
namespace NzbDrone.Common.EnvironmentInfo
{
-
public enum PlatformType
{
DotNet = 0,
diff --git a/src/NzbDrone.Common/EnvironmentInfo/RuntimeInfo.cs b/src/NzbDrone.Common/EnvironmentInfo/RuntimeInfo.cs
index f5d06bf64..c4a22fcc7 100644
--- a/src/NzbDrone.Common/EnvironmentInfo/RuntimeInfo.cs
+++ b/src/NzbDrone.Common/EnvironmentInfo/RuntimeInfo.cs
@@ -124,7 +124,6 @@ namespace NzbDrone.Common.EnvironmentInfo
public static bool IsProduction { get; }
public static bool IsDevelopment { get; }
-
private static bool InternalIsTesting()
{
try
@@ -153,7 +152,6 @@ namespace NzbDrone.Common.EnvironmentInfo
}
catch
{
-
}
try
diff --git a/src/NzbDrone.Common/Exceptions/NzbDroneException.cs b/src/NzbDrone.Common/Exceptions/NzbDroneException.cs
index 7e0be7312..015ffc0b5 100644
--- a/src/NzbDrone.Common/Exceptions/NzbDroneException.cs
+++ b/src/NzbDrone.Common/Exceptions/NzbDroneException.cs
@@ -7,19 +7,16 @@ namespace NzbDrone.Common.Exceptions
protected NzbDroneException(string message, params object[] args)
: base(string.Format(message, args))
{
-
}
protected NzbDroneException(string message)
: base(message)
{
-
}
protected NzbDroneException(string message, Exception innerException, params object[] args)
: base(string.Format(message, args), innerException)
{
-
}
protected NzbDroneException(string message, Exception innerException)
diff --git a/src/NzbDrone.Common/Exceptions/SonarrStartupException.cs b/src/NzbDrone.Common/Exceptions/SonarrStartupException.cs
index 899596d8d..f39ab31d8 100644
--- a/src/NzbDrone.Common/Exceptions/SonarrStartupException.cs
+++ b/src/NzbDrone.Common/Exceptions/SonarrStartupException.cs
@@ -7,19 +7,16 @@ namespace NzbDrone.Common.Exceptions
public SonarrStartupException(string message, params object[] args)
: base("Sonarr failed to start: " + string.Format(message, args))
{
-
}
public SonarrStartupException(string message)
: base("Sonarr failed to start: " + message)
{
-
}
public SonarrStartupException()
: base("Sonarr failed to start")
{
-
}
public SonarrStartupException(Exception innerException, string message, params object[] args)
@@ -35,7 +32,6 @@ namespace NzbDrone.Common.Exceptions
public SonarrStartupException(Exception innerException)
: base("Sonarr failed to start: " + innerException.Message)
{
-
}
}
}
diff --git a/src/NzbDrone.Common/Expansive/CircularReferenceException.cs b/src/NzbDrone.Common/Expansive/CircularReferenceException.cs
index 93478ad00..737663c54 100644
--- a/src/NzbDrone.Common/Expansive/CircularReferenceException.cs
+++ b/src/NzbDrone.Common/Expansive/CircularReferenceException.cs
@@ -9,4 +9,4 @@ namespace NzbDrone.Common.Expansive
{
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Common/Expansive/Expansive.cs b/src/NzbDrone.Common/Expansive/Expansive.cs
index 9ad255ce6..7f7a2816b 100644
--- a/src/NzbDrone.Common/Expansive/Expansive.cs
+++ b/src/NzbDrone.Common/Expansive/Expansive.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Dynamic;
@@ -11,7 +11,6 @@ namespace NzbDrone.Common.Expansive
{
private static PatternStyle _patternStyle;
-
public static bool RequireAllExpansions { get; set; }
public static Func DefaultExpansionFactory { get; set; }
@@ -26,7 +25,6 @@ namespace NzbDrone.Common.Expansive
return source.Expand(DefaultExpansionFactory);
}
-
public static string Expand(this string source, params string[] args)
{
var output = source;
@@ -50,9 +48,11 @@ namespace NzbDrone.Common.Expansive
{
tokenIndex = tokens.IndexOf(token);
}
+
output = Regex.Replace(output, _patternStyle.OutputFilter(match.Value), "{" + tokenIndex + "}");
}
}
+
var newArgs = new List();
foreach (var arg in args)
{
@@ -63,15 +63,20 @@ namespace NzbDrone.Common.Expansive
foreach (Match match in tokenPattern.Matches(newArg))
{
var token = _patternStyle.TokenReplaceFilter(match.Value);
- if (calls.Contains(string.Format("{0}:{1}", callingToken, token))) throw new CircularReferenceException(string.Format("Circular Reference Detected for token '{0}'.", callingToken));
+ if (calls.Contains(string.Format("{0}:{1}", callingToken, token)))
+ {
+ throw new CircularReferenceException(string.Format("Circular Reference Detected for token '{0}'.", callingToken));
+ }
+
calls.Push(string.Format("{0}:{1}", callingToken, token));
callingToken = token;
newArg = Regex.Replace(newArg, _patternStyle.OutputFilter(match.Value), args[tokens.IndexOf(token)]);
}
-
}
+
newArgs.Add(newArg);
}
+
return string.Format(output, newArgs.ToArray());
}
@@ -80,9 +85,6 @@ namespace NzbDrone.Common.Expansive
return source.ExpandInternal(expansionFactory);
}
-
-
-
public static string Expand(this string source, object model)
{
return source.ExpandInternal(
@@ -116,7 +118,10 @@ namespace NzbDrone.Common.Expansive
private static string ExpandInternal(this string source, Func expansionFactory)
{
- if (expansionFactory == null) throw new ApplicationException("ExpansionFactory not defined.\nDefine a DefaultExpansionFactory or call Expand(source, Func expansionFactory))");
+ if (expansionFactory == null)
+ {
+ throw new ApplicationException("ExpansionFactory not defined.\nDefine a DefaultExpansionFactory or call Expand(source, Func expansionFactory))");
+ }
var pattern = new Regex(_patternStyle.TokenMatchPattern, RegexOptions.IgnoreCase);
@@ -139,9 +144,12 @@ namespace NzbDrone.Common.Expansive
// if we have already encountered this token in this call tree, we have a circular reference
if (thisNode.CallTree.Contains(token))
+ {
throw new CircularReferenceException(string.Format("Circular Reference Detected for token '{0}'. Call Tree: {1}->{2}",
token,
- string.Join("->", thisNode.CallTree.ToArray().Reverse()), token));
+ string.Join("->", thisNode.CallTree.ToArray().Reverse()),
+ token));
+ }
// expand this match
var expandedValue = expansionFactory(token);
@@ -156,6 +164,7 @@ namespace NzbDrone.Common.Expansive
output = Regex.Replace(output, patternStyle.OutputFilter(match.Value), child);
}
}
+
return output;
}
@@ -171,7 +180,11 @@ namespace NzbDrone.Common.Expansive
{
var result = new ExpandoObject();
var d = result as IDictionary; //work with the Expando as a Dictionary
- if (o is ExpandoObject) return o; //shouldn't have to... but just in case
+ if (o is ExpandoObject)
+ {
+ return o; //shouldn't have to... but just in case
+ }
+
if (o is NameValueCollection || o.GetType().IsSubclassOf(typeof(NameValueCollection)))
{
var nv = (NameValueCollection)o;
@@ -185,8 +198,10 @@ namespace NzbDrone.Common.Expansive
d.Add(item.Name, item.GetValue(o, null));
}
}
+
return result;
}
+
///
/// Turns the object into a Dictionary
///
@@ -195,4 +210,4 @@ namespace NzbDrone.Common.Expansive
return (IDictionary)thingy.ToExpando();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Common/Expansive/PatternStyle.cs b/src/NzbDrone.Common/Expansive/PatternStyle.cs
index 0e4f0fcc1..011e77315 100644
--- a/src/NzbDrone.Common/Expansive/PatternStyle.cs
+++ b/src/NzbDrone.Common/Expansive/PatternStyle.cs
@@ -9,4 +9,4 @@ namespace NzbDrone.Common.Expansive
public Func TokenReplaceFilter { get; set; }
public Func OutputFilter { get; set; }
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Common/Expansive/Tree.cs b/src/NzbDrone.Common/Expansive/Tree.cs
index 24be6b642..744c0714e 100644
--- a/src/NzbDrone.Common/Expansive/Tree.cs
+++ b/src/NzbDrone.Common/Expansive/Tree.cs
@@ -8,4 +8,4 @@
Value = rootValue;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Common/Expansive/TreeNode.cs b/src/NzbDrone.Common/Expansive/TreeNode.cs
index d3470072a..1b928db16 100644
--- a/src/NzbDrone.Common/Expansive/TreeNode.cs
+++ b/src/NzbDrone.Common/Expansive/TreeNode.cs
@@ -1,4 +1,4 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
namespace NzbDrone.Common.Expansive
{
@@ -7,25 +7,29 @@ namespace NzbDrone.Common.Expansive
private List _CallTree;
private TreeNode _Parent;
- public TreeNode(T Value)
+ public TreeNode(T value)
{
- this.Value = Value;
+ Value = value;
Parent = null;
Children = new TreeNodeList(this);
_CallTree = new List();
}
- public TreeNode(T Value, TreeNode Parent)
+ public TreeNode(T value, TreeNode parent)
{
- this.Value = Value;
- this.Parent = Parent;
+ Value = value;
+ Parent = parent;
Children = new TreeNodeList(this);
_CallTree = new List();
}
public TreeNode Parent
{
- get { return _Parent; }
+ get
+ {
+ return _Parent;
+ }
+
set
{
if (value == _Parent)
@@ -58,6 +62,7 @@ namespace NzbDrone.Common.Expansive
{
node = node.Parent;
}
+
return node;
}
}
@@ -75,11 +80,16 @@ namespace NzbDrone.Common.Expansive
node = node.Parent;
_CallTree.Add(node.Value);
}
+
return _CallTree;
}
- private set { _CallTree = value; }
+
+ private set
+ {
+ _CallTree = value;
+ }
}
public T Value { get; set; }
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Common/Expansive/TreeNodeList.cs b/src/NzbDrone.Common/Expansive/TreeNodeList.cs
index 3c92944b2..6e9303a1e 100644
--- a/src/NzbDrone.Common/Expansive/TreeNodeList.cs
+++ b/src/NzbDrone.Common/Expansive/TreeNodeList.cs
@@ -6,27 +6,26 @@ namespace NzbDrone.Common.Expansive
{
public TreeNode Parent;
- public TreeNodeList(TreeNode Parent)
+ public TreeNodeList(TreeNode parent)
{
- this.Parent = Parent;
+ this.Parent = parent;
}
- public new TreeNode Add(TreeNode Node)
+ public new TreeNode Add(TreeNode node)
{
- base.Add(Node);
- Node.Parent = Parent;
- return Node;
+ base.Add(node);
+ node.Parent = Parent;
+ return node;
}
- public TreeNode Add(T Value)
+ public TreeNode Add(T value)
{
- return Add(new TreeNode(Value));
+ return Add(new TreeNode(value));
}
-
public override string ToString()
{
return "Count=" + Count.ToString();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Common/Extensions/ExceptionExtensions.cs b/src/NzbDrone.Common/Extensions/ExceptionExtensions.cs
index ec07e73ed..cdc57681b 100644
--- a/src/NzbDrone.Common/Extensions/ExceptionExtensions.cs
+++ b/src/NzbDrone.Common/Extensions/ExceptionExtensions.cs
@@ -7,30 +7,37 @@ namespace NzbDrone.Common.Extensions
{
public static class ExceptionExtensions
{
- public static T WithData(this T ex, string key, string value) where T : Exception
+ public static T WithData(this T ex, string key, string value)
+ where T : Exception
{
ex.AddData(key, value);
return ex;
}
- public static T WithData(this T ex, string key, int value) where T : Exception
+
+ public static T WithData(this T ex, string key, int value)
+ where T : Exception
{
ex.AddData(key, value.ToString());
return ex;
}
- public static T WithData(this T ex, string key, Http.HttpUri value) where T : Exception
+ public static T WithData(this T ex, string key, Http.HttpUri value)
+ where T : Exception
{
ex.AddData(key, value.ToString());
return ex;
}
-
- public static T WithData(this T ex, Http.HttpResponse response, int maxSampleLength = 512) where T : Exception
+ public static T WithData(this T ex, Http.HttpResponse response, int maxSampleLength = 512)
+ where T : Exception
{
- if (response == null || response.Content == null) return ex;
+ if (response == null || response.Content == null)
+ {
+ return ex;
+ }
var contentSample = response.Content.Substring(0, Math.Min(response.Content.Length, maxSampleLength));
@@ -50,16 +57,19 @@ namespace NzbDrone.Common.Extensions
{
ex.AddData("ContentType", response.Headers.ContentType ?? string.Empty);
}
+
ex.AddData("ContentLength", response.Content.Length.ToString());
ex.AddData("ContentSample", contentSample);
return ex;
}
-
private static void AddData(this Exception ex, string key, string value)
{
- if (value.IsNullOrWhiteSpace()) return;
+ if (value.IsNullOrWhiteSpace())
+ {
+ return;
+ }
ex.Data[key] = value;
}
diff --git a/src/NzbDrone.Common/Extensions/IEnumerableExtensions.cs b/src/NzbDrone.Common/Extensions/IEnumerableExtensions.cs
index 0d2b6fb11..4af3c5f67 100644
--- a/src/NzbDrone.Common/Extensions/IEnumerableExtensions.cs
+++ b/src/NzbDrone.Common/Extensions/IEnumerableExtensions.cs
@@ -7,9 +7,11 @@ namespace NzbDrone.Common.Extensions
{
public static class EnumerableExtensions
{
- public static IEnumerable IntersectBy(this IEnumerable first, Func firstKeySelector,
- IEnumerable second, Func secondKeySelector,
- IEqualityComparer keyComparer)
+ public static IEnumerable IntersectBy(this IEnumerable first,
+ Func firstKeySelector,
+ IEnumerable second,
+ Func secondKeySelector,
+ IEqualityComparer keyComparer)
{
var keys = new HashSet(second.Select(secondKeySelector), keyComparer);
@@ -25,9 +27,11 @@ namespace NzbDrone.Common.Extensions
}
}
- public static IEnumerable ExceptBy(this IEnumerable first, Func firstKeySelector,
- IEnumerable second, Func secondKeySelector,
- IEqualityComparer keyComparer)
+ public static IEnumerable ExceptBy(this IEnumerable