From 72d0fc50ed63a07d4ccb7772ee1e2a8aa50b2fa1 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sat, 12 Nov 2011 23:27:16 -0800 Subject: [PATCH] Alot of refactoring. --- NzbDrone.App.Test/ConfigProviderTest.cs | 59 ------ NzbDrone.App.Test/IISProviderTest.cs | 36 ---- NzbDrone.App.Test/NzbDrone.App.Test.csproj | 2 - .../ConfigFileProviderTest.cs | 10 +- .../NzbDrone.Common.Test.csproj | 2 + NzbDrone.Common.Test/PathExtentionFixture.cs | 52 +++++ .../ConfigFileProvider.cs | 183 +++++++----------- NzbDrone.Common/EnviromentProvider.cs | 8 + NzbDrone.Common/LogConfiguration.cs | 22 +-- NzbDrone.Common/Model/AuthenticationType.cs | 10 + NzbDrone.Common/NzbDrone.Common.csproj | 5 +- NzbDrone.Common/PathExtentions.cs | 76 ++++++-- NzbDrone.Common/PathProvider.cs | 107 ---------- NzbDrone.Core.Test/CentralDispatchFixture.cs | 10 +- NzbDrone.Core.Test/EpisodeStatusTest.cs | 2 +- NzbDrone.Core.Test/FluentTest.cs | 2 +- NzbDrone.Core.Test/Framework/CoreTest.cs | 53 +++++ NzbDrone.Core.Test/Framework/TestBase.cs | 111 ----------- NzbDrone.Core.Test/IndexerTests.cs | 2 +- .../JobTests/BannerDownloadJobTest.cs | 41 +--- .../JobTests/DiskScanJobTest.cs | 2 +- .../JobTests/ImportNewSeriesJobTest.cs | 2 +- .../JobTests/SeasonSearchJobTest.cs | 2 +- .../JobTests/SeriesSearchJobTest.cs | 2 +- NzbDrone.Core.Test/NzbDrone.Core.Test.csproj | 3 +- NzbDrone.Core.Test/ParserTest.cs | 2 +- .../ProviderTests/ConfigProviderTest.cs | 2 +- .../ExtractArchiveFixture.cs | 2 +- .../DiskProviderTests/FreeDiskSpaceTest.cs | 2 +- .../ProviderTests/DiskScanProviderTest.cs | 2 +- .../DiskScanProviderTest_ImportFile.cs | 2 +- .../ProviderTests/DownloadProviderTest.cs | 2 +- .../ProviderTests/EpisodeProviderTest.cs | 2 +- ...isodeProviderTest_DeleteInvalidEpisodes.cs | 2 +- ...deProviderTest_GetEpisodesByParseResult.cs | 2 +- .../ProviderTests/EventClientProviderTest.cs | 2 +- .../ProviderTests/GrowlProviderTest.cs | 2 +- .../ProviderTests/HistoryProviderTest.cs | 2 +- .../ProviderTests/IndexerProviderTest.cs | 2 +- .../InventoryProvider_IsAcceptableSizeTest.cs | 2 +- .../InventoryProvider_IsMonitoredTest.cs | 2 +- .../InventoryProvider_QualityNeededTest.cs | 2 +- .../JobProviderTests/JobProviderTest.cs | 2 +- .../ProviderTests/LogProviderTest.cs | 2 +- .../ProviderTests/MediaFileProviderTests.cs | 2 +- .../MediaFileProvider_GetNewFilenameTest.cs | 2 +- .../PostDownloadProviderFixture.cs | 2 +- .../ProcessDownloadFixture.cs | 2 +- .../ProviderTests/ProwlProviderTest.cs | 2 +- .../ProviderTests/QualityTypeProviderTest.cs | 2 +- .../ProviderTests/RootDirProviderTest.cs | 2 +- .../ProviderTests/SabProviderTest.cs | 2 +- .../SearchProviderTest_Episode.cs | 2 +- .../SearchProviderTest_PartialSeason.cs | 2 +- .../SearchProviderTest_Season.cs | 2 +- .../ProviderTests/SeriesProviderTest.cs | 2 +- .../ProviderTests/TvDbProviderTest.cs | 2 +- .../UpcomingEpisodesProviderTest.cs | 2 +- .../GetAvilableUpdateFixture.cs | 2 +- .../PreformUpdateFixture.cs | 8 +- .../ProviderTests/XbmcProviderTest.cs | 2 +- NzbDrone.Core.Test/QualityProfileTest.cs | 2 +- NzbDrone.Core.Test/QualityTest.cs | 2 +- NzbDrone.Core.Test/SceneMappingTest.cs | 2 +- NzbDrone.Core.Test/SortHelperTest.cs | 2 +- NzbDrone.Core.Test/dbBenchmark.cs | 2 +- NzbDrone.Core/CentralDispatch.cs | 2 + NzbDrone.Core/Datastore/Connection.cs | 18 +- .../Instrumentation/LogConfiguration.cs | 9 +- NzbDrone.Core/Model/AuthenticationType.cs | 13 -- NzbDrone.Core/NzbDrone.Core.csproj | 4 +- .../{DiskProvider.cs => ArchiveProvider.cs} | 0 .../Providers/Core/ConfigFileProvider.cs | 124 ------------ .../Providers/Jobs/BannerDownloadJob.cs | 8 +- NzbDrone.Core/Providers/TvDbProvider.cs | 6 +- NzbDrone.Core/Providers/UpdateProvider.cs | 30 ++- NzbDrone.Test.Common/LoggingTest.cs | 16 +- .../NzbDrone.Test.Common.csproj | 1 + NzbDrone.Test.Common/TestBase.cs | 68 +++++++ .../UpdateProviderStartTest.cs | 6 +- .../UpdateProviderVerifyTest.cs | 2 +- NzbDrone.Update/Providers/UpdateProvider.cs | 16 +- .../Controllers/SettingsController.cs | 2 + NzbDrone.Web/Models/SystemSettingsModel.cs | 7 +- NzbDrone/ApplicationServer.cs | 9 +- NzbDrone/CentralDispatch.cs | 6 +- NzbDrone/Model/AuthenticationType.cs | 13 -- NzbDrone/NzbDrone.csproj | 2 - NzbDrone/Providers/IISProvider.cs | 16 +- 89 files changed, 503 insertions(+), 767 deletions(-) delete mode 100644 NzbDrone.App.Test/ConfigProviderTest.cs delete mode 100644 NzbDrone.App.Test/IISProviderTest.cs rename {NzbDrone.Core.Test/ProviderTests => NzbDrone.Common.Test}/ConfigFileProviderTest.cs (95%) create mode 100644 NzbDrone.Common.Test/PathExtentionFixture.cs rename NzbDrone/Providers/ConfigProvider.cs => NzbDrone.Common/ConfigFileProvider.cs (67%) create mode 100644 NzbDrone.Common/Model/AuthenticationType.cs delete mode 100644 NzbDrone.Common/PathProvider.cs create mode 100644 NzbDrone.Core.Test/Framework/CoreTest.cs delete mode 100644 NzbDrone.Core.Test/Framework/TestBase.cs delete mode 100644 NzbDrone.Core/Model/AuthenticationType.cs rename NzbDrone.Core/Providers/Core/{DiskProvider.cs => ArchiveProvider.cs} (100%) delete mode 100644 NzbDrone.Core/Providers/Core/ConfigFileProvider.cs create mode 100644 NzbDrone.Test.Common/TestBase.cs delete mode 100644 NzbDrone/Model/AuthenticationType.cs diff --git a/NzbDrone.App.Test/ConfigProviderTest.cs b/NzbDrone.App.Test/ConfigProviderTest.cs deleted file mode 100644 index 87f133ee7..000000000 --- a/NzbDrone.App.Test/ConfigProviderTest.cs +++ /dev/null @@ -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(); - 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"); - } - } -} diff --git a/NzbDrone.App.Test/IISProviderTest.cs b/NzbDrone.App.Test/IISProviderTest.cs deleted file mode 100644 index 00c3e548b..000000000 --- a/NzbDrone.App.Test/IISProviderTest.cs +++ /dev/null @@ -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(); - configMock.SetupGet(c => c.IISExePath).Returns("NzbDrone.Test.Dummy.exe"); - - mocker.Resolve(); - - var iisProvider = mocker.Resolve(); - - iisProvider.StartServer(); - - iisProvider.IISProcessId.Should().NotBe(0); - } - - } -} diff --git a/NzbDrone.App.Test/NzbDrone.App.Test.csproj b/NzbDrone.App.Test/NzbDrone.App.Test.csproj index b928d92fc..543832cf4 100644 --- a/NzbDrone.App.Test/NzbDrone.App.Test.csproj +++ b/NzbDrone.App.Test/NzbDrone.App.Test.csproj @@ -68,8 +68,6 @@ - - diff --git a/NzbDrone.Core.Test/ProviderTests/ConfigFileProviderTest.cs b/NzbDrone.Common.Test/ConfigFileProviderTest.cs similarity index 95% rename from NzbDrone.Core.Test/ProviderTests/ConfigFileProviderTest.cs rename to NzbDrone.Common.Test/ConfigFileProviderTest.cs index 6b56ff532..2d1f0ff7f 100644 --- a/NzbDrone.Core.Test/ProviderTests/ConfigFileProviderTest.cs +++ b/NzbDrone.Common.Test/ConfigFileProviderTest.cs @@ -3,9 +3,9 @@ using AutoMoq; 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 @@ namespace NzbDrone.Core.Test.ProviderTests [SetUp] public void SetUp() { - WithTempAsStartUpPath(); + WithTempAsAppPath(); //Reset config file - var configFile = Mocker.Resolve().AppConfigFile; + var configFile = Mocker.Resolve().GetConfigPath(); if (File.Exists(configFile)) File.Delete(configFile); diff --git a/NzbDrone.Common.Test/NzbDrone.Common.Test.csproj b/NzbDrone.Common.Test/NzbDrone.Common.Test.csproj index bf72a48ee..705d95e02 100644 --- a/NzbDrone.Common.Test/NzbDrone.Common.Test.csproj +++ b/NzbDrone.Common.Test/NzbDrone.Common.Test.csproj @@ -61,6 +61,8 @@ + + diff --git a/NzbDrone.Common.Test/PathExtentionFixture.cs b/NzbDrone.Common.Test/PathExtentionFixture.cs new file mode 100644 index 000000000..96c6342de --- /dev/null +++ b/NzbDrone.Common.Test/PathExtentionFixture.cs @@ -0,0 +1,52 @@ +using FluentAssertions; +using Moq; +using NUnit.Framework; +using NzbDrone.Common; + +namespace NzbDrone.App.Test +{ + [TestFixture] + public class PathExtentionFixture + { + + private EnviromentProvider GetEnviromentProvider() + { + var envMoq = new Mock(); + 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"); + } + } +} diff --git a/NzbDrone/Providers/ConfigProvider.cs b/NzbDrone.Common/ConfigFileProvider.cs similarity index 67% rename from NzbDrone/Providers/ConfigProvider.cs rename to NzbDrone.Common/ConfigFileProvider.cs index b6e77cbea..e3768b1fe 100644 --- a/NzbDrone/Providers/ConfigProvider.cs +++ b/NzbDrone.Common/ConfigFileProvider.cs @@ -4,132 +4,45 @@ using System.Linq; 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) - { - _enviromentProvider = enviromentProvider; - } - public ConfigProvider() + + private readonly string _configFile; + public ConfigFileProvider(EnviromentProvider enviromentProvider) { - + _enviromentProvider = enviromentProvider; + _configFile = _enviromentProvider.GetConfigPath(); } - 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 @@ namespace NzbDrone.Providers SetValue(key, defaultValue, parent); //Reload the configFile - xDoc = XDocument.Load(ConfigFile); + xDoc = XDocument.Load(_configFile); config = xDoc.Descendants("Config").Single(); } @@ -173,7 +86,7 @@ namespace NzbDrone.Providers 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 @@ namespace NzbDrone.Providers 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.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(); - xDoc.Add(new XElement("Config")); - xDoc.Save(ConfigFile); + 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); } } -} \ No newline at end of file +} diff --git a/NzbDrone.Common/EnviromentProvider.cs b/NzbDrone.Common/EnviromentProvider.cs index 6ff76153f..3680860c0 100644 --- a/NzbDrone.Common/EnviromentProvider.cs +++ b/NzbDrone.Common/EnviromentProvider.cs @@ -72,6 +72,14 @@ namespace NzbDrone.Common } } + public virtual String SystemTemp + { + get + { + return Path.GetTempPath(); + } + } + public virtual Version Version { get { return Assembly.GetExecutingAssembly().GetName().Version; } diff --git a/NzbDrone.Common/LogConfiguration.cs b/NzbDrone.Common/LogConfiguration.cs index 716b18edd..99dbb48c4 100644 --- a/NzbDrone.Common/LogConfiguration.cs +++ b/NzbDrone.Common/LogConfiguration.cs @@ -33,7 +33,6 @@ namespace NzbDrone.Common 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 @@ namespace NzbDrone.Common udpTarget.IncludeNdc = true; LogManager.Configuration.AddTarget(udpTarget.GetType().Name, udpTarget); LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Trace, udpTarget)); - Reload(); } catch (Exception e) { @@ -71,16 +69,18 @@ namespace NzbDrone.Common public static void RegisterExceptioneer() { - try - { - var exTarget = new ExceptioneerTarget(); - LogManager.Configuration.AddTarget("Exceptioneer", exTarget); - LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Error, exTarget)); - Reload(); - } - catch (Exception e) + if (EnviromentProvider.IsProduction) { - 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); + } } } diff --git a/NzbDrone.Common/Model/AuthenticationType.cs b/NzbDrone.Common/Model/AuthenticationType.cs new file mode 100644 index 000000000..34d37edf6 --- /dev/null +++ b/NzbDrone.Common/Model/AuthenticationType.cs @@ -0,0 +1,10 @@ +using System.Linq; + +namespace NzbDrone.Common.Model +{ + public enum AuthenticationType + { + Anonymous = 0, + Windows = 1 + } +} diff --git a/NzbDrone.Common/NzbDrone.Common.csproj b/NzbDrone.Common/NzbDrone.Common.csproj index d4e1e1631..b7461ac7b 100644 --- a/NzbDrone.Common/NzbDrone.Common.csproj +++ b/NzbDrone.Common/NzbDrone.Common.csproj @@ -42,11 +42,14 @@ + + + + - diff --git a/NzbDrone.Common/PathExtentions.cs b/NzbDrone.Common/PathExtentions.cs index 9f3b40074..3e6ff95a2 100644 --- a/NzbDrone.Common/PathExtentions.cs +++ b/NzbDrone.Common/PathExtentions.cs @@ -1,7 +1,4 @@ -using System; -using System.Diagnostics; -using System.IO; -using System.Reflection; +using System.IO; namespace NzbDrone.Common { @@ -9,7 +6,9 @@ namespace NzbDrone.Common { 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"; @@ -21,19 +20,74 @@ namespace NzbDrone.Common private const string UPDATE_PACKAGE_FOLDER_NAME = "nzbdrone\\"; private const string UPDATE_BACKUP_FOLDER_NAME = "nzbdrone_backup\\"; - public static string GetUpdateSandboxFolder(this PathProvider pathProvider) + 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(pathProvider.SystemTemp, UPDATE_SANDBOX_FOLDER_NAME); + return Path.Combine(enviromentProvider.GetAppDataPath(), LOG_DB_FILE); } - public static string GetUpdateBackUpFolder(this PathProvider pathProvider) + public static string GetBannerPath(this EnviromentProvider enviromentProvider) { - return Path.Combine(pathProvider.GetUpdateSandboxFolder(), UPDATE_BACKUP_FOLDER_NAME); + return Path.Combine(enviromentProvider.GetWebRoot(), "Content", "Images", "Banners"); } - public static string GetUpdatePackageFolder(this PathProvider pathProvider) + public static string GetCacheFolder(this EnviromentProvider enviromentProvider) { - return Path.Combine(pathProvider.GetUpdateSandboxFolder(), UPDATE_PACKAGE_FOLDER_NAME); + return Path.Combine(enviromentProvider.GetWebRoot(), "Cache"); } } } \ No newline at end of file diff --git a/NzbDrone.Common/PathProvider.cs b/NzbDrone.Common/PathProvider.cs deleted file mode 100644 index fdae9143e..000000000 --- a/NzbDrone.Common/PathProvider.cs +++ /dev/null @@ -1,107 +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"; - - private const string UPDATE_SANDBOX_FOLDER_NAME = "nzbdrone_update"; - private const string UPDATE_BACKUP_FOLDER_NAME = "nzbdrone_backup"; - - 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"); } - } - } -} \ No newline at end of file diff --git a/NzbDrone.Core.Test/CentralDispatchFixture.cs b/NzbDrone.Core.Test/CentralDispatchFixture.cs index cc1895813..9f1cec65c 100644 --- a/NzbDrone.Core.Test/CentralDispatchFixture.cs +++ b/NzbDrone.Core.Test/CentralDispatchFixture.cs @@ -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 indexers = typeof(CentralDispatch).Assembly.GetTypes().Where(t => t.IsSubclassOf(typeof(IndexerBase))).ToList(); readonly IList jobs = typeof(CentralDispatch).Assembly.GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IJob))).ToList(); @@ -99,5 +100,12 @@ namespace NzbDrone.Core.Test first.Should().BeSameAs(second); } + + [TearDown] + public void TearDownBase() + { + WebTimer.Stop(); + + } } } diff --git a/NzbDrone.Core.Test/EpisodeStatusTest.cs b/NzbDrone.Core.Test/EpisodeStatusTest.cs index 8ff0cee59..051575c04 100644 --- a/NzbDrone.Core.Test/EpisodeStatusTest.cs +++ b/NzbDrone.Core.Test/EpisodeStatusTest.cs @@ -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)] diff --git a/NzbDrone.Core.Test/FluentTest.cs b/NzbDrone.Core.Test/FluentTest.cs index a6e7be4cc..8a703d3fa 100644 --- a/NzbDrone.Core.Test/FluentTest.cs +++ b/NzbDrone.Core.Test/FluentTest.cs @@ -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")] diff --git a/NzbDrone.Core.Test/Framework/CoreTest.cs b/NzbDrone.Core.Test/Framework/CoreTest.cs new file mode 100644 index 000000000..0bf8e1037 --- /dev/null +++ b/NzbDrone.Core.Test/Framework/CoreTest.cs @@ -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); + } + } +} diff --git a/NzbDrone.Core.Test/Framework/TestBase.cs b/NzbDrone.Core.Test/Framework/TestBase.cs deleted file mode 100644 index 351c9cf0d..000000000 --- a/NzbDrone.Core.Test/Framework/TestBase.cs +++ /dev/null @@ -1,111 +0,0 @@ -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 -{ - 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 string VirtualPath - { - get - { - var virtualPath = Path.Combine(TempFolder, "VirtualNzbDrone"); - if (!Directory.Exists(virtualPath)) Directory.CreateDirectory(virtualPath); - - return virtualPath; - } - } - - [SetUp] - public virtual void SetupBase() - { - InitLogging(); - - ExceptionVerification.Reset(); - if (Directory.Exists(TempFolder)) - { - Directory.Delete(TempFolder, true); - } - - 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() - { - ExceptionVerification.AssertNoUnexcpectedLogs(); - Mocker = new AutoMoqer(MockBehavior.Strict); - WebTimer.Stop(); - } - - - protected void WithTempAsStartUpPath() - { - Mocker.GetMock() - .SetupGet(c => c.ApplicationPath) - .Returns(VirtualPath); - - Mocker.Resolve(); - } - - - protected string TempFolder - { - get { return Path.Combine(Directory.GetCurrentDirectory(), "temp"); } - } - - protected string GetTestFilePath(string fileName) - { - return Path.Combine(@".\Files\", fileName); - } - - protected string ReadTestFile(string fileName) - { - return File.ReadAllText(GetTestFilePath(fileName)); - } - } -} diff --git a/NzbDrone.Core.Test/IndexerTests.cs b/NzbDrone.Core.Test/IndexerTests.cs index f698d5af7..df5d66b31 100644 --- a/NzbDrone.Core.Test/IndexerTests.cs +++ b/NzbDrone.Core.Test/IndexerTests.cs @@ -22,7 +22,7 @@ namespace NzbDrone.Core.Test { [TestFixture] // ReSharper disable InconsistentNaming - public class IndexerTests : TestBase + public class IndexerTests : CoreTest { [TestCase("nzbsorg.xml", 2)] diff --git a/NzbDrone.Core.Test/JobTests/BannerDownloadJobTest.cs b/NzbDrone.Core.Test/JobTests/BannerDownloadJobTest.cs index 4ff3f8e60..2e3f0922f 100644 --- a/NzbDrone.Core.Test/JobTests/BannerDownloadJobTest.cs +++ b/NzbDrone.Core.Test/JobTests/BannerDownloadJobTest.cs @@ -16,14 +16,14 @@ 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] @@ -90,11 +90,11 @@ namespace NzbDrone.Core.Test.JobTests public void BannerDownload_some_failed_download() { //Setup - var fakeSeries = Builder.CreateListOfSize(10) + var fakeSeries = Builder.CreateListOfSize(4) .Build(); - var pathProvider = Mocker.Resolve(); + var bannerPath = Mocker.GetMock().Object.GetBannerPath(); var notification = new ProgressNotification("Banner Download"); @@ -103,43 +103,18 @@ namespace NzbDrone.Core.Test.JobTests .Returns(fakeSeries); Mocker.GetMock() - .Setup(s => s.DownloadFile(It.IsAny(), Path.Combine(pathProvider.BannerPath, "1.jpg"))) - .Throws(new WebException()); - - Mocker.GetMock() - .Setup(s => s.DownloadFile(It.IsAny(), Path.Combine(pathProvider.BannerPath, "2.jpg"))); - - Mocker.GetMock() - .Setup(s => s.DownloadFile(It.IsAny(), Path.Combine(pathProvider.BannerPath, "3.jpg"))) - .Throws(new WebException()); - - Mocker.GetMock() - .Setup(s => s.DownloadFile(It.IsAny(), Path.Combine(pathProvider.BannerPath, "4.jpg"))); - - - Mocker.GetMock() - .Setup(s => s.DownloadFile(It.IsAny(), Path.Combine(pathProvider.BannerPath, "5.jpg"))) - .Throws(new WebException()); - - Mocker.GetMock() - .Setup(s => s.DownloadFile(It.IsAny(), Path.Combine(pathProvider.BannerPath, "6.jpg"))); - - - Mocker.GetMock() - .Setup(s => s.DownloadFile(It.IsAny(), Path.Combine(pathProvider.BannerPath, "7.jpg"))) + .Setup(s => s.DownloadFile(It.IsAny(), Path.Combine(bannerPath, "1.jpg"))) .Throws(new WebException()); Mocker.GetMock() - .Setup(s => s.DownloadFile(It.IsAny(), Path.Combine(pathProvider.BannerPath, "8.jpg"))); - + .Setup(s => s.DownloadFile(It.IsAny(), Path.Combine(bannerPath, "2.jpg"))); Mocker.GetMock() - .Setup(s => s.DownloadFile(It.IsAny(), Path.Combine(pathProvider.BannerPath, "9.jpg"))) + .Setup(s => s.DownloadFile(It.IsAny(), Path.Combine(bannerPath, "3.jpg"))) .Throws(new WebException()); Mocker.GetMock() - .Setup(s => s.DownloadFile(It.IsAny(), Path.Combine(pathProvider.BannerPath, "10.jpg"))); - + .Setup(s => s.DownloadFile(It.IsAny(), Path.Combine(bannerPath, "4.jpg"))); Mocker.GetMock() .Setup(S => S.CreateDirectory(It.IsAny())) diff --git a/NzbDrone.Core.Test/JobTests/DiskScanJobTest.cs b/NzbDrone.Core.Test/JobTests/DiskScanJobTest.cs index 0d9a211c6..2ca294f16 100644 --- a/NzbDrone.Core.Test/JobTests/DiskScanJobTest.cs +++ b/NzbDrone.Core.Test/JobTests/DiskScanJobTest.cs @@ -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() diff --git a/NzbDrone.Core.Test/JobTests/ImportNewSeriesJobTest.cs b/NzbDrone.Core.Test/JobTests/ImportNewSeriesJobTest.cs index 41a7b334e..1cdaa57a3 100644 --- a/NzbDrone.Core.Test/JobTests/ImportNewSeriesJobTest.cs +++ b/NzbDrone.Core.Test/JobTests/ImportNewSeriesJobTest.cs @@ -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() diff --git a/NzbDrone.Core.Test/JobTests/SeasonSearchJobTest.cs b/NzbDrone.Core.Test/JobTests/SeasonSearchJobTest.cs index cf6edf385..fa95e89d8 100644 --- a/NzbDrone.Core.Test/JobTests/SeasonSearchJobTest.cs +++ b/NzbDrone.Core.Test/JobTests/SeasonSearchJobTest.cs @@ -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() diff --git a/NzbDrone.Core.Test/JobTests/SeriesSearchJobTest.cs b/NzbDrone.Core.Test/JobTests/SeriesSearchJobTest.cs index ad9c148cc..a8a69f91d 100644 --- a/NzbDrone.Core.Test/JobTests/SeriesSearchJobTest.cs +++ b/NzbDrone.Core.Test/JobTests/SeriesSearchJobTest.cs @@ -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() diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index 1aa915b0d..8df497f7e 100644 --- a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -84,7 +84,6 @@ - @@ -115,7 +114,7 @@ - + diff --git a/NzbDrone.Core.Test/ParserTest.cs b/NzbDrone.Core.Test/ParserTest.cs index 6bf30377b..34913a87d 100644 --- a/NzbDrone.Core.Test/ParserTest.cs +++ b/NzbDrone.Core.Test/ParserTest.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 diff --git a/NzbDrone.Core.Test/ProviderTests/ConfigProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/ConfigProviderTest.cs index 6c4d488b9..62bce6cf9 100644 --- a/NzbDrone.Core.Test/ProviderTests/ConfigProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/ConfigProviderTest.cs @@ -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() diff --git a/NzbDrone.Core.Test/ProviderTests/DiskProviderTests/ExtractArchiveFixture.cs b/NzbDrone.Core.Test/ProviderTests/DiskProviderTests/ExtractArchiveFixture.cs index 9b0ffca27..60256ab1d 100644 --- a/NzbDrone.Core.Test/ProviderTests/DiskProviderTests/ExtractArchiveFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/DiskProviderTests/ExtractArchiveFixture.cs @@ -7,7 +7,7 @@ using System.IO; namespace NzbDrone.Core.Test.ProviderTests.DiskProviderTests { [TestFixture] - public class ExtractArchiveFixture : TestBase + public class ExtractArchiveFixture : CoreTest { [Test] public void Should_extract_to_correct_folder() diff --git a/NzbDrone.Core.Test/ProviderTests/DiskProviderTests/FreeDiskSpaceTest.cs b/NzbDrone.Core.Test/ProviderTests/DiskProviderTests/FreeDiskSpaceTest.cs index 7679538ee..e7a27d4a6 100644 --- a/NzbDrone.Core.Test/ProviderTests/DiskProviderTests/FreeDiskSpaceTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/DiskProviderTests/FreeDiskSpaceTest.cs @@ -14,7 +14,7 @@ using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.ProviderTests.DiskProviderTests { [TestFixture] - public class FreeDiskSpaceTest : TestBase + public class FreeDiskSpaceTest : CoreTest { [Test] public void FreeDiskSpace() diff --git a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTest.cs index 1fc8d35bb..b58b59e84 100644 --- a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTest.cs @@ -14,7 +14,7 @@ using NzbDrone.Test.Common; 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() diff --git a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTest_ImportFile.cs b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTest_ImportFile.cs index caec1d8f1..a34adfda1 100644 --- a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTest_ImportFile.cs +++ b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTest_ImportFile.cs @@ -17,7 +17,7 @@ using NzbDrone.Test.Common; 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() diff --git a/NzbDrone.Core.Test/ProviderTests/DownloadProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/DownloadProviderTest.cs index 7b8033a11..ce1ac4713 100644 --- a/NzbDrone.Core.Test/ProviderTests/DownloadProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/DownloadProviderTest.cs @@ -14,7 +14,7 @@ using NzbDrone.Core.Test.Framework; 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() diff --git a/NzbDrone.Core.Test/ProviderTests/EpisodeProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/EpisodeProviderTest.cs index 05781e5e2..7482c3d91 100644 --- a/NzbDrone.Core.Test/ProviderTests/EpisodeProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/EpisodeProviderTest.cs @@ -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() diff --git a/NzbDrone.Core.Test/ProviderTests/EpisodeProviderTest_DeleteInvalidEpisodes.cs b/NzbDrone.Core.Test/ProviderTests/EpisodeProviderTest_DeleteInvalidEpisodes.cs index 70cdf960e..efc47f1a0 100644 --- a/NzbDrone.Core.Test/ProviderTests/EpisodeProviderTest_DeleteInvalidEpisodes.cs +++ b/NzbDrone.Core.Test/ProviderTests/EpisodeProviderTest_DeleteInvalidEpisodes.cs @@ -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() diff --git a/NzbDrone.Core.Test/ProviderTests/EpisodeProviderTest_GetEpisodesByParseResult.cs b/NzbDrone.Core.Test/ProviderTests/EpisodeProviderTest_GetEpisodesByParseResult.cs index 1e588c6b9..f2cb6db5c 100644 --- a/NzbDrone.Core.Test/ProviderTests/EpisodeProviderTest_GetEpisodesByParseResult.cs +++ b/NzbDrone.Core.Test/ProviderTests/EpisodeProviderTest_GetEpisodesByParseResult.cs @@ -15,7 +15,7 @@ namespace NzbDrone.Core.Test.ProviderTests { [TestFixture] // ReSharper disable InconsistentNaming - public class EpisodeProviderTest_GetEpisodesByParseResult : TestBase + public class EpisodeProviderTest_GetEpisodesByParseResult : CoreTest { [Test] diff --git a/NzbDrone.Core.Test/ProviderTests/EventClientProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/EventClientProviderTest.cs index bc15cc152..6e6bc544e 100644 --- a/NzbDrone.Core.Test/ProviderTests/EventClientProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/EventClientProviderTest.cs @@ -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() diff --git a/NzbDrone.Core.Test/ProviderTests/GrowlProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/GrowlProviderTest.cs index a7586aa7f..3c70d4a96 100644 --- a/NzbDrone.Core.Test/ProviderTests/GrowlProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/GrowlProviderTest.cs @@ -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() diff --git a/NzbDrone.Core.Test/ProviderTests/HistoryProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/HistoryProviderTest.cs index 8f4ef6700..556559b93 100644 --- a/NzbDrone.Core.Test/ProviderTests/HistoryProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/HistoryProviderTest.cs @@ -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() diff --git a/NzbDrone.Core.Test/ProviderTests/IndexerProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/IndexerProviderTest.cs index 9dde9b574..8df70dd2b 100644 --- a/NzbDrone.Core.Test/ProviderTests/IndexerProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/IndexerProviderTest.cs @@ -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() diff --git a/NzbDrone.Core.Test/ProviderTests/InventoryProvider_IsAcceptableSizeTest.cs b/NzbDrone.Core.Test/ProviderTests/InventoryProvider_IsAcceptableSizeTest.cs index 1f2e2d6b0..b25538a03 100644 --- a/NzbDrone.Core.Test/ProviderTests/InventoryProvider_IsAcceptableSizeTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/InventoryProvider_IsAcceptableSizeTest.cs @@ -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; diff --git a/NzbDrone.Core.Test/ProviderTests/InventoryProvider_IsMonitoredTest.cs b/NzbDrone.Core.Test/ProviderTests/InventoryProvider_IsMonitoredTest.cs index 333c1b36a..c786f106a 100644 --- a/NzbDrone.Core.Test/ProviderTests/InventoryProvider_IsMonitoredTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/InventoryProvider_IsMonitoredTest.cs @@ -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; diff --git a/NzbDrone.Core.Test/ProviderTests/InventoryProvider_QualityNeededTest.cs b/NzbDrone.Core.Test/ProviderTests/InventoryProvider_QualityNeededTest.cs index 46334e1ea..3b538664a 100644 --- a/NzbDrone.Core.Test/ProviderTests/InventoryProvider_QualityNeededTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/InventoryProvider_QualityNeededTest.cs @@ -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; diff --git a/NzbDrone.Core.Test/ProviderTests/JobProviderTests/JobProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/JobProviderTests/JobProviderTest.cs index a36bda385..6c0ce248c 100644 --- a/NzbDrone.Core.Test/ProviderTests/JobProviderTests/JobProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/JobProviderTests/JobProviderTest.cs @@ -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() diff --git a/NzbDrone.Core.Test/ProviderTests/LogProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/LogProviderTest.cs index 9ed70808a..22012c763 100644 --- a/NzbDrone.Core.Test/ProviderTests/LogProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/LogProviderTest.cs @@ -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"; diff --git a/NzbDrone.Core.Test/ProviderTests/MediaFileProviderTests.cs b/NzbDrone.Core.Test/ProviderTests/MediaFileProviderTests.cs index 4b5f55391..e92fb5dbd 100644 --- a/NzbDrone.Core.Test/ProviderTests/MediaFileProviderTests.cs +++ b/NzbDrone.Core.Test/ProviderTests/MediaFileProviderTests.cs @@ -16,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() diff --git a/NzbDrone.Core.Test/ProviderTests/MediaFileProvider_GetNewFilenameTest.cs b/NzbDrone.Core.Test/ProviderTests/MediaFileProvider_GetNewFilenameTest.cs index 3435c70a2..2b7609f61 100644 --- a/NzbDrone.Core.Test/ProviderTests/MediaFileProvider_GetNewFilenameTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/MediaFileProvider_GetNewFilenameTest.cs @@ -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() diff --git a/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/PostDownloadProviderFixture.cs b/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/PostDownloadProviderFixture.cs index 9d49d06c5..55861608a 100644 --- a/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/PostDownloadProviderFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/PostDownloadProviderFixture.cs @@ -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)] diff --git a/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDownloadFixture.cs b/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDownloadFixture.cs index 77a87f7c6..c9f3b70d6 100644 --- a/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDownloadFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDownloadFixture.cs @@ -18,7 +18,7 @@ using NzbDrone.Test.Common; 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() diff --git a/NzbDrone.Core.Test/ProviderTests/ProwlProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/ProwlProviderTest.cs index c6d6c506e..2e856935f 100644 --- a/NzbDrone.Core.Test/ProviderTests/ProwlProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/ProwlProviderTest.cs @@ -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"; diff --git a/NzbDrone.Core.Test/ProviderTests/QualityTypeProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/QualityTypeProviderTest.cs index a31cd4031..4431f3559 100644 --- a/NzbDrone.Core.Test/ProviderTests/QualityTypeProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/QualityTypeProviderTest.cs @@ -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() diff --git a/NzbDrone.Core.Test/ProviderTests/RootDirProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/RootDirProviderTest.cs index af1179cf5..17cf3d018 100644 --- a/NzbDrone.Core.Test/ProviderTests/RootDirProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/RootDirProviderTest.cs @@ -16,7 +16,7 @@ namespace NzbDrone.Core.Test.ProviderTests { [TestFixture] // ReSharper disable InconsistentNaming - public class RootDirProviderTest : TestBase + public class RootDirProviderTest : CoreTest { [Test] diff --git a/NzbDrone.Core.Test/ProviderTests/SabProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/SabProviderTest.cs index 75c592395..0618c33a7 100644 --- a/NzbDrone.Core.Test/ProviderTests/SabProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/SabProviderTest.cs @@ -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() diff --git a/NzbDrone.Core.Test/ProviderTests/SearchProviderTest_Episode.cs b/NzbDrone.Core.Test/ProviderTests/SearchProviderTest_Episode.cs index e68839f6e..e4d1601fe 100644 --- a/NzbDrone.Core.Test/ProviderTests/SearchProviderTest_Episode.cs +++ b/NzbDrone.Core.Test/ProviderTests/SearchProviderTest_Episode.cs @@ -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() diff --git a/NzbDrone.Core.Test/ProviderTests/SearchProviderTest_PartialSeason.cs b/NzbDrone.Core.Test/ProviderTests/SearchProviderTest_PartialSeason.cs index 39bc18407..82d389571 100644 --- a/NzbDrone.Core.Test/ProviderTests/SearchProviderTest_PartialSeason.cs +++ b/NzbDrone.Core.Test/ProviderTests/SearchProviderTest_PartialSeason.cs @@ -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() diff --git a/NzbDrone.Core.Test/ProviderTests/SearchProviderTest_Season.cs b/NzbDrone.Core.Test/ProviderTests/SearchProviderTest_Season.cs index e10bc647c..5366202f6 100644 --- a/NzbDrone.Core.Test/ProviderTests/SearchProviderTest_Season.cs +++ b/NzbDrone.Core.Test/ProviderTests/SearchProviderTest_Season.cs @@ -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() diff --git a/NzbDrone.Core.Test/ProviderTests/SeriesProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/SeriesProviderTest.cs index 8e2d7d548..5d8042b03 100644 --- a/NzbDrone.Core.Test/ProviderTests/SeriesProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/SeriesProviderTest.cs @@ -15,7 +15,7 @@ using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.ProviderTests { [TestFixture] - public class SeriesProviderTest : TestBase + public class SeriesProviderTest : CoreTest { [TestCase(true)] [TestCase(false)] diff --git a/NzbDrone.Core.Test/ProviderTests/TvDbProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/TvDbProviderTest.cs index cb894ebf6..5e8cfe7f9 100644 --- a/NzbDrone.Core.Test/ProviderTests/TvDbProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/TvDbProviderTest.cs @@ -15,7 +15,7 @@ namespace NzbDrone.Core.Test.ProviderTests { [TestFixture] // ReSharper disable InconsistentNaming - public class TvDbProviderTest : TestBase + public class TvDbProviderTest : CoreTest { private TvDbProvider tvDbProvider; diff --git a/NzbDrone.Core.Test/ProviderTests/UpcomingEpisodesProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/UpcomingEpisodesProviderTest.cs index 0a8d7c801..311c58ab0 100644 --- a/NzbDrone.Core.Test/ProviderTests/UpcomingEpisodesProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/UpcomingEpisodesProviderTest.cs @@ -15,7 +15,7 @@ namespace NzbDrone.Core.Test.ProviderTests { [TestFixture] // ReSharper disable InconsistentNaming - public class UpcomingEpisodesProviderTest : TestBase + public class UpcomingEpisodesProviderTest : CoreTest { private IList episodes; private Series series; diff --git a/NzbDrone.Core.Test/ProviderTests/UpdateProviderTests/GetAvilableUpdateFixture.cs b/NzbDrone.Core.Test/ProviderTests/UpdateProviderTests/GetAvilableUpdateFixture.cs index 5e30f3206..5e988e858 100644 --- a/NzbDrone.Core.Test/ProviderTests/UpdateProviderTests/GetAvilableUpdateFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/UpdateProviderTests/GetAvilableUpdateFixture.cs @@ -10,7 +10,7 @@ using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests { - class GetAvilableUpdateFixture : TestBase + class GetAvilableUpdateFixture : CoreTest { private AutoMoqer _mocker = null; diff --git a/NzbDrone.Core.Test/ProviderTests/UpdateProviderTests/PreformUpdateFixture.cs b/NzbDrone.Core.Test/ProviderTests/UpdateProviderTests/PreformUpdateFixture.cs index bcbf1d92d..8dfe0e488 100644 --- a/NzbDrone.Core.Test/ProviderTests/UpdateProviderTests/PreformUpdateFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/UpdateProviderTests/PreformUpdateFixture.cs @@ -11,7 +11,7 @@ using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests { [TestFixture] - internal class PreformUpdateFixture : TestBase + internal class PreformUpdateFixture : CoreTest { @@ -29,7 +29,7 @@ namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests [Test] public void Should_call_download_and_extract_using_correct_arguments() { - Mocker.GetMock().SetupGet(c => c.SystemTemp).Returns(@"C:\Temp\"); + Mocker.GetMock().SetupGet(c => c.SystemTemp).Returns(@"C:\Temp\"); var updatePackage = new UpdatePackage { @@ -54,9 +54,9 @@ namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests public void Should_download_and_extract_to_temp_folder() { - Mocker.GetMock().SetupGet(c => c.SystemTemp).Returns(TempFolder); + Mocker.GetMock().SetupGet(c => c.SystemTemp).Returns(TempFolder); - var updateSubFolder = new DirectoryInfo(Mocker.GetMock().Object.GetUpdateSandboxFolder()); + var updateSubFolder = new DirectoryInfo(Mocker.GetMock().Object.GetUpdateSandboxFolder()); var updatePackage = new UpdatePackage { diff --git a/NzbDrone.Core.Test/ProviderTests/XbmcProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/XbmcProviderTest.cs index eebaacf01..cba1bf035 100644 --- a/NzbDrone.Core.Test/ProviderTests/XbmcProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/XbmcProviderTest.cs @@ -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() diff --git a/NzbDrone.Core.Test/QualityProfileTest.cs b/NzbDrone.Core.Test/QualityProfileTest.cs index 10cf89eaf..d185e199e 100644 --- a/NzbDrone.Core.Test/QualityProfileTest.cs +++ b/NzbDrone.Core.Test/QualityProfileTest.cs @@ -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() diff --git a/NzbDrone.Core.Test/QualityTest.cs b/NzbDrone.Core.Test/QualityTest.cs index 03c2f9af0..176005171 100644 --- a/NzbDrone.Core.Test/QualityTest.cs +++ b/NzbDrone.Core.Test/QualityTest.cs @@ -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() diff --git a/NzbDrone.Core.Test/SceneMappingTest.cs b/NzbDrone.Core.Test/SceneMappingTest.cs index 6f55f2c78..c703f3480 100644 --- a/NzbDrone.Core.Test/SceneMappingTest.cs +++ b/NzbDrone.Core.Test/SceneMappingTest.cs @@ -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() diff --git a/NzbDrone.Core.Test/SortHelperTest.cs b/NzbDrone.Core.Test/SortHelperTest.cs index fbbc675e3..90f11bcce 100644 --- a/NzbDrone.Core.Test/SortHelperTest.cs +++ b/NzbDrone.Core.Test/SortHelperTest.cs @@ -17,7 +17,7 @@ namespace NzbDrone.Core.Test { [TestFixture] // ReSharper disable InconsistentNaming - public class SortHelperTest : TestBase + public class SortHelperTest : CoreTest { //American Gladiators //Ancient Apocalypse diff --git a/NzbDrone.Core.Test/dbBenchmark.cs b/NzbDrone.Core.Test/dbBenchmark.cs index 66fae0a9f..ea9033100 100644 --- a/NzbDrone.Core.Test/dbBenchmark.cs +++ b/NzbDrone.Core.Test/dbBenchmark.cs @@ -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 seasonsNumbers = new List { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; diff --git a/NzbDrone.Core/CentralDispatch.cs b/NzbDrone.Core/CentralDispatch.cs index 3f38a2abf..0d313883b 100644 --- a/NzbDrone.Core/CentralDispatch.cs +++ b/NzbDrone.Core/CentralDispatch.cs @@ -3,6 +3,7 @@ using System.Diagnostics; 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.ExternalNotification; using NzbDrone.Core.Providers.Indexer; using NzbDrone.Core.Providers.Jobs; using PetaPoco; +using LogConfiguration = NzbDrone.Core.Instrumentation.LogConfiguration; namespace NzbDrone.Core { diff --git a/NzbDrone.Core/Datastore/Connection.cs b/NzbDrone.Core/Datastore/Connection.cs index 8dfc38859..3d3c15fdd 100644 --- a/NzbDrone.Core/Datastore/Connection.cs +++ b/NzbDrone.Core/Datastore/Connection.cs @@ -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 @@ namespace NzbDrone.Core.Datastore { get { - return GetConnectionString(_pathProvider.NzbDronoeDbFile); + return GetConnectionString(_enviromentProvider.GetNzbDronoeDbFile()); } } @@ -36,7 +30,7 @@ namespace NzbDrone.Core.Datastore { get { - return GetConnectionString(_pathProvider.LogDbFile); + return GetConnectionString(_enviromentProvider.GetLogDbFileDbFile()); } } @@ -45,7 +39,7 @@ namespace NzbDrone.Core.Datastore //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); diff --git a/NzbDrone.Core/Instrumentation/LogConfiguration.cs b/NzbDrone.Core/Instrumentation/LogConfiguration.cs index 0baba5855..60ecfec45 100644 --- a/NzbDrone.Core/Instrumentation/LogConfiguration.cs +++ b/NzbDrone.Core/Instrumentation/LogConfiguration.cs @@ -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,12 +25,13 @@ namespace NzbDrone.Core.Instrumentation 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)); + Common.LogConfiguration.Reload(); } public static void RegisterDatabaseLogger(DatabaseTarget databaseTarget) diff --git a/NzbDrone.Core/Model/AuthenticationType.cs b/NzbDrone.Core/Model/AuthenticationType.cs deleted file mode 100644 index 0ffc02991..000000000 --- a/NzbDrone.Core/Model/AuthenticationType.cs +++ /dev/null @@ -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 - } -} diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index f1e127439..d63ebccc3 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -197,7 +197,6 @@ - @@ -219,7 +218,6 @@ - @@ -311,7 +309,7 @@ - + diff --git a/NzbDrone.Core/Providers/Core/DiskProvider.cs b/NzbDrone.Core/Providers/Core/ArchiveProvider.cs similarity index 100% rename from NzbDrone.Core/Providers/Core/DiskProvider.cs rename to NzbDrone.Core/Providers/Core/ArchiveProvider.cs diff --git a/NzbDrone.Core/Providers/Core/ConfigFileProvider.cs b/NzbDrone.Core/Providers/Core/ConfigFileProvider.cs deleted file mode 100644 index 25ffac54e..000000000 --- a/NzbDrone.Core/Providers/Core/ConfigFileProvider.cs +++ /dev/null @@ -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); - } - } - } -} diff --git a/NzbDrone.Core/Providers/Jobs/BannerDownloadJob.cs b/NzbDrone.Core/Providers/Jobs/BannerDownloadJob.cs index 7d3942e9c..527e07ac0 100644 --- a/NzbDrone.Core/Providers/Jobs/BannerDownloadJob.cs +++ b/NzbDrone.Core/Providers/Jobs/BannerDownloadJob.cs @@ -17,20 +17,18 @@ namespace NzbDrone.Core.Providers.Jobs 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() @@ -53,7 +51,7 @@ namespace NzbDrone.Core.Providers.Jobs Logger.Debug("Starting banner download job"); - _diskProvider.CreateDirectory(_pathProvider.BannerPath); + _diskProvider.CreateDirectory(_enviromentProvider.GetBannerPath()); if (targetId > 0) { @@ -77,7 +75,7 @@ namespace NzbDrone.Core.Providers.Jobs 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); diff --git a/NzbDrone.Core/Providers/TvDbProvider.cs b/NzbDrone.Core/Providers/TvDbProvider.cs index 7998e55ef..45dc3a09d 100644 --- a/NzbDrone.Core/Providers/TvDbProvider.cs +++ b/NzbDrone.Core/Providers/TvDbProvider.cs @@ -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() diff --git a/NzbDrone.Core/Providers/UpdateProvider.cs b/NzbDrone.Core/Providers/UpdateProvider.cs index 720466e28..e9863b636 100644 --- a/NzbDrone.Core/Providers/UpdateProvider.cs +++ b/NzbDrone.Core/Providers/UpdateProvider.cs @@ -17,24 +17,20 @@ namespace NzbDrone.Core.Providers private readonly HttpProvider _httpProvider; private readonly ConfigProvider _configProvider; private readonly EnviromentProvider _enviromentProvider; - private readonly PathProvider _pathProvider; - private readonly DiskProvider _diskProvider; private readonly ArchiveProvider _archiveProvider; - private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); + private static readonly Logger logger = LogManager.GetCurrentClassLogger(); - private static readonly Regex ParseRegex = new Regex(@"(?:\>)(?NzbDrone.+?(?\d+\.\d+\.\d+\.\d+).+?)(?:\<\/A\>)", RegexOptions.IgnoreCase); + private static readonly Regex parseRegex = new Regex(@"(?:\>)(?NzbDrone.+?(?\d+\.\d+\.\d+\.\d+).+?)(?:\<\/A\>)", RegexOptions.IgnoreCase); [Inject] - public UpdateProvider(HttpProvider httpProvider, ConfigProvider configProvider, EnviromentProvider enviromentProvider, - PathProvider pathProvider, DiskProvider diskProvider, ArchiveProvider archiveProvider) + public UpdateProvider(HttpProvider httpProvider, ConfigProvider configProvider, + EnviromentProvider enviromentProvider, ArchiveProvider archiveProvider) { _httpProvider = httpProvider; _configProvider = configProvider; _enviromentProvider = enviromentProvider; - _pathProvider = pathProvider; - _diskProvider = diskProvider; _archiveProvider = archiveProvider; } @@ -47,7 +43,7 @@ namespace NzbDrone.Core.Providers { var updateList = new List(); var rawUpdateList = _httpProvider.DownloadString(_configProvider.UpdateUrl); - var matches = ParseRegex.Matches(rawUpdateList); + var matches = parseRegex.Matches(rawUpdateList); foreach (Match match in matches) { @@ -67,25 +63,25 @@ namespace NzbDrone.Core.Providers 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 StartUpgrade(UpdatePackage updatePackage) { - var packageDestination = Path.Combine(_pathProvider.GetUpdateSandboxFolder(), 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"); - _archiveProvider.ExtractArchive(packageDestination, _pathProvider.GetUpdateSandboxFolder()); - Logger.Info("Update package extracted successfully"); + logger.Info("Extracting Update package"); + _archiveProvider.ExtractArchive(packageDestination, _enviromentProvider.GetUpdateSandboxFolder()); + logger.Info("Update package extracted successfully"); } } diff --git a/NzbDrone.Test.Common/LoggingTest.cs b/NzbDrone.Test.Common/LoggingTest.cs index 5c8a13748..83acc938a 100644 --- a/NzbDrone.Test.Common/LoggingTest.cs +++ b/NzbDrone.Test.Common/LoggingTest.cs @@ -1,5 +1,6 @@ using NLog; using NLog.Config; +using NUnit.Framework; using NzbDrone.Common; namespace NzbDrone.Test.Common @@ -15,6 +16,7 @@ namespace NzbDrone.Test.Common LogConfiguration.RegisterUdpLogger(); RegisterExceptionVerification(); + LogConfiguration.Reload(); } } @@ -23,7 +25,19 @@ namespace NzbDrone.Test.Common 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(); } } } diff --git a/NzbDrone.Test.Common/NzbDrone.Test.Common.csproj b/NzbDrone.Test.Common/NzbDrone.Test.Common.csproj index fba895fe7..71cdb191b 100644 --- a/NzbDrone.Test.Common/NzbDrone.Test.Common.csproj +++ b/NzbDrone.Test.Common/NzbDrone.Test.Common.csproj @@ -71,6 +71,7 @@ + diff --git a/NzbDrone.Test.Common/TestBase.cs b/NzbDrone.Test.Common/TestBase.cs new file mode 100644 index 000000000..ba3bba103 --- /dev/null +++ b/NzbDrone.Test.Common/TestBase.cs @@ -0,0 +1,68 @@ +using System.Linq; +using System.IO; +using AutoMoq; +using Moq; +using NUnit.Framework; +using NzbDrone.Common; + +namespace NzbDrone.Test.Common +{ + public class TestBase : LoggingTest + // ReSharper disable InconsistentNaming + { + protected AutoMoqer Mocker; + + protected string VirtualPath + { + get + { + var virtualPath = Path.Combine(TempFolder, "VirtualNzbDrone"); + if (!Directory.Exists(virtualPath)) Directory.CreateDirectory(virtualPath); + + return virtualPath; + } + } + + [SetUp] + public virtual void TestBaseSetup() + { + if (Directory.Exists(TempFolder)) + { + Directory.Delete(TempFolder, true); + } + + Directory.CreateDirectory(TempFolder); + + Mocker = new AutoMoqer(); + } + + protected virtual void WithStrictMocker() + { + Mocker = new AutoMoqer(MockBehavior.Strict); + } + + + protected void WithTempAsAppPath() + { + Mocker.GetMock() + .SetupGet(c => c.ApplicationPath) + .Returns(VirtualPath); + } + + + protected string TempFolder + { + get { return Path.Combine(Directory.GetCurrentDirectory(), "temp"); } + } + + protected string GetTestFilePath(string fileName) + { + return Path.Combine(@".\Files\", fileName); + } + + protected string ReadTestFile(string fileName) + { + return File.ReadAllText(GetTestFilePath(fileName)); + } + } +} diff --git a/NzbDrone.Update.Test/UpdateProviderStartTest.cs b/NzbDrone.Update.Test/UpdateProviderStartTest.cs index 699af817d..21d693558 100644 --- a/NzbDrone.Update.Test/UpdateProviderStartTest.cs +++ b/NzbDrone.Update.Test/UpdateProviderStartTest.cs @@ -18,7 +18,7 @@ namespace NzbDrone.Update.Test private const string BACKUP_FOLDER = @"C:\Temp\nzbdrone_update\nzbdrone_backup\"; private const string TARGET_FOLDER = @"C:\NzbDrone\"; - Mock _pathProvider; + Mock _enviromentProvider; [SetUp] @@ -26,9 +26,9 @@ namespace NzbDrone.Update.Test { mocker = new AutoMoqer(); - _pathProvider = mocker.GetMock(); + _enviromentProvider = mocker.GetMock(); - _pathProvider.SetupGet(c => c.SystemTemp).Returns(@"C:\Temp\"); + _enviromentProvider.SetupGet(c => c.SystemTemp).Returns(@"C:\Temp\"); mocker.GetMock() .Setup(c => c.FolderExists(UPDATE_FOLDER)) diff --git a/NzbDrone.Update.Test/UpdateProviderVerifyTest.cs b/NzbDrone.Update.Test/UpdateProviderVerifyTest.cs index 7c133869d..593ef0e2b 100644 --- a/NzbDrone.Update.Test/UpdateProviderVerifyTest.cs +++ b/NzbDrone.Update.Test/UpdateProviderVerifyTest.cs @@ -24,7 +24,7 @@ namespace NzbDrone.Update.Test mocker.GetMock() .Setup(c => c.StartUpPath).Returns(@"C:\Temp\NzbDrone_update\"); - mocker.GetMock() + mocker.GetMock() .Setup(c => c.SystemTemp).Returns(@"C:\Temp\"); } diff --git a/NzbDrone.Update/Providers/UpdateProvider.cs b/NzbDrone.Update/Providers/UpdateProvider.cs index 9dd5279fa..3d8b96742 100644 --- a/NzbDrone.Update/Providers/UpdateProvider.cs +++ b/NzbDrone.Update/Providers/UpdateProvider.cs @@ -11,16 +11,16 @@ namespace NzbDrone.Update.Providers private readonly DiskProvider _diskProvider; private readonly ServiceProvider _serviceProvider; private readonly ProcessProvider _processProvider; - private readonly PathProvider _pathProvider; + private readonly EnviromentProvider _enviromentProvider; private static readonly Logger logger = LogManager.GetCurrentClassLogger(); public UpdateProvider(DiskProvider diskProvider,ServiceProvider serviceProvider, - ProcessProvider processProvider, PathProvider pathProvider) + ProcessProvider processProvider, EnviromentProvider enviromentProvider) { _diskProvider = diskProvider; _serviceProvider = serviceProvider; _processProvider = processProvider; - _pathProvider = pathProvider; + _enviromentProvider = enviromentProvider; } private void Verify(string targetFolder) @@ -34,8 +34,8 @@ namespace NzbDrone.Update.Providers throw new DirectoryNotFoundException("Target folder doesn't exist " + targetFolder); logger.Info("Verifying Update Folder"); - if (!_diskProvider.FolderExists(_pathProvider.GetUpdatePackageFolder())) - throw new DirectoryNotFoundException("Update folder doesn't exist " + _pathProvider.GetUpdatePackageFolder()); + if (!_diskProvider.FolderExists(_enviromentProvider.GetUpdatePackageFolder())) + throw new DirectoryNotFoundException("Update folder doesn't exist " + _enviromentProvider.GetUpdatePackageFolder()); } @@ -62,14 +62,14 @@ namespace NzbDrone.Update.Providers } logger.Info("Creating backup of existing installation"); - _diskProvider.CopyDirectory(targetFolder, _pathProvider.GetUpdateBackUpFolder()); + _diskProvider.CopyDirectory(targetFolder, _enviromentProvider.GetUpdateBackUpFolder()); logger.Info("Copying update package to target"); try { - _diskProvider.CopyDirectory(_pathProvider.GetUpdatePackageFolder(), targetFolder); + _diskProvider.CopyDirectory(_enviromentProvider.GetUpdatePackageFolder(), targetFolder); } catch (Exception e) { @@ -85,7 +85,7 @@ namespace NzbDrone.Update.Providers private void RollBack(string targetFolder) { logger.Info("Attempting to rollback upgrade"); - _diskProvider.CopyDirectory(_pathProvider.GetUpdateBackUpFolder(), targetFolder); + _diskProvider.CopyDirectory(_enviromentProvider.GetUpdateBackUpFolder(), targetFolder); } diff --git a/NzbDrone.Web/Controllers/SettingsController.cs b/NzbDrone.Web/Controllers/SettingsController.cs index d7bea1647..23b6d83e1 100644 --- a/NzbDrone.Web/Controllers/SettingsController.cs +++ b/NzbDrone.Web/Controllers/SettingsController.cs @@ -4,6 +4,8 @@ using System.IO; using System.Linq; using System.Web.Mvc; using NLog; +using NzbDrone.Common; +using NzbDrone.Common.Model; using NzbDrone.Core.Helpers; using NzbDrone.Core.Model; using NzbDrone.Core.Model.Notification; diff --git a/NzbDrone.Web/Models/SystemSettingsModel.cs b/NzbDrone.Web/Models/SystemSettingsModel.cs index 19a17791d..c1ebfb5ee 100644 --- a/NzbDrone.Web/Models/SystemSettingsModel.cs +++ b/NzbDrone.Web/Models/SystemSettingsModel.cs @@ -1,11 +1,8 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; +using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Linq; -using System.Web; using System.Web.Mvc; -using NzbDrone.Core.Model; +using NzbDrone.Common.Model; namespace NzbDrone.Web.Models { diff --git a/NzbDrone/ApplicationServer.cs b/NzbDrone/ApplicationServer.cs index 145869b5c..41ed6ce96 100644 --- a/NzbDrone/ApplicationServer.cs +++ b/NzbDrone/ApplicationServer.cs @@ -6,13 +6,14 @@ using Ninject; using NzbDrone.Common; using NzbDrone.Providers; + namespace NzbDrone { public class ApplicationServer : ServiceBase { private static readonly Logger Logger = LogManager.GetLogger("Host.App"); - private readonly ConfigProvider _configProvider; + private readonly ConfigFileProvider _configFileProvider; private readonly DebuggerProvider _debuggerProvider; private readonly EnviromentProvider _enviromentProvider; private readonly IISProvider _iisProvider; @@ -21,11 +22,11 @@ namespace NzbDrone private readonly WebClient _webClient; [Inject] - public ApplicationServer(ConfigProvider configProvider, WebClient webClient, IISProvider iisProvider, + public ApplicationServer(ConfigFileProvider configFileProvider, WebClient webClient, IISProvider iisProvider, DebuggerProvider debuggerProvider, EnviromentProvider enviromentProvider, ProcessProvider processProvider, MonitoringProvider monitoringProvider) { - _configProvider = configProvider; + _configFileProvider = configFileProvider; _webClient = webClient; _iisProvider = iisProvider; _debuggerProvider = debuggerProvider; @@ -51,7 +52,7 @@ namespace NzbDrone _debuggerProvider.Attach(); - if (_enviromentProvider.IsUserInteractive && _configProvider.LaunchBrowser) + if (_enviromentProvider.IsUserInteractive && _configFileProvider.LaunchBrowser) { try { diff --git a/NzbDrone/CentralDispatch.cs b/NzbDrone/CentralDispatch.cs index d6a262440..68c52fb77 100644 --- a/NzbDrone/CentralDispatch.cs +++ b/NzbDrone/CentralDispatch.cs @@ -29,7 +29,7 @@ namespace NzbDrone { _kernel = new StandardKernel(); _kernel.Bind().ToSelf().InSingletonScope(); - _kernel.Bind().ToSelf().InSingletonScope(); + _kernel.Bind().ToSelf().InSingletonScope(); _kernel.Bind().ToSelf().InSingletonScope(); _kernel.Bind().ToSelf().InSingletonScope(); _kernel.Bind().ToSelf().InSingletonScope(); @@ -45,7 +45,9 @@ namespace NzbDrone { LogConfiguration.RegisterConsoleLogger(LogLevel.Debug); LogConfiguration.RegisterUdpLogger(); - _kernel.Get().CreateDefaultConfigFile(); + LogConfiguration.RegisterExceptioneer(); + LogConfiguration.Reload(); + _kernel.Get().CreateDefaultConfigFile(); Logger.Info("Start-up Path:'{0}'", _kernel.Get().ApplicationPath); } } diff --git a/NzbDrone/Model/AuthenticationType.cs b/NzbDrone/Model/AuthenticationType.cs deleted file mode 100644 index 243154383..000000000 --- a/NzbDrone/Model/AuthenticationType.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace NzbDrone.Model -{ - public enum AuthenticationType - { - Anonymous = 0, - Windows = 1 - } -} diff --git a/NzbDrone/NzbDrone.csproj b/NzbDrone/NzbDrone.csproj index ff4dbf855..2b221c2d3 100644 --- a/NzbDrone/NzbDrone.csproj +++ b/NzbDrone/NzbDrone.csproj @@ -85,10 +85,8 @@ - - diff --git a/NzbDrone/Providers/IISProvider.cs b/NzbDrone/Providers/IISProvider.cs index 473893380..cb49b192b 100644 --- a/NzbDrone/Providers/IISProvider.cs +++ b/NzbDrone/Providers/IISProvider.cs @@ -12,15 +12,15 @@ namespace NzbDrone.Providers { private static readonly Logger IISLogger = LogManager.GetLogger("Host.IISExpress"); private static readonly Logger Logger = LogManager.GetLogger("Host.IISProvider"); - private readonly ConfigProvider _configProvider; + private readonly ConfigFileProvider _configFileProvider; private readonly ProcessProvider _processProvider; private readonly EnviromentProvider _enviromentProvider; [Inject] - public IISProvider(ConfigProvider configProvider, ProcessProvider processProvider, EnviromentProvider enviromentProvider) + public IISProvider(ConfigFileProvider configFileProvider, ProcessProvider processProvider, EnviromentProvider enviromentProvider) { - _configProvider = configProvider; + _configFileProvider = configFileProvider; _processProvider = processProvider; _enviromentProvider = enviromentProvider; } @@ -31,7 +31,7 @@ namespace NzbDrone.Providers public string AppUrl { - get { return string.Format("http://localhost:{0}/", _configProvider.PortNumber); } + get { return string.Format("http://localhost:{0}/", _configFileProvider.Port); } } public int IISProcessId { get; private set; } @@ -44,8 +44,8 @@ namespace NzbDrone.Providers var startInfo = new ProcessStartInfo(); - startInfo.FileName = _configProvider.IISExePath; - startInfo.Arguments = String.Format("/config:\"{0}\" /trace:i", _configProvider.IISConfigPath); + startInfo.FileName = _enviromentProvider.GetIISExe(); + startInfo.Arguments = String.Format("/config:\"{0}\" /trace:i", _enviromentProvider.GetIISExe()); startInfo.WorkingDirectory = _enviromentProvider.ApplicationPath; startInfo.UseShellExecute = false; @@ -59,7 +59,7 @@ namespace NzbDrone.Providers try { - _configProvider.UpdateIISConfig(_configProvider.IISConfigPath); + _configFileProvider.UpdateIISConfig(_enviromentProvider.GetIISConfigPath()); } catch (Exception e) { @@ -94,7 +94,7 @@ namespace NzbDrone.Providers foreach (var process in _processProvider.GetProcessByName("IISExpress")) { Logger.Info("[{0}]IIS Process found. Path:{1}", process.Id, process.StartPath); - if (NormalizePath(process.StartPath) == NormalizePath(_configProvider.IISExePath)) + if (NormalizePath(process.StartPath) == NormalizePath(_enviromentProvider.GetIISExe())) { Logger.Info("[{0}]Process is considered orphaned.", process.Id); _processProvider.Kill(process.Id);