fixed more tests.

pull/6/head
kay.one 12 years ago
parent 9fdfd13dbf
commit b03388f7b9

@ -74,12 +74,19 @@
<Project>{f2be0fdf-6e47-4827-a420-dd4ef82407f8}</Project>
<Name>NzbDrone.Common</Name>
</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">
<Project>{CADDFCE0-7509-4430-8364-2074E1EEFCA2}</Project>
<Name>NzbDrone.Test.Common</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="..\NzbDrone.Test.Common\App.config">
<Link>App.config</Link>
</None>
<None Include="packages.config" />
</ItemGroup>
<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.Diagnostics;
using System.Linq;
using FizzWare.NBuilder;
using Moq;
using NUnit.Framework;
@ -12,9 +10,8 @@ using NzbDrone.Test.Common;
namespace NzbDrone.App.Test
{
[TestFixture]
public class MonitoringProviderTest : TestBase
public class MonitoringProviderTest : TestBase<PriorityMonitor>
{
[Test]
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.Resolve<PriorityMonitor>().EnsurePriority(null);
Subject.EnsurePriority(null);
}
[Test]
public void Ensure_should_log_warn_exception_rather_than_throw()
{
Mocker.GetMock<ProcessProvider>().Setup(c => c.GetCurrentProcess()).Throws<InvalidOperationException>();
Mocker.Resolve<PriorityMonitor>().EnsurePriority(null);
Subject.EnsurePriority(null);
ExceptionVerification.ExpectedWarns(1);
}
}
}

@ -86,12 +86,14 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="IISProviderFixture.cs" />
<Compile Include="RouterTest.cs" />
<Compile Include="MonitoringProviderTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="..\NzbDrone.Test.Common\App.config">
<Link>App.config</Link>
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
@ -99,6 +101,10 @@
<Project>{F2BE0FDF-6E47-4827-A420-DD4EF82407F8}</Project>
<Name>NzbDrone.Common</Name>
</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">
<Project>{CADDFCE0-7509-4430-8364-2074E1EEFCA2}</Project>
<Name>NzbDrone.Test.Common</Name>

@ -8,7 +8,7 @@ using NzbDrone.Test.Common;
namespace NzbDrone.App.Test
{
[TestFixture]
public class RouterTest : TestBase
public class RouterTest : TestBase<Router>
{
[TestCase(null, ApplicationModes.Console)]
@ -50,12 +50,12 @@ namespace NzbDrone.App.Test
serviceProviderMock.Setup(c => c.Start(ServiceProvider.NZBDRONE_SERVICE_NAME));
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());
}
[Test]
public void Route_should_call_uninstall_service_when_application_mode_is_uninstall()
{
@ -64,7 +64,7 @@ namespace NzbDrone.App.Test
Mocker.GetMock<EnvironmentProvider>().SetupGet(c => c.IsUserInteractive).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());
}
@ -72,16 +72,13 @@ namespace NzbDrone.App.Test
[Test]
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<IConsoleService>().SetupGet(c => c.IsConsoleApplication).Returns(true);
Mocker.Resolve<Router>().Route(ApplicationModes.Console);
Subject.Route(ApplicationModes.Console);
consoleProvider.Verify(c => c.WaitForClose(), Times.Once());
appServerProvider.Verify(c => c.Start(), Times.Once());
Mocker.GetMock<IConsoleService>().Verify(c => c.WaitForClose(), Times.Once());
Mocker.GetMock<INzbDroneServiceFactory>().Verify(c => c.Start(), Times.Once());
}
[TestCase(ApplicationModes.Console)]
@ -97,7 +94,7 @@ namespace NzbDrone.App.Test
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());
}
@ -106,14 +103,14 @@ namespace NzbDrone.App.Test
[Test]
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>();
Mocker.GetMock<EnvironmentProvider>().SetupGet(c => c.IsUserInteractive).Returns(true);
consoleMock.Setup(c => c.PrintServiceAlreadyExist());
serviceMock.Setup(c => c.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)).Returns(true);
Mocker.Resolve<Router>().Route(ApplicationModes.InstallService);
Subject.Route(ApplicationModes.InstallService);
Mocker.VerifyAllMocks();
}
@ -121,14 +118,14 @@ namespace NzbDrone.App.Test
[Test]
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>();
Mocker.GetMock<EnvironmentProvider>().SetupGet(c => c.IsUserInteractive).Returns(true);
consoleMock.Setup(c => c.PrintServiceDoestExist());
serviceMock.Setup(c => c.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)).Returns(false);
Mocker.Resolve<Router>().Route(ApplicationModes.UninstallService);
Subject.Route(ApplicationModes.UninstallService);
Mocker.VerifyAllMocks();
}

@ -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 @@ namespace NzbDrone.Common.Test
{
Mocker.Resolve<DiskProvider>().FolderExists(@"\\localhost\c$").Should().BeTrue();
}
[Test]
public void directory_exist_should_not_be_able_to_find_none_existing_folder()
{
@ -55,12 +55,12 @@ namespace NzbDrone.Common.Test
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 @@ namespace NzbDrone.Common.Test
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 @@ namespace NzbDrone.Common.Test
[Test]
public void CopyFolder_should_copy_folder()
{
var diskProvider = new DiskProvider();
diskProvider.CopyDirectory(BinFolder.FullName, BinFolderCopy.FullName);
diskProvider.CopyDirectory(_binFolder.FullName, _binFolderCopy.FullName);
VerifyCopy();
}
@ -94,18 +94,18 @@ namespace NzbDrone.Common.Test
[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 @@ namespace NzbDrone.Common.Test
{
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 @@ namespace NzbDrone.Common.Test
[Explicit]
public void check_last_write()
{
Console.WriteLine(Mocker.Resolve<DiskProvider>().GetLastFolderWrite(@"C:\DRIVERS"));
Console.WriteLine(new DirectoryInfo(@"C:\DRIVERS").LastWriteTimeUtc);
Console.WriteLine(Mocker.Resolve<DiskProvider>().GetLastFolderWrite(@"C:\DRIVERS"));
Console.WriteLine(new DirectoryInfo(@"C:\DRIVERS").LastWriteTimeUtc);
}
[Test]
@ -187,27 +187,27 @@ namespace NzbDrone.Common.Test
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());
}
}
}

@ -90,6 +90,9 @@
<Compile Include="WebClientTests.cs" />
</ItemGroup>
<ItemGroup>
<None Include="..\NzbDrone.Test.Common\App.config">
<Link>App.config</Link>
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>

@ -14,9 +14,11 @@
<IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace>
<DefaultTestTimeout>60000</DefaultTestTimeout>
<UseBuildConfiguration></UseBuildConfiguration>
<UseBuildPlatform />
<UseBuildPlatform></UseBuildPlatform>
<ProxyProcessPath></ProxyProcessPath>
<UseCPUArchitecture>AutoDetect</UseCPUArchitecture>
<MSTestThreadApartmentState>STA</MSTestThreadApartmentState>
<BuildProcessArchitecture>x86</BuildProcessArchitecture>
<IgnoredTests>
<NamedTestSelector>
<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>
</NamedTestSelector>
<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>
</IgnoredTests>
</ProjectConfiguration>

@ -34,25 +34,27 @@ namespace NzbDrone.Common.Test
}
[Test]
[ExpectedException(typeof(ArgumentException), ExpectedMessage = "Path can not be null or empty")]
public void normalize_path_exception_empty()
{
"".NormalizePath();
Assert.Throws<ArgumentException>(()=> "".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<ArgumentException>(() => 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\");
}

@ -4,14 +4,23 @@ using System.IO;
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 @@ namespace NzbDrone.Common
}
}
public virtual void PrintHelp()
public void PrintHelp()
{
Console.WriteLine();
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.");
}
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);
}

@ -119,7 +119,7 @@
<Compile Include="StringExtention.cs" />
<Compile Include="HttpProvider.cs" />
<Compile Include="ConfigFileProvider.cs" />
<Compile Include="ConsoleProvider.cs" />
<Compile Include="ConsoleService.cs" />
<Compile Include="Contract\ReportBase.cs" />
<Compile Include="Contract\ParseErrorReport.cs" />
<Compile Include="Model\AuthenticationType.cs" />

@ -22,9 +22,6 @@ namespace NzbDrone.Common
{
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

@ -66,7 +66,7 @@ namespace NzbDrone.Common
Logger.Info("Uninstalling {0} service", serviceName);
Stop(serviceName);
var serviceInstaller = new ServiceInstaller();
var context = new InstallContext("service_uninstall.log", null);
@ -84,9 +84,7 @@ namespace NzbDrone.Common
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)

@ -6,7 +6,6 @@ using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.HelperTests
{
[TestFixture]
public class SortHelperTest : CoreTest
{
[TestCase("The Office (US)", "Office (US)")]

@ -9,7 +9,7 @@ using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.JobTests
{
[TestFixture]
internal class PostDownloadScanJobFixture : CoreTest<PostDownloadScanJob>
public class PostDownloadScanJobFixture : CoreTest<PostDownloadScanJob>
{
[SetUp]
public void Setup()

@ -260,6 +260,9 @@
<Content Include="Files\JsonError.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Include="..\NzbDrone.Test.Common\App.config">
<Link>App.config</Link>
</None>
<None Include="Files\RSS\nzbx_search.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
@ -311,10 +314,6 @@
</Content>
</ItemGroup>
<ItemGroup>
<None Include="App.config">
<SubType>Designer</SubType>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<Content Include="Files\Xem\Ids.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>

@ -3,6 +3,7 @@ using System.Linq;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Common.Contract;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Model;

@ -7,7 +7,6 @@ using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.Qualities
{
[TestFixture]
public class QualityFixture : CoreTest
{
public static object[] FromIntCases =

@ -7,7 +7,7 @@ using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.UpdateTests
{
class GetUpdateLogFixture : CoreTest<UpdateService>
public class GetUpdateLogFixture : CoreTest<UpdateService>
{
String _updateLogFolder;

@ -13,7 +13,7 @@ using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.UpdateTests
{
[TestFixture]
internal class UpdateServiceFixture : CoreTest<UpdateService>
public class UpdateServiceFixture : CoreTest<UpdateService>
{
private string _sandboxFolder;

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<!-- Supported values: nunit, xunit and mstest -->
<add key="FluentAssertions.TestFramework" value="nunit" />
</appSettings>
<runtime>
@ -10,6 +9,10 @@
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" />
</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>
</runtime>
</configuration>

@ -53,6 +53,9 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="FluentAssertions">
<HintPath>..\packages\FluentAssertions.2.0.1\lib\net40\FluentAssertions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Practices.ServiceLocation">
<HintPath>..\packages\CommonServiceLocator.1.0\lib\NET35\Microsoft.Practices.ServiceLocation.dll</HintPath>
</Reference>
@ -99,6 +102,10 @@
<Content Include="AutoMoq\License.txt" />
</ItemGroup>
<ItemGroup>
<None Include="App.config">
<SubType>Designer</SubType>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
@ -106,6 +113,10 @@
<Project>{F2BE0FDF-6E47-4827-A420-DD4EF82407F8}</Project>
<Name>NzbDrone.Common</Name>
</ProjectReference>
<ProjectReference Include="..\NzbDrone.Core\NzbDrone.Core.csproj">
<Project>{ff5ee3b6-913b-47ce-9ceb-11c51b4e1205}</Project>
<Name>NzbDrone.Core</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />

@ -1,5 +1,6 @@
using System;
using System.IO;
using FluentAssertions;
using Moq;
using NLog;
using NUnit.Framework;
@ -69,6 +70,8 @@ namespace NzbDrone.Test.Common
[SetUp]
public void TestBaseSetup()
{
GetType().IsPublic.Should().BeTrue("All Test fixtures should be public to work in mono.");
Mocker.SetConstant(LogManager.GetLogger("TestLogger"));

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CommonServiceLocator" version="1.0" />
<package id="FluentAssertions" version="2.0.1" targetFramework="net40" />
<package id="Moq" version="4.0.10827" />
<package id="NLog" version="2.0.1.2" targetFramework="net40" />
<package id="NUnit" version="2.6.2" targetFramework="net40" />

@ -91,6 +91,9 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="..\NzbDrone.Test.Common\App.config">
<Link>App.config</Link>
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>

@ -12,7 +12,7 @@ using NzbDrone.Update.Providers;
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\";

@ -11,7 +11,7 @@ using NzbDrone.Update.Providers;
namespace NzbDrone.Update.Test
{
[TestFixture]
class UpdateProviderVerifyFixture : TestBase
public class UpdateProviderVerifyFixture : TestBase
{

@ -9,7 +9,6 @@
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="consoleLogger"/>
<logger name="*" minlevel="Trace" writeTo="udpTarget"/>
<logger name="*" minlevel="Trace" writeTo="rollingFileLogger"/>
<logger name="*" minlevel="Trace" writeTo="fileLogger"/>
</rules>
</nlog>

@ -3,24 +3,28 @@ using System.ServiceProcess;
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 @@ namespace NzbDrone
_processProvider = processProvider;
_priorityMonitor = priorityMonitor;
_securityProvider = securityProvider;
_logger = logger;
}
protected override void OnStart(string[] args)
@ -35,7 +40,7 @@ namespace NzbDrone
Start();
}
public virtual void Start()
public void Start()
{
_securityProvider.MakeAccessible();
@ -45,12 +50,12 @@ namespace NzbDrone
{
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 @@ namespace NzbDrone
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;
}
}
}

@ -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 @@ namespace NzbDrone
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 @@ namespace NzbDrone
_logger.Trace("Install Service selected");
if (_serviceProvider.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME))
{
_consoleProvider.PrintServiceAlreadyExist();
_consoleService.PrintServiceAlreadyExist();
}
else
{
@ -83,7 +84,7 @@ namespace NzbDrone
_logger.Trace("Uninstall Service selected");
if (!_serviceProvider.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME))
{
_consoleProvider.PrintServiceDoestExist();
_consoleService.PrintServiceDoestExist();
}
else
{
@ -94,7 +95,7 @@ namespace NzbDrone
}
default:
{
_consoleProvider.PrintHelp();
_consoleService.PrintHelp();
break;
}
}

@ -6,10 +6,6 @@
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<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>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" />

Loading…
Cancel
Save