mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-11-26 04:33:01 +01:00
Merge branch 'kay.one' of github.com:NzbDrone/NzbDrone into markus
This commit is contained in:
commit
8c1f7e6663
@ -1,6 +1,6 @@
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using AutoMoq;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
@ -8,6 +8,7 @@ using NzbDrone.Common;
|
||||
using NzbDrone.Common.Model;
|
||||
using NzbDrone.Providers;
|
||||
using NzbDrone.Test.Common;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.App.Test
|
||||
{
|
||||
|
@ -1,11 +1,11 @@
|
||||
using System.ServiceProcess;
|
||||
using AutoMoq;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Model;
|
||||
using NzbDrone.Test.Common;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.App.Test
|
||||
{
|
||||
|
@ -1,13 +1,13 @@
|
||||
using System.IO;
|
||||
using AutoMoq;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Model;
|
||||
using NzbDrone.Test.Common;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
namespace NzbDrone.Common.Test
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
@ -23,8 +23,6 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||
|
||||
if (File.Exists(configFile))
|
||||
File.Delete(configFile);
|
||||
|
||||
Mocker.Resolve<ConfigFileProvider>().CreateDefaultConfigFile();
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -133,19 +131,6 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||
result.Should().Be(value);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetValue_New_Key_with_new_parent()
|
||||
{
|
||||
const string key = "Hello";
|
||||
const string value = "World";
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<ConfigFileProvider>().GetValue(key, value, "Universe");
|
||||
|
||||
//Assert
|
||||
result.Should().Be(value);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetAuthenticationType_No_Existing_Value()
|
||||
{
|
||||
@ -169,5 +154,17 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||
//Assert
|
||||
result.Should().Be(AuthenticationType.Windows);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Guid_should_return_the_same_every_time()
|
||||
{
|
||||
//Act
|
||||
var firstResponse = Mocker.Resolve<ConfigFileProvider>().Guid;
|
||||
var secondResponse = Mocker.Resolve<ConfigFileProvider>().Guid;
|
||||
|
||||
|
||||
//Assert
|
||||
secondResponse.Should().Be(firstResponse);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
using FluentAssertions;
|
||||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.App.Test
|
||||
namespace NzbDrone.Common.Test
|
||||
{
|
||||
[TestFixture]
|
||||
public class PathExtentionFixture : TestBase
|
||||
|
@ -13,13 +13,27 @@ namespace NzbDrone.Common
|
||||
private readonly EnviromentProvider _enviromentProvider;
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
|
||||
|
||||
private readonly string _configFile;
|
||||
public ConfigFileProvider(EnviromentProvider enviromentProvider)
|
||||
{
|
||||
_enviromentProvider = enviromentProvider;
|
||||
_configFile = _enviromentProvider.GetConfigPath();
|
||||
|
||||
CreateDefaultConfigFile();
|
||||
}
|
||||
|
||||
public virtual Guid Guid
|
||||
{
|
||||
get
|
||||
{
|
||||
var key = "Guid";
|
||||
if (string.IsNullOrWhiteSpace(GetValue(key, string.Empty)))
|
||||
{
|
||||
SetValue(key, Guid.NewGuid().ToString());
|
||||
}
|
||||
|
||||
return Guid.Parse(GetValue(key, string.Empty));
|
||||
}
|
||||
}
|
||||
|
||||
public virtual int Port
|
||||
@ -40,27 +54,23 @@ namespace NzbDrone.Common
|
||||
set { SetValue("AuthenticationType", (int)value); }
|
||||
}
|
||||
|
||||
public virtual string GetValue(string key, object defaultValue, string parent = null)
|
||||
public virtual int GetValueInt(string key, int defaultValue)
|
||||
{
|
||||
return Convert.ToInt32(GetValue(key, defaultValue));
|
||||
}
|
||||
|
||||
public virtual bool GetValueBoolean(string key, bool defaultValue)
|
||||
{
|
||||
return Convert.ToBoolean(GetValue(key, defaultValue));
|
||||
}
|
||||
|
||||
public virtual string GetValue(string key, object defaultValue)
|
||||
{
|
||||
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();
|
||||
|
||||
@ -68,40 +78,20 @@ namespace NzbDrone.Common
|
||||
return valueHolder.First().Value;
|
||||
|
||||
//Save the value
|
||||
SetValue(key, defaultValue, parent);
|
||||
SetValue(key, defaultValue);
|
||||
|
||||
//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)
|
||||
public virtual void SetValue(string key, object value)
|
||||
{
|
||||
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)
|
||||
@ -113,7 +103,7 @@ namespace NzbDrone.Common
|
||||
xDoc.Save(_configFile);
|
||||
}
|
||||
|
||||
public virtual void CreateDefaultConfigFile()
|
||||
private void CreateDefaultConfigFile()
|
||||
{
|
||||
if (!File.Exists(_configFile))
|
||||
{
|
||||
@ -125,8 +115,6 @@ namespace NzbDrone.Common
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public virtual void UpdateIISConfig(string configPath)
|
||||
{
|
||||
logger.Info(@"Server configuration file: {0}", configPath);
|
||||
|
@ -33,6 +33,8 @@ namespace NzbDrone.Common
|
||||
consoleTarget.Layout = "${message} ${exception}";
|
||||
LogManager.Configuration.AddTarget(consoleTarget.GetType().Name, consoleTarget);
|
||||
LogManager.Configuration.LoggingRules.Add(new LoggingRule(loggerNamePattern, minLevel, consoleTarget));
|
||||
|
||||
LogManager.ConfigurationReloaded += (sender, args) => RegisterConsoleLogger(minLevel, loggerNamePattern);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -56,6 +58,8 @@ namespace NzbDrone.Common
|
||||
udpTarget.IncludeNdc = true;
|
||||
LogManager.Configuration.AddTarget(udpTarget.GetType().Name, udpTarget);
|
||||
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Trace, udpTarget));
|
||||
|
||||
LogManager.ConfigurationReloaded += (sender, args) => RegisterUdpLogger();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -76,6 +80,8 @@ namespace NzbDrone.Common
|
||||
var exTarget = new ExceptioneerTarget();
|
||||
LogManager.Configuration.AddTarget("Exceptioneer", exTarget);
|
||||
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Error, exTarget));
|
||||
|
||||
LogManager.ConfigurationReloaded += (sender, args) => RegisterExceptioneer();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -19,21 +19,7 @@ namespace NzbDrone.Common
|
||||
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);
|
||||
}
|
||||
private const string UPDATE_CLIENT_EXE = "nzbdrone.update.exe";
|
||||
|
||||
public static string GetIISFolder(this EnviromentProvider enviromentProvider)
|
||||
{
|
||||
@ -89,5 +75,25 @@ namespace NzbDrone.Common
|
||||
{
|
||||
return Path.Combine(enviromentProvider.GetWebRoot(), "Cache");
|
||||
}
|
||||
|
||||
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 GetUpdateClientExePath(this EnviromentProvider enviromentProvider)
|
||||
{
|
||||
return Path.Combine(enviromentProvider.GetUpdateSandboxFolder(), UPDATE_CLIENT_EXE);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,9 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
using NLog;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Indexer;
|
||||
using NzbDrone.Core.Providers.Jobs;
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System.IO;
|
||||
using NUnit.Framework;
|
||||
using Ninject;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Test.Common;
|
||||
using PetaPoco;
|
||||
|
||||
@ -11,6 +12,7 @@ namespace NzbDrone.Core.Test.Framework
|
||||
{
|
||||
static CoreTest()
|
||||
{
|
||||
//Delete old db files
|
||||
var oldDbFiles = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.sdf", SearchOption.AllDirectories);
|
||||
foreach (var file in oldDbFiles)
|
||||
{
|
||||
@ -21,6 +23,14 @@ namespace NzbDrone.Core.Test.Framework
|
||||
catch { }
|
||||
}
|
||||
|
||||
//Delete App_data folder
|
||||
var appData = new EnviromentProvider().GetAppDataPath();
|
||||
|
||||
if (Directory.Exists(appData))
|
||||
{
|
||||
Directory.Delete(appData, true);
|
||||
}
|
||||
|
||||
MockLib.CreateDataBaseTemplate();
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.ServiceModel.Syndication;
|
||||
using AutoMoq;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
@ -17,6 +17,7 @@ using NzbDrone.Core.Repository.Quality;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Test.ProviderTests;
|
||||
using NzbDrone.Test.Common;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using AutoMoq;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
@ -8,6 +8,7 @@ using NzbDrone.Core.Model.Notification;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Jobs;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test.JobTests
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using AutoMoq;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using AutoMoq;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
@ -12,6 +12,7 @@ using NzbDrone.Core.Providers.Jobs;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test.JobTests
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using AutoMoq;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
@ -12,6 +12,7 @@ using NzbDrone.Core.Providers.Jobs;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test.JobTests
|
||||
{
|
||||
|
@ -1,9 +1,10 @@
|
||||
using System;
|
||||
using AutoMoq;
|
||||
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
using NzbDrone.Core.Providers.Jobs;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test.JobTests
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using AutoMoq;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
@ -9,6 +9,7 @@ using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Jobs;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test.JobTests
|
||||
{
|
||||
|
@ -1,11 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using AutoMoq;
|
||||
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Jobs;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test.JobTests
|
||||
{
|
||||
|
@ -1,13 +1,14 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using AutoMoq;
|
||||
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
using PetaPoco;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
|
@ -3,13 +3,14 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using AutoMoq;
|
||||
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.DiskProviderTests
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using AutoMoq;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
@ -10,6 +10,7 @@ using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using AutoMoq;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
@ -13,6 +13,7 @@ using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using AutoMoq;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
@ -8,6 +8,7 @@ using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using AutoMoq;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
@ -14,6 +14,7 @@ using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
using PetaPoco;
|
||||
using TvdbLib.Data;
|
||||
|
||||
|
@ -2,13 +2,14 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using AutoMoq;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
using TvdbLib.Data;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using AutoMoq;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
@ -10,6 +10,7 @@ using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
|
@ -1,13 +1,14 @@
|
||||
// ReSharper disable RedundantUsingDirective
|
||||
|
||||
using System;
|
||||
using AutoMoq;
|
||||
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Model.Xbmc;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Providers.Xbmc;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using AutoMoq;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
@ -9,6 +9,7 @@ using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using AutoMoq;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
@ -9,6 +9,7 @@ using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
|
@ -4,7 +4,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.ServiceModel.Syndication;
|
||||
using AutoMoq;
|
||||
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Model;
|
||||
@ -13,6 +13,7 @@ using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Providers.Indexer;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using AutoMoq;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
@ -12,6 +12,7 @@ using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using AutoMoq;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
@ -12,6 +12,7 @@ using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using AutoMoq;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
@ -12,6 +12,7 @@ using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
|
@ -4,13 +4,14 @@ using System.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using AutoMoq;
|
||||
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers.Jobs;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using AutoMoq;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
@ -13,6 +13,7 @@ using NzbDrone.Core.Instrumentation;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
using PetaPoco;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
@ -31,7 +32,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||
public void Setup()
|
||||
{
|
||||
db = MockLib.GetEmptyDatabase(true);
|
||||
LogConfiguration.RegisterDatabaseLogger(new DatabaseTarget(db));
|
||||
new DatabaseTarget(db).Register();
|
||||
Logger = LogManager.GetCurrentClassLogger();
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
// ReSharper disable RedundantUsingDirective
|
||||
|
||||
using System.Collections.Generic;
|
||||
using AutoMoq;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
@ -11,6 +11,7 @@ using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
// ReSharper disable RedundantUsingDirective
|
||||
|
||||
using System.Collections.Generic;
|
||||
using AutoMoq;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Providers;
|
||||
@ -9,6 +9,7 @@ using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using AutoMoq;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
@ -7,6 +7,7 @@ using NUnit.Framework;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
|
@ -1,5 +1,6 @@
|
||||
// ReSharper disable RedundantUsingDirective
|
||||
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.IO;
|
||||
using FluentAssertions;
|
||||
@ -8,7 +9,7 @@ using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
@ -3,7 +3,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using AutoMoq;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
@ -14,6 +14,7 @@ using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using AutoMoq;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
@ -10,6 +10,7 @@ using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
using Prowlin;
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
@ -1,13 +1,14 @@
|
||||
// ReSharper disable RedundantUsingDirective
|
||||
|
||||
using System.Collections.Generic;
|
||||
using AutoMoq;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using AutoMoq;
|
||||
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
@ -11,6 +11,7 @@ using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
|
@ -3,7 +3,7 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using AutoMoq;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
@ -15,6 +15,7 @@ using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using AutoMoq;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
@ -14,6 +14,7 @@ using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using AutoMoq;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
@ -12,6 +12,7 @@ using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Indexer;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using AutoMoq;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
@ -13,6 +13,7 @@ using NzbDrone.Core.Providers.Indexer;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using AutoMoq;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
@ -10,6 +10,7 @@ using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
|
@ -3,13 +3,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using AutoMoq;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using AutoMoq;
|
||||
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
@ -7,6 +7,7 @@ using NzbDrone.Common;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests
|
||||
{
|
||||
|
@ -1,7 +1,10 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Ninject.Activation.Strategies;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers;
|
||||
@ -13,44 +16,68 @@ namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests
|
||||
[TestFixture]
|
||||
internal class PreformUpdateFixture : CoreTest
|
||||
{
|
||||
|
||||
|
||||
private const string SANDBOX_FOLDER = @"C:\Temp\nzbdrone_update\";
|
||||
|
||||
[SetUp]
|
||||
public void setup()
|
||||
private readonly UpdatePackage updatePackage = new UpdatePackage
|
||||
{
|
||||
WithStrictMocker();
|
||||
|
||||
FileName = "NzbDrone.kay.one.0.6.0.2031.zip",
|
||||
Url = "http://update.nzbdrone.com/_test/NzbDrone.zip",
|
||||
Version = new Version("0.6.0.2031")
|
||||
};
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
Mocker.GetMock<EnviromentProvider>().SetupGet(c => c.SystemTemp).Returns(@"C:\Temp\");
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Test]
|
||||
public void Should_download_update_package()
|
||||
{
|
||||
var updateArchive = Path.Combine(SANDBOX_FOLDER, updatePackage.FileName);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<UpdateProvider>().StartUpgrade(updatePackage);
|
||||
|
||||
//Assert
|
||||
Mocker.GetMock<HttpProvider>().Verify(
|
||||
c => c.DownloadFile(updatePackage.Url, updateArchive));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Should_call_download_and_extract_using_correct_arguments()
|
||||
{
|
||||
Mocker.GetMock<EnviromentProvider>().SetupGet(c => c.SystemTemp).Returns(@"C:\Temp\");
|
||||
|
||||
var updatePackage = new UpdatePackage
|
||||
{
|
||||
FileName = "NzbDrone.kay.one.0.6.0.2031.zip",
|
||||
Url = "http://update.nzbdrone.com/kayone/NzbDrone.kay.one.0.6.0.2031.zip",
|
||||
Version = new Version("0.6.0.2031")
|
||||
};
|
||||
|
||||
var updateArchive = Path.Combine(SANDBOX_FOLDER, updatePackage.FileName);
|
||||
|
||||
Mocker.GetMock<HttpProvider>().Setup(
|
||||
c => c.DownloadFile(updatePackage.Url, updateArchive));
|
||||
|
||||
Mocker.GetMock<ArchiveProvider>().Setup(
|
||||
c => c.ExtractArchive(updateArchive, SANDBOX_FOLDER));
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<UpdateProvider>().StartUpgrade(updatePackage);
|
||||
|
||||
//Assert
|
||||
Mocker.GetMock<ArchiveProvider>().Verify(
|
||||
c => c.ExtractArchive(updateArchive, SANDBOX_FOLDER));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_start_update_client()
|
||||
{
|
||||
//Setup
|
||||
var updateClientPath = Mocker.GetMock<EnviromentProvider>().Object.GetUpdateClientExePath();
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<UpdateProvider>().StartUpgrade(updatePackage);
|
||||
|
||||
//Assert
|
||||
Mocker.GetMock<ProcessProvider>().Verify(
|
||||
c => c.Start(It.Is<ProcessStartInfo>(p =>
|
||||
p.FileName == updateClientPath &&
|
||||
p.Arguments == "/12 /"
|
||||
)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Category(IntegrationTest)]
|
||||
public void Should_download_and_extract_to_temp_folder()
|
||||
{
|
||||
|
||||
@ -58,13 +85,6 @@ namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests
|
||||
|
||||
var updateSubFolder = new DirectoryInfo(Mocker.GetMock<EnviromentProvider>().Object.GetUpdateSandboxFolder());
|
||||
|
||||
var updatePackage = new UpdatePackage
|
||||
{
|
||||
FileName = "NzbDrone.kay.one.0.6.0.2031.zip",
|
||||
Url = "http://update.nzbdrone.com/_test/NzbDrone.zip",
|
||||
Version = new Version("0.6.0.2031")
|
||||
};
|
||||
|
||||
|
||||
//Act
|
||||
updateSubFolder.Exists.Should().BeFalse();
|
||||
@ -81,6 +101,5 @@ namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests
|
||||
updateSubFolder.GetDirectories().Should().HaveCount(1);
|
||||
updateSubFolder.GetFiles().Should().HaveCount(1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
// ReSharper disable RedundantUsingDirective
|
||||
|
||||
using System;
|
||||
using AutoMoq;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
@ -12,6 +12,7 @@ using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Providers.Xbmc;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
// ReSharper disable RedundantUsingDirective
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using AutoMoq;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
@ -9,6 +9,7 @@ using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test
|
||||
{
|
||||
|
@ -1,9 +1,10 @@
|
||||
using AutoMoq;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
// ReSharper disable RedundantUsingDirective
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using AutoMoq;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
|
@ -2,7 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using AutoMoq;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
@ -10,6 +10,7 @@ using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
using PetaPoco;
|
||||
|
||||
namespace NzbDrone.Core.Test
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Ninject;
|
||||
using NLog;
|
||||
@ -7,68 +8,58 @@ using NzbDrone.Common;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Instrumentation;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
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
|
||||
{
|
||||
public class CentralDispatch
|
||||
{
|
||||
private readonly Object KernelLock = new object();
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public CentralDispatch()
|
||||
{
|
||||
InitializeApp();
|
||||
}
|
||||
|
||||
public StandardKernel Kernel { get; private set; }
|
||||
|
||||
private void InitializeApp()
|
||||
public CentralDispatch()
|
||||
{
|
||||
BindKernel();
|
||||
|
||||
Kernel.Get<LogConfiguration>().Setup();
|
||||
|
||||
var mainConnectionString = Kernel.Get<Connection>().MainConnectionString;
|
||||
|
||||
MigrationsHelper.Run(mainConnectionString, true);
|
||||
|
||||
LogConfiguration.RegisterDatabaseLogger(Kernel.Get<DatabaseTarget>());
|
||||
LogConfiguration.Reload();
|
||||
|
||||
Kernel.Get<QualityProvider>().SetupDefaultProfiles();
|
||||
Kernel.Get<QualityTypeProvider>().SetupDefault();
|
||||
Kernel.Get<ConfigFileProvider>().CreateDefaultConfigFile();
|
||||
|
||||
BindExternalNotifications();
|
||||
BindIndexers();
|
||||
BindJobs();
|
||||
}
|
||||
|
||||
private void BindKernel()
|
||||
{
|
||||
lock (KernelLock)
|
||||
{
|
||||
Logger.Debug("Binding Ninject's Kernel");
|
||||
Logger.Debug("Initializing Kernel:");
|
||||
Kernel = new StandardKernel();
|
||||
|
||||
var connection = Kernel.Get<Connection>();
|
||||
InitDatabase();
|
||||
|
||||
InitQuality();
|
||||
InitExternalNotifications();
|
||||
InitIndexers();
|
||||
InitJobs();
|
||||
}
|
||||
|
||||
private void InitDatabase()
|
||||
{
|
||||
Logger.Info("Initializing Database...");
|
||||
|
||||
var appDataPath = new EnviromentProvider().GetAppDataPath();
|
||||
if (!Directory.Exists(appDataPath)) Directory.CreateDirectory(appDataPath);
|
||||
|
||||
var connection = Kernel.Get<Connection>();
|
||||
Kernel.Bind<IDatabase>().ToMethod(c => connection.GetMainPetaPocoDb()).InTransientScope();
|
||||
Kernel.Bind<IDatabase>().ToMethod(c => connection.GetLogPetaPocoDb(false)).WhenInjectedInto<DatabaseTarget>().InSingletonScope();
|
||||
Kernel.Bind<IDatabase>().ToMethod(c => connection.GetLogPetaPocoDb()).WhenInjectedInto<LogProvider>().InSingletonScope();
|
||||
|
||||
Kernel.Bind<JobProvider>().ToSelf().InSingletonScope();
|
||||
}
|
||||
Kernel.Get<DatabaseTarget>().Register();
|
||||
LogConfiguration.Reload();
|
||||
}
|
||||
|
||||
private void BindIndexers()
|
||||
private void InitQuality()
|
||||
{
|
||||
Logger.Info("Initializing Quality...");
|
||||
Kernel.Get<QualityProvider>().SetupDefaultProfiles();
|
||||
Kernel.Get<QualityTypeProvider>().SetupDefault();
|
||||
}
|
||||
|
||||
private void InitIndexers()
|
||||
{
|
||||
Logger.Info("Initializing Indexers...");
|
||||
Kernel.Bind<IndexerBase>().To<NzbsOrg>();
|
||||
Kernel.Bind<IndexerBase>().To<NzbMatrix>();
|
||||
Kernel.Bind<IndexerBase>().To<NzbsRUs>();
|
||||
@ -79,8 +70,12 @@ namespace NzbDrone.Core
|
||||
Kernel.Get<IndexerProvider>().InitializeIndexers(indexers.ToList());
|
||||
}
|
||||
|
||||
private void BindJobs()
|
||||
private void InitJobs()
|
||||
{
|
||||
Logger.Info("Initializing Background Jobs...");
|
||||
|
||||
Kernel.Bind<JobProvider>().ToSelf().InSingletonScope();
|
||||
|
||||
Kernel.Bind<IJob>().To<RssSyncJob>().InSingletonScope();
|
||||
Kernel.Bind<IJob>().To<ImportNewSeriesJob>().InSingletonScope();
|
||||
Kernel.Bind<IJob>().To<UpdateInfoJob>().InSingletonScope();
|
||||
@ -102,8 +97,9 @@ namespace NzbDrone.Core
|
||||
Kernel.Get<WebTimer>().StartTimer(30);
|
||||
}
|
||||
|
||||
private void BindExternalNotifications()
|
||||
private void InitExternalNotifications()
|
||||
{
|
||||
Logger.Info("Initializing External Notifications...");
|
||||
Kernel.Bind<ExternalNotificationBase>().To<Xbmc>();
|
||||
Kernel.Bind<ExternalNotificationBase>().To<Smtp>();
|
||||
Kernel.Bind<ExternalNotificationBase>().To<Twitter>();
|
||||
@ -114,9 +110,6 @@ namespace NzbDrone.Core
|
||||
Kernel.Get<ExternalNotificationProvider>().InitializeNotifiers(notifiers.ToList());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Forces IISExpress process to exit with the host application
|
||||
/// </summary>
|
||||
public void DedicateToHost()
|
||||
{
|
||||
try
|
||||
@ -144,7 +137,7 @@ namespace NzbDrone.Core
|
||||
|
||||
private static void ShutDown()
|
||||
{
|
||||
Logger.Info("Shutting down application.");
|
||||
Logger.Info("Shutting down application...");
|
||||
WebTimer.Stop();
|
||||
Process.GetCurrentProcess().Kill();
|
||||
}
|
||||
|
@ -53,6 +53,7 @@ namespace NzbDrone.Core.Datastore
|
||||
private static void EnsureDatabase(string constr)
|
||||
{
|
||||
var connection = new SqlCeConnection(constr);
|
||||
|
||||
if (!File.Exists(connection.Database))
|
||||
{
|
||||
var engine = new SqlCeEngine(constr);
|
||||
|
@ -9,6 +9,7 @@
|
||||
*/
|
||||
|
||||
//#define PETAPOCO_NO_DYNAMIC //in your project settings on .NET 3.5
|
||||
// ReSharper disable CheckNamespace
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
@ -23,7 +24,6 @@ using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using System.Linq.Expressions;
|
||||
|
||||
|
||||
namespace PetaPoco
|
||||
{
|
||||
// Poco's marked [Explicit] require all column properties to be marked
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using NLog.Config;
|
||||
using Ninject;
|
||||
using NLog;
|
||||
using NLog.Targets;
|
||||
@ -20,6 +21,15 @@ namespace NzbDrone.Core.Instrumentation
|
||||
}
|
||||
|
||||
|
||||
public void Register()
|
||||
{
|
||||
LogManager.Configuration.AddTarget("DbLogger", this);
|
||||
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Debug, this));
|
||||
|
||||
LogManager.ConfigurationReloaded += (sender, args) => Register();
|
||||
LogConfiguration.Reload();
|
||||
}
|
||||
|
||||
|
||||
protected override void Write(LogEventInfo logEvent)
|
||||
{
|
||||
|
@ -1,49 +0,0 @@
|
||||
using System.IO;
|
||||
using Ninject;
|
||||
using NLog;
|
||||
using NLog.Config;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Providers;
|
||||
|
||||
namespace NzbDrone.Core.Instrumentation
|
||||
{
|
||||
public class LogConfiguration
|
||||
{
|
||||
private readonly EnviromentProvider _enviromentProvider;
|
||||
private readonly DatabaseTarget _databaseTarget;
|
||||
|
||||
public LogConfiguration(EnviromentProvider enviromentProvider, DatabaseTarget databaseTarget)
|
||||
{
|
||||
_enviromentProvider = enviromentProvider;
|
||||
_databaseTarget = databaseTarget;
|
||||
}
|
||||
|
||||
public void Setup()
|
||||
{
|
||||
if (Common.EnviromentProvider.IsProduction)
|
||||
{
|
||||
LogManager.ThrowExceptions = 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();
|
||||
}
|
||||
}
|
||||
}
|
@ -292,7 +292,6 @@
|
||||
<Compile Include="Providers\XbmcProvider.cs" />
|
||||
<Compile Include="Repository\EpisodeFile.cs" />
|
||||
<Compile Include="Model\Notification\ProgressNotificationStatus.cs" />
|
||||
<Compile Include="Instrumentation\LogConfiguration.cs" />
|
||||
<Compile Include="Parser.cs" />
|
||||
<Compile Include="Providers\MediaFileProvider.cs" />
|
||||
<Compile Include="Model\Notification\ProgressNotification.cs" />
|
||||
|
@ -1,17 +1,18 @@
|
||||
// ReSharper disable RedundantUsingDirective
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Runtime.CompilerServices;
|
||||
using AutoMoq.Unity;
|
||||
using Microsoft.Practices.Unity;
|
||||
using Moq;
|
||||
using Moq.Language.Flow;
|
||||
using NzbDrone.Test.Common.AutoMoq.Unity;
|
||||
|
||||
[assembly: InternalsVisibleTo("AutoMoq.Tests")]
|
||||
|
||||
namespace AutoMoq
|
||||
namespace NzbDrone.Test.Common.AutoMoq
|
||||
{
|
||||
public class AutoMoqer
|
||||
{
|
||||
|
@ -1,4 +1,5 @@
|
||||
// ReSharper disable RedundantUsingDirective
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -7,7 +8,7 @@ using Microsoft.Practices.ObjectBuilder2;
|
||||
using Microsoft.Practices.Unity;
|
||||
using Moq;
|
||||
|
||||
namespace AutoMoq.Unity
|
||||
namespace NzbDrone.Test.Common.AutoMoq.Unity
|
||||
{
|
||||
internal class AutoMockingBuilderStrategy : BuilderStrategy
|
||||
{
|
||||
|
@ -1,10 +1,12 @@
|
||||
// ReSharper disable RedundantUsingDirective
|
||||
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Practices.Unity;
|
||||
using Microsoft.Practices.Unity.ObjectBuilder;
|
||||
|
||||
namespace AutoMoq.Unity
|
||||
namespace NzbDrone.Test.Common.AutoMoq.Unity
|
||||
{
|
||||
internal class AutoMockingContainerExtension : UnityContainerExtension
|
||||
{
|
||||
|
@ -1,15 +1,19 @@
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using AutoMoq;
|
||||
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Test.Common
|
||||
{
|
||||
public class TestBase : LoggingTest
|
||||
// ReSharper disable InconsistentNaming
|
||||
{
|
||||
|
||||
protected const string IntegrationTest = "Integration Test";
|
||||
|
||||
protected AutoMoqer Mocker;
|
||||
|
||||
protected string VirtualPath
|
||||
|
@ -1,12 +1,13 @@
|
||||
// ReSharper disable InconsistentNaming
|
||||
using System;
|
||||
using System.IO;
|
||||
using AutoMoq;
|
||||
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Test.Common;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
using NzbDrone.Update.Providers;
|
||||
|
||||
namespace NzbDrone.Update.Test
|
||||
|
@ -7,7 +7,7 @@
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// ReSharper disable CheckNamespace
|
||||
namespace Resources {
|
||||
using System;
|
||||
|
||||
|
@ -8,9 +8,11 @@ using System.Web.Caching;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using MvcMiniProfiler;
|
||||
using NLog.Config;
|
||||
using Ninject;
|
||||
using Ninject.Web.Mvc;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core;
|
||||
using NzbDrone.Core.Instrumentation;
|
||||
using Telerik.Web.Mvc;
|
||||
@ -54,6 +56,12 @@ namespace NzbDrone.Web
|
||||
|
||||
protected override IKernel CreateKernel()
|
||||
{
|
||||
Common.LogConfiguration.RegisterUdpLogger();
|
||||
Common.LogConfiguration.RegisterExceptioneer();
|
||||
Common.LogConfiguration.RegisterConsoleLogger(LogLevel.Info, "NzbDrone.Web.MvcApplication");
|
||||
Common.LogConfiguration.RegisterConsoleLogger(LogLevel.Info, "NzbDrone.Core.CentralDispatch");
|
||||
|
||||
LogManager.Configuration = new XmlLoggingConfiguration(new EnviromentProvider().GetNlogConfigPath(), false);
|
||||
|
||||
var dispatch = new CentralDispatch();
|
||||
Logger.Info("NzbDrone Starting up.");
|
||||
|
@ -1,8 +1,9 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Mvc.Html;
|
||||
|
||||
namespace Helpers
|
||||
namespace NzbDrone.Web.Helpers
|
||||
{
|
||||
public static class IsCurrentActionHelper
|
||||
{
|
||||
|
@ -63,6 +63,10 @@
|
||||
<Reference Include="System.ComponentModel.DataAnnotations">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
|
||||
<Private>True</Private>
|
||||
<HintPath>..\packages\SqlServerCompact.4.0.8482.1\lib\System.Data.SqlServerCe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.Abstractions">
|
||||
<Private>True</Private>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
@using Helpers;
|
||||
@using NzbDrone.Common
|
||||
@using NzbDrone.Web.Helpers
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head runat="server">
|
||||
<link rel="SHORTCUT ICON" href="../../favicon.ico" />
|
||||
|
@ -1,24 +1,10 @@
|
||||
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" autoReload="true">
|
||||
<targets>
|
||||
<target name="udpTarget" xsi:type="Chainsaw" address="udp://127.0.0.1:20480"
|
||||
includeCallSite="true" includeSourceInfo="true" includeNLogData="true" includeNDC="true" includeMDC="true">
|
||||
<parameter name="exception" layout="${exception:format=ToString}" xsi:type="NLogViewerParameterInfo" />
|
||||
<parameter name="processname" layout="${processname}" xsi:type="NLogViewerParameterInfo" />
|
||||
<parameter name="stacktrace" layout="${stacktrace:topFrames=99}" xsi:type="NLogViewerParameterInfo" />
|
||||
<parameter name="ThreadName" layout="${threadname}" xsi:type="NLogViewerParameterInfo" />
|
||||
</target>
|
||||
|
||||
<target name="file" xsi:type="File" keepFileOpen="true" openFileCacheTimeout="1"
|
||||
layout="${longdate} [${level}] ${logger}: ${message} ${exception:ToString}"
|
||||
fileName="${basedir}/App_Data/logs/${shortdate}.txt" />
|
||||
<target name ="xmlFile" xsi:type="File" keepFileOpen="true" openFileCacheTimeout="1"
|
||||
fileName="${basedir}/App_Data/logs/${shortdate}.xml"
|
||||
layout="${log4jxmlevent:includeSourceInfo=true:includeCallSite=true:includeMDC=true:appInfo=true:includeNDC=true:includeNLogData=true}"/>
|
||||
</targets>
|
||||
|
||||
<rules>
|
||||
<logger name="*" minlevel="Debug" writeTo="udpTarget"/>
|
||||
<logger name="*" minlevel="Off" writeTo="xmlFile"/>
|
||||
<logger name="*" minlevel="Warn" writeTo="file"/>
|
||||
<logger name="*" minlevel="Off" writeTo="file"/>
|
||||
</rules>
|
||||
</nlog>
|
@ -47,7 +47,6 @@ namespace NzbDrone
|
||||
LogConfiguration.RegisterUdpLogger();
|
||||
LogConfiguration.RegisterExceptioneer();
|
||||
LogConfiguration.Reload();
|
||||
_kernel.Get<ConfigFileProvider>().CreateDefaultConfigFile();
|
||||
Logger.Info("Start-up Path:'{0}'", _kernel.Get<EnviromentProvider>().ApplicationPath);
|
||||
}
|
||||
}
|
||||
|
@ -1,2 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
|
||||
<Config />
|
||||
<Config>
|
||||
<Port>8989</Port>
|
||||
<AuthenticationType>0</AuthenticationType>
|
||||
<LaunchBrowser>true</LaunchBrowser>
|
||||
</Config>
|
Loading…
Reference in New Issue
Block a user