mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-12 11:15:43 +02:00
Merge branch 'kay.one' of github.com:NzbDrone/NzbDrone into markus
This commit is contained in:
commit
639480e3ef
3
.gitignore
vendored
3
.gitignore
vendored
@ -39,4 +39,5 @@ NzbDrone.Web/NzbDrone.Web.Publish.xml
|
||||
[Bb]anners
|
||||
*.orig
|
||||
_rawPackage/
|
||||
NzbDrone.zip
|
||||
NzbDrone.zip
|
||||
NzbDrone.sln.DotSettings.user*
|
148
NzbDrone.6.1.ReSharper
Normal file
148
NzbDrone.6.1.ReSharper
Normal file
@ -0,0 +1,148 @@
|
||||
<Configuration>
|
||||
<CodeStyleSettings>
|
||||
<ExternalPath IsNull="False" />
|
||||
<Sharing>SOLUTION</Sharing>
|
||||
<CSS>
|
||||
<FormatSettings />
|
||||
<Naming2 />
|
||||
</CSS>
|
||||
<CSharp>
|
||||
<FormatSettings>
|
||||
<ALIGN_FIRST_ARG_BY_PAREN>True</ALIGN_FIRST_ARG_BY_PAREN>
|
||||
<ALIGN_MULTILINE_FOR_STMT>False</ALIGN_MULTILINE_FOR_STMT>
|
||||
<CONTINUOUS_INDENT_MULTIPLIER>2</CONTINUOUS_INDENT_MULTIPLIER>
|
||||
<FORCE_ATTRIBUTE_STYLE>SEPARATE</FORCE_ATTRIBUTE_STYLE>
|
||||
<INDENT_NESTED_FIXED_STMT>True</INDENT_NESTED_FIXED_STMT>
|
||||
<INDENT_NESTED_USINGS_STMT>True</INDENT_NESTED_USINGS_STMT>
|
||||
<LINE_FEED_AT_FILE_END>True</LINE_FEED_AT_FILE_END>
|
||||
<MODIFIERS_ORDER IsNull="False">
|
||||
<Item>public</Item>
|
||||
<Item>protected</Item>
|
||||
<Item>internal</Item>
|
||||
<Item>private</Item>
|
||||
<Item>new</Item>
|
||||
<Item>abstract</Item>
|
||||
<Item>virtual</Item>
|
||||
<Item>override</Item>
|
||||
<Item>sealed</Item>
|
||||
<Item>static</Item>
|
||||
<Item>readonly</Item>
|
||||
<Item>extern</Item>
|
||||
<Item>unsafe</Item>
|
||||
<Item>volatile</Item>
|
||||
</MODIFIERS_ORDER>
|
||||
<SPACE_AFTER_TYPECAST_PARENTHESES>False</SPACE_AFTER_TYPECAST_PARENTHESES>
|
||||
<SPACE_AROUND_ARROW_OP>True</SPACE_AROUND_ARROW_OP>
|
||||
<SPACE_AROUND_MULTIPLICATIVE_OP>True</SPACE_AROUND_MULTIPLICATIVE_OP>
|
||||
<SPACE_BEFORE_CATCH_PARENTHESES>False</SPACE_BEFORE_CATCH_PARENTHESES>
|
||||
<SPACE_BEFORE_FIXED_PARENTHESES>False</SPACE_BEFORE_FIXED_PARENTHESES>
|
||||
<SPACE_BEFORE_FOR_PARENTHESES>False</SPACE_BEFORE_FOR_PARENTHESES>
|
||||
<SPACE_BEFORE_FOR_SEMICOLON>True</SPACE_BEFORE_FOR_SEMICOLON>
|
||||
<SPACE_BEFORE_FOREACH_PARENTHESES>False</SPACE_BEFORE_FOREACH_PARENTHESES>
|
||||
<SPACE_BEFORE_IF_PARENTHESES>False</SPACE_BEFORE_IF_PARENTHESES>
|
||||
<SPACE_BEFORE_LOCK_PARENTHESES>False</SPACE_BEFORE_LOCK_PARENTHESES>
|
||||
<SPACE_BEFORE_SIZEOF_PARENTHESES>False</SPACE_BEFORE_SIZEOF_PARENTHESES>
|
||||
<SPACE_BEFORE_SWITCH_PARENTHESES>False</SPACE_BEFORE_SWITCH_PARENTHESES>
|
||||
<SPACE_BEFORE_TYPE_PARAMETER_ANGLE>True</SPACE_BEFORE_TYPE_PARAMETER_ANGLE>
|
||||
<SPACE_BEFORE_TYPE_PARAMETER_CONSTRAINT_COLON>False</SPACE_BEFORE_TYPE_PARAMETER_CONSTRAINT_COLON>
|
||||
<SPACE_BEFORE_TYPEOF_PARENTHESES>False</SPACE_BEFORE_TYPEOF_PARENTHESES>
|
||||
<SPACE_BEFORE_USING_PARENTHESES>False</SPACE_BEFORE_USING_PARENTHESES>
|
||||
<SPACE_BEFORE_WHILE_PARENTHESES>False</SPACE_BEFORE_WHILE_PARENTHESES>
|
||||
<STICK_COMMENT>False</STICK_COMMENT>
|
||||
</FormatSettings>
|
||||
<UsingsSettings>
|
||||
<MandatoryImports IsNull="False">
|
||||
<Item>System.Linq</Item>
|
||||
</MandatoryImports>
|
||||
</UsingsSettings>
|
||||
<Naming2>
|
||||
<EventHandlerPatternLong>$object$_On$event$</EventHandlerPatternLong>
|
||||
<EventHandlerPatternShort>$event$Handler</EventHandlerPatternShort>
|
||||
</Naming2>
|
||||
</CSharp>
|
||||
<HTML>
|
||||
<FormatSettings />
|
||||
</HTML>
|
||||
<JavaScript>
|
||||
<FormatSettings />
|
||||
<Naming2>
|
||||
<UserRule Name="JS_LOCAL_VARIABLE" Inspect="True" Prefix="" Suffix="" Style="aaBb" />
|
||||
<UserRule Name="JS_FUNCTION" Inspect="True" Prefix="" Suffix="" Style="aaBb" />
|
||||
<UserRule Name="JS_PARAMETER" Inspect="True" Prefix="" Suffix="" Style="aaBb" />
|
||||
<UserRule Name="JS_LABEL" Inspect="True" Prefix="" Suffix="" Style="aaBb" />
|
||||
<UserRule Name="JS_GLOBAL_VARIABLE" Inspect="True" Prefix="" Suffix="" Style="AaBb" />
|
||||
<UserRule Name="JS_OBJECT_PROPERTY_OF_FUNCTION" Inspect="True" Prefix="" Suffix="" Style="aaBb" />
|
||||
<UserRule Name="JS_CONSTRUCTOR" Inspect="True" Prefix="" Suffix="" Style="AaBb" />
|
||||
</Naming2>
|
||||
</JavaScript>
|
||||
<VB>
|
||||
<FormatSettings />
|
||||
<ImportsSettings />
|
||||
<Naming2>
|
||||
<EventHandlerPatternLong>$object$_On$event$</EventHandlerPatternLong>
|
||||
<EventHandlerPatternShort>$event$Handler</EventHandlerPatternShort>
|
||||
</Naming2>
|
||||
</VB>
|
||||
<Web>
|
||||
<Naming2 />
|
||||
</Web>
|
||||
<XML>
|
||||
<FormatSettings />
|
||||
</XML>
|
||||
<Xaml>
|
||||
<Naming2 />
|
||||
</Xaml>
|
||||
<GenerateMemberBody />
|
||||
<Naming2>
|
||||
<EventHandlerPatternLong>$object$_On$event$</EventHandlerPatternLong>
|
||||
<EventHandlerPatternShort>$event$Handler</EventHandlerPatternShort>
|
||||
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="PrivateStaticReadonly" />
|
||||
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="TypesAndNamespaces" />
|
||||
<PredefinedRule Inspect="True" Prefix="I" Suffix="" Style="AaBb" ElementKind="Interfaces" />
|
||||
<PredefinedRule Inspect="True" Prefix="T" Suffix="" Style="AaBb" ElementKind="TypeParameters" />
|
||||
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="MethodPropertyEvent" />
|
||||
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="Locals" />
|
||||
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="LocalConstants" />
|
||||
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="Parameters" />
|
||||
<PredefinedRule Inspect="True" Prefix="_" Suffix="" Style="aaBb" ElementKind="PublicFields" />
|
||||
<PredefinedRule Inspect="True" Prefix="_" Suffix="" Style="aaBb" ElementKind="PrivateInstanceFields" />
|
||||
<PredefinedRule Inspect="True" Prefix="_" Suffix="" Style="aaBb" ElementKind="PrivateStaticFields" />
|
||||
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AA_BB" ElementKind="Constants" />
|
||||
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AA_BB" ElementKind="PrivateConstants" />
|
||||
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="StaticReadonly" />
|
||||
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="EnumMember" />
|
||||
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="Other" />
|
||||
<Abbreviation Text="IIS" />
|
||||
</Naming2>
|
||||
</CodeStyleSettings>
|
||||
<Daemon.SolutionSettings>
|
||||
<SkipFilesAndFolders>
|
||||
<Item>43BD3BBD-1531-4D8F-9C08-E1CD544AB2CD/d:Content/d:2011.2.712</Item>
|
||||
<Item>43BD3BBD-1531-4D8F-9C08-E1CD544AB2CD/d:Content/d:jQueryUI</Item>
|
||||
</SkipFilesAndFolders>
|
||||
</Daemon.SolutionSettings>
|
||||
<SharedSolutionTemplateManager>
|
||||
<LiveTemplates>
|
||||
<Template uid="3ec01bf0-ad83-4b4c-a0b2-381f28e3c369" shortcut="Test" description="Test Method" text="[NUnit.Framework.Test]
[NUnit.Framework.Description("$TEST_NAME$")]
public void $TEST_METHOD_NAME$() 
{
 //Act

 //Assert

}" reformat="True" shortenQualifiedReferences="True">
|
||||
<Scopes>
|
||||
<Scope type="InCSharpTypeMember" minimumLanguageVersion="2.0" />
|
||||
</Scopes>
|
||||
<Categories />
|
||||
<Variables>
|
||||
<Variable name="TEST_NAME" expression="" initialRange="0" />
|
||||
<Variable name="TEST_METHOD_NAME" expression="spacestounderstrokes(TEST_NAME)" initialRange="-1" />
|
||||
</Variables>
|
||||
<CustomProperties />
|
||||
</Template>
|
||||
<Template uid="26915659-690b-46fa-a776-0d5995a33936" shortcut="Logger" description="" text="private static readonly Logger Logger = LogManager.GetCurrentClassLogger();" reformat="True" shortenQualifiedReferences="True">
|
||||
<Scopes>
|
||||
<Scope type="Everywhere" />
|
||||
<Scope type="InCSharpTypeMember" minimumLanguageVersion="2.0" />
|
||||
</Scopes>
|
||||
<Categories />
|
||||
<Variables />
|
||||
<CustomProperties />
|
||||
</Template>
|
||||
</LiveTemplates>
|
||||
</SharedSolutionTemplateManager>
|
||||
</Configuration>
|
@ -1,11 +1,12 @@
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using Ninject;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.App.Test
|
||||
{
|
||||
[TestFixture]
|
||||
public class CentralDispatchTests
|
||||
public class CentralDispatchTests : TestBase
|
||||
{
|
||||
[Test]
|
||||
public void Kernel_can_get_kernel()
|
||||
|
@ -1,59 +0,0 @@
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Providers;
|
||||
|
||||
namespace NzbDrone.App.Test
|
||||
{
|
||||
[TestFixture]
|
||||
public class ConfigProviderTest
|
||||
{
|
||||
|
||||
private ConfigProvider GetConfigProvider()
|
||||
{
|
||||
var envMoq = new Mock<EnviromentProvider>();
|
||||
envMoq.SetupGet(c => c.ApplicationPath).Returns(@"C:\NzbDrone\");
|
||||
|
||||
return new ConfigProvider(envMoq.Object);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void IISExpress_path_test()
|
||||
{
|
||||
GetConfigProvider().IISDirectory.Should().BeEquivalentTo(@"C:\NzbDrone\IISExpress");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AppDataDirectory_path_test()
|
||||
{
|
||||
GetConfigProvider().AppDataDirectory.Should().BeEquivalentTo(@"C:\NzbDrone\NzbDrone.Web\App_Data");
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void Config_path_test()
|
||||
{
|
||||
GetConfigProvider().ConfigFile.Should().BeEquivalentTo(@"C:\NzbDrone\NzbDrone.Web\App_Data\Config.xml");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IISConfig_path_test()
|
||||
{
|
||||
GetConfigProvider().IISConfigPath.Should().BeEquivalentTo(@"C:\NzbDrone\IISExpress\AppServer\applicationhost.config");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IISExe_path_test()
|
||||
{
|
||||
GetConfigProvider().IISExePath.Should().BeEquivalentTo(@"C:\NzbDrone\IISExpress\IISExpress.exe");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NlogConfig_path_test()
|
||||
{
|
||||
GetConfigProvider().NlogConfigPath.Should().BeEquivalentTo(@"C:\NzbDrone\NzbDrone.Web\log.config");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
// ReSharper disable CheckNamespace
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
[SetUpFixture]
|
||||
public class Fixtures : LoggingTest
|
||||
{
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using AutoMoq;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Providers;
|
||||
|
||||
namespace NzbDrone.App.Test
|
||||
{
|
||||
[TestFixture]
|
||||
public class IISProviderTest
|
||||
{
|
||||
[Test]
|
||||
public void start_should_set_IISProccessId_property()
|
||||
{
|
||||
var mocker = new AutoMoqer();
|
||||
|
||||
var configMock = mocker.GetMock<ConfigProvider>();
|
||||
configMock.SetupGet(c => c.IISExePath).Returns("NzbDrone.Test.Dummy.exe");
|
||||
|
||||
mocker.Resolve<ProcessProvider>();
|
||||
|
||||
var iisProvider = mocker.Resolve<IISProvider>();
|
||||
|
||||
iisProvider.StartServer();
|
||||
|
||||
iisProvider.IISProcessId.Should().NotBe(0);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,22 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using AutoMoq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Model;
|
||||
using NzbDrone.Model;
|
||||
using NzbDrone.Providers;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.App.Test
|
||||
{
|
||||
[TestFixture]
|
||||
public class MonitoringProviderTest
|
||||
public class MonitoringProviderTest : TestBase
|
||||
{
|
||||
|
||||
[Test]
|
||||
|
@ -65,11 +65,8 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CentralDispatchTests.cs" />
|
||||
<Compile Include="Fixtures.cs" />
|
||||
<Compile Include="RouterTest.cs" />
|
||||
<Compile Include="MonitoringProviderTest.cs" />
|
||||
<Compile Include="ConfigProviderTest.cs" />
|
||||
<Compile Include="IISProviderTest.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -5,11 +5,12 @@
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Model;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.App.Test
|
||||
{
|
||||
[TestFixture]
|
||||
public class RouterTest
|
||||
public class RouterTest : TestBase
|
||||
{
|
||||
|
||||
[TestCase(null, ApplicationMode.Console)]
|
||||
|
@ -3,9 +3,9 @@
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Common.Model;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
@ -16,10 +16,10 @@ public class ConfigFileProviderTest : TestBase
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
WithTempAsStartUpPath();
|
||||
WithTempAsAppPath();
|
||||
|
||||
//Reset config file
|
||||
var configFile = Mocker.Resolve<PathProvider>().AppConfigFile;
|
||||
var configFile = Mocker.Resolve<EnviromentProvider>().GetConfigPath();
|
||||
|
||||
if (File.Exists(configFile))
|
||||
File.Delete(configFile);
|
@ -4,11 +4,12 @@
|
||||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Common.Test
|
||||
{
|
||||
[TestFixture]
|
||||
public class DiskProviderTests
|
||||
public class DiskProviderTests : TestBase
|
||||
{
|
||||
DirectoryInfo BinFolder;
|
||||
DirectoryInfo BinFolderCopy;
|
||||
|
@ -4,11 +4,12 @@
|
||||
using System.IO;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Common.Test
|
||||
{
|
||||
[TestFixture]
|
||||
public class EnviromentProviderTest
|
||||
public class EnviromentProviderTest : TestBase
|
||||
{
|
||||
readonly EnviromentProvider enviromentProvider = new EnviromentProvider();
|
||||
|
||||
|
@ -1,8 +0,0 @@
|
||||
// ReSharper disable CheckNamespace
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
[SetUpFixture]
|
||||
public class Fixtures : LoggingTest
|
||||
{
|
||||
}
|
@ -61,9 +61,10 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ConfigFileProviderTest.cs" />
|
||||
<Compile Include="PathExtentionFixture.cs" />
|
||||
<Compile Include="DiskProviderTests.cs" />
|
||||
<Compile Include="EnviromentProviderTest.cs" />
|
||||
<Compile Include="Fixtures.cs" />
|
||||
<Compile Include="ProcessProviderTests.cs" />
|
||||
<Compile Include="ServiceControllerTests.cs" />
|
||||
<Compile Include="WebClientTests.cs" />
|
||||
|
53
NzbDrone.Common.Test/PathExtentionFixture.cs
Normal file
53
NzbDrone.Common.Test/PathExtentionFixture.cs
Normal file
@ -0,0 +1,53 @@
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.App.Test
|
||||
{
|
||||
[TestFixture]
|
||||
public class PathExtentionFixture : TestBase
|
||||
{
|
||||
|
||||
private EnviromentProvider GetEnviromentProvider()
|
||||
{
|
||||
var envMoq = new Mock<EnviromentProvider>();
|
||||
envMoq.SetupGet(c => c.ApplicationPath).Returns(@"C:\NzbDrone\");
|
||||
|
||||
return envMoq.Object;
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void AppDataDirectory_path_test()
|
||||
{
|
||||
GetEnviromentProvider().GetAppDataPath().Should().BeEquivalentTo(@"C:\NzbDrone\NzbDrone.Web\App_Data\");
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void Config_path_test()
|
||||
{
|
||||
GetEnviromentProvider().GetConfigPath().Should().BeEquivalentTo(@"C:\NzbDrone\Config.xml");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IISConfig_path_test()
|
||||
{
|
||||
GetEnviromentProvider().GetIISConfigPath().Should().BeEquivalentTo(@"C:\NzbDrone\IISExpress\AppServer\applicationhost.config");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IISExe_path_test()
|
||||
{
|
||||
GetEnviromentProvider().GetIISExe().Should().BeEquivalentTo(@"C:\NzbDrone\IISExpress\IISExpress.exe");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NlogConfig_path_test()
|
||||
{
|
||||
GetEnviromentProvider().GetNlogConfigPath().Should().BeEquivalentTo(@"C:\NzbDrone\NzbDrone.Web\log.config");
|
||||
}
|
||||
}
|
||||
}
|
@ -3,11 +3,12 @@
|
||||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Common.Test
|
||||
{
|
||||
[TestFixture]
|
||||
public class ProcessProviderTests
|
||||
public class ProcessProviderTests : TestBase
|
||||
{
|
||||
private const string DummyProccessName = "NzbDrone.Test.Dummy";
|
||||
ProcessProvider _processProvider;
|
||||
|
@ -3,11 +3,12 @@
|
||||
using System.ServiceProcess;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Common.Test
|
||||
{
|
||||
[TestFixture]
|
||||
public class ServiceControllerTests
|
||||
public class ServiceControllerTests:TestBase
|
||||
{
|
||||
private const string ALWAYS_INSTALLED_SERVICE = "SCardSvr"; //Smart Card
|
||||
private const string TEMP_SERVICE_NAME = "NzbDrone_Nunit"; //Smart Card
|
||||
@ -74,7 +75,7 @@ public void UnInstallService()
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Timeout(10000)]
|
||||
//[Timeout(10000)]
|
||||
public void Should_be_able_to_start_and_stop_service()
|
||||
{
|
||||
serviceProvider.GetService(ALWAYS_INSTALLED_SERVICE).Status
|
||||
|
@ -1,11 +1,12 @@
|
||||
// ReSharper disable InconsistentNaming
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Common.Test
|
||||
{
|
||||
[TestFixture]
|
||||
public class WebClientTests
|
||||
public class WebClientTests : TestBase
|
||||
{
|
||||
[Test]
|
||||
public void DownloadString_should_be_able_to_download_jquery()
|
||||
|
@ -4,132 +4,45 @@
|
||||
using System.Xml.Linq;
|
||||
using System.Xml.XPath;
|
||||
using NLog;
|
||||
using Ninject;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Model;
|
||||
using NzbDrone.Common.Model;
|
||||
|
||||
namespace NzbDrone.Providers
|
||||
namespace NzbDrone.Common
|
||||
{
|
||||
public class ConfigProvider
|
||||
public class ConfigFileProvider
|
||||
{
|
||||
private readonly EnviromentProvider _enviromentProvider;
|
||||
private static readonly Logger Logger = LogManager.GetLogger("Host.ConfigProvider");
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
[Inject]
|
||||
public ConfigProvider(EnviromentProvider enviromentProvider)
|
||||
|
||||
|
||||
private readonly string _configFile;
|
||||
public ConfigFileProvider(EnviromentProvider enviromentProvider)
|
||||
{
|
||||
_enviromentProvider = enviromentProvider;
|
||||
_configFile = _enviromentProvider.GetConfigPath();
|
||||
}
|
||||
|
||||
public ConfigProvider()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual int PortNumber
|
||||
public virtual int Port
|
||||
{
|
||||
get { return GetValueInt("Port", 8989); }
|
||||
set { SetValue("Port", value); }
|
||||
}
|
||||
|
||||
public virtual bool LaunchBrowser
|
||||
{
|
||||
get { return GetValueBoolean("LaunchBrowser", true); }
|
||||
}
|
||||
|
||||
public virtual string IISDirectory
|
||||
{
|
||||
get { return Path.Combine(_enviromentProvider.ApplicationPath, "IISExpress"); }
|
||||
}
|
||||
|
||||
public virtual string IISExePath
|
||||
{
|
||||
get { return Path.Combine(IISDirectory, "iisexpress.exe"); }
|
||||
}
|
||||
|
||||
public virtual string IISConfigPath
|
||||
{
|
||||
get { return Path.Combine(IISDirectory, "AppServer", "applicationhost.config"); }
|
||||
}
|
||||
|
||||
public virtual string AppDataDirectory
|
||||
{
|
||||
get { return Path.Combine(_enviromentProvider.ApplicationPath, "NzbDrone.Web", "App_Data"); }
|
||||
}
|
||||
|
||||
public virtual string ConfigFile
|
||||
{
|
||||
get { return Path.Combine(AppDataDirectory, "Config.xml"); }
|
||||
}
|
||||
|
||||
public virtual string NlogConfigPath
|
||||
{
|
||||
get { return Path.Combine(_enviromentProvider.ApplicationPath, "NzbDrone.Web\\log.config"); }
|
||||
set { SetValue("LaunchBrowser", value); }
|
||||
}
|
||||
|
||||
public virtual AuthenticationType AuthenticationType
|
||||
{
|
||||
get { return (AuthenticationType)GetValueInt("AuthenticationType", 0); }
|
||||
set { SetValue("AuthenticationType", (int)value); }
|
||||
}
|
||||
|
||||
public virtual void UpdateIISConfig(string configPath)
|
||||
public virtual string GetValue(string key, object defaultValue, string parent = null)
|
||||
{
|
||||
Logger.Info(@"Server configuration file: {0}", configPath);
|
||||
Logger.Info(@"Configuring server to: [http://localhost:{0}]", PortNumber);
|
||||
|
||||
var configXml = XDocument.Load(configPath);
|
||||
|
||||
var bindings =
|
||||
configXml.XPathSelectElement("configuration/system.applicationHost/sites").Elements("site").Where(
|
||||
d => d.Attribute("name").Value.ToLowerInvariant() == "nzbdrone").First().Element("bindings");
|
||||
bindings.Descendants().Remove();
|
||||
bindings.Add(
|
||||
new XElement("binding",
|
||||
new XAttribute("protocol", "http"),
|
||||
new XAttribute("bindingInformation", String.Format("*:{0}:localhost", PortNumber))
|
||||
));
|
||||
|
||||
bindings.Add(
|
||||
new XElement("binding",
|
||||
new XAttribute("protocol", "http"),
|
||||
new XAttribute("bindingInformation", String.Format("*:{0}:", PortNumber))
|
||||
));
|
||||
|
||||
//Update the authenticationTypes
|
||||
|
||||
var location = configXml.XPathSelectElement("configuration").Elements("location").Where(
|
||||
d => d.Attribute("path").Value.ToLowerInvariant() == "nzbdrone").First();
|
||||
|
||||
|
||||
var authenticationTypes = location.XPathSelectElements("system.webServer/security/authentication").First().Descendants();
|
||||
|
||||
//Set all authentication types enabled to false
|
||||
foreach (var child in authenticationTypes)
|
||||
{
|
||||
child.Attribute("enabled").Value = "false";
|
||||
}
|
||||
|
||||
var configuredAuthType = String.Format("{0}Authentication", AuthenticationType.ToString()).ToLowerInvariant();
|
||||
|
||||
//Set the users authenticationType to true
|
||||
authenticationTypes.Where(t => t.Name.ToString().ToLowerInvariant() == configuredAuthType).Single().Attribute("enabled").Value = "true";
|
||||
|
||||
configXml.Save(configPath);
|
||||
}
|
||||
|
||||
public virtual void CreateDefaultConfigFile()
|
||||
{
|
||||
//Create the config file here
|
||||
Directory.CreateDirectory(AppDataDirectory);
|
||||
|
||||
if (!File.Exists(ConfigFile))
|
||||
{
|
||||
WriteDefaultConfig();
|
||||
}
|
||||
}
|
||||
|
||||
private string GetValue(string key, object defaultValue, string parent = null)
|
||||
{
|
||||
var xDoc = XDocument.Load(ConfigFile);
|
||||
var xDoc = XDocument.Load(_configFile);
|
||||
var config = xDoc.Descendants("Config").Single();
|
||||
|
||||
var parentContainer = config;
|
||||
@ -142,7 +55,7 @@ private string GetValue(string key, object defaultValue, string parent = null)
|
||||
SetValue(key, defaultValue, parent);
|
||||
|
||||
//Reload the configFile
|
||||
xDoc = XDocument.Load(ConfigFile);
|
||||
xDoc = XDocument.Load(_configFile);
|
||||
config = xDoc.Descendants("Config").Single();
|
||||
}
|
||||
|
||||
@ -173,7 +86,7 @@ public virtual bool GetValueBoolean(string key, bool defaultValue, string parent
|
||||
|
||||
public virtual void SetValue(string key, object value, string parent = null)
|
||||
{
|
||||
var xDoc = XDocument.Load(ConfigFile);
|
||||
var xDoc = XDocument.Load(_configFile);
|
||||
var config = xDoc.Descendants("Config").Single();
|
||||
|
||||
var parentContainer = config;
|
||||
@ -197,16 +110,66 @@ public virtual void SetValue(string key, object value, string parent = null)
|
||||
else
|
||||
parentContainer.Descendants(key).Single().Value = value.ToString();
|
||||
|
||||
xDoc.Save(ConfigFile);
|
||||
xDoc.Save(_configFile);
|
||||
}
|
||||
|
||||
public virtual void WriteDefaultConfig()
|
||||
public virtual void CreateDefaultConfigFile()
|
||||
{
|
||||
var xDoc = new XDocument(new XDeclaration("1.0", "utf-8", "yes"));
|
||||
if (!File.Exists(_configFile))
|
||||
{
|
||||
var xDoc = new XDocument(new XDeclaration("1.0", "utf-8", "yes"));
|
||||
|
||||
xDoc.Add(new XElement("Config"));
|
||||
xDoc.Add(new XElement("Config"));
|
||||
|
||||
xDoc.Save(ConfigFile);
|
||||
xDoc.Save(_configFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public virtual void UpdateIISConfig(string configPath)
|
||||
{
|
||||
logger.Info(@"Server configuration file: {0}", configPath);
|
||||
logger.Info(@"Configuring server to: [http://localhost:{0}]", Port);
|
||||
|
||||
var configXml = XDocument.Load(configPath);
|
||||
|
||||
var bindings =
|
||||
configXml.XPathSelectElement("configuration/system.applicationHost/sites").Elements("site").Where(
|
||||
d => d.Attribute("name").Value.ToLowerInvariant() == "nzbdrone").First().Element("bindings");
|
||||
bindings.Descendants().Remove();
|
||||
bindings.Add(
|
||||
new XElement("binding",
|
||||
new XAttribute("protocol", "http"),
|
||||
new XAttribute("bindingInformation", String.Format("*:{0}:localhost", Port))
|
||||
));
|
||||
|
||||
bindings.Add(
|
||||
new XElement("binding",
|
||||
new XAttribute("protocol", "http"),
|
||||
new XAttribute("bindingInformation", String.Format("*:{0}:", Port))
|
||||
));
|
||||
|
||||
//Update the authenticationTypes
|
||||
|
||||
var location = configXml.XPathSelectElement("configuration").Elements("location").Where(
|
||||
d => d.Attribute("path").Value.ToLowerInvariant() == "nzbdrone").First();
|
||||
|
||||
|
||||
var authenticationTypes = location.XPathSelectElements("system.webServer/security/authentication").First().Descendants();
|
||||
|
||||
//Set all authentication types enabled to false
|
||||
foreach (var child in authenticationTypes)
|
||||
{
|
||||
child.Attribute("enabled").Value = "false";
|
||||
}
|
||||
|
||||
var configuredAuthType = String.Format("{0}Authentication", AuthenticationType.ToString()).ToLowerInvariant();
|
||||
|
||||
//Set the users authenticationType to true
|
||||
authenticationTypes.Where(t => t.Name.ToString().ToLowerInvariant() == configuredAuthType).Single().Attribute("enabled").Value = "true";
|
||||
|
||||
configXml.Save(configPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -2,12 +2,20 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using NLog;
|
||||
|
||||
namespace NzbDrone.Common
|
||||
{
|
||||
public class DiskProvider
|
||||
{
|
||||
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
static extern bool GetDiskFreeSpaceEx(string lpDirectoryName,
|
||||
out ulong lpFreeBytesAvailable,
|
||||
out ulong lpTotalNumberOfBytes,
|
||||
out ulong lpTotalNumberOfFreeBytes);
|
||||
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public virtual bool FolderExists(string path)
|
||||
@ -47,6 +55,25 @@ public virtual String CreateDirectory(string path)
|
||||
return Directory.CreateDirectory(path).FullName;
|
||||
}
|
||||
|
||||
public virtual void CopyDirectory(string source, string target)
|
||||
{
|
||||
Logger.Trace("Copying {0} -> {1}", source, target);
|
||||
|
||||
var sourceFolder = new DirectoryInfo(source);
|
||||
var targetFolder = new DirectoryInfo(target);
|
||||
|
||||
if (!targetFolder.Exists)
|
||||
{
|
||||
targetFolder.Create();
|
||||
}
|
||||
|
||||
foreach (var file in sourceFolder.GetFiles("*.*", SearchOption.AllDirectories))
|
||||
{
|
||||
var destFile = Path.Combine(target, file.Name);
|
||||
file.CopyTo(destFile, true);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void DeleteFile(string path)
|
||||
{
|
||||
File.Delete(path);
|
||||
@ -77,30 +104,25 @@ public virtual void MoveDirectory(string source, string destination)
|
||||
Directory.Move(source, destination);
|
||||
}
|
||||
|
||||
public virtual void CopyDirectory(string source, string target)
|
||||
{
|
||||
Logger.Trace("Copying {0} -> {1}", source, target);
|
||||
|
||||
var sourceFolder = new DirectoryInfo(source);
|
||||
var targetFolder = new DirectoryInfo(target);
|
||||
|
||||
if (!targetFolder.Exists)
|
||||
{
|
||||
targetFolder.Create();
|
||||
}
|
||||
|
||||
foreach (var file in sourceFolder.GetFiles("*.*", SearchOption.AllDirectories))
|
||||
{
|
||||
var destFile = Path.Combine(target, file.Name);
|
||||
file.CopyTo(destFile, true);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void InheritFolderPermissions(string filename)
|
||||
{
|
||||
var fs = File.GetAccessControl(filename);
|
||||
fs.SetAccessRuleProtection(false, false);
|
||||
File.SetAccessControl(filename, fs);
|
||||
}
|
||||
|
||||
public virtual ulong FreeDiskSpace(DirectoryInfo directoryInfo)
|
||||
{
|
||||
ulong freeBytesAvailable;
|
||||
ulong totalNumberOfBytes;
|
||||
ulong totalNumberOfFreeBytes;
|
||||
|
||||
bool success = GetDiskFreeSpaceEx(directoryInfo.FullName, out freeBytesAvailable, out totalNumberOfBytes,
|
||||
out totalNumberOfFreeBytes);
|
||||
if (!success)
|
||||
throw new System.ComponentModel.Win32Exception();
|
||||
|
||||
return freeBytesAvailable;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -63,7 +63,7 @@ public virtual string ApplicationPath
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public virtual string StartUpPath
|
||||
{
|
||||
get
|
||||
@ -72,6 +72,14 @@ public virtual string StartUpPath
|
||||
}
|
||||
}
|
||||
|
||||
public virtual String SystemTemp
|
||||
{
|
||||
get
|
||||
{
|
||||
return Path.GetTempPath();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual Version Version
|
||||
{
|
||||
get { return Assembly.GetExecutingAssembly().GetName().Version; }
|
||||
@ -84,7 +92,19 @@ public virtual DateTime BuildDateTime
|
||||
var fileLocation = Assembly.GetCallingAssembly().Location;
|
||||
return new FileInfo(fileLocation).CreationTime;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual int NzbDroneProcessIdFromEnviroment
|
||||
{
|
||||
get
|
||||
{
|
||||
var id = Convert.ToInt32(Environment.GetEnvironmentVariable("NZBDRONE_PID"));
|
||||
|
||||
if (id == 0)
|
||||
throw new InvalidOperationException("NZBDRONE_PID isn't a valid environment variable.");
|
||||
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool ContainsIIS(DirectoryInfo dir)
|
||||
|
@ -33,7 +33,6 @@ public static void RegisterConsoleLogger(LogLevel minLevel, string loggerNamePat
|
||||
consoleTarget.Layout = "${message} ${exception}";
|
||||
LogManager.Configuration.AddTarget(consoleTarget.GetType().Name, consoleTarget);
|
||||
LogManager.Configuration.LoggingRules.Add(new LoggingRule(loggerNamePattern, minLevel, consoleTarget));
|
||||
Reload();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -57,7 +56,6 @@ public static void RegisterUdpLogger()
|
||||
udpTarget.IncludeNdc = true;
|
||||
LogManager.Configuration.AddTarget(udpTarget.GetType().Name, udpTarget);
|
||||
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Trace, udpTarget));
|
||||
Reload();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -71,23 +69,27 @@ public static void RegisterUdpLogger()
|
||||
|
||||
public static void RegisterExceptioneer()
|
||||
{
|
||||
try
|
||||
if (EnviromentProvider.IsProduction)
|
||||
{
|
||||
var exTarget = new ExceptioneerTarget();
|
||||
LogManager.Configuration.AddTarget("Exceptioneer", exTarget);
|
||||
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Error, exTarget));
|
||||
Reload();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
try
|
||||
{
|
||||
var exTarget = new ExceptioneerTarget();
|
||||
LogManager.Configuration.AddTarget("Exceptioneer", exTarget);
|
||||
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Error, exTarget));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Reload()
|
||||
{
|
||||
var sw = Stopwatch.StartNew();
|
||||
LogManager.Configuration.Reload();
|
||||
LogManager.ReconfigExistingLoggers();
|
||||
sw.Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
10
NzbDrone.Common/Model/AuthenticationType.cs
Normal file
10
NzbDrone.Common/Model/AuthenticationType.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using System.Linq;
|
||||
|
||||
namespace NzbDrone.Common.Model
|
||||
{
|
||||
public enum AuthenticationType
|
||||
{
|
||||
Anonymous = 0,
|
||||
Windows = 1
|
||||
}
|
||||
}
|
@ -42,15 +42,14 @@
|
||||
<Reference Include="System.Configuration.Install" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.ServiceProcess" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ConfigFileProvider.cs" />
|
||||
<Compile Include="ConsoleProvider.cs" />
|
||||
<Compile Include="PathProvider.cs" />
|
||||
<Compile Include="Model\AuthenticationType.cs" />
|
||||
<Compile Include="PathExtentions.cs" />
|
||||
<Compile Include="DiskProvider.cs" />
|
||||
<Compile Include="EnviromentProvider.cs" />
|
||||
<Compile Include="ExceptioneerTarget.cs" />
|
||||
|
93
NzbDrone.Common/PathExtentions.cs
Normal file
93
NzbDrone.Common/PathExtentions.cs
Normal file
@ -0,0 +1,93 @@
|
||||
using System.IO;
|
||||
|
||||
namespace NzbDrone.Common
|
||||
{
|
||||
public static class PathExtentions
|
||||
{
|
||||
private const string WEB_FOLDER = "NzbDrone.Web\\";
|
||||
private const string APP_DATA = "App_Data\\";
|
||||
public const string IIS_FOLDER = EnviromentProvider.IIS_FOLDER_NAME;
|
||||
public const string IIS_EXE = "iisexpress.exe";
|
||||
|
||||
|
||||
private const string LOG_CONFIG_FILE = "log.config";
|
||||
private const string APP_CONFIG_FILE = "config.xml";
|
||||
|
||||
private const string NZBDRONE_DB_FILE = "nzbdrone.sdf";
|
||||
private const string LOG_DB_FILE = "log.sdf";
|
||||
|
||||
private const string UPDATE_SANDBOX_FOLDER_NAME = "nzbdrone_update\\";
|
||||
private const string UPDATE_PACKAGE_FOLDER_NAME = "nzbdrone\\";
|
||||
private const string UPDATE_BACKUP_FOLDER_NAME = "nzbdrone_backup\\";
|
||||
|
||||
public static string GetUpdateSandboxFolder(this EnviromentProvider enviromentProvider)
|
||||
{
|
||||
return Path.Combine(enviromentProvider.SystemTemp, UPDATE_SANDBOX_FOLDER_NAME);
|
||||
}
|
||||
|
||||
public static string GetUpdateBackUpFolder(this EnviromentProvider enviromentProvider)
|
||||
{
|
||||
return Path.Combine(enviromentProvider.GetUpdateSandboxFolder(), UPDATE_BACKUP_FOLDER_NAME);
|
||||
}
|
||||
|
||||
public static string GetUpdatePackageFolder(this EnviromentProvider enviromentProvider)
|
||||
{
|
||||
return Path.Combine(enviromentProvider.GetUpdateSandboxFolder(), UPDATE_PACKAGE_FOLDER_NAME);
|
||||
}
|
||||
|
||||
public static string GetIISFolder(this EnviromentProvider enviromentProvider)
|
||||
{
|
||||
return Path.Combine(enviromentProvider.ApplicationPath, IIS_FOLDER);
|
||||
}
|
||||
|
||||
public static string GetIISExe(this EnviromentProvider enviromentProvider)
|
||||
{
|
||||
return Path.Combine(enviromentProvider.GetIISFolder(), IIS_EXE);
|
||||
}
|
||||
|
||||
public static string GetIISConfigPath(this EnviromentProvider enviromentProvider)
|
||||
{
|
||||
return Path.Combine(enviromentProvider.GetIISFolder(), "AppServer", "applicationhost.config");
|
||||
}
|
||||
|
||||
public static string GetWebRoot(this EnviromentProvider enviromentProvider)
|
||||
{
|
||||
return Path.Combine(enviromentProvider.ApplicationPath, WEB_FOLDER);
|
||||
}
|
||||
|
||||
public static string GetAppDataPath(this EnviromentProvider enviromentProvider)
|
||||
{
|
||||
return Path.Combine(enviromentProvider.GetWebRoot(), APP_DATA);
|
||||
}
|
||||
|
||||
public static string GetNlogConfigPath(this EnviromentProvider enviromentProvider)
|
||||
{
|
||||
return Path.Combine(enviromentProvider.GetWebRoot(), LOG_CONFIG_FILE);
|
||||
}
|
||||
|
||||
public static string GetConfigPath(this EnviromentProvider enviromentProvider)
|
||||
{
|
||||
return Path.Combine(enviromentProvider.ApplicationPath, APP_CONFIG_FILE);
|
||||
}
|
||||
|
||||
public static string GetNzbDronoeDbFile(this EnviromentProvider enviromentProvider)
|
||||
{
|
||||
return Path.Combine(enviromentProvider.GetAppDataPath(), NZBDRONE_DB_FILE);
|
||||
}
|
||||
|
||||
public static string GetLogDbFileDbFile(this EnviromentProvider enviromentProvider)
|
||||
{
|
||||
return Path.Combine(enviromentProvider.GetAppDataPath(), LOG_DB_FILE);
|
||||
}
|
||||
|
||||
public static string GetBannerPath(this EnviromentProvider enviromentProvider)
|
||||
{
|
||||
return Path.Combine(enviromentProvider.GetWebRoot(), "Content", "Images", "Banners");
|
||||
}
|
||||
|
||||
public static string GetCacheFolder(this EnviromentProvider enviromentProvider)
|
||||
{
|
||||
return Path.Combine(enviromentProvider.GetWebRoot(), "Cache");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,111 +0,0 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
namespace NzbDrone.Common
|
||||
{
|
||||
public class PathProvider
|
||||
{
|
||||
|
||||
private const string WEB_FOLDER = "NzbDrone.Web";
|
||||
private const string APP_DATA = "App_Data";
|
||||
|
||||
private const string LOG_CONFIG_FILE = "log.config";
|
||||
private const string APP_CONFIG_FILE = "config.xml";
|
||||
|
||||
private const string NZBDRONE_DB_FILE = "nzbdrone.sdf";
|
||||
private const string LOG_DB_FILE = "log.sdf";
|
||||
|
||||
public const string UPDATE_SANDBOX_FOLDER_NAME = "nzbdrone_update";
|
||||
|
||||
private readonly string _applicationPath;
|
||||
|
||||
|
||||
public PathProvider(EnviromentProvider enviromentProvider)
|
||||
{
|
||||
_applicationPath = enviromentProvider.ApplicationPath;
|
||||
}
|
||||
|
||||
public PathProvider()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual String LogPath
|
||||
{
|
||||
get { return Environment.CurrentDirectory; }
|
||||
}
|
||||
|
||||
public virtual string WebRoot
|
||||
{
|
||||
get
|
||||
{
|
||||
return Path.Combine(_applicationPath, WEB_FOLDER);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual string AppData
|
||||
{
|
||||
get
|
||||
{
|
||||
var path = Path.Combine(WebRoot, APP_DATA);
|
||||
if (!Directory.Exists(path))
|
||||
Directory.CreateDirectory(path);
|
||||
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual string NzbDronoeDbFile
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
return Path.Combine(AppData, NZBDRONE_DB_FILE);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual string LogDbFile
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
return Path.Combine(AppData, LOG_DB_FILE);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual String SystemTemp
|
||||
{
|
||||
get
|
||||
{
|
||||
return Path.GetTempPath();
|
||||
}
|
||||
}
|
||||
|
||||
public string LogConfigFile
|
||||
{
|
||||
get { return Path.Combine(WebRoot, LOG_CONFIG_FILE); }
|
||||
}
|
||||
|
||||
public string AppConfigFile
|
||||
{
|
||||
get { return Path.Combine(_applicationPath, APP_CONFIG_FILE); }
|
||||
}
|
||||
|
||||
public string BannerPath
|
||||
{
|
||||
get { return Path.Combine(WebRoot, "Content", "Images", "Banners"); }
|
||||
}
|
||||
|
||||
public string CacheFolder
|
||||
{
|
||||
get { return Path.Combine(AppData, "Cache"); }
|
||||
}
|
||||
|
||||
public string UpdateSandboxFolder
|
||||
{
|
||||
get { return Path.Combine(SystemTemp, UPDATE_SANDBOX_FOLDER_NAME); }
|
||||
}
|
||||
}
|
||||
}
|
@ -22,6 +22,16 @@ public virtual bool ServiceExist(string name)
|
||||
s => String.Equals(s.ServiceName, name, StringComparison.InvariantCultureIgnoreCase));
|
||||
}
|
||||
|
||||
public virtual bool IsServiceRunning(string name)
|
||||
{
|
||||
Logger.Debug("Checking if '{0}' service is running", name);
|
||||
|
||||
var service = ServiceController.GetServices()
|
||||
.SingleOrDefault(s => String.Equals(s.ServiceName, name, StringComparison.InvariantCultureIgnoreCase));
|
||||
|
||||
return service != null && service.Status == ServiceControllerStatus.Running;
|
||||
}
|
||||
|
||||
|
||||
public virtual void Install(string serviceName)
|
||||
{
|
||||
@ -106,16 +116,16 @@ public virtual void Stop(string serviceName)
|
||||
|
||||
public virtual void Start(string serviceName)
|
||||
{
|
||||
Logger.Info("Starting {0} Service...");
|
||||
Logger.Info("Starting {0} Service...", serviceName);
|
||||
var service = GetService(serviceName);
|
||||
if (service == null)
|
||||
{
|
||||
Logger.Warn("Unable to start '{0}' no service with that name exists.", serviceName);
|
||||
}
|
||||
|
||||
if (service.Status != ServiceControllerStatus.Paused || service.Status != ServiceControllerStatus.Stopped)
|
||||
if (service.Status != ServiceControllerStatus.Paused && service.Status != ServiceControllerStatus.Stopped)
|
||||
{
|
||||
Logger.Warn("Service is in a state that can't be started {0}", service.Status);
|
||||
Logger.Warn("Service is in a state that can't be started. Current status: {0}", service.Status);
|
||||
}
|
||||
|
||||
service.Start();
|
||||
@ -125,7 +135,7 @@ public virtual void Start(string serviceName)
|
||||
|
||||
if (service.Status == ServiceControllerStatus.Running)
|
||||
{
|
||||
Logger.Info("{0} has started successfully.");
|
||||
Logger.Info("{0} has started successfully.", serviceName);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
using NLog;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Indexer;
|
||||
@ -13,7 +14,7 @@ namespace NzbDrone.Core.Test
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
class CentralDispatchFixture : TestBase
|
||||
class CentralDispatchFixture : CoreTest
|
||||
{
|
||||
readonly IList<Type> indexers = typeof(CentralDispatch).Assembly.GetTypes().Where(t => t.IsSubclassOf(typeof(IndexerBase))).ToList();
|
||||
readonly IList<Type> jobs = typeof(CentralDispatch).Assembly.GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IJob))).ToList();
|
||||
@ -99,5 +100,12 @@ public void JobProvider_should_be_singletone()
|
||||
|
||||
first.Should().BeSameAs(second);
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDownBase()
|
||||
{
|
||||
WebTimer.Stop();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ namespace NzbDrone.Core.Test
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class EpisodeStatusTest : TestBase
|
||||
public class EpisodeStatusTest : CoreTest
|
||||
{
|
||||
[TestCase(1, false, false, EpisodeStatusType.NotAired)]
|
||||
[TestCase(-2, false, false, EpisodeStatusType.Missing)]
|
||||
|
@ -8,7 +8,7 @@ namespace NzbDrone.Core.Test
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class FluentTest : TestBase
|
||||
public class FluentTest : CoreTest
|
||||
{
|
||||
[TestCase(null, "def", "def")]
|
||||
[TestCase("", "def", "def")]
|
||||
|
53
NzbDrone.Core.Test/Framework/CoreTest.cs
Normal file
53
NzbDrone.Core.Test/Framework/CoreTest.cs
Normal file
@ -0,0 +1,53 @@
|
||||
using System.IO;
|
||||
using NUnit.Framework;
|
||||
using Ninject;
|
||||
using NzbDrone.Test.Common;
|
||||
using PetaPoco;
|
||||
|
||||
namespace NzbDrone.Core.Test.Framework
|
||||
{
|
||||
public class CoreTest : TestBase
|
||||
// ReSharper disable InconsistentNaming
|
||||
{
|
||||
static CoreTest()
|
||||
{
|
||||
var oldDbFiles = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.sdf", SearchOption.AllDirectories);
|
||||
foreach (var file in oldDbFiles)
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(file);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
MockLib.CreateDataBaseTemplate();
|
||||
}
|
||||
|
||||
protected StandardKernel LiveKernel = null;
|
||||
protected IDatabase Db = null;
|
||||
|
||||
|
||||
[SetUp]
|
||||
public virtual void SetupBase()
|
||||
{
|
||||
LiveKernel = new StandardKernel();
|
||||
}
|
||||
|
||||
protected override void WithStrictMocker()
|
||||
{
|
||||
base.WithStrictMocker();
|
||||
|
||||
if (Db != null)
|
||||
{
|
||||
Mocker.SetConstant(Db);
|
||||
}
|
||||
}
|
||||
|
||||
protected void WithRealDb()
|
||||
{
|
||||
Db = MockLib.GetEmptyDatabase();
|
||||
Mocker.SetConstant(Db);
|
||||
}
|
||||
}
|
||||
}
|
@ -22,7 +22,7 @@ namespace NzbDrone.Core.Test
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class IndexerTests : TestBase
|
||||
public class IndexerTests : CoreTest
|
||||
{
|
||||
|
||||
[TestCase("nzbsorg.xml", 2)]
|
||||
|
@ -11,20 +11,19 @@
|
||||
using NzbDrone.Core.Providers.Jobs;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using DiskProvider = NzbDrone.Core.Providers.Core.DiskProvider;
|
||||
|
||||
namespace NzbDrone.Core.Test.JobTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class BannerDownloadJobTest : TestBase
|
||||
public class BannerDownloadJobTest : CoreTest
|
||||
{
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
WithStrictMocker();
|
||||
WithTempAsStartUpPath();
|
||||
WithTempAsAppPath();
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -91,11 +90,11 @@ public void BannerDownload_some_null_BannerUrl()
|
||||
public void BannerDownload_some_failed_download()
|
||||
{
|
||||
//Setup
|
||||
var fakeSeries = Builder<Series>.CreateListOfSize(10)
|
||||
var fakeSeries = Builder<Series>.CreateListOfSize(4)
|
||||
.Build();
|
||||
|
||||
|
||||
var pathProvider = Mocker.Resolve<PathProvider>();
|
||||
var bannerPath = Mocker.GetMock<EnviromentProvider>().Object.GetBannerPath();
|
||||
|
||||
var notification = new ProgressNotification("Banner Download");
|
||||
|
||||
@ -104,43 +103,18 @@ public void BannerDownload_some_failed_download()
|
||||
.Returns(fakeSeries);
|
||||
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(s => s.DownloadFile(It.IsAny<string>(), Path.Combine(pathProvider.BannerPath, "1.jpg")))
|
||||
.Setup(s => s.DownloadFile(It.IsAny<string>(), Path.Combine(bannerPath, "1.jpg")))
|
||||
.Throws(new WebException());
|
||||
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(s => s.DownloadFile(It.IsAny<string>(), Path.Combine(pathProvider.BannerPath, "2.jpg")));
|
||||
.Setup(s => s.DownloadFile(It.IsAny<string>(), Path.Combine(bannerPath, "2.jpg")));
|
||||
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(s => s.DownloadFile(It.IsAny<string>(), Path.Combine(pathProvider.BannerPath, "3.jpg")))
|
||||
.Setup(s => s.DownloadFile(It.IsAny<string>(), Path.Combine(bannerPath, "3.jpg")))
|
||||
.Throws(new WebException());
|
||||
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(s => s.DownloadFile(It.IsAny<string>(), Path.Combine(pathProvider.BannerPath, "4.jpg")));
|
||||
|
||||
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(s => s.DownloadFile(It.IsAny<string>(), Path.Combine(pathProvider.BannerPath, "5.jpg")))
|
||||
.Throws(new WebException());
|
||||
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(s => s.DownloadFile(It.IsAny<string>(), Path.Combine(pathProvider.BannerPath, "6.jpg")));
|
||||
|
||||
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(s => s.DownloadFile(It.IsAny<string>(), Path.Combine(pathProvider.BannerPath, "7.jpg")))
|
||||
.Throws(new WebException());
|
||||
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(s => s.DownloadFile(It.IsAny<string>(), Path.Combine(pathProvider.BannerPath, "8.jpg")));
|
||||
|
||||
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(s => s.DownloadFile(It.IsAny<string>(), Path.Combine(pathProvider.BannerPath, "9.jpg")))
|
||||
.Throws(new WebException());
|
||||
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(s => s.DownloadFile(It.IsAny<string>(), Path.Combine(pathProvider.BannerPath, "10.jpg")));
|
||||
|
||||
.Setup(s => s.DownloadFile(It.IsAny<string>(), Path.Combine(bannerPath, "4.jpg")));
|
||||
|
||||
Mocker.GetMock<DiskProvider>()
|
||||
.Setup(S => S.CreateDirectory(It.IsAny<string>()))
|
||||
|
@ -17,7 +17,7 @@ namespace NzbDrone.Core.Test.JobTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class DiskScanJobTest : TestBase
|
||||
public class DiskScanJobTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void series_specific_scan_should_scan_series()
|
||||
|
@ -17,7 +17,7 @@ namespace NzbDrone.Core.Test.JobTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class ImportNewSeriesJobTest : TestBase
|
||||
public class ImportNewSeriesJobTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void import_new_series_succesfull()
|
||||
|
@ -14,7 +14,7 @@ namespace NzbDrone.Core.Test.JobTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class SeasonSearchJobTest : TestBase
|
||||
public class SeasonSearchJobTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void SeasonSearch_full_season_success()
|
||||
|
@ -11,7 +11,7 @@ namespace NzbDrone.Core.Test.JobTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class SeriesSearchJobTest : TestBase
|
||||
public class SeriesSearchJobTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void SeriesSearch_success()
|
||||
|
@ -84,7 +84,6 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="JobTests\BacklogSearchJobTest.cs" />
|
||||
<Compile Include="JobTests\BannerDownloadJobTest.cs" />
|
||||
<Compile Include="ProviderTests\ConfigFileProviderTest.cs" />
|
||||
<Compile Include="ProviderTests\DiskProviderTests\FreeDiskSpaceTest.cs" />
|
||||
<Compile Include="ProviderTests\ProwlProviderTest.cs" />
|
||||
<Compile Include="ProviderTests\GrowlProviderTest.cs" />
|
||||
@ -115,7 +114,7 @@
|
||||
<Compile Include="ProviderTests\UpcomingEpisodesProviderTest.cs" />
|
||||
<Compile Include="ProviderTests\MediaFileProvider_GetNewFilenameTest.cs" />
|
||||
<Compile Include="dbBenchmark.cs" />
|
||||
<Compile Include="Framework\TestBase.cs" />
|
||||
<Compile Include="Framework\CoreTest.cs" />
|
||||
<Compile Include="ProviderTests\InventoryProvider_IsMonitoredTest.cs" />
|
||||
<Compile Include="ProviderTests\DownloadProviderTest.cs" />
|
||||
<Compile Include="ProviderTests\SearchProviderTest_Episode.cs" />
|
||||
|
@ -10,7 +10,7 @@ namespace NzbDrone.Core.Test
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class ParserTest : TestBase
|
||||
public class ParserTest : CoreTest
|
||||
{
|
||||
/*Fucked-up hall of shame,
|
||||
* WWE.Wrestlemania.27.PPV.HDTV.XviD-KYR
|
||||
|
@ -14,7 +14,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class ConfigProviderTest : TestBase
|
||||
public class ConfigProviderTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void Add_new_value_to_database()
|
||||
|
@ -7,15 +7,15 @@
|
||||
namespace NzbDrone.Core.Test.ProviderTests.DiskProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class ExtractArchiveFixture : TestBase
|
||||
public class ExtractArchiveFixture : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void Should_extract_to_correct_folder()
|
||||
{
|
||||
var diskProvider = new DiskProvider();
|
||||
var archiveProvider = new ArchiveProvider();
|
||||
|
||||
var destination = Path.Combine(TempFolder, "destination");
|
||||
diskProvider.ExtractArchive(GetTestFilePath("TestArchive.zip"), destination);
|
||||
archiveProvider.ExtractArchive(GetTestFilePath("TestArchive.zip"), destination);
|
||||
|
||||
|
||||
var destinationFolder = new DirectoryInfo(destination);
|
||||
|
@ -7,13 +7,14 @@
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.DiskProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class FreeDiskSpaceTest : TestBase
|
||||
public class FreeDiskSpaceTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void FreeDiskSpace()
|
||||
|
@ -4,6 +4,7 @@
|
||||
using FizzWare.NBuilder;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
@ -13,7 +14,7 @@
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class DiskScanProviderTest : TestBase
|
||||
public class DiskScanProviderTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void scan_series_should_update_the_last_scan_date()
|
||||
|
@ -5,6 +5,7 @@
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
@ -16,7 +17,7 @@
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class DiskScanProviderTest_ImportFile : TestBase
|
||||
public class DiskScanProviderTest_ImportFile : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void import_new_file_should_succeed()
|
||||
|
@ -14,7 +14,7 @@
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class DownloadProviderTest : TestBase
|
||||
public class DownloadProviderTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void Download_report_should_send_to_sab_add_to_history_mark_as_grabbed()
|
||||
|
@ -21,7 +21,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class EpisodeProviderTest : TestBase
|
||||
public class EpisodeProviderTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void GetEpisodes_exists()
|
||||
|
@ -15,7 +15,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class EpisodeProviderTest_DeleteInvalidEpisodes : TestBase
|
||||
public class EpisodeProviderTest_DeleteInvalidEpisodes : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void Delete_None_Valid_TvDbEpisodeId()
|
||||
|
@ -15,7 +15,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class EpisodeProviderTest_GetEpisodesByParseResult : TestBase
|
||||
public class EpisodeProviderTest_GetEpisodesByParseResult : CoreTest
|
||||
{
|
||||
|
||||
[Test]
|
||||
|
@ -13,7 +13,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class EventClientProviderTest : TestBase
|
||||
public class EventClientProviderTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void SendNotification_true()
|
||||
|
@ -16,7 +16,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
[Explicit]
|
||||
[TestFixture]
|
||||
public class GrowlProviderTest : TestBase
|
||||
public class GrowlProviderTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void Register_should_add_new_application_to_local_growl_instance()
|
||||
|
@ -14,7 +14,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class HistoryProviderTest : TestBase
|
||||
public class HistoryProviderTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void AllItems()
|
||||
|
@ -18,7 +18,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class IndexerProviderTest : TestBase
|
||||
public class IndexerProviderTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void Init_indexer_test()
|
||||
|
@ -17,7 +17,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class InventoryProvider_IsAcceptableSizeTest : TestBase
|
||||
public class InventoryProvider_IsAcceptableSizeTest : CoreTest
|
||||
{
|
||||
private EpisodeParseResult parseResultMulti;
|
||||
private EpisodeParseResult parseResultSingle;
|
||||
|
@ -17,7 +17,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class InventoryProvider_IsMonitoredTest : TestBase
|
||||
public class InventoryProvider_IsMonitoredTest : CoreTest
|
||||
{
|
||||
private EpisodeParseResult parseResultMulti;
|
||||
private Series series;
|
||||
|
@ -17,7 +17,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class InventoryProvider_QualityNeededTest : TestBase
|
||||
public class InventoryProvider_QualityNeededTest : CoreTest
|
||||
{
|
||||
private Episode episode;
|
||||
private Episode episode2;
|
||||
|
@ -16,7 +16,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class JobProviderTest : TestBase
|
||||
public class JobProviderTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void Run_Jobs_Updates_Last_Execution()
|
||||
|
@ -19,7 +19,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class LogProviderTest : TestBase
|
||||
public class LogProviderTest : CoreTest
|
||||
{
|
||||
|
||||
private const string loggerName = "Core.Test.ProviderTests.LogProviderTest";
|
||||
|
@ -6,6 +6,7 @@
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
@ -15,7 +16,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class MediaFileProviderTests : TestBase
|
||||
public class MediaFileProviderTests : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void get_series_files()
|
||||
|
@ -14,7 +14,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class MediaFileProvider_GetNewFilenameTest : TestBase
|
||||
public class MediaFileProvider_GetNewFilenameTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void GetNewFilename_Series_Episode_Quality_S01E05_Dash()
|
||||
|
@ -12,7 +12,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class PostDownloadProviderFixture : TestBase
|
||||
public class PostDownloadProviderFixture : CoreTest
|
||||
{
|
||||
[TestCase(@"c:\_NzbDrone_InvalidEpisode_Title", @"c:\_UnknownSeries_Title", PostDownloadStatusType.UnknownSeries)]
|
||||
[TestCase(@"c:\Title", @"c:\_Failed_Title", PostDownloadStatusType.Failed)]
|
||||
|
@ -7,6 +7,7 @@
|
||||
using FizzWare.NBuilder;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
@ -17,7 +18,7 @@
|
||||
namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class ProcessDownloadFixture : TestBase
|
||||
public class ProcessDownloadFixture : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void should_skip_if_folder_is_tagged_and_too_fresh()
|
||||
|
@ -18,7 +18,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
[Explicit]
|
||||
[TestFixture]
|
||||
public class ProwlProviderTest : TestBase
|
||||
public class ProwlProviderTest : CoreTest
|
||||
{
|
||||
private const string _apiKey = "c3bdc0f48168f72d546cc6872925b160f5cbffc1";
|
||||
private const string _apiKey2 = "46a710a46b111b0b8633819b0d8a1e0272a3affa";
|
||||
|
@ -13,7 +13,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class QualityTypeProviderTest : TestBase
|
||||
public class QualityTypeProviderTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void SetupDefault_should_add_six_profiles()
|
||||
|
@ -6,6 +6,7 @@
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
@ -15,7 +16,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class RootDirProviderTest : TestBase
|
||||
public class RootDirProviderTest : CoreTest
|
||||
{
|
||||
|
||||
[Test]
|
||||
|
@ -20,7 +20,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class SabProviderTest : TestBase
|
||||
public class SabProviderTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void AddByUrlSuccess()
|
||||
|
@ -19,7 +19,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class SearchProviderTest_Episode : TestBase
|
||||
public class SearchProviderTest_Episode : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void processResults_ParseResult_should_return_after_match()
|
||||
|
@ -17,7 +17,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class SearchProviderTest_PartialSeason : TestBase
|
||||
public class SearchProviderTest_PartialSeason : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void SeasonPartialSearch_season_success()
|
||||
|
@ -18,7 +18,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class SearchProviderTest_Season : TestBase
|
||||
public class SearchProviderTest_Season : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void SeasonSearch_season_success()
|
||||
|
@ -15,7 +15,7 @@
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class SeriesProviderTest : TestBase
|
||||
public class SeriesProviderTest : CoreTest
|
||||
{
|
||||
[TestCase(true)]
|
||||
[TestCase(false)]
|
||||
|
@ -15,7 +15,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class TvDbProviderTest : TestBase
|
||||
public class TvDbProviderTest : CoreTest
|
||||
{
|
||||
private TvDbProvider tvDbProvider;
|
||||
|
||||
|
@ -15,7 +15,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class UpcomingEpisodesProviderTest : TestBase
|
||||
public class UpcomingEpisodesProviderTest : CoreTest
|
||||
{
|
||||
private IList<Episode> episodes;
|
||||
private Series series;
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests
|
||||
{
|
||||
class GetAvilableUpdateFixture : TestBase
|
||||
class GetAvilableUpdateFixture : CoreTest
|
||||
{
|
||||
private AutoMoqer _mocker = null;
|
||||
|
||||
|
@ -1,36 +1,36 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using AutoMoq;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using DiskProvider = NzbDrone.Core.Providers.Core.DiskProvider;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
internal class PreformUpdateFixture : TestBase
|
||||
internal class PreformUpdateFixture : CoreTest
|
||||
{
|
||||
private AutoMoqer _mocker = null;
|
||||
|
||||
|
||||
private const string SANDBOX_FOLDER = @"C:\Temp\nzbdrone_update\";
|
||||
|
||||
[SetUp]
|
||||
public void setup()
|
||||
{
|
||||
_mocker = new AutoMoqer(MockBehavior.Strict);
|
||||
_mocker.GetMock<PathProvider>()
|
||||
.SetupGet(c => c.SystemTemp).Returns(TempFolder);
|
||||
WithStrictMocker();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void Should_call_download_and_extract_using_correct_arguments()
|
||||
{
|
||||
//Act
|
||||
Mocker.GetMock<EnviromentProvider>().SetupGet(c => c.SystemTemp).Returns(@"C:\Temp\");
|
||||
|
||||
var updatePackage = new UpdatePackage
|
||||
{
|
||||
FileName = "NzbDrone.kay.one.0.6.0.2031.zip",
|
||||
@ -38,21 +38,25 @@ public void Should_call_download_and_extract_using_correct_arguments()
|
||||
Version = new Version("0.6.0.2031")
|
||||
};
|
||||
|
||||
_mocker.GetMock<HttpProvider>().Setup(
|
||||
c => c.DownloadFile(updatePackage.Url, Path.Combine(TempFolder, PathProvider.UPDATE_SANDBOX_FOLDER_NAME, updatePackage.FileName)));
|
||||
var updateArchive = Path.Combine(SANDBOX_FOLDER, updatePackage.FileName);
|
||||
|
||||
_mocker.GetMock<DiskProvider>().Setup(
|
||||
c => c.ExtractArchive(Path.Combine(TempFolder, PathProvider.UPDATE_SANDBOX_FOLDER_NAME, updatePackage.FileName),
|
||||
Path.Combine(TempFolder, PathProvider.UPDATE_SANDBOX_FOLDER_NAME)));
|
||||
Mocker.GetMock<HttpProvider>().Setup(
|
||||
c => c.DownloadFile(updatePackage.Url, updateArchive));
|
||||
|
||||
_mocker.Resolve<UpdateProvider>().PreformUpdate(updatePackage);
|
||||
Mocker.GetMock<ArchiveProvider>().Setup(
|
||||
c => c.ExtractArchive(updateArchive, SANDBOX_FOLDER));
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<UpdateProvider>().StartUpgrade(updatePackage);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Should_download_and_extract_to_temp_folder()
|
||||
{
|
||||
|
||||
var updateSubFolder = new DirectoryInfo(Path.Combine(TempFolder, PathProvider.UPDATE_SANDBOX_FOLDER_NAME));
|
||||
Mocker.GetMock<EnviromentProvider>().SetupGet(c => c.SystemTemp).Returns(TempFolder);
|
||||
|
||||
var updateSubFolder = new DirectoryInfo(Mocker.GetMock<EnviromentProvider>().Object.GetUpdateSandboxFolder());
|
||||
|
||||
var updatePackage = new UpdatePackage
|
||||
{
|
||||
@ -65,9 +69,10 @@ public void Should_download_and_extract_to_temp_folder()
|
||||
//Act
|
||||
updateSubFolder.Exists.Should().BeFalse();
|
||||
|
||||
_mocker.Resolve<HttpProvider>();
|
||||
_mocker.Resolve<DiskProvider>();
|
||||
_mocker.Resolve<UpdateProvider>().PreformUpdate(updatePackage);
|
||||
Mocker.Resolve<HttpProvider>();
|
||||
Mocker.Resolve<DiskProvider>();
|
||||
Mocker.Resolve<ArchiveProvider>();
|
||||
Mocker.Resolve<UpdateProvider>().StartUpgrade(updatePackage);
|
||||
updateSubFolder.Refresh();
|
||||
//Assert
|
||||
|
||||
|
@ -17,7 +17,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class XbmcProviderTest : TestBase
|
||||
public class XbmcProviderTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void JsonError_true()
|
||||
|
@ -14,7 +14,7 @@ namespace NzbDrone.Core.Test
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class QualityProfileTest : TestBase
|
||||
public class QualityProfileTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void Test_Storage()
|
||||
|
@ -8,7 +8,7 @@ namespace NzbDrone.Core.Test
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class QualityTest : TestBase
|
||||
public class QualityTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void Icomparer_greater_test()
|
||||
|
@ -9,7 +9,7 @@ namespace NzbDrone.Core.Test
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class SceneMappingTest : TestBase
|
||||
public class SceneMappingTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void GetSceneName_exists()
|
||||
|
@ -17,7 +17,7 @@ namespace NzbDrone.Core.Test
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class SortHelperTest : TestBase
|
||||
public class SortHelperTest : CoreTest
|
||||
{
|
||||
//American Gladiators
|
||||
//Ancient Apocalypse
|
||||
|
@ -18,7 +18,7 @@ namespace NzbDrone.Core.Test
|
||||
[Explicit]
|
||||
[Category("Benchmark")]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class DbBenchmark : TestBase
|
||||
public class DbBenchmark : CoreTest
|
||||
{
|
||||
const int Episodes_Per_Season = 20;
|
||||
private readonly List<int> seasonsNumbers = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
|
||||
|
@ -3,6 +3,7 @@
|
||||
using System.Linq;
|
||||
using Ninject;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Instrumentation;
|
||||
using NzbDrone.Core.Providers;
|
||||
@ -11,6 +12,7 @@
|
||||
using NzbDrone.Core.Providers.Indexer;
|
||||
using NzbDrone.Core.Providers.Jobs;
|
||||
using PetaPoco;
|
||||
using LogConfiguration = NzbDrone.Core.Instrumentation.LogConfiguration;
|
||||
|
||||
namespace NzbDrone.Core
|
||||
{
|
||||
@ -37,6 +39,7 @@ private void InitializeApp()
|
||||
MigrationsHelper.Run(mainConnectionString, true);
|
||||
|
||||
LogConfiguration.RegisterDatabaseLogger(Kernel.Get<DatabaseTarget>());
|
||||
LogConfiguration.Reload();
|
||||
|
||||
Kernel.Get<QualityProvider>().SetupDefaultProfiles();
|
||||
Kernel.Get<QualityTypeProvider>().SetupDefault();
|
||||
@ -118,7 +121,7 @@ public void DedicateToHost()
|
||||
{
|
||||
try
|
||||
{
|
||||
var pid = Convert.ToInt32(Environment.GetEnvironmentVariable("NZBDRONE_PID"));
|
||||
var pid = new EnviromentProvider().NzbDroneProcessIdFromEnviroment;
|
||||
|
||||
Logger.Debug("Attaching to parent process ({0}) for automatic termination.", pid);
|
||||
|
||||
@ -135,7 +138,7 @@ public void DedicateToHost()
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Fatal(e);
|
||||
Logger.FatalException("An error has occurred while dedicating to host.", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,22 +1,16 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Data.SqlServerCe;
|
||||
using System.IO;
|
||||
using MvcMiniProfiler.Data;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Providers;
|
||||
using PetaPoco;
|
||||
|
||||
namespace NzbDrone.Core.Datastore
|
||||
{
|
||||
public class Connection
|
||||
{
|
||||
private readonly PathProvider _pathProvider;
|
||||
private readonly EnviromentProvider _enviromentProvider;
|
||||
|
||||
public Connection(PathProvider pathProvider)
|
||||
public Connection(EnviromentProvider enviromentProvider)
|
||||
{
|
||||
_pathProvider = pathProvider;
|
||||
_enviromentProvider = enviromentProvider;
|
||||
}
|
||||
|
||||
static Connection()
|
||||
@ -28,7 +22,7 @@ public String MainConnectionString
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetConnectionString(_pathProvider.NzbDronoeDbFile);
|
||||
return GetConnectionString(_enviromentProvider.GetNzbDronoeDbFile());
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,7 +30,7 @@ public String LogConnectionString
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetConnectionString(_pathProvider.LogDbFile);
|
||||
return GetConnectionString(_enviromentProvider.GetLogDbFileDbFile());
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,7 +39,7 @@ public static string GetConnectionString(string path)
|
||||
//return String.Format("Data Source={0};Version=3;Cache Size=30000;Pooling=true;Default Timeout=2", path);
|
||||
return String.Format("Data Source={0}", path);
|
||||
}
|
||||
|
||||
|
||||
public IDatabase GetMainPetaPocoDb(Boolean profiled = true)
|
||||
{
|
||||
return GetPetaPocoDb(MainConnectionString, profiled);
|
||||
|
@ -9,12 +9,12 @@ namespace NzbDrone.Core.Instrumentation
|
||||
{
|
||||
public class LogConfiguration
|
||||
{
|
||||
private readonly PathProvider _pathProvider;
|
||||
private readonly EnviromentProvider _enviromentProvider;
|
||||
private readonly DatabaseTarget _databaseTarget;
|
||||
|
||||
public LogConfiguration(PathProvider pathProvider, DatabaseTarget databaseTarget)
|
||||
public LogConfiguration(EnviromentProvider enviromentProvider, DatabaseTarget databaseTarget)
|
||||
{
|
||||
_pathProvider = pathProvider;
|
||||
_enviromentProvider = enviromentProvider;
|
||||
_databaseTarget = databaseTarget;
|
||||
}
|
||||
|
||||
@ -25,18 +25,24 @@ public void Setup()
|
||||
LogManager.ThrowExceptions = false;
|
||||
}
|
||||
|
||||
LogManager.Configuration = new XmlLoggingConfiguration(_pathProvider.LogConfigFile, false);
|
||||
LogManager.Configuration = new XmlLoggingConfiguration(_enviromentProvider.GetNlogConfigPath(), false);
|
||||
|
||||
Common.LogConfiguration.RegisterConsoleLogger(LogLevel.Info, "NzbDrone.Web.MvcApplication");
|
||||
Common.LogConfiguration.RegisterConsoleLogger(LogLevel.Info, "NzbDrone.Core.CentralDispatch");
|
||||
|
||||
LogManager.ConfigurationReloaded += ((s, e) => RegisterDatabaseLogger(_databaseTarget));
|
||||
|
||||
}
|
||||
|
||||
public static void RegisterDatabaseLogger(DatabaseTarget databaseTarget)
|
||||
{
|
||||
LogManager.Configuration.AddTarget("DbLogger", databaseTarget);
|
||||
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Debug, databaseTarget));
|
||||
Reload();
|
||||
}
|
||||
|
||||
public static void Reload()
|
||||
{
|
||||
Common.LogConfiguration.Reload();
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace NzbDrone.Core.Model
|
||||
{
|
||||
public enum AuthenticationType
|
||||
{
|
||||
Anonymous = 0,
|
||||
Windows = 1
|
||||
}
|
||||
}
|
@ -121,10 +121,6 @@
|
||||
<StartupObject />
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Exceptioneer.WindowsFormsClient, Version=1.0.0.812, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Libraries\Exceptioneer.WindowsFormsClient.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Growl.Connector">
|
||||
<HintPath>..\packages\Growl.0.6\lib\Growl.Connector.dll</HintPath>
|
||||
</Reference>
|
||||
@ -134,7 +130,6 @@
|
||||
<Reference Include="Ionic.Zip">
|
||||
<HintPath>..\packages\DotNetZip.1.9.1.8\lib\net20\Ionic.Zip.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Migrator, Version=0.9.1.26254, Culture=neutral, PublicKeyToken=3b3586e9632ecfce, processorArchitecture=x86">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Libraries\Migrator.NET\Migrator.dll</HintPath>
|
||||
@ -143,17 +138,10 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Libraries\Migrator.NET\Migrator.Framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Migrator.Providers, Version=0.0.0.0, Culture=neutral, PublicKeyToken=3b3586e9632ecfce, processorArchitecture=x86">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Libraries\Migrator.NET\Migrator.Providers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MvcMiniProfiler, Version=1.9.0.0, Culture=neutral, PublicKeyToken=b44f9351044011a3, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\MiniProfiler.1.9\lib\net40\MvcMiniProfiler.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>..\packages\Newtonsoft.Json.3.5.8\lib\35\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Ninject, Version=2.2.0.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Ninject.2.2.1.4\lib\net40-Full\Ninject.dll</HintPath>
|
||||
</Reference>
|
||||
@ -164,7 +152,6 @@
|
||||
<HintPath>..\packages\Prowlin 0.9.4163.39219\Prowlin.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.Composition" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System.configuration" />
|
||||
<Reference Include="System.Core" />
|
||||
@ -174,7 +161,6 @@
|
||||
<HintPath>..\packages\SqlServerCompact.4.0.8482.1\lib\System.Data.SqlServerCe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.ServiceModel" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.Extensions" />
|
||||
@ -212,7 +198,6 @@
|
||||
<Compile Include="Instrumentation\NlogWriter.cs" />
|
||||
<Compile Include="Datastore\PetaPoco\PetaPoco.cs" />
|
||||
<Compile Include="Model\AtomicParsleyTitleType.cs" />
|
||||
<Compile Include="Model\AuthenticationType.cs" />
|
||||
<Compile Include="Model\ConnectionInfoModel.cs" />
|
||||
<Compile Include="Model\PostDownloadStatusType.cs" />
|
||||
<Compile Include="Model\ExternalNotificationType.cs" />
|
||||
@ -236,7 +221,6 @@
|
||||
<Compile Include="Providers\NewznzbProvider.cs" />
|
||||
<Compile Include="Providers\ExternalNotification\Prowl.cs" />
|
||||
<Compile Include="Providers\ProwlProvider.cs" />
|
||||
<Compile Include="Providers\Core\ConfigFileProvider.cs" />
|
||||
<Compile Include="Providers\Core\UdpProvider.cs" />
|
||||
<Compile Include="Providers\ExternalNotification\Growl.cs" />
|
||||
<Compile Include="Providers\ExternalNotification\Twitter.cs" />
|
||||
@ -329,7 +313,7 @@
|
||||
<Compile Include="Repository\Series.cs" />
|
||||
<Compile Include="CentralDispatch.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Providers\Core\DiskProvider.cs" />
|
||||
<Compile Include="Providers\Core\ArchiveProvider.cs" />
|
||||
<Compile Include="Providers\SeriesProvider.cs" />
|
||||
<Compile Include="Providers\TvDbProvider.cs" />
|
||||
<Compile Include="WebTimer.cs" />
|
||||
|
25
NzbDrone.Core/Providers/Core/ArchiveProvider.cs
Normal file
25
NzbDrone.Core/Providers/Core/ArchiveProvider.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System.Linq;
|
||||
using Ionic.Zip;
|
||||
using NLog;
|
||||
|
||||
namespace NzbDrone.Core.Providers.Core
|
||||
{
|
||||
public class ArchiveProvider
|
||||
{
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
|
||||
public virtual void ExtractArchive(string compressedFile, string destination)
|
||||
{
|
||||
logger.Trace("Extracting archive [{0}] to [{1}]", compressedFile, destination);
|
||||
|
||||
using (ZipFile zipFile = ZipFile.Read(compressedFile))
|
||||
{
|
||||
zipFile.ExtractAll(destination);
|
||||
}
|
||||
|
||||
logger.Trace("Extraction complete.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,124 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Model;
|
||||
|
||||
namespace NzbDrone.Core.Providers.Core
|
||||
{
|
||||
public class ConfigFileProvider
|
||||
{
|
||||
private readonly PathProvider _pathProvider;
|
||||
|
||||
private readonly string _configFile;
|
||||
public ConfigFileProvider(PathProvider pathProvider)
|
||||
{
|
||||
_pathProvider = pathProvider;
|
||||
_configFile = _pathProvider.AppConfigFile;
|
||||
}
|
||||
|
||||
public virtual int Port
|
||||
{
|
||||
get { return GetValueInt("Port", 8989); }
|
||||
set { SetValue("Port", value); }
|
||||
}
|
||||
|
||||
public virtual bool LaunchBrowser
|
||||
{
|
||||
get { return GetValueBoolean("LaunchBrowser", true); }
|
||||
set { SetValue("LaunchBrowser", value); }
|
||||
}
|
||||
|
||||
public virtual AuthenticationType AuthenticationType
|
||||
{
|
||||
get { return (AuthenticationType)GetValueInt("AuthenticationType", 0); }
|
||||
set { SetValue("AuthenticationType", (int)value); }
|
||||
}
|
||||
|
||||
public virtual string GetValue(string key, object defaultValue, string parent = null)
|
||||
{
|
||||
var xDoc = XDocument.Load(_configFile);
|
||||
var config = xDoc.Descendants("Config").Single();
|
||||
|
||||
var parentContainer = config;
|
||||
|
||||
if (!String.IsNullOrEmpty(parent))
|
||||
{
|
||||
//Add the parent
|
||||
if (config.Descendants(parent).Count() != 1)
|
||||
{
|
||||
SetValue(key, defaultValue, parent);
|
||||
|
||||
//Reload the configFile
|
||||
xDoc = XDocument.Load(_configFile);
|
||||
config = xDoc.Descendants("Config").Single();
|
||||
}
|
||||
|
||||
parentContainer = config.Descendants(parent).Single();
|
||||
}
|
||||
|
||||
var valueHolder = parentContainer.Descendants(key).ToList();
|
||||
|
||||
if (valueHolder.Count() == 1)
|
||||
return valueHolder.First().Value;
|
||||
|
||||
//Save the value
|
||||
SetValue(key, defaultValue, parent);
|
||||
|
||||
//return the default value
|
||||
return defaultValue.ToString();
|
||||
}
|
||||
|
||||
public virtual int GetValueInt(string key, int defaultValue, string parent = null)
|
||||
{
|
||||
return Convert.ToInt32(GetValue(key, defaultValue, parent));
|
||||
}
|
||||
|
||||
public virtual bool GetValueBoolean(string key, bool defaultValue, string parent = null)
|
||||
{
|
||||
return Convert.ToBoolean(GetValue(key, defaultValue, parent));
|
||||
}
|
||||
|
||||
public virtual void SetValue(string key, object value, string parent = null)
|
||||
{
|
||||
var xDoc = XDocument.Load(_configFile);
|
||||
var config = xDoc.Descendants("Config").Single();
|
||||
|
||||
var parentContainer = config;
|
||||
|
||||
if (!String.IsNullOrEmpty(parent))
|
||||
{
|
||||
//Add the parent container if it doesn't already exist
|
||||
if (config.Descendants(parent).Count() != 1)
|
||||
{
|
||||
config.Add(new XElement(parent));
|
||||
}
|
||||
|
||||
parentContainer = config.Descendants(parent).Single();
|
||||
}
|
||||
|
||||
var keyHolder = parentContainer.Descendants(key);
|
||||
|
||||
if (keyHolder.Count() != 1)
|
||||
parentContainer.Add(new XElement(key, value));
|
||||
|
||||
else
|
||||
parentContainer.Descendants(key).Single().Value = value.ToString();
|
||||
|
||||
xDoc.Save(_configFile);
|
||||
}
|
||||
|
||||
public virtual void CreateDefaultConfigFile()
|
||||
{
|
||||
if (!File.Exists(_configFile))
|
||||
{
|
||||
var xDoc = new XDocument(new XDeclaration("1.0", "utf-8", "yes"));
|
||||
|
||||
xDoc.Add(new XElement("Config"));
|
||||
|
||||
xDoc.Save(_configFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,122 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using Ionic.Zip;
|
||||
using NLog;
|
||||
|
||||
namespace NzbDrone.Core.Providers.Core
|
||||
{
|
||||
public class DiskProvider
|
||||
{
|
||||
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
static extern bool GetDiskFreeSpaceEx(string lpDirectoryName,
|
||||
out ulong lpFreeBytesAvailable,
|
||||
out ulong lpTotalNumberOfBytes,
|
||||
out ulong lpTotalNumberOfFreeBytes);
|
||||
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public virtual bool FolderExists(string path)
|
||||
{
|
||||
return Directory.Exists(path);
|
||||
}
|
||||
|
||||
public virtual bool FileExists(string path)
|
||||
{
|
||||
return File.Exists(path);
|
||||
}
|
||||
|
||||
public virtual string[] GetDirectories(string path)
|
||||
{
|
||||
return Directory.GetDirectories(path);
|
||||
}
|
||||
|
||||
public virtual string[] GetFiles(string path, SearchOption searchOption)
|
||||
{
|
||||
return Directory.GetFiles(path, "*.*", searchOption);
|
||||
}
|
||||
|
||||
public virtual long GetDirectorySize(string path)
|
||||
{
|
||||
return GetFiles(path, SearchOption.AllDirectories).Sum(e => new FileInfo(e).Length);
|
||||
}
|
||||
|
||||
public virtual long GetSize(string path)
|
||||
{
|
||||
var fi = new FileInfo(path);
|
||||
return fi.Length;
|
||||
//return new FileInfo(path).Length;
|
||||
}
|
||||
|
||||
public virtual String CreateDirectory(string path)
|
||||
{
|
||||
return Directory.CreateDirectory(path).FullName;
|
||||
}
|
||||
|
||||
public virtual void DeleteFile(string path)
|
||||
{
|
||||
File.Delete(path);
|
||||
}
|
||||
|
||||
public virtual void MoveFile(string sourcePath, string destinationPath)
|
||||
{
|
||||
File.Move(sourcePath, destinationPath);
|
||||
}
|
||||
|
||||
public virtual void DeleteFolder(string path, bool recursive)
|
||||
{
|
||||
Directory.Delete(path, recursive);
|
||||
}
|
||||
|
||||
public virtual DateTime DirectoryDateCreated(string path)
|
||||
{
|
||||
return Directory.GetCreationTime(path);
|
||||
}
|
||||
|
||||
public virtual IEnumerable<FileInfo> GetFileInfos(string path, string pattern, SearchOption searchOption)
|
||||
{
|
||||
return new DirectoryInfo(path).GetFiles(pattern, searchOption);
|
||||
}
|
||||
|
||||
public virtual void MoveDirectory(string source, string destination)
|
||||
{
|
||||
Directory.Move(source, destination);
|
||||
}
|
||||
|
||||
public virtual void ExtractArchive(string compressedFile, string destination)
|
||||
{
|
||||
Logger.Trace("Extracting archive [{0}] to [{1}]", compressedFile, destination);
|
||||
|
||||
using (ZipFile zipFile = ZipFile.Read(compressedFile))
|
||||
{
|
||||
zipFile.ExtractAll(destination);
|
||||
}
|
||||
|
||||
Logger.Trace("Extraction complete.");
|
||||
}
|
||||
|
||||
public virtual void InheritFolderPermissions(string filename)
|
||||
{
|
||||
var fs = File.GetAccessControl(filename);
|
||||
fs.SetAccessRuleProtection(false, false);
|
||||
File.SetAccessControl(filename, fs);
|
||||
}
|
||||
|
||||
public virtual ulong FreeDiskSpace(DirectoryInfo directoryInfo)
|
||||
{
|
||||
ulong freeBytesAvailable;
|
||||
ulong totalNumberOfBytes;
|
||||
ulong totalNumberOfFreeBytes;
|
||||
|
||||
bool success = GetDiskFreeSpaceEx(directoryInfo.FullName, out freeBytesAvailable, out totalNumberOfBytes,
|
||||
out totalNumberOfFreeBytes);
|
||||
if (!success)
|
||||
throw new System.ComponentModel.Win32Exception();
|
||||
|
||||
return freeBytesAvailable;
|
||||
}
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@
|
||||
using System.Linq;
|
||||
using Ninject;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
|
@ -8,7 +8,6 @@
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
using DiskProvider = NzbDrone.Core.Providers.Core.DiskProvider;
|
||||
|
||||
namespace NzbDrone.Core.Providers.Jobs
|
||||
{
|
||||
@ -18,20 +17,18 @@ public class BannerDownloadJob : IJob
|
||||
private readonly HttpProvider _httpProvider;
|
||||
private readonly DiskProvider _diskProvider;
|
||||
private readonly EnviromentProvider _enviromentProvider;
|
||||
private readonly PathProvider _pathProvider;
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private const string _bannerUrlPrefix = "http://www.thetvdb.com/banners/";
|
||||
|
||||
[Inject]
|
||||
public BannerDownloadJob(SeriesProvider seriesProvider, HttpProvider httpProvider, DiskProvider diskProvider,
|
||||
EnviromentProvider enviromentProvider, PathProvider pathProvider)
|
||||
EnviromentProvider enviromentProvider)
|
||||
{
|
||||
_seriesProvider = seriesProvider;
|
||||
_httpProvider = httpProvider;
|
||||
_diskProvider = diskProvider;
|
||||
_enviromentProvider = enviromentProvider;
|
||||
_pathProvider = pathProvider;
|
||||
}
|
||||
|
||||
public BannerDownloadJob()
|
||||
@ -54,7 +51,7 @@ public virtual void Start(ProgressNotification notification, int targetId, int s
|
||||
Logger.Debug("Starting banner download job");
|
||||
|
||||
|
||||
_diskProvider.CreateDirectory(_pathProvider.BannerPath);
|
||||
_diskProvider.CreateDirectory(_enviromentProvider.GetBannerPath());
|
||||
|
||||
if (targetId > 0)
|
||||
{
|
||||
@ -78,7 +75,7 @@ public virtual void Start(ProgressNotification notification, int targetId, int s
|
||||
|
||||
public virtual void DownloadBanner(ProgressNotification notification, Series series)
|
||||
{
|
||||
var bannerFilename = Path.Combine(_pathProvider.BannerPath, series.SeriesId.ToString()) + ".jpg";
|
||||
var bannerFilename = Path.Combine(_enviromentProvider.GetBannerPath(), series.SeriesId.ToString()) + ".jpg";
|
||||
|
||||
notification.CurrentMessage = string.Format("Downloading banner for '{0}'", series.Title);
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using NLog;
|
||||
using Ninject;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using NLog;
|
||||
using Ninject;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
using System.IO;
|
||||
using Ninject;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
using PetaPoco;
|
||||
|
@ -13,15 +13,17 @@ namespace NzbDrone.Core.Providers
|
||||
{
|
||||
public class TvDbProvider
|
||||
{
|
||||
private readonly EnviromentProvider _enviromentProvider;
|
||||
private const string TVDB_APIKEY = "5D2D188E86E07F4F";
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private readonly TvdbHandler _handler;
|
||||
|
||||
[Inject]
|
||||
public TvDbProvider(PathProvider pathProvider)
|
||||
public TvDbProvider(EnviromentProvider enviromentProvider)
|
||||
{
|
||||
_handler = new TvdbHandler(new XmlCacheProvider(pathProvider.CacheFolder), TVDB_APIKEY);
|
||||
_enviromentProvider = enviromentProvider;
|
||||
_handler = new TvdbHandler(new XmlCacheProvider(_enviromentProvider.GetCacheFolder()), TVDB_APIKEY);
|
||||
}
|
||||
|
||||
public TvDbProvider()
|
||||
|
@ -2,14 +2,13 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using NLog;
|
||||
using Ninject;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using DiskProvider = NzbDrone.Core.Providers.Core.DiskProvider;
|
||||
|
||||
|
||||
namespace NzbDrone.Core.Providers
|
||||
{
|
||||
@ -18,23 +17,21 @@ class UpdateProvider
|
||||
private readonly HttpProvider _httpProvider;
|
||||
private readonly ConfigProvider _configProvider;
|
||||
private readonly EnviromentProvider _enviromentProvider;
|
||||
private readonly PathProvider _pathProvider;
|
||||
private readonly DiskProvider _diskProvider;
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
private readonly ArchiveProvider _archiveProvider;
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private static readonly Regex ParseRegex = new Regex(@"(?:\>)(?<filename>NzbDrone.+?(?<version>\d+\.\d+\.\d+\.\d+).+?)(?:\<\/A\>)", RegexOptions.IgnoreCase);
|
||||
private static readonly Regex parseRegex = new Regex(@"(?:\>)(?<filename>NzbDrone.+?(?<version>\d+\.\d+\.\d+\.\d+).+?)(?:\<\/A\>)", RegexOptions.IgnoreCase);
|
||||
|
||||
|
||||
|
||||
[Inject]
|
||||
public UpdateProvider(HttpProvider httpProvider, ConfigProvider configProvider, EnviromentProvider enviromentProvider,
|
||||
PathProvider pathProvider, DiskProvider diskProvider)
|
||||
public UpdateProvider(HttpProvider httpProvider, ConfigProvider configProvider,
|
||||
EnviromentProvider enviromentProvider, ArchiveProvider archiveProvider)
|
||||
{
|
||||
_httpProvider = httpProvider;
|
||||
_configProvider = configProvider;
|
||||
_enviromentProvider = enviromentProvider;
|
||||
_pathProvider = pathProvider;
|
||||
_diskProvider = diskProvider;
|
||||
_archiveProvider = archiveProvider;
|
||||
}
|
||||
|
||||
public UpdateProvider()
|
||||
@ -46,7 +43,7 @@ private List<UpdatePackage> GetAvailablePackages()
|
||||
{
|
||||
var updateList = new List<UpdatePackage>();
|
||||
var rawUpdateList = _httpProvider.DownloadString(_configProvider.UpdateUrl);
|
||||
var matches = ParseRegex.Matches(rawUpdateList);
|
||||
var matches = parseRegex.Matches(rawUpdateList);
|
||||
|
||||
foreach (Match match in matches)
|
||||
{
|
||||
@ -66,25 +63,25 @@ public virtual UpdatePackage GetAvilableUpdate()
|
||||
|
||||
if (latestAvailable != null && latestAvailable.Version > _enviromentProvider.Version)
|
||||
{
|
||||
Logger.Debug("An update is available ({0}) => ({1})", _enviromentProvider.Version, latestAvailable.Version);
|
||||
logger.Debug("An update is available ({0}) => ({1})", _enviromentProvider.Version, latestAvailable.Version);
|
||||
return latestAvailable;
|
||||
}
|
||||
|
||||
Logger.Trace("No updates available");
|
||||
logger.Trace("No updates available");
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual void PreformUpdate(UpdatePackage updatePackage)
|
||||
public virtual void StartUpgrade(UpdatePackage updatePackage)
|
||||
{
|
||||
var packageDestination = Path.Combine(_pathProvider.UpdateSandboxFolder, updatePackage.FileName);
|
||||
var packageDestination = Path.Combine(_enviromentProvider.GetUpdateSandboxFolder(), updatePackage.FileName);
|
||||
|
||||
Logger.Info("Downloading update package from [{0}] to [{1}]", updatePackage.Url, packageDestination);
|
||||
logger.Info("Downloading update package from [{0}] to [{1}]", updatePackage.Url, packageDestination);
|
||||
_httpProvider.DownloadFile(updatePackage.Url, packageDestination);
|
||||
Logger.Info("Download completed for update package from [{0}]", updatePackage.FileName);
|
||||
logger.Info("Download completed for update package from [{0}]", updatePackage.FileName);
|
||||
|
||||
Logger.Info("Extracting Update package");
|
||||
_diskProvider.ExtractArchive(packageDestination, _pathProvider.UpdateSandboxFolder);
|
||||
Logger.Info("Update package extracted successfully");
|
||||
logger.Info("Extracting Update package");
|
||||
_archiveProvider.ExtractArchive(packageDestination, _enviromentProvider.GetUpdateSandboxFolder());
|
||||
logger.Info("Update package extracted successfully");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
using NLog;
|
||||
using NLog.Config;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
|
||||
namespace NzbDrone.Test.Common
|
||||
@ -15,6 +16,7 @@ protected static void InitLogging()
|
||||
LogConfiguration.RegisterUdpLogger();
|
||||
|
||||
RegisterExceptionVerification();
|
||||
LogConfiguration.Reload();
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,7 +25,19 @@ private static void RegisterExceptionVerification()
|
||||
var exceptionVerification = new ExceptionVerification();
|
||||
LogManager.Configuration.AddTarget("ExceptionVerification", exceptionVerification);
|
||||
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Trace, exceptionVerification));
|
||||
LogConfiguration.Reload();
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
public void LoggingTestSetup()
|
||||
{
|
||||
InitLogging();
|
||||
ExceptionVerification.Reset();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void LoggingDownBase()
|
||||
{
|
||||
ExceptionVerification.AssertNoUnexcpectedLogs();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -71,6 +71,7 @@
|
||||
<Compile Include="ExceptionVerification.cs" />
|
||||
<Compile Include="LoggingTest.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="TestBase.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="AutoMoq\License.txt" />
|
||||
|
@ -1,35 +1,16 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using AutoMoq;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Ninject;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Test.Common;
|
||||
using PetaPoco;
|
||||
|
||||
namespace NzbDrone.Core.Test.Framework
|
||||
namespace NzbDrone.Test.Common
|
||||
{
|
||||
public class TestBase : LoggingTest
|
||||
// ReSharper disable InconsistentNaming
|
||||
{
|
||||
static TestBase()
|
||||
{
|
||||
var oldDbFiles = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.sdf", SearchOption.AllDirectories);
|
||||
foreach (var file in oldDbFiles)
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(file);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
MockLib.CreateDataBaseTemplate();
|
||||
}
|
||||
|
||||
protected StandardKernel LiveKernel = null;
|
||||
protected AutoMoqer Mocker = null;
|
||||
protected IDatabase Db = null;
|
||||
protected AutoMoqer Mocker;
|
||||
|
||||
protected string VirtualPath
|
||||
{
|
||||
@ -43,11 +24,8 @@ protected string VirtualPath
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
public virtual void SetupBase()
|
||||
public void TestBaseSetup()
|
||||
{
|
||||
InitLogging();
|
||||
|
||||
ExceptionVerification.Reset();
|
||||
if (Directory.Exists(TempFolder))
|
||||
{
|
||||
Directory.Delete(TempFolder, true);
|
||||
@ -55,41 +33,26 @@ public virtual void SetupBase()
|
||||
|
||||
Directory.CreateDirectory(TempFolder);
|
||||
|
||||
LiveKernel = new StandardKernel();
|
||||
Mocker = new AutoMoqer();
|
||||
}
|
||||
|
||||
protected void WithStrictMocker()
|
||||
{
|
||||
Mocker = new AutoMoqer(MockBehavior.Strict);
|
||||
if (Db != null)
|
||||
{
|
||||
Mocker.SetConstant(Db);
|
||||
}
|
||||
}
|
||||
|
||||
protected void WithRealDb()
|
||||
{
|
||||
Db = MockLib.GetEmptyDatabase();
|
||||
Mocker.SetConstant(Db);
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDownBase()
|
||||
public void TestBaseTearDown()
|
||||
{
|
||||
Mocker.VerifyAllMocks();
|
||||
}
|
||||
|
||||
protected virtual void WithStrictMocker()
|
||||
{
|
||||
ExceptionVerification.AssertNoUnexcpectedLogs();
|
||||
Mocker = new AutoMoqer(MockBehavior.Strict);
|
||||
WebTimer.Stop();
|
||||
}
|
||||
|
||||
|
||||
protected void WithTempAsStartUpPath()
|
||||
protected void WithTempAsAppPath()
|
||||
{
|
||||
Mocker.GetMock<EnviromentProvider>()
|
||||
.SetupGet(c => c.ApplicationPath)
|
||||
.Returns(VirtualPath);
|
||||
|
||||
Mocker.Resolve<PathProvider>();
|
||||
}
|
||||
|
||||
|
@ -1,8 +0,0 @@
|
||||
// ReSharper disable CheckNamespace
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
[SetUpFixture]
|
||||
public class Fixtures : LoggingTest
|
||||
{
|
||||
}
|
@ -48,6 +48,7 @@
|
||||
<Reference Include="Moq">
|
||||
<HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NLog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL" />
|
||||
<Reference Include="nunit.framework">
|
||||
<HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
@ -66,9 +67,9 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Fixtures.cs" />
|
||||
<Compile Include="UpdateProviderVerifyTest.cs" />
|
||||
<Compile Include="UpdateProviderStartTest.cs" />
|
||||
<Compile Include="ProgramFixture.cs" />
|
||||
<Compile Include="UpdateProviderVerifyFixture.cs" />
|
||||
<Compile Include="UpdateProviderStartFixture.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
72
NzbDrone.Update.Test/ProgramFixture.cs
Normal file
72
NzbDrone.Update.Test/ProgramFixture.cs
Normal file
@ -0,0 +1,72 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Model;
|
||||
using NzbDrone.Test.Common;
|
||||
using NzbDrone.Update.Providers;
|
||||
|
||||
namespace NzbDrone.Update.Test
|
||||
{
|
||||
[TestFixture]
|
||||
public class ProgramFixture : TestBase
|
||||
{
|
||||
private Program _program;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_program = Mocker.Resolve<Program>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_throw_if_null_passed_in()
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() => _program.Start(null));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_throw_if_less_than_two_arguments_arent_passed_in()
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() => _program.Start(new[] { "" }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_throw_if_more_than_two_arguments_arent_passed_in()
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() => _program.Start(new[] { "", "", "" }));
|
||||
}
|
||||
|
||||
[TestCase("d", "")]
|
||||
[TestCase("", "")]
|
||||
[TestCase("0", "")]
|
||||
[TestCase("-1", "")]
|
||||
[TestCase(" ", "")]
|
||||
[TestCase(".", "")]
|
||||
public void should_throw_if_first_arg_isnt_an_int(string arg1, string arg2)
|
||||
{
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => _program.Start(new[] { arg1, arg2 }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_call_update_with_corret_path()
|
||||
{
|
||||
const string ProcessPath = @"C:\NzbDrone\nzbdrone.exe";
|
||||
|
||||
Mocker.GetMock<ProcessProvider>().Setup(c => c.GetProcessById(12))
|
||||
.Returns(new ProcessInfo() { StartPath = ProcessPath });
|
||||
|
||||
//Act
|
||||
_program.Start(new[] { "12", "" });
|
||||
|
||||
//Assert
|
||||
Mocker.GetMock<UpdateProvider>().Verify(c => c.Start(ProcessPath), Times.Once());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user