diff --git a/NzbDrone.Api.Test/NzbDrone.Api.Test.csproj b/NzbDrone.Api.Test/NzbDrone.Api.Test.csproj
index d1ac785c3..6298e65ee 100644
--- a/NzbDrone.Api.Test/NzbDrone.Api.Test.csproj
+++ b/NzbDrone.Api.Test/NzbDrone.Api.Test.csproj
@@ -74,12 +74,19 @@
{f2be0fdf-6e47-4827-a420-dd4ef82407f8}
NzbDrone.Common
+
+ {ff5ee3b6-913b-47ce-9ceb-11c51b4e1205}
+ NzbDrone.Core
+
{CADDFCE0-7509-4430-8364-2074E1EEFCA2}
NzbDrone.Test.Common
+
+ App.config
+
diff --git a/NzbDrone.App.Test/IISProviderFixture.cs b/NzbDrone.App.Test/IISProviderFixture.cs
deleted file mode 100644
index 70f663b1b..000000000
--- a/NzbDrone.App.Test/IISProviderFixture.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-//using System;
-//using System.Diagnostics;
-//using FluentAssertions;
-//using Moq;
-//using NUnit.Framework;
-////using NzbDrone.Common;
-//using NzbDrone.Common.Model;
-//using NzbDrone.Providers;
-//using NzbDrone.Test.Common;
-//using NzbDrone.Test.Dummy;
-
-//namespace NzbDrone.App.Test
-//{
-// [TestFixture]
-// public class IISProviderFixture : TestBase
-// {
-// [Test]
-// public void should_update_pid_env_varibles()
-// {
-// WithTempAsAppPath();
-
-// var dummy = StartDummyProcess();
-
-// Environment.SetEnvironmentVariable(EnviromentProvider.NZBDRONE_PID, "0");
-// Environment.SetEnvironmentVariable(EnviromentProvider.NZBDRONE_PATH, "Test");
-
-// Mocker.GetMock()
-// .Setup(c => c.Start(It.IsAny()))
-// .Returns(dummy);
-
-// Mocker.Resolve().StartServer();
-// }
-
-// [Test]
-// public void should_set_iis_procces_id()
-// {
-// WithTempAsAppPath();
-// var dummy = StartDummyProcess();
-
-// Mocker.GetMock()
-// .Setup(c => c.Start(It.IsAny()))
-// .Returns(dummy);
-
-//
-// Mocker.Resolve().StartServer();
-
-//
-// Mocker.Resolve().IISProcessId.Should().Be(dummy.Id);
-// }
-
-
-// public Process StartDummyProcess()
-// {
-// var startInfo = new ProcessStartInfo(DummyApp.DUMMY_PROCCESS_NAME + ".exe");
-// startInfo.UseShellExecute = false;
-// startInfo.RedirectStandardOutput = true;
-// startInfo.RedirectStandardError = true;
-// startInfo.CreateNoWindow = true;
-// return new ProcessProvider().Start(startInfo);
-// }
-
-// }
-//}
diff --git a/NzbDrone.App.Test/MonitoringProviderTest.cs b/NzbDrone.App.Test/MonitoringProviderTest.cs
index 3954d299b..9ecf56be6 100644
--- a/NzbDrone.App.Test/MonitoringProviderTest.cs
+++ b/NzbDrone.App.Test/MonitoringProviderTest.cs
@@ -1,7 +1,5 @@
using System;
using System.Diagnostics;
-using System.Linq;
-
using FizzWare.NBuilder;
using Moq;
using NUnit.Framework;
@@ -12,9 +10,8 @@
namespace NzbDrone.App.Test
{
[TestFixture]
- public class MonitoringProviderTest : TestBase
+ public class MonitoringProviderTest : TestBase
{
-
[Test]
public void Ensure_priority_doesnt_fail_on_invalid_iis_proccess_id()
{
@@ -23,18 +20,16 @@ public void Ensure_priority_doesnt_fail_on_invalid_iis_proccess_id()
Mocker.GetMock().Setup(c => c.GetProcessById(It.IsAny())).Returns((ProcessInfo)null);
- Mocker.Resolve().EnsurePriority(null);
+ Subject.EnsurePriority(null);
}
[Test]
public void Ensure_should_log_warn_exception_rather_than_throw()
{
Mocker.GetMock().Setup(c => c.GetCurrentProcess()).Throws();
- Mocker.Resolve().EnsurePriority(null);
+ Subject.EnsurePriority(null);
ExceptionVerification.ExpectedWarns(1);
}
-
-
}
}
diff --git a/NzbDrone.App.Test/NzbDrone.App.Test.csproj b/NzbDrone.App.Test/NzbDrone.App.Test.csproj
index 07122d8df..3eee2d4f3 100644
--- a/NzbDrone.App.Test/NzbDrone.App.Test.csproj
+++ b/NzbDrone.App.Test/NzbDrone.App.Test.csproj
@@ -86,12 +86,14 @@
-
+
+ App.config
+
@@ -99,6 +101,10 @@
{F2BE0FDF-6E47-4827-A420-DD4EF82407F8}
NzbDrone.Common
+
+ {ff5ee3b6-913b-47ce-9ceb-11c51b4e1205}
+ NzbDrone.Core
+
{CADDFCE0-7509-4430-8364-2074E1EEFCA2}
NzbDrone.Test.Common
diff --git a/NzbDrone.App.Test/RouterTest.cs b/NzbDrone.App.Test/RouterTest.cs
index 640838b6f..e0727af2f 100644
--- a/NzbDrone.App.Test/RouterTest.cs
+++ b/NzbDrone.App.Test/RouterTest.cs
@@ -8,7 +8,7 @@
namespace NzbDrone.App.Test
{
[TestFixture]
- public class RouterTest : TestBase
+ public class RouterTest : TestBase
{
[TestCase(null, ApplicationModes.Console)]
@@ -50,12 +50,12 @@ public void Route_should_call_install_service_when_application_mode_is_install()
serviceProviderMock.Setup(c => c.Start(ServiceProvider.NZBDRONE_SERVICE_NAME));
Mocker.GetMock().SetupGet(c => c.IsUserInteractive).Returns(true);
- Mocker.Resolve().Route(ApplicationModes.InstallService);
+ Subject.Route(ApplicationModes.InstallService);
serviceProviderMock.Verify(c => c.Install(ServiceProvider.NZBDRONE_SERVICE_NAME), Times.Once());
}
-
+
[Test]
public void Route_should_call_uninstall_service_when_application_mode_is_uninstall()
{
@@ -64,7 +64,7 @@ public void Route_should_call_uninstall_service_when_application_mode_is_uninsta
Mocker.GetMock().SetupGet(c => c.IsUserInteractive).Returns(true);
serviceProviderMock.Setup(c => c.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)).Returns(true);
- Mocker.Resolve().Route(ApplicationModes.UninstallService);
+ Subject.Route(ApplicationModes.UninstallService);
serviceProviderMock.Verify(c => c.UnInstall(ServiceProvider.NZBDRONE_SERVICE_NAME), Times.Once());
}
@@ -72,16 +72,13 @@ public void Route_should_call_uninstall_service_when_application_mode_is_uninsta
[Test]
public void Route_should_call_console_service_when_application_mode_is_console()
{
- var consoleProvider = Mocker.GetMock();
- var appServerProvider = Mocker.GetMock();
- consoleProvider.Setup(c => c.WaitForClose());
- appServerProvider.Setup(c => c.Start());
Mocker.GetMock().SetupGet(c => c.IsUserInteractive).Returns(true);
+ Mocker.GetMock().SetupGet(c => c.IsConsoleApplication).Returns(true);
- Mocker.Resolve().Route(ApplicationModes.Console);
+ Subject.Route(ApplicationModes.Console);
- consoleProvider.Verify(c => c.WaitForClose(), Times.Once());
- appServerProvider.Verify(c => c.Start(), Times.Once());
+ Mocker.GetMock().Verify(c => c.WaitForClose(), Times.Once());
+ Mocker.GetMock().Verify(c => c.Start(), Times.Once());
}
[TestCase(ApplicationModes.Console)]
@@ -97,7 +94,7 @@ public void Route_should_call_service_start_when_run_in_service_more(Application
serviceProvider.Setup(c => c.Run(It.IsAny()));
- Mocker.Resolve().Route(applicationModes);
+ Subject.Route(applicationModes);
serviceProvider.Verify(c => c.Run(It.IsAny()), Times.Once());
}
@@ -106,14 +103,14 @@ public void Route_should_call_service_start_when_run_in_service_more(Application
[Test]
public void show_error_on_install_if_service_already_exist()
{
- var consoleMock = Mocker.GetMock();
+ var consoleMock = Mocker.GetMock();
var serviceMock = Mocker.GetMock();
Mocker.GetMock().SetupGet(c => c.IsUserInteractive).Returns(true);
consoleMock.Setup(c => c.PrintServiceAlreadyExist());
serviceMock.Setup(c => c.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)).Returns(true);
- Mocker.Resolve().Route(ApplicationModes.InstallService);
+ Subject.Route(ApplicationModes.InstallService);
Mocker.VerifyAllMocks();
}
@@ -121,14 +118,14 @@ public void show_error_on_install_if_service_already_exist()
[Test]
public void show_error_on_uninstall_if_service_doesnt_exist()
{
- var consoleMock = Mocker.GetMock();
+ var consoleMock = Mocker.GetMock();
var serviceMock = Mocker.GetMock();
Mocker.GetMock().SetupGet(c => c.IsUserInteractive).Returns(true);
consoleMock.Setup(c => c.PrintServiceDoestExist());
serviceMock.Setup(c => c.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)).Returns(false);
- Mocker.Resolve().Route(ApplicationModes.UninstallService);
+ Subject.Route(ApplicationModes.UninstallService);
Mocker.VerifyAllMocks();
}
diff --git a/NzbDrone.Common.Test/DiskProviderFixture.cs b/NzbDrone.Common.Test/DiskProviderFixture.cs
index d385913ee..9ced34909 100644
--- a/NzbDrone.Common.Test/DiskProviderFixture.cs
+++ b/NzbDrone.Common.Test/DiskProviderFixture.cs
@@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Linq;
+using System.Reflection;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Test.Common;
@@ -10,26 +11,25 @@ namespace NzbDrone.Common.Test
[TestFixture]
public class DiskProviderFixture : TestBase
{
- DirectoryInfo BinFolder;
- DirectoryInfo BinFolderCopy;
- DirectoryInfo BinFolderMove;
+ DirectoryInfo _binFolder;
+ DirectoryInfo _binFolderCopy;
+ DirectoryInfo _binFolderMove;
[SetUp]
public void Setup()
{
- var binRoot = new DirectoryInfo(Directory.GetCurrentDirectory()).Parent.Parent;
- BinFolder = new DirectoryInfo(Path.Combine(binRoot.FullName, "bin"));
- BinFolderCopy = new DirectoryInfo(Path.Combine(binRoot.FullName, "bin_copy"));
- BinFolderMove = new DirectoryInfo(Path.Combine(binRoot.FullName, "bin_move"));
+ _binFolder = new DirectoryInfo(Directory.GetCurrentDirectory());
+ _binFolderCopy = new DirectoryInfo(Path.Combine(_binFolder.Parent.FullName, "bin_copy"));
+ _binFolderMove = new DirectoryInfo(Path.Combine(_binFolder.Parent.FullName, "bin_move"));
- if (BinFolderCopy.Exists)
+ if (_binFolderCopy.Exists)
{
- BinFolderCopy.Delete(true);
+ _binFolderCopy.Delete(true);
}
- if (BinFolderMove.Exists)
+ if (_binFolderMove.Exists)
{
- BinFolderMove.Delete(true);
+ _binFolderMove.Delete(true);
}
}
@@ -44,7 +44,7 @@ public void directory_exist_should_be_able_to_find_existing_unc_share()
{
Mocker.Resolve().FolderExists(@"\\localhost\c$").Should().BeTrue();
}
-
+
[Test]
public void directory_exist_should_not_be_able_to_find_none_existing_folder()
{
@@ -55,12 +55,12 @@ public void directory_exist_should_not_be_able_to_find_none_existing_folder()
public void moveFile_should_overwrite_existing_file()
{
var diskProvider = new DiskProvider();
- diskProvider.CopyDirectory(BinFolder.FullName, BinFolderCopy.FullName);
+ diskProvider.CopyDirectory(_binFolder.FullName, _binFolderCopy.FullName);
- var targetPath = Path.Combine(BinFolderCopy.FullName, "file.move");
+ var targetPath = Path.Combine(_binFolderCopy.FullName, "file.move");
- diskProvider.MoveFile(BinFolderCopy.GetFiles("*.dll", SearchOption.AllDirectories).First().FullName, targetPath);
- diskProvider.MoveFile(BinFolderCopy.GetFiles("*.pdb", SearchOption.AllDirectories).First().FullName, targetPath);
+ diskProvider.MoveFile(_binFolderCopy.GetFiles("*.dll", SearchOption.AllDirectories).First().FullName, targetPath);
+ diskProvider.MoveFile(_binFolderCopy.GetFiles("*.pdb", SearchOption.AllDirectories).First().FullName, targetPath);
File.Exists(targetPath).Should().BeTrue();
}
@@ -69,9 +69,9 @@ public void moveFile_should_overwrite_existing_file()
public void moveFile_should_not_move_overwrite_itself()
{
var diskProvider = new DiskProvider();
- diskProvider.CopyDirectory(BinFolder.FullName, BinFolderCopy.FullName);
+ diskProvider.CopyDirectory(_binFolder.FullName, _binFolderCopy.FullName);
- var targetPath = BinFolderCopy.GetFiles("*.dll", SearchOption.AllDirectories).First().FullName;
+ var targetPath = _binFolderCopy.GetFiles("*.dll", SearchOption.AllDirectories).First().FullName;
diskProvider.MoveFile(targetPath, targetPath);
@@ -82,11 +82,11 @@ public void moveFile_should_not_move_overwrite_itself()
[Test]
public void CopyFolder_should_copy_folder()
{
-
- var diskProvider = new DiskProvider();
- diskProvider.CopyDirectory(BinFolder.FullName, BinFolderCopy.FullName);
-
+ var diskProvider = new DiskProvider();
+ diskProvider.CopyDirectory(_binFolder.FullName, _binFolderCopy.FullName);
+
+
VerifyCopy();
}
@@ -94,18 +94,18 @@ public void CopyFolder_should_copy_folder()
[Test]
public void CopyFolder_should_overright_existing_folder()
{
-
+
var diskProvider = new DiskProvider();
- diskProvider.CopyDirectory(BinFolder.FullName, BinFolderCopy.FullName);
+ diskProvider.CopyDirectory(_binFolder.FullName, _binFolderCopy.FullName);
//Delete Random File
- BinFolderCopy.Refresh();
- BinFolderCopy.GetFiles("*.*", SearchOption.AllDirectories).First().Delete();
+ _binFolderCopy.Refresh();
+ _binFolderCopy.GetFiles("*.*", SearchOption.AllDirectories).First().Delete();
+
+ diskProvider.CopyDirectory(_binFolder.FullName, _binFolderCopy.FullName);
- diskProvider.CopyDirectory(BinFolder.FullName, BinFolderCopy.FullName);
-
VerifyCopy();
}
@@ -114,14 +114,14 @@ public void MoveFolder_should_overright_existing_folder()
{
var diskProvider = new DiskProvider();
- diskProvider.CopyDirectory(BinFolder.FullName, BinFolderCopy.FullName);
- diskProvider.CopyDirectory(BinFolder.FullName, BinFolderMove.FullName);
+ diskProvider.CopyDirectory(_binFolder.FullName, _binFolderCopy.FullName);
+ diskProvider.CopyDirectory(_binFolder.FullName, _binFolderMove.FullName);
VerifyCopy();
-
- diskProvider.MoveDirectory(BinFolderCopy.FullName, BinFolderMove.FullName);
-
+ diskProvider.MoveDirectory(_binFolderCopy.FullName, _binFolderMove.FullName);
+
+
VerifyMove();
}
@@ -169,8 +169,8 @@ public void folder_should_return_correct_value_for_last_write()
[Explicit]
public void check_last_write()
{
- Console.WriteLine(Mocker.Resolve().GetLastFolderWrite(@"C:\DRIVERS"));
- Console.WriteLine(new DirectoryInfo(@"C:\DRIVERS").LastWriteTimeUtc);
+ Console.WriteLine(Mocker.Resolve().GetLastFolderWrite(@"C:\DRIVERS"));
+ Console.WriteLine(new DirectoryInfo(@"C:\DRIVERS").LastWriteTimeUtc);
}
[Test]
@@ -187,27 +187,27 @@ public void IsChildOfPath_should_return_false_when_it_is_not_a_child()
private void VerifyCopy()
{
- BinFolder.Refresh();
- BinFolderCopy.Refresh();
+ _binFolder.Refresh();
+ _binFolderCopy.Refresh();
- BinFolderCopy.GetFiles("*.*", SearchOption.AllDirectories)
- .Should().HaveSameCount(BinFolder.GetFiles("*.*", SearchOption.AllDirectories));
+ _binFolderCopy.GetFiles("*.*", SearchOption.AllDirectories)
+ .Should().HaveSameCount(_binFolder.GetFiles("*.*", SearchOption.AllDirectories));
- BinFolderCopy.GetDirectories().Should().HaveSameCount(BinFolder.GetDirectories());
+ _binFolderCopy.GetDirectories().Should().HaveSameCount(_binFolder.GetDirectories());
}
private void VerifyMove()
{
- BinFolder.Refresh();
- BinFolderCopy.Refresh();
- BinFolderMove.Refresh();
+ _binFolder.Refresh();
+ _binFolderCopy.Refresh();
+ _binFolderMove.Refresh();
- BinFolderCopy.Exists.Should().BeFalse();
+ _binFolderCopy.Exists.Should().BeFalse();
- BinFolderMove.GetFiles("*.*", SearchOption.AllDirectories)
- .Should().HaveSameCount(BinFolder.GetFiles("*.*", SearchOption.AllDirectories));
+ _binFolderMove.GetFiles("*.*", SearchOption.AllDirectories)
+ .Should().HaveSameCount(_binFolder.GetFiles("*.*", SearchOption.AllDirectories));
- BinFolderMove.GetDirectories().Should().HaveSameCount(BinFolder.GetDirectories());
+ _binFolderMove.GetDirectories().Should().HaveSameCount(_binFolder.GetDirectories());
}
}
}
diff --git a/NzbDrone.Common.Test/NzbDrone.Common.Test.csproj b/NzbDrone.Common.Test/NzbDrone.Common.Test.csproj
index b7f47d49e..2d9b65164 100644
--- a/NzbDrone.Common.Test/NzbDrone.Common.Test.csproj
+++ b/NzbDrone.Common.Test/NzbDrone.Common.Test.csproj
@@ -90,6 +90,9 @@
+
+ App.config
+
diff --git a/NzbDrone.Common.Test/NzbDrone.Common.Test.ncrunchproject b/NzbDrone.Common.Test/NzbDrone.Common.Test.ncrunchproject
index a11e9b3c3..6fc4c6260 100644
--- a/NzbDrone.Common.Test/NzbDrone.Common.Test.ncrunchproject
+++ b/NzbDrone.Common.Test/NzbDrone.Common.Test.ncrunchproject
@@ -14,9 +14,11 @@
true
60000
-
+
AutoDetect
+ STA
+ x86
NzbDrone.Common.Test.EnviromentProviderTest.ApplicationPath_should_find_root_in_current_folder
@@ -34,7 +36,28 @@
NzbDrone.Common.Test.ServiceProviderTests.Should_be_able_to_start_and_stop_service
- .*
+ NzbDrone\.Common\.Test\.ConfigFileProviderTest\..*
+
+
+ NzbDrone\.Common\.Test\.EnvironmentProviderTest\..*
+
+
+ NzbDrone\.Common\.Test\.EventingTests\.ServiceNameFixture\..*
+
+
+ NzbDrone\.Common\.Test\.PathExtentionFixture\..*
+
+
+ NzbDrone\.Common\.Test\.ProcessProviderTests\..*
+
+
+ NzbDrone\.Common\.Test\.ReportingService_ReportParseError_Fixture\..*
+
+
+ NzbDrone\.Common\.Test\.ServiceProviderTests\..*
+
+
+ NzbDrone\.Common\.Test\.WebClientTests\..*
\ No newline at end of file
diff --git a/NzbDrone.Common.Test/PathExtentionFixture.cs b/NzbDrone.Common.Test/PathExtentionFixture.cs
index 2f54d8c07..a4420dced 100644
--- a/NzbDrone.Common.Test/PathExtentionFixture.cs
+++ b/NzbDrone.Common.Test/PathExtentionFixture.cs
@@ -34,25 +34,27 @@ public void Normalize_Path(string dirty, string clean)
}
[Test]
- [ExpectedException(typeof(ArgumentException), ExpectedMessage = "Path can not be null or empty")]
public void normalize_path_exception_empty()
{
- "".NormalizePath();
+ Assert.Throws(()=> "".NormalizePath());
+ ExceptionVerification.ExpectedWarns(1);
+
+
}
[Test]
- [ExpectedException(typeof(ArgumentException), ExpectedMessage = "Path can not be null or empty")]
public void normalize_path_exception_null()
{
string nullPath = null;
- nullPath.NormalizePath();
+ Assert.Throws(() => nullPath.NormalizePath());
+ ExceptionVerification.ExpectedWarns(1);
}
[Test]
public void AppDataDirectory_path_test()
{
- GetEnviromentProvider().GetAppDataPath().Should().BeEquivalentTo(@"C:\NzbDrone\NzbDrone.Web\App_Data\");
+ GetEnviromentProvider().GetAppDataPath().Should().BeEquivalentTo(@"C:\NzbDrone\App_Data\");
}
diff --git a/NzbDrone.Common/ConsoleProvider.cs b/NzbDrone.Common/ConsoleService.cs
similarity index 71%
rename from NzbDrone.Common/ConsoleProvider.cs
rename to NzbDrone.Common/ConsoleService.cs
index 7b9ce162a..6a2830876 100644
--- a/NzbDrone.Common/ConsoleProvider.cs
+++ b/NzbDrone.Common/ConsoleService.cs
@@ -4,14 +4,23 @@
namespace NzbDrone.Common
{
- public class ConsoleProvider
+ public interface IConsoleService
{
- public static bool IsConsoleApplication
+ bool IsConsoleApplication { get; }
+ void WaitForClose();
+ void PrintHelp();
+ void PrintServiceAlreadyExist();
+ void PrintServiceDoestExist();
+ }
+
+ public class ConsoleService : IConsoleService
+ {
+ public bool IsConsoleApplication
{
get { return Console.In != StreamReader.Null; }
}
- public virtual void WaitForClose()
+ public void WaitForClose()
{
while (true)
{
@@ -19,7 +28,7 @@ public virtual void WaitForClose()
}
}
- public virtual void PrintHelp()
+ public void PrintHelp()
{
Console.WriteLine();
Console.WriteLine(" Usage: {0} ", Process.GetCurrentProcess().MainModule.ModuleName);
@@ -29,12 +38,12 @@ public virtual void PrintHelp()
Console.WriteLine(" Run application in console mode.");
}
- public virtual void PrintServiceAlreadyExist()
+ public void PrintServiceAlreadyExist()
{
Console.WriteLine("A service with the same name ({0}) already exists. Aborting installation", ServiceProvider.NZBDRONE_SERVICE_NAME);
}
- public virtual void PrintServiceDoestExist()
+ public void PrintServiceDoestExist()
{
Console.WriteLine("Can't find service ({0})", ServiceProvider.NZBDRONE_SERVICE_NAME);
}
diff --git a/NzbDrone.Common/NzbDrone.Common.csproj b/NzbDrone.Common/NzbDrone.Common.csproj
index 9990c2b76..e94af7a0b 100644
--- a/NzbDrone.Common/NzbDrone.Common.csproj
+++ b/NzbDrone.Common/NzbDrone.Common.csproj
@@ -119,7 +119,7 @@
-
+
diff --git a/NzbDrone.Common/PathExtensions.cs b/NzbDrone.Common/PathExtensions.cs
index 9c4bb25b6..689b37563 100644
--- a/NzbDrone.Common/PathExtensions.cs
+++ b/NzbDrone.Common/PathExtensions.cs
@@ -22,9 +22,6 @@ public static string NormalizePath(this string path)
{
Ensure.That(() => path).IsNotNullOrWhiteSpace();
- if (String.IsNullOrWhiteSpace(path))
- throw new ArgumentException("Path can not be null or empty");
-
var info = new FileInfo(path);
if (info.FullName.StartsWith(@"\\")) //UNC
diff --git a/NzbDrone.Common/ServiceProvider.cs b/NzbDrone.Common/ServiceProvider.cs
index 7bebe5f20..8abddd963 100644
--- a/NzbDrone.Common/ServiceProvider.cs
+++ b/NzbDrone.Common/ServiceProvider.cs
@@ -66,7 +66,7 @@ public virtual void UnInstall(string serviceName)
Logger.Info("Uninstalling {0} service", serviceName);
Stop(serviceName);
-
+
var serviceInstaller = new ServiceInstaller();
var context = new InstallContext("service_uninstall.log", null);
@@ -84,9 +84,7 @@ public virtual void Run(ServiceBase service)
public virtual ServiceController GetService(string serviceName)
{
- return ServiceController.GetServices().Where(
- c => String.Equals(c.ServiceName, serviceName, StringComparison.InvariantCultureIgnoreCase))
- .FirstOrDefault();
+ return ServiceController.GetServices().FirstOrDefault(c => String.Equals(c.ServiceName, serviceName, StringComparison.InvariantCultureIgnoreCase));
}
public virtual void Stop(string serviceName)
diff --git a/NzbDrone.Core.Test/HelperTests/SortHelperTest.cs b/NzbDrone.Core.Test/HelperTests/SortHelperTest.cs
index ce2c5e5be..c1f31c0cd 100644
--- a/NzbDrone.Core.Test/HelperTests/SortHelperTest.cs
+++ b/NzbDrone.Core.Test/HelperTests/SortHelperTest.cs
@@ -6,7 +6,6 @@
namespace NzbDrone.Core.Test.HelperTests
{
[TestFixture]
-
public class SortHelperTest : CoreTest
{
[TestCase("The Office (US)", "Office (US)")]
diff --git a/NzbDrone.Core.Test/JobTests/PostDownloadScanJobFixture.cs b/NzbDrone.Core.Test/JobTests/PostDownloadScanJobFixture.cs
index 0b7a0e1e1..521fb1ec1 100644
--- a/NzbDrone.Core.Test/JobTests/PostDownloadScanJobFixture.cs
+++ b/NzbDrone.Core.Test/JobTests/PostDownloadScanJobFixture.cs
@@ -9,7 +9,7 @@
namespace NzbDrone.Core.Test.JobTests
{
[TestFixture]
- internal class PostDownloadScanJobFixture : CoreTest
+ public class PostDownloadScanJobFixture : CoreTest
{
[SetUp]
public void Setup()
diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
index dbaaecc8d..2d0e6ce4b 100644
--- a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
+++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
@@ -260,6 +260,9 @@
Always
+
+ App.config
+
Always
@@ -311,10 +314,6 @@
-
- Designer
- Always
-
Always
diff --git a/NzbDrone.Core.Test/ParserTests/ParserFixture.cs b/NzbDrone.Core.Test/ParserTests/ParserFixture.cs
index 6f159e318..bcd59206d 100644
--- a/NzbDrone.Core.Test/ParserTests/ParserFixture.cs
+++ b/NzbDrone.Core.Test/ParserTests/ParserFixture.cs
@@ -3,6 +3,7 @@
using FluentAssertions;
using Moq;
using NUnit.Framework;
+using NzbDrone.Common;
using NzbDrone.Common.Contract;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Model;
diff --git a/NzbDrone.Core.Test/Qualities/QualityFixture.cs b/NzbDrone.Core.Test/Qualities/QualityFixture.cs
index 08fb95802..827a4a643 100644
--- a/NzbDrone.Core.Test/Qualities/QualityFixture.cs
+++ b/NzbDrone.Core.Test/Qualities/QualityFixture.cs
@@ -7,7 +7,6 @@
namespace NzbDrone.Core.Test.Qualities
{
[TestFixture]
-
public class QualityFixture : CoreTest
{
public static object[] FromIntCases =
diff --git a/NzbDrone.Core.Test/UpdateTests/GetUpdateLogFixture.cs b/NzbDrone.Core.Test/UpdateTests/GetUpdateLogFixture.cs
index 0f45b7a27..eed45876f 100644
--- a/NzbDrone.Core.Test/UpdateTests/GetUpdateLogFixture.cs
+++ b/NzbDrone.Core.Test/UpdateTests/GetUpdateLogFixture.cs
@@ -7,7 +7,7 @@
namespace NzbDrone.Core.Test.UpdateTests
{
- class GetUpdateLogFixture : CoreTest
+ public class GetUpdateLogFixture : CoreTest
{
String _updateLogFolder;
diff --git a/NzbDrone.Core.Test/UpdateTests/UpdateServiceFixture.cs b/NzbDrone.Core.Test/UpdateTests/UpdateServiceFixture.cs
index b416c3601..f989ce825 100644
--- a/NzbDrone.Core.Test/UpdateTests/UpdateServiceFixture.cs
+++ b/NzbDrone.Core.Test/UpdateTests/UpdateServiceFixture.cs
@@ -13,7 +13,7 @@
namespace NzbDrone.Core.Test.UpdateTests
{
[TestFixture]
- internal class UpdateServiceFixture : CoreTest
+ public class UpdateServiceFixture : CoreTest
{
private string _sandboxFolder;
diff --git a/NzbDrone.Core.Test/App.config b/NzbDrone.Test.Common/App.config
similarity index 69%
rename from NzbDrone.Core.Test/App.config
rename to NzbDrone.Test.Common/App.config
index a7d3b0b7f..4a6e1d98a 100644
--- a/NzbDrone.Core.Test/App.config
+++ b/NzbDrone.Test.Common/App.config
@@ -1,7 +1,6 @@
-
@@ -10,6 +9,10 @@
+
+
+
+
\ No newline at end of file
diff --git a/NzbDrone.Test.Common/NzbDrone.Test.Common.csproj b/NzbDrone.Test.Common/NzbDrone.Test.Common.csproj
index 594a7e567..8d12bda0d 100644
--- a/NzbDrone.Test.Common/NzbDrone.Test.Common.csproj
+++ b/NzbDrone.Test.Common/NzbDrone.Test.Common.csproj
@@ -53,6 +53,9 @@
MinimumRecommendedRules.ruleset
+
+ ..\packages\FluentAssertions.2.0.1\lib\net40\FluentAssertions.dll
+
..\packages\CommonServiceLocator.1.0\lib\NET35\Microsoft.Practices.ServiceLocation.dll
@@ -99,6 +102,10 @@
+
+ Designer
+ Always
+
@@ -106,6 +113,10 @@
{F2BE0FDF-6E47-4827-A420-DD4EF82407F8}
NzbDrone.Common
+
+ {ff5ee3b6-913b-47ce-9ceb-11c51b4e1205}
+ NzbDrone.Core
+
diff --git a/NzbDrone.Test.Common/TestBase.cs b/NzbDrone.Test.Common/TestBase.cs
index 72de44c50..9143aa0f5 100644
--- a/NzbDrone.Test.Common/TestBase.cs
+++ b/NzbDrone.Test.Common/TestBase.cs
@@ -1,5 +1,6 @@
using System;
using System.IO;
+using FluentAssertions;
using Moq;
using NLog;
using NUnit.Framework;
@@ -69,6 +70,8 @@ private string VirtualPath
[SetUp]
public void TestBaseSetup()
{
+ GetType().IsPublic.Should().BeTrue("All Test fixtures should be public to work in mono.");
+
Mocker.SetConstant(LogManager.GetLogger("TestLogger"));
diff --git a/NzbDrone.Test.Common/packages.config b/NzbDrone.Test.Common/packages.config
index 8884f1059..df8a9c997 100644
--- a/NzbDrone.Test.Common/packages.config
+++ b/NzbDrone.Test.Common/packages.config
@@ -1,6 +1,7 @@
+
diff --git a/NzbDrone.Update.Test/NzbDrone.Update.Test.csproj b/NzbDrone.Update.Test/NzbDrone.Update.Test.csproj
index f9ba8f2c9..78193ac90 100644
--- a/NzbDrone.Update.Test/NzbDrone.Update.Test.csproj
+++ b/NzbDrone.Update.Test/NzbDrone.Update.Test.csproj
@@ -91,6 +91,9 @@
+
+ App.config
+
diff --git a/NzbDrone.Update.Test/UpdateProviderStartFixture.cs b/NzbDrone.Update.Test/UpdateProviderStartFixture.cs
index 37e59a598..65e527345 100644
--- a/NzbDrone.Update.Test/UpdateProviderStartFixture.cs
+++ b/NzbDrone.Update.Test/UpdateProviderStartFixture.cs
@@ -12,7 +12,7 @@
namespace NzbDrone.Update.Test
{
[TestFixture]
- class UpdateProviderStartFixture : TestBase
+ public class UpdateProviderStartFixture : TestBase
{
private const string UPDATE_FOLDER = @"C:\Temp\nzbdrone_update\nzbdrone\";
private const string BACKUP_FOLDER = @"C:\Temp\nzbdrone_update\nzbdrone_backup\";
diff --git a/NzbDrone.Update.Test/UpdateProviderVerifyFixture.cs b/NzbDrone.Update.Test/UpdateProviderVerifyFixture.cs
index 54f1a5c8b..c652680ef 100644
--- a/NzbDrone.Update.Test/UpdateProviderVerifyFixture.cs
+++ b/NzbDrone.Update.Test/UpdateProviderVerifyFixture.cs
@@ -11,7 +11,7 @@
namespace NzbDrone.Update.Test
{
[TestFixture]
- class UpdateProviderVerifyFixture : TestBase
+ public class UpdateProviderVerifyFixture : TestBase
{
diff --git a/NzbDrone.Update/NLog.config b/NzbDrone.Update/NLog.config
index 1bcb823d5..86e4b11e1 100644
--- a/NzbDrone.Update/NLog.config
+++ b/NzbDrone.Update/NLog.config
@@ -9,7 +9,6 @@
-
-
+
\ No newline at end of file
diff --git a/NzbDrone/ApplicationServer.cs b/NzbDrone/ApplicationServer.cs
index 4444e85bb..00bb9262c 100644
--- a/NzbDrone/ApplicationServer.cs
+++ b/NzbDrone/ApplicationServer.cs
@@ -3,24 +3,28 @@
using NLog;
using NzbDrone.Common;
-
namespace NzbDrone
{
- public class ApplicationServer : ServiceBase
+ public interface INzbDroneServiceFactory
{
- private static readonly Logger logger = LogManager.GetCurrentClassLogger();
+ ServiceBase Build();
+ void Start();
+ }
+ public class NzbDroneServiceFactory : ServiceBase, INzbDroneServiceFactory
+ {
private readonly ConfigFileProvider _configFileProvider;
private readonly EnvironmentProvider _environmentProvider;
private readonly IHostController _hostController;
private readonly ProcessProvider _processProvider;
private readonly PriorityMonitor _priorityMonitor;
private readonly SecurityProvider _securityProvider;
+ private readonly Logger _logger;
- public ApplicationServer(ConfigFileProvider configFileProvider, IHostController hostController,
+ public NzbDroneServiceFactory(ConfigFileProvider configFileProvider, IHostController hostController,
EnvironmentProvider environmentProvider,
ProcessProvider processProvider, PriorityMonitor priorityMonitor,
- SecurityProvider securityProvider)
+ SecurityProvider securityProvider, Logger logger)
{
_configFileProvider = configFileProvider;
_hostController = hostController;
@@ -28,6 +32,7 @@ public ApplicationServer(ConfigFileProvider configFileProvider, IHostController
_processProvider = processProvider;
_priorityMonitor = priorityMonitor;
_securityProvider = securityProvider;
+ _logger = logger;
}
protected override void OnStart(string[] args)
@@ -35,7 +40,7 @@ protected override void OnStart(string[] args)
Start();
}
- public virtual void Start()
+ public void Start()
{
_securityProvider.MakeAccessible();
@@ -45,12 +50,12 @@ public virtual void Start()
{
try
{
- logger.Info("Starting default browser. {0}", _hostController.AppUrl);
+ _logger.Info("Starting default browser. {0}", _hostController.AppUrl);
_processProvider.Start(_hostController.AppUrl);
}
catch (Exception e)
{
- logger.ErrorException("Failed to open URL in default browser.", e);
+ _logger.ErrorException("Failed to open URL in default browser.", e);
}
}
@@ -59,9 +64,15 @@ public virtual void Start()
protected override void OnStop()
{
- logger.Info("Attempting to stop application.");
+ _logger.Info("Attempting to stop application.");
_hostController.StopServer();
- logger.Info("Application has finished stop routine.");
+ _logger.Info("Application has finished stop routine.");
+ }
+
+ public ServiceBase Build()
+ {
+ return this;
}
}
+
}
\ No newline at end of file
diff --git a/NzbDrone/Router.cs b/NzbDrone/Router.cs
index 0996b128b..ad0cbe8f5 100644
--- a/NzbDrone/Router.cs
+++ b/NzbDrone/Router.cs
@@ -9,19 +9,19 @@ namespace NzbDrone
{
public class Router
{
- private readonly ApplicationServer _applicationServer;
+ private readonly INzbDroneServiceFactory _nzbDroneServiceFactory;
private readonly ServiceProvider _serviceProvider;
- private readonly ConsoleProvider _consoleProvider;
+ private readonly IConsoleService _consoleService;
private readonly EnvironmentProvider _environmentProvider;
private readonly SysTrayProvider _sysTrayProvider;
private readonly Logger _logger;
- public Router(ApplicationServer applicationServer, ServiceProvider serviceProvider,
- ConsoleProvider consoleProvider, EnvironmentProvider environmentProvider, SysTrayProvider sysTrayProvider, Logger logger)
+ public Router(INzbDroneServiceFactory nzbDroneServiceFactory, ServiceProvider serviceProvider,
+ IConsoleService consoleService, EnvironmentProvider environmentProvider, SysTrayProvider sysTrayProvider, Logger logger)
{
- _applicationServer = applicationServer;
+ _nzbDroneServiceFactory = nzbDroneServiceFactory;
_serviceProvider = serviceProvider;
- _consoleProvider = consoleProvider;
+ _consoleService = consoleService;
_environmentProvider = environmentProvider;
_sysTrayProvider = sysTrayProvider;
_logger = logger;
@@ -46,17 +46,18 @@ public void Route(ApplicationModes applicationModes)
case ApplicationModes.Service:
{
_logger.Trace("Service selected");
- _serviceProvider.Run(_applicationServer);
+ _serviceProvider.Run(_nzbDroneServiceFactory.Build());
break;
}
case ApplicationModes.Console:
{
_logger.Trace("Console selected");
- _applicationServer.Start();
- if (ConsoleProvider.IsConsoleApplication)
- _consoleProvider.WaitForClose();
-
+ _nzbDroneServiceFactory.Start();
+ if (_consoleService.IsConsoleApplication)
+ {
+ _consoleService.WaitForClose();
+ }
else
{
_sysTrayProvider.Start();
@@ -69,7 +70,7 @@ public void Route(ApplicationModes applicationModes)
_logger.Trace("Install Service selected");
if (_serviceProvider.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME))
{
- _consoleProvider.PrintServiceAlreadyExist();
+ _consoleService.PrintServiceAlreadyExist();
}
else
{
@@ -83,7 +84,7 @@ public void Route(ApplicationModes applicationModes)
_logger.Trace("Uninstall Service selected");
if (!_serviceProvider.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME))
{
- _consoleProvider.PrintServiceDoestExist();
+ _consoleService.PrintServiceDoestExist();
}
else
{
@@ -94,7 +95,7 @@ public void Route(ApplicationModes applicationModes)
}
default:
{
- _consoleProvider.PrintHelp();
+ _consoleService.PrintHelp();
break;
}
}
diff --git a/NzbDrone/app.config b/NzbDrone/app.config
index d056611a0..d4319d1f4 100644
--- a/NzbDrone/app.config
+++ b/NzbDrone/app.config
@@ -6,10 +6,6 @@
-
-
-
-