fixed more tests.
This commit is contained in:
parent
9fdfd13dbf
commit
b03388f7b9
|
@ -74,12 +74,19 @@
|
||||||
<Project>{f2be0fdf-6e47-4827-a420-dd4ef82407f8}</Project>
|
<Project>{f2be0fdf-6e47-4827-a420-dd4ef82407f8}</Project>
|
||||||
<Name>NzbDrone.Common</Name>
|
<Name>NzbDrone.Common</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\NzbDrone.Core\NzbDrone.Core.csproj">
|
||||||
|
<Project>{ff5ee3b6-913b-47ce-9ceb-11c51b4e1205}</Project>
|
||||||
|
<Name>NzbDrone.Core</Name>
|
||||||
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\NzbDrone.Test.Common\NzbDrone.Test.Common.csproj">
|
<ProjectReference Include="..\NzbDrone.Test.Common\NzbDrone.Test.Common.csproj">
|
||||||
<Project>{CADDFCE0-7509-4430-8364-2074E1EEFCA2}</Project>
|
<Project>{CADDFCE0-7509-4430-8364-2074E1EEFCA2}</Project>
|
||||||
<Name>NzbDrone.Test.Common</Name>
|
<Name>NzbDrone.Test.Common</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<None Include="..\NzbDrone.Test.Common\App.config">
|
||||||
|
<Link>App.config</Link>
|
||||||
|
</None>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
|
|
@ -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<ProcessProvider>()
|
|
||||||
// .Setup(c => c.Start(It.IsAny<ProcessStartInfo>()))
|
|
||||||
// .Returns(dummy);
|
|
||||||
|
|
||||||
// Mocker.Resolve<IISProvider>().StartServer();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [Test]
|
|
||||||
// public void should_set_iis_procces_id()
|
|
||||||
// {
|
|
||||||
// WithTempAsAppPath();
|
|
||||||
// var dummy = StartDummyProcess();
|
|
||||||
|
|
||||||
// Mocker.GetMock<ProcessProvider>()
|
|
||||||
// .Setup(c => c.Start(It.IsAny<ProcessStartInfo>()))
|
|
||||||
// .Returns(dummy);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Mocker.Resolve<IISProvider>().StartServer();
|
|
||||||
|
|
||||||
//
|
|
||||||
// Mocker.Resolve<IISProvider>().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);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// }
|
|
||||||
//}
|
|
|
@ -1,7 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
using FizzWare.NBuilder;
|
using FizzWare.NBuilder;
|
||||||
using Moq;
|
using Moq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
@ -12,9 +10,8 @@ using NzbDrone.Test.Common;
|
||||||
namespace NzbDrone.App.Test
|
namespace NzbDrone.App.Test
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class MonitoringProviderTest : TestBase
|
public class MonitoringProviderTest : TestBase<PriorityMonitor>
|
||||||
{
|
{
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void Ensure_priority_doesnt_fail_on_invalid_iis_proccess_id()
|
public void Ensure_priority_doesnt_fail_on_invalid_iis_proccess_id()
|
||||||
{
|
{
|
||||||
|
@ -23,18 +20,16 @@ namespace NzbDrone.App.Test
|
||||||
|
|
||||||
Mocker.GetMock<ProcessProvider>().Setup(c => c.GetProcessById(It.IsAny<int>())).Returns((ProcessInfo)null);
|
Mocker.GetMock<ProcessProvider>().Setup(c => c.GetProcessById(It.IsAny<int>())).Returns((ProcessInfo)null);
|
||||||
|
|
||||||
Mocker.Resolve<PriorityMonitor>().EnsurePriority(null);
|
Subject.EnsurePriority(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void Ensure_should_log_warn_exception_rather_than_throw()
|
public void Ensure_should_log_warn_exception_rather_than_throw()
|
||||||
{
|
{
|
||||||
Mocker.GetMock<ProcessProvider>().Setup(c => c.GetCurrentProcess()).Throws<InvalidOperationException>();
|
Mocker.GetMock<ProcessProvider>().Setup(c => c.GetCurrentProcess()).Throws<InvalidOperationException>();
|
||||||
Mocker.Resolve<PriorityMonitor>().EnsurePriority(null);
|
Subject.EnsurePriority(null);
|
||||||
|
|
||||||
ExceptionVerification.ExpectedWarns(1);
|
ExceptionVerification.ExpectedWarns(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,12 +86,14 @@
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="IISProviderFixture.cs" />
|
|
||||||
<Compile Include="RouterTest.cs" />
|
<Compile Include="RouterTest.cs" />
|
||||||
<Compile Include="MonitoringProviderTest.cs" />
|
<Compile Include="MonitoringProviderTest.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<None Include="..\NzbDrone.Test.Common\App.config">
|
||||||
|
<Link>App.config</Link>
|
||||||
|
</None>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -99,6 +101,10 @@
|
||||||
<Project>{F2BE0FDF-6E47-4827-A420-DD4EF82407F8}</Project>
|
<Project>{F2BE0FDF-6E47-4827-A420-DD4EF82407F8}</Project>
|
||||||
<Name>NzbDrone.Common</Name>
|
<Name>NzbDrone.Common</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\NzbDrone.Core\NzbDrone.Core.csproj">
|
||||||
|
<Project>{ff5ee3b6-913b-47ce-9ceb-11c51b4e1205}</Project>
|
||||||
|
<Name>NzbDrone.Core</Name>
|
||||||
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\NzbDrone.Test.Common\NzbDrone.Test.Common.csproj">
|
<ProjectReference Include="..\NzbDrone.Test.Common\NzbDrone.Test.Common.csproj">
|
||||||
<Project>{CADDFCE0-7509-4430-8364-2074E1EEFCA2}</Project>
|
<Project>{CADDFCE0-7509-4430-8364-2074E1EEFCA2}</Project>
|
||||||
<Name>NzbDrone.Test.Common</Name>
|
<Name>NzbDrone.Test.Common</Name>
|
||||||
|
|
|
@ -8,7 +8,7 @@ using NzbDrone.Test.Common;
|
||||||
namespace NzbDrone.App.Test
|
namespace NzbDrone.App.Test
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class RouterTest : TestBase
|
public class RouterTest : TestBase<Router>
|
||||||
{
|
{
|
||||||
|
|
||||||
[TestCase(null, ApplicationModes.Console)]
|
[TestCase(null, ApplicationModes.Console)]
|
||||||
|
@ -50,7 +50,7 @@ namespace NzbDrone.App.Test
|
||||||
serviceProviderMock.Setup(c => c.Start(ServiceProvider.NZBDRONE_SERVICE_NAME));
|
serviceProviderMock.Setup(c => c.Start(ServiceProvider.NZBDRONE_SERVICE_NAME));
|
||||||
Mocker.GetMock<EnvironmentProvider>().SetupGet(c => c.IsUserInteractive).Returns(true);
|
Mocker.GetMock<EnvironmentProvider>().SetupGet(c => c.IsUserInteractive).Returns(true);
|
||||||
|
|
||||||
Mocker.Resolve<Router>().Route(ApplicationModes.InstallService);
|
Subject.Route(ApplicationModes.InstallService);
|
||||||
|
|
||||||
serviceProviderMock.Verify(c => c.Install(ServiceProvider.NZBDRONE_SERVICE_NAME), Times.Once());
|
serviceProviderMock.Verify(c => c.Install(ServiceProvider.NZBDRONE_SERVICE_NAME), Times.Once());
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ namespace NzbDrone.App.Test
|
||||||
Mocker.GetMock<EnvironmentProvider>().SetupGet(c => c.IsUserInteractive).Returns(true);
|
Mocker.GetMock<EnvironmentProvider>().SetupGet(c => c.IsUserInteractive).Returns(true);
|
||||||
serviceProviderMock.Setup(c => c.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)).Returns(true);
|
serviceProviderMock.Setup(c => c.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)).Returns(true);
|
||||||
|
|
||||||
Mocker.Resolve<Router>().Route(ApplicationModes.UninstallService);
|
Subject.Route(ApplicationModes.UninstallService);
|
||||||
|
|
||||||
serviceProviderMock.Verify(c => c.UnInstall(ServiceProvider.NZBDRONE_SERVICE_NAME), Times.Once());
|
serviceProviderMock.Verify(c => c.UnInstall(ServiceProvider.NZBDRONE_SERVICE_NAME), Times.Once());
|
||||||
}
|
}
|
||||||
|
@ -72,16 +72,13 @@ namespace NzbDrone.App.Test
|
||||||
[Test]
|
[Test]
|
||||||
public void Route_should_call_console_service_when_application_mode_is_console()
|
public void Route_should_call_console_service_when_application_mode_is_console()
|
||||||
{
|
{
|
||||||
var consoleProvider = Mocker.GetMock<ConsoleProvider>();
|
|
||||||
var appServerProvider = Mocker.GetMock<ApplicationServer>();
|
|
||||||
consoleProvider.Setup(c => c.WaitForClose());
|
|
||||||
appServerProvider.Setup(c => c.Start());
|
|
||||||
Mocker.GetMock<EnvironmentProvider>().SetupGet(c => c.IsUserInteractive).Returns(true);
|
Mocker.GetMock<EnvironmentProvider>().SetupGet(c => c.IsUserInteractive).Returns(true);
|
||||||
|
Mocker.GetMock<IConsoleService>().SetupGet(c => c.IsConsoleApplication).Returns(true);
|
||||||
|
|
||||||
Mocker.Resolve<Router>().Route(ApplicationModes.Console);
|
Subject.Route(ApplicationModes.Console);
|
||||||
|
|
||||||
consoleProvider.Verify(c => c.WaitForClose(), Times.Once());
|
Mocker.GetMock<IConsoleService>().Verify(c => c.WaitForClose(), Times.Once());
|
||||||
appServerProvider.Verify(c => c.Start(), Times.Once());
|
Mocker.GetMock<INzbDroneServiceFactory>().Verify(c => c.Start(), Times.Once());
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase(ApplicationModes.Console)]
|
[TestCase(ApplicationModes.Console)]
|
||||||
|
@ -97,7 +94,7 @@ namespace NzbDrone.App.Test
|
||||||
|
|
||||||
serviceProvider.Setup(c => c.Run(It.IsAny<ServiceBase>()));
|
serviceProvider.Setup(c => c.Run(It.IsAny<ServiceBase>()));
|
||||||
|
|
||||||
Mocker.Resolve<Router>().Route(applicationModes);
|
Subject.Route(applicationModes);
|
||||||
|
|
||||||
serviceProvider.Verify(c => c.Run(It.IsAny<ServiceBase>()), Times.Once());
|
serviceProvider.Verify(c => c.Run(It.IsAny<ServiceBase>()), Times.Once());
|
||||||
}
|
}
|
||||||
|
@ -106,14 +103,14 @@ namespace NzbDrone.App.Test
|
||||||
[Test]
|
[Test]
|
||||||
public void show_error_on_install_if_service_already_exist()
|
public void show_error_on_install_if_service_already_exist()
|
||||||
{
|
{
|
||||||
var consoleMock = Mocker.GetMock<ConsoleProvider>();
|
var consoleMock = Mocker.GetMock<IConsoleService>();
|
||||||
var serviceMock = Mocker.GetMock<ServiceProvider>();
|
var serviceMock = Mocker.GetMock<ServiceProvider>();
|
||||||
Mocker.GetMock<EnvironmentProvider>().SetupGet(c => c.IsUserInteractive).Returns(true);
|
Mocker.GetMock<EnvironmentProvider>().SetupGet(c => c.IsUserInteractive).Returns(true);
|
||||||
|
|
||||||
consoleMock.Setup(c => c.PrintServiceAlreadyExist());
|
consoleMock.Setup(c => c.PrintServiceAlreadyExist());
|
||||||
serviceMock.Setup(c => c.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)).Returns(true);
|
serviceMock.Setup(c => c.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)).Returns(true);
|
||||||
|
|
||||||
Mocker.Resolve<Router>().Route(ApplicationModes.InstallService);
|
Subject.Route(ApplicationModes.InstallService);
|
||||||
|
|
||||||
Mocker.VerifyAllMocks();
|
Mocker.VerifyAllMocks();
|
||||||
}
|
}
|
||||||
|
@ -121,14 +118,14 @@ namespace NzbDrone.App.Test
|
||||||
[Test]
|
[Test]
|
||||||
public void show_error_on_uninstall_if_service_doesnt_exist()
|
public void show_error_on_uninstall_if_service_doesnt_exist()
|
||||||
{
|
{
|
||||||
var consoleMock = Mocker.GetMock<ConsoleProvider>();
|
var consoleMock = Mocker.GetMock<IConsoleService>();
|
||||||
var serviceMock = Mocker.GetMock<ServiceProvider>();
|
var serviceMock = Mocker.GetMock<ServiceProvider>();
|
||||||
Mocker.GetMock<EnvironmentProvider>().SetupGet(c => c.IsUserInteractive).Returns(true);
|
Mocker.GetMock<EnvironmentProvider>().SetupGet(c => c.IsUserInteractive).Returns(true);
|
||||||
|
|
||||||
consoleMock.Setup(c => c.PrintServiceDoestExist());
|
consoleMock.Setup(c => c.PrintServiceDoestExist());
|
||||||
serviceMock.Setup(c => c.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)).Returns(false);
|
serviceMock.Setup(c => c.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)).Returns(false);
|
||||||
|
|
||||||
Mocker.Resolve<Router>().Route(ApplicationModes.UninstallService);
|
Subject.Route(ApplicationModes.UninstallService);
|
||||||
|
|
||||||
Mocker.VerifyAllMocks();
|
Mocker.VerifyAllMocks();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
|
@ -10,26 +11,25 @@ namespace NzbDrone.Common.Test
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class DiskProviderFixture : TestBase
|
public class DiskProviderFixture : TestBase
|
||||||
{
|
{
|
||||||
DirectoryInfo BinFolder;
|
DirectoryInfo _binFolder;
|
||||||
DirectoryInfo BinFolderCopy;
|
DirectoryInfo _binFolderCopy;
|
||||||
DirectoryInfo BinFolderMove;
|
DirectoryInfo _binFolderMove;
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup()
|
public void Setup()
|
||||||
{
|
{
|
||||||
var binRoot = new DirectoryInfo(Directory.GetCurrentDirectory()).Parent.Parent;
|
_binFolder = new DirectoryInfo(Directory.GetCurrentDirectory());
|
||||||
BinFolder = new DirectoryInfo(Path.Combine(binRoot.FullName, "bin"));
|
_binFolderCopy = new DirectoryInfo(Path.Combine(_binFolder.Parent.FullName, "bin_copy"));
|
||||||
BinFolderCopy = new DirectoryInfo(Path.Combine(binRoot.FullName, "bin_copy"));
|
_binFolderMove = new DirectoryInfo(Path.Combine(_binFolder.Parent.FullName, "bin_move"));
|
||||||
BinFolderMove = new DirectoryInfo(Path.Combine(binRoot.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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,12 +55,12 @@ namespace NzbDrone.Common.Test
|
||||||
public void moveFile_should_overwrite_existing_file()
|
public void moveFile_should_overwrite_existing_file()
|
||||||
{
|
{
|
||||||
var diskProvider = new DiskProvider();
|
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("*.dll", SearchOption.AllDirectories).First().FullName, targetPath);
|
||||||
diskProvider.MoveFile(BinFolderCopy.GetFiles("*.pdb", SearchOption.AllDirectories).First().FullName, targetPath);
|
diskProvider.MoveFile(_binFolderCopy.GetFiles("*.pdb", SearchOption.AllDirectories).First().FullName, targetPath);
|
||||||
|
|
||||||
File.Exists(targetPath).Should().BeTrue();
|
File.Exists(targetPath).Should().BeTrue();
|
||||||
}
|
}
|
||||||
|
@ -69,9 +69,9 @@ namespace NzbDrone.Common.Test
|
||||||
public void moveFile_should_not_move_overwrite_itself()
|
public void moveFile_should_not_move_overwrite_itself()
|
||||||
{
|
{
|
||||||
var diskProvider = new DiskProvider();
|
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);
|
diskProvider.MoveFile(targetPath, targetPath);
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ namespace NzbDrone.Common.Test
|
||||||
{
|
{
|
||||||
|
|
||||||
var diskProvider = new DiskProvider();
|
var diskProvider = new DiskProvider();
|
||||||
diskProvider.CopyDirectory(BinFolder.FullName, BinFolderCopy.FullName);
|
diskProvider.CopyDirectory(_binFolder.FullName, _binFolderCopy.FullName);
|
||||||
|
|
||||||
|
|
||||||
VerifyCopy();
|
VerifyCopy();
|
||||||
|
@ -97,13 +97,13 @@ namespace NzbDrone.Common.Test
|
||||||
|
|
||||||
var diskProvider = new DiskProvider();
|
var diskProvider = new DiskProvider();
|
||||||
|
|
||||||
diskProvider.CopyDirectory(BinFolder.FullName, BinFolderCopy.FullName);
|
diskProvider.CopyDirectory(_binFolder.FullName, _binFolderCopy.FullName);
|
||||||
|
|
||||||
//Delete Random File
|
//Delete Random File
|
||||||
BinFolderCopy.Refresh();
|
_binFolderCopy.Refresh();
|
||||||
BinFolderCopy.GetFiles("*.*", SearchOption.AllDirectories).First().Delete();
|
_binFolderCopy.GetFiles("*.*", SearchOption.AllDirectories).First().Delete();
|
||||||
|
|
||||||
diskProvider.CopyDirectory(BinFolder.FullName, BinFolderCopy.FullName);
|
diskProvider.CopyDirectory(_binFolder.FullName, _binFolderCopy.FullName);
|
||||||
|
|
||||||
|
|
||||||
VerifyCopy();
|
VerifyCopy();
|
||||||
|
@ -114,12 +114,12 @@ namespace NzbDrone.Common.Test
|
||||||
{
|
{
|
||||||
var diskProvider = new DiskProvider();
|
var diskProvider = new DiskProvider();
|
||||||
|
|
||||||
diskProvider.CopyDirectory(BinFolder.FullName, BinFolderCopy.FullName);
|
diskProvider.CopyDirectory(_binFolder.FullName, _binFolderCopy.FullName);
|
||||||
diskProvider.CopyDirectory(BinFolder.FullName, BinFolderMove.FullName);
|
diskProvider.CopyDirectory(_binFolder.FullName, _binFolderMove.FullName);
|
||||||
VerifyCopy();
|
VerifyCopy();
|
||||||
|
|
||||||
|
|
||||||
diskProvider.MoveDirectory(BinFolderCopy.FullName, BinFolderMove.FullName);
|
diskProvider.MoveDirectory(_binFolderCopy.FullName, _binFolderMove.FullName);
|
||||||
|
|
||||||
|
|
||||||
VerifyMove();
|
VerifyMove();
|
||||||
|
@ -169,8 +169,8 @@ namespace NzbDrone.Common.Test
|
||||||
[Explicit]
|
[Explicit]
|
||||||
public void check_last_write()
|
public void check_last_write()
|
||||||
{
|
{
|
||||||
Console.WriteLine(Mocker.Resolve<DiskProvider>().GetLastFolderWrite(@"C:\DRIVERS"));
|
Console.WriteLine(Mocker.Resolve<DiskProvider>().GetLastFolderWrite(@"C:\DRIVERS"));
|
||||||
Console.WriteLine(new DirectoryInfo(@"C:\DRIVERS").LastWriteTimeUtc);
|
Console.WriteLine(new DirectoryInfo(@"C:\DRIVERS").LastWriteTimeUtc);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -187,27 +187,27 @@ namespace NzbDrone.Common.Test
|
||||||
|
|
||||||
private void VerifyCopy()
|
private void VerifyCopy()
|
||||||
{
|
{
|
||||||
BinFolder.Refresh();
|
_binFolder.Refresh();
|
||||||
BinFolderCopy.Refresh();
|
_binFolderCopy.Refresh();
|
||||||
|
|
||||||
BinFolderCopy.GetFiles("*.*", SearchOption.AllDirectories)
|
_binFolderCopy.GetFiles("*.*", SearchOption.AllDirectories)
|
||||||
.Should().HaveSameCount(BinFolder.GetFiles("*.*", SearchOption.AllDirectories));
|
.Should().HaveSameCount(_binFolder.GetFiles("*.*", SearchOption.AllDirectories));
|
||||||
|
|
||||||
BinFolderCopy.GetDirectories().Should().HaveSameCount(BinFolder.GetDirectories());
|
_binFolderCopy.GetDirectories().Should().HaveSameCount(_binFolder.GetDirectories());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void VerifyMove()
|
private void VerifyMove()
|
||||||
{
|
{
|
||||||
BinFolder.Refresh();
|
_binFolder.Refresh();
|
||||||
BinFolderCopy.Refresh();
|
_binFolderCopy.Refresh();
|
||||||
BinFolderMove.Refresh();
|
_binFolderMove.Refresh();
|
||||||
|
|
||||||
BinFolderCopy.Exists.Should().BeFalse();
|
_binFolderCopy.Exists.Should().BeFalse();
|
||||||
|
|
||||||
BinFolderMove.GetFiles("*.*", SearchOption.AllDirectories)
|
_binFolderMove.GetFiles("*.*", SearchOption.AllDirectories)
|
||||||
.Should().HaveSameCount(BinFolder.GetFiles("*.*", SearchOption.AllDirectories));
|
.Should().HaveSameCount(_binFolder.GetFiles("*.*", SearchOption.AllDirectories));
|
||||||
|
|
||||||
BinFolderMove.GetDirectories().Should().HaveSameCount(BinFolder.GetDirectories());
|
_binFolderMove.GetDirectories().Should().HaveSameCount(_binFolder.GetDirectories());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,6 +90,9 @@
|
||||||
<Compile Include="WebClientTests.cs" />
|
<Compile Include="WebClientTests.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<None Include="..\NzbDrone.Test.Common\App.config">
|
||||||
|
<Link>App.config</Link>
|
||||||
|
</None>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -14,9 +14,11 @@
|
||||||
<IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace>
|
<IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace>
|
||||||
<DefaultTestTimeout>60000</DefaultTestTimeout>
|
<DefaultTestTimeout>60000</DefaultTestTimeout>
|
||||||
<UseBuildConfiguration></UseBuildConfiguration>
|
<UseBuildConfiguration></UseBuildConfiguration>
|
||||||
<UseBuildPlatform />
|
<UseBuildPlatform></UseBuildPlatform>
|
||||||
<ProxyProcessPath></ProxyProcessPath>
|
<ProxyProcessPath></ProxyProcessPath>
|
||||||
<UseCPUArchitecture>AutoDetect</UseCPUArchitecture>
|
<UseCPUArchitecture>AutoDetect</UseCPUArchitecture>
|
||||||
|
<MSTestThreadApartmentState>STA</MSTestThreadApartmentState>
|
||||||
|
<BuildProcessArchitecture>x86</BuildProcessArchitecture>
|
||||||
<IgnoredTests>
|
<IgnoredTests>
|
||||||
<NamedTestSelector>
|
<NamedTestSelector>
|
||||||
<TestName>NzbDrone.Common.Test.EnviromentProviderTest.ApplicationPath_should_find_root_in_current_folder</TestName>
|
<TestName>NzbDrone.Common.Test.EnviromentProviderTest.ApplicationPath_should_find_root_in_current_folder</TestName>
|
||||||
|
@ -34,7 +36,28 @@
|
||||||
<TestName>NzbDrone.Common.Test.ServiceProviderTests.Should_be_able_to_start_and_stop_service</TestName>
|
<TestName>NzbDrone.Common.Test.ServiceProviderTests.Should_be_able_to_start_and_stop_service</TestName>
|
||||||
</NamedTestSelector>
|
</NamedTestSelector>
|
||||||
<RegexTestSelector>
|
<RegexTestSelector>
|
||||||
<RegularExpression>.*</RegularExpression>
|
<RegularExpression>NzbDrone\.Common\.Test\.ConfigFileProviderTest\..*</RegularExpression>
|
||||||
|
</RegexTestSelector>
|
||||||
|
<RegexTestSelector>
|
||||||
|
<RegularExpression>NzbDrone\.Common\.Test\.EnvironmentProviderTest\..*</RegularExpression>
|
||||||
|
</RegexTestSelector>
|
||||||
|
<RegexTestSelector>
|
||||||
|
<RegularExpression>NzbDrone\.Common\.Test\.EventingTests\.ServiceNameFixture\..*</RegularExpression>
|
||||||
|
</RegexTestSelector>
|
||||||
|
<RegexTestSelector>
|
||||||
|
<RegularExpression>NzbDrone\.Common\.Test\.PathExtentionFixture\..*</RegularExpression>
|
||||||
|
</RegexTestSelector>
|
||||||
|
<RegexTestSelector>
|
||||||
|
<RegularExpression>NzbDrone\.Common\.Test\.ProcessProviderTests\..*</RegularExpression>
|
||||||
|
</RegexTestSelector>
|
||||||
|
<RegexTestSelector>
|
||||||
|
<RegularExpression>NzbDrone\.Common\.Test\.ReportingService_ReportParseError_Fixture\..*</RegularExpression>
|
||||||
|
</RegexTestSelector>
|
||||||
|
<RegexTestSelector>
|
||||||
|
<RegularExpression>NzbDrone\.Common\.Test\.ServiceProviderTests\..*</RegularExpression>
|
||||||
|
</RegexTestSelector>
|
||||||
|
<RegexTestSelector>
|
||||||
|
<RegularExpression>NzbDrone\.Common\.Test\.WebClientTests\..*</RegularExpression>
|
||||||
</RegexTestSelector>
|
</RegexTestSelector>
|
||||||
</IgnoredTests>
|
</IgnoredTests>
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
|
@ -34,25 +34,27 @@ namespace NzbDrone.Common.Test
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
[ExpectedException(typeof(ArgumentException), ExpectedMessage = "Path can not be null or empty")]
|
|
||||||
public void normalize_path_exception_empty()
|
public void normalize_path_exception_empty()
|
||||||
{
|
{
|
||||||
"".NormalizePath();
|
Assert.Throws<ArgumentException>(()=> "".NormalizePath());
|
||||||
|
ExceptionVerification.ExpectedWarns(1);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
[ExpectedException(typeof(ArgumentException), ExpectedMessage = "Path can not be null or empty")]
|
|
||||||
public void normalize_path_exception_null()
|
public void normalize_path_exception_null()
|
||||||
{
|
{
|
||||||
string nullPath = null;
|
string nullPath = null;
|
||||||
nullPath.NormalizePath();
|
Assert.Throws<ArgumentException>(() => nullPath.NormalizePath());
|
||||||
|
ExceptionVerification.ExpectedWarns(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void AppDataDirectory_path_test()
|
public void AppDataDirectory_path_test()
|
||||||
{
|
{
|
||||||
GetEnviromentProvider().GetAppDataPath().Should().BeEquivalentTo(@"C:\NzbDrone\NzbDrone.Web\App_Data\");
|
GetEnviromentProvider().GetAppDataPath().Should().BeEquivalentTo(@"C:\NzbDrone\App_Data\");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,14 +4,23 @@ using System.IO;
|
||||||
|
|
||||||
namespace NzbDrone.Common
|
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; }
|
get { return Console.In != StreamReader.Null; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void WaitForClose()
|
public void WaitForClose()
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
@ -19,7 +28,7 @@ namespace NzbDrone.Common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void PrintHelp()
|
public void PrintHelp()
|
||||||
{
|
{
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
Console.WriteLine(" Usage: {0} <command> ", Process.GetCurrentProcess().MainModule.ModuleName);
|
Console.WriteLine(" Usage: {0} <command> ", Process.GetCurrentProcess().MainModule.ModuleName);
|
||||||
|
@ -29,12 +38,12 @@ namespace NzbDrone.Common
|
||||||
Console.WriteLine(" <No Arguments> Run application in console mode.");
|
Console.WriteLine(" <No Arguments> 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);
|
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);
|
Console.WriteLine("Can't find service ({0})", ServiceProvider.NZBDRONE_SERVICE_NAME);
|
||||||
}
|
}
|
|
@ -119,7 +119,7 @@
|
||||||
<Compile Include="StringExtention.cs" />
|
<Compile Include="StringExtention.cs" />
|
||||||
<Compile Include="HttpProvider.cs" />
|
<Compile Include="HttpProvider.cs" />
|
||||||
<Compile Include="ConfigFileProvider.cs" />
|
<Compile Include="ConfigFileProvider.cs" />
|
||||||
<Compile Include="ConsoleProvider.cs" />
|
<Compile Include="ConsoleService.cs" />
|
||||||
<Compile Include="Contract\ReportBase.cs" />
|
<Compile Include="Contract\ReportBase.cs" />
|
||||||
<Compile Include="Contract\ParseErrorReport.cs" />
|
<Compile Include="Contract\ParseErrorReport.cs" />
|
||||||
<Compile Include="Model\AuthenticationType.cs" />
|
<Compile Include="Model\AuthenticationType.cs" />
|
||||||
|
|
|
@ -22,9 +22,6 @@ namespace NzbDrone.Common
|
||||||
{
|
{
|
||||||
Ensure.That(() => path).IsNotNullOrWhiteSpace();
|
Ensure.That(() => path).IsNotNullOrWhiteSpace();
|
||||||
|
|
||||||
if (String.IsNullOrWhiteSpace(path))
|
|
||||||
throw new ArgumentException("Path can not be null or empty");
|
|
||||||
|
|
||||||
var info = new FileInfo(path);
|
var info = new FileInfo(path);
|
||||||
|
|
||||||
if (info.FullName.StartsWith(@"\\")) //UNC
|
if (info.FullName.StartsWith(@"\\")) //UNC
|
||||||
|
|
|
@ -84,9 +84,7 @@ namespace NzbDrone.Common
|
||||||
|
|
||||||
public virtual ServiceController GetService(string serviceName)
|
public virtual ServiceController GetService(string serviceName)
|
||||||
{
|
{
|
||||||
return ServiceController.GetServices().Where(
|
return ServiceController.GetServices().FirstOrDefault(c => String.Equals(c.ServiceName, serviceName, StringComparison.InvariantCultureIgnoreCase));
|
||||||
c => String.Equals(c.ServiceName, serviceName, StringComparison.InvariantCultureIgnoreCase))
|
|
||||||
.FirstOrDefault();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Stop(string serviceName)
|
public virtual void Stop(string serviceName)
|
||||||
|
|
|
@ -6,7 +6,6 @@ using NzbDrone.Core.Test.Framework;
|
||||||
namespace NzbDrone.Core.Test.HelperTests
|
namespace NzbDrone.Core.Test.HelperTests
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
|
|
||||||
public class SortHelperTest : CoreTest
|
public class SortHelperTest : CoreTest
|
||||||
{
|
{
|
||||||
[TestCase("The Office (US)", "Office (US)")]
|
[TestCase("The Office (US)", "Office (US)")]
|
||||||
|
|
|
@ -9,7 +9,7 @@ using NzbDrone.Core.Test.Framework;
|
||||||
namespace NzbDrone.Core.Test.JobTests
|
namespace NzbDrone.Core.Test.JobTests
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
internal class PostDownloadScanJobFixture : CoreTest<PostDownloadScanJob>
|
public class PostDownloadScanJobFixture : CoreTest<PostDownloadScanJob>
|
||||||
{
|
{
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup()
|
public void Setup()
|
||||||
|
|
|
@ -260,6 +260,9 @@
|
||||||
<Content Include="Files\JsonError.txt">
|
<Content Include="Files\JsonError.txt">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<None Include="..\NzbDrone.Test.Common\App.config">
|
||||||
|
<Link>App.config</Link>
|
||||||
|
</None>
|
||||||
<None Include="Files\RSS\nzbx_search.json">
|
<None Include="Files\RSS\nzbx_search.json">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
@ -311,10 +314,6 @@
|
||||||
</Content>
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="App.config">
|
|
||||||
<SubType>Designer</SubType>
|
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
<Content Include="Files\Xem\Ids.txt">
|
<Content Include="Files\Xem\Ids.txt">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
|
|
@ -3,6 +3,7 @@ using System.Linq;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using Moq;
|
using Moq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
using NzbDrone.Common;
|
||||||
using NzbDrone.Common.Contract;
|
using NzbDrone.Common.Contract;
|
||||||
using NzbDrone.Core.Indexers;
|
using NzbDrone.Core.Indexers;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
|
|
|
@ -7,7 +7,6 @@ using NzbDrone.Core.Test.Framework;
|
||||||
namespace NzbDrone.Core.Test.Qualities
|
namespace NzbDrone.Core.Test.Qualities
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
|
|
||||||
public class QualityFixture : CoreTest
|
public class QualityFixture : CoreTest
|
||||||
{
|
{
|
||||||
public static object[] FromIntCases =
|
public static object[] FromIntCases =
|
||||||
|
|
|
@ -7,7 +7,7 @@ using NzbDrone.Core.Test.Framework;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.UpdateTests
|
namespace NzbDrone.Core.Test.UpdateTests
|
||||||
{
|
{
|
||||||
class GetUpdateLogFixture : CoreTest<UpdateService>
|
public class GetUpdateLogFixture : CoreTest<UpdateService>
|
||||||
{
|
{
|
||||||
String _updateLogFolder;
|
String _updateLogFolder;
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ using NzbDrone.Test.Common;
|
||||||
namespace NzbDrone.Core.Test.UpdateTests
|
namespace NzbDrone.Core.Test.UpdateTests
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
internal class UpdateServiceFixture : CoreTest<UpdateService>
|
public class UpdateServiceFixture : CoreTest<UpdateService>
|
||||||
{
|
{
|
||||||
private string _sandboxFolder;
|
private string _sandboxFolder;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<appSettings>
|
<appSettings>
|
||||||
<!-- Supported values: nunit, xunit and mstest -->
|
|
||||||
<add key="FluentAssertions.TestFramework" value="nunit" />
|
<add key="FluentAssertions.TestFramework" value="nunit" />
|
||||||
</appSettings>
|
</appSettings>
|
||||||
<runtime>
|
<runtime>
|
||||||
|
@ -10,6 +9,10 @@
|
||||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||||
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" />
|
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" />
|
||||||
</dependentAssembly>
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="NLog" publicKeyToken="5120e14c03d0593c" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-2.0.1.0" newVersion="2.0.1.0" />
|
||||||
|
</dependentAssembly>
|
||||||
</assemblyBinding>
|
</assemblyBinding>
|
||||||
</runtime>
|
</runtime>
|
||||||
</configuration>
|
</configuration>
|
|
@ -53,6 +53,9 @@
|
||||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Reference Include="FluentAssertions">
|
||||||
|
<HintPath>..\packages\FluentAssertions.2.0.1\lib\net40\FluentAssertions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="Microsoft.Practices.ServiceLocation">
|
<Reference Include="Microsoft.Practices.ServiceLocation">
|
||||||
<HintPath>..\packages\CommonServiceLocator.1.0\lib\NET35\Microsoft.Practices.ServiceLocation.dll</HintPath>
|
<HintPath>..\packages\CommonServiceLocator.1.0\lib\NET35\Microsoft.Practices.ServiceLocation.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
@ -99,6 +102,10 @@
|
||||||
<Content Include="AutoMoq\License.txt" />
|
<Content Include="AutoMoq\License.txt" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<None Include="App.config">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -106,6 +113,10 @@
|
||||||
<Project>{F2BE0FDF-6E47-4827-A420-DD4EF82407F8}</Project>
|
<Project>{F2BE0FDF-6E47-4827-A420-DD4EF82407F8}</Project>
|
||||||
<Name>NzbDrone.Common</Name>
|
<Name>NzbDrone.Common</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\NzbDrone.Core\NzbDrone.Core.csproj">
|
||||||
|
<Project>{ff5ee3b6-913b-47ce-9ceb-11c51b4e1205}</Project>
|
||||||
|
<Name>NzbDrone.Core</Name>
|
||||||
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
|
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using FluentAssertions;
|
||||||
using Moq;
|
using Moq;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
@ -69,6 +70,8 @@ namespace NzbDrone.Test.Common
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void TestBaseSetup()
|
public void TestBaseSetup()
|
||||||
{
|
{
|
||||||
|
GetType().IsPublic.Should().BeTrue("All Test fixtures should be public to work in mono.");
|
||||||
|
|
||||||
|
|
||||||
Mocker.SetConstant(LogManager.GetLogger("TestLogger"));
|
Mocker.SetConstant(LogManager.GetLogger("TestLogger"));
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
<package id="CommonServiceLocator" version="1.0" />
|
<package id="CommonServiceLocator" version="1.0" />
|
||||||
|
<package id="FluentAssertions" version="2.0.1" targetFramework="net40" />
|
||||||
<package id="Moq" version="4.0.10827" />
|
<package id="Moq" version="4.0.10827" />
|
||||||
<package id="NLog" version="2.0.1.2" targetFramework="net40" />
|
<package id="NLog" version="2.0.1.2" targetFramework="net40" />
|
||||||
<package id="NUnit" version="2.6.2" targetFramework="net40" />
|
<package id="NUnit" version="2.6.2" targetFramework="net40" />
|
||||||
|
|
|
@ -91,6 +91,9 @@
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<None Include="..\NzbDrone.Test.Common\App.config">
|
||||||
|
<Link>App.config</Link>
|
||||||
|
</None>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -12,7 +12,7 @@ using NzbDrone.Update.Providers;
|
||||||
namespace NzbDrone.Update.Test
|
namespace NzbDrone.Update.Test
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
class UpdateProviderStartFixture : TestBase
|
public class UpdateProviderStartFixture : TestBase
|
||||||
{
|
{
|
||||||
private const string UPDATE_FOLDER = @"C:\Temp\nzbdrone_update\nzbdrone\";
|
private const string UPDATE_FOLDER = @"C:\Temp\nzbdrone_update\nzbdrone\";
|
||||||
private const string BACKUP_FOLDER = @"C:\Temp\nzbdrone_update\nzbdrone_backup\";
|
private const string BACKUP_FOLDER = @"C:\Temp\nzbdrone_update\nzbdrone_backup\";
|
||||||
|
|
|
@ -11,7 +11,7 @@ using NzbDrone.Update.Providers;
|
||||||
namespace NzbDrone.Update.Test
|
namespace NzbDrone.Update.Test
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
class UpdateProviderVerifyFixture : TestBase
|
public class UpdateProviderVerifyFixture : TestBase
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
</targets>
|
</targets>
|
||||||
<rules>
|
<rules>
|
||||||
<logger name="*" minlevel="Debug" writeTo="consoleLogger"/>
|
<logger name="*" minlevel="Debug" writeTo="consoleLogger"/>
|
||||||
<logger name="*" minlevel="Trace" writeTo="udpTarget"/>
|
<logger name="*" minlevel="Trace" writeTo="fileLogger"/>
|
||||||
<logger name="*" minlevel="Trace" writeTo="rollingFileLogger"/>
|
|
||||||
</rules>
|
</rules>
|
||||||
</nlog>
|
</nlog>
|
|
@ -3,24 +3,28 @@ using System.ServiceProcess;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Common;
|
using NzbDrone.Common;
|
||||||
|
|
||||||
|
|
||||||
namespace NzbDrone
|
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 ConfigFileProvider _configFileProvider;
|
||||||
private readonly EnvironmentProvider _environmentProvider;
|
private readonly EnvironmentProvider _environmentProvider;
|
||||||
private readonly IHostController _hostController;
|
private readonly IHostController _hostController;
|
||||||
private readonly ProcessProvider _processProvider;
|
private readonly ProcessProvider _processProvider;
|
||||||
private readonly PriorityMonitor _priorityMonitor;
|
private readonly PriorityMonitor _priorityMonitor;
|
||||||
private readonly SecurityProvider _securityProvider;
|
private readonly SecurityProvider _securityProvider;
|
||||||
|
private readonly Logger _logger;
|
||||||
|
|
||||||
public ApplicationServer(ConfigFileProvider configFileProvider, IHostController hostController,
|
public NzbDroneServiceFactory(ConfigFileProvider configFileProvider, IHostController hostController,
|
||||||
EnvironmentProvider environmentProvider,
|
EnvironmentProvider environmentProvider,
|
||||||
ProcessProvider processProvider, PriorityMonitor priorityMonitor,
|
ProcessProvider processProvider, PriorityMonitor priorityMonitor,
|
||||||
SecurityProvider securityProvider)
|
SecurityProvider securityProvider, Logger logger)
|
||||||
{
|
{
|
||||||
_configFileProvider = configFileProvider;
|
_configFileProvider = configFileProvider;
|
||||||
_hostController = hostController;
|
_hostController = hostController;
|
||||||
|
@ -28,6 +32,7 @@ namespace NzbDrone
|
||||||
_processProvider = processProvider;
|
_processProvider = processProvider;
|
||||||
_priorityMonitor = priorityMonitor;
|
_priorityMonitor = priorityMonitor;
|
||||||
_securityProvider = securityProvider;
|
_securityProvider = securityProvider;
|
||||||
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnStart(string[] args)
|
protected override void OnStart(string[] args)
|
||||||
|
@ -35,7 +40,7 @@ namespace NzbDrone
|
||||||
Start();
|
Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
_securityProvider.MakeAccessible();
|
_securityProvider.MakeAccessible();
|
||||||
|
|
||||||
|
@ -45,12 +50,12 @@ namespace NzbDrone
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
logger.Info("Starting default browser. {0}", _hostController.AppUrl);
|
_logger.Info("Starting default browser. {0}", _hostController.AppUrl);
|
||||||
_processProvider.Start(_hostController.AppUrl);
|
_processProvider.Start(_hostController.AppUrl);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
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 @@ namespace NzbDrone
|
||||||
|
|
||||||
protected override void OnStop()
|
protected override void OnStop()
|
||||||
{
|
{
|
||||||
logger.Info("Attempting to stop application.");
|
_logger.Info("Attempting to stop application.");
|
||||||
_hostController.StopServer();
|
_hostController.StopServer();
|
||||||
logger.Info("Application has finished stop routine.");
|
_logger.Info("Application has finished stop routine.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public ServiceBase Build()
|
||||||
|
{
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -9,19 +9,19 @@ namespace NzbDrone
|
||||||
{
|
{
|
||||||
public class Router
|
public class Router
|
||||||
{
|
{
|
||||||
private readonly ApplicationServer _applicationServer;
|
private readonly INzbDroneServiceFactory _nzbDroneServiceFactory;
|
||||||
private readonly ServiceProvider _serviceProvider;
|
private readonly ServiceProvider _serviceProvider;
|
||||||
private readonly ConsoleProvider _consoleProvider;
|
private readonly IConsoleService _consoleService;
|
||||||
private readonly EnvironmentProvider _environmentProvider;
|
private readonly EnvironmentProvider _environmentProvider;
|
||||||
private readonly SysTrayProvider _sysTrayProvider;
|
private readonly SysTrayProvider _sysTrayProvider;
|
||||||
private readonly Logger _logger;
|
private readonly Logger _logger;
|
||||||
|
|
||||||
public Router(ApplicationServer applicationServer, ServiceProvider serviceProvider,
|
public Router(INzbDroneServiceFactory nzbDroneServiceFactory, ServiceProvider serviceProvider,
|
||||||
ConsoleProvider consoleProvider, EnvironmentProvider environmentProvider, SysTrayProvider sysTrayProvider, Logger logger)
|
IConsoleService consoleService, EnvironmentProvider environmentProvider, SysTrayProvider sysTrayProvider, Logger logger)
|
||||||
{
|
{
|
||||||
_applicationServer = applicationServer;
|
_nzbDroneServiceFactory = nzbDroneServiceFactory;
|
||||||
_serviceProvider = serviceProvider;
|
_serviceProvider = serviceProvider;
|
||||||
_consoleProvider = consoleProvider;
|
_consoleService = consoleService;
|
||||||
_environmentProvider = environmentProvider;
|
_environmentProvider = environmentProvider;
|
||||||
_sysTrayProvider = sysTrayProvider;
|
_sysTrayProvider = sysTrayProvider;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
@ -46,17 +46,18 @@ namespace NzbDrone
|
||||||
case ApplicationModes.Service:
|
case ApplicationModes.Service:
|
||||||
{
|
{
|
||||||
_logger.Trace("Service selected");
|
_logger.Trace("Service selected");
|
||||||
_serviceProvider.Run(_applicationServer);
|
_serviceProvider.Run(_nzbDroneServiceFactory.Build());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case ApplicationModes.Console:
|
case ApplicationModes.Console:
|
||||||
{
|
{
|
||||||
_logger.Trace("Console selected");
|
_logger.Trace("Console selected");
|
||||||
_applicationServer.Start();
|
_nzbDroneServiceFactory.Start();
|
||||||
if (ConsoleProvider.IsConsoleApplication)
|
if (_consoleService.IsConsoleApplication)
|
||||||
_consoleProvider.WaitForClose();
|
{
|
||||||
|
_consoleService.WaitForClose();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_sysTrayProvider.Start();
|
_sysTrayProvider.Start();
|
||||||
|
@ -69,7 +70,7 @@ namespace NzbDrone
|
||||||
_logger.Trace("Install Service selected");
|
_logger.Trace("Install Service selected");
|
||||||
if (_serviceProvider.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME))
|
if (_serviceProvider.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME))
|
||||||
{
|
{
|
||||||
_consoleProvider.PrintServiceAlreadyExist();
|
_consoleService.PrintServiceAlreadyExist();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -83,7 +84,7 @@ namespace NzbDrone
|
||||||
_logger.Trace("Uninstall Service selected");
|
_logger.Trace("Uninstall Service selected");
|
||||||
if (!_serviceProvider.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME))
|
if (!_serviceProvider.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME))
|
||||||
{
|
{
|
||||||
_consoleProvider.PrintServiceDoestExist();
|
_consoleService.PrintServiceDoestExist();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -94,7 +95,7 @@ namespace NzbDrone
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
_consoleProvider.PrintHelp();
|
_consoleService.PrintHelp();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,10 +6,6 @@
|
||||||
<runtime>
|
<runtime>
|
||||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||||
<probing privatePath="libs" />
|
<probing privatePath="libs" />
|
||||||
<dependentAssembly>
|
|
||||||
<assemblyIdentity name="Autofac" publicKeyToken="17863af14b0044da" culture="neutral" />
|
|
||||||
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
|
|
||||||
</dependentAssembly>
|
|
||||||
<dependentAssembly>
|
<dependentAssembly>
|
||||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||||
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" />
|
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" />
|
||||||
|
|
Loading…
Reference in New Issue