mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-04 10:02:40 +01:00
fixed some broken tests.
This commit is contained in:
parent
acaa05c9c0
commit
324b5e3b80
16
NzbDrone.Api/ApiContainerExtensions.cs
Normal file
16
NzbDrone.Api/ApiContainerExtensions.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using System.Linq;
|
||||||
|
using Autofac;
|
||||||
|
using Nancy.Bootstrapper;
|
||||||
|
using NzbDrone.Common;
|
||||||
|
|
||||||
|
namespace NzbDrone.Api
|
||||||
|
{
|
||||||
|
public static class ApiContainerExtensions
|
||||||
|
{
|
||||||
|
public static void RegisterApiServices(this ContainerBuilder containerBuilder)
|
||||||
|
{
|
||||||
|
containerBuilder.RegisterAssemblyTypes("NzbDrone.Api");
|
||||||
|
containerBuilder.RegisterType<NancyBootstrapper>().As<INancyBootstrapper>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,23 +0,0 @@
|
|||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
|
||||||
using Autofac;
|
|
||||||
|
|
||||||
namespace NzbDrone.Api
|
|
||||||
{
|
|
||||||
public static class ContainerExtensions
|
|
||||||
{
|
|
||||||
public static void RegisterApiServices(this ContainerBuilder containerBuilder)
|
|
||||||
{
|
|
||||||
var apiAssembly = Assembly.Load("NzbDrone.Api");
|
|
||||||
|
|
||||||
|
|
||||||
containerBuilder.RegisterAssemblyTypes(apiAssembly)
|
|
||||||
.AsImplementedInterfaces()
|
|
||||||
.SingleInstance();
|
|
||||||
|
|
||||||
containerBuilder.RegisterAssemblyTypes(apiAssembly)
|
|
||||||
.AsSelf()
|
|
||||||
.SingleInstance();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -108,7 +108,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="AutomapperBootstraper.cs" />
|
<Compile Include="AutomapperBootstraper.cs" />
|
||||||
<Compile Include="ContainerExtentions.cs" />
|
<Compile Include="ApiContainerExtensions.cs" />
|
||||||
<Compile Include="Directories\DirectoryModule.cs" />
|
<Compile Include="Directories\DirectoryModule.cs" />
|
||||||
<Compile Include="Extentions\NancyJsonSerializer.cs" />
|
<Compile Include="Extentions\NancyJsonSerializer.cs" />
|
||||||
<Compile Include="Extentions\Serializer.cs" />
|
<Compile Include="Extentions\Serializer.cs" />
|
||||||
|
@ -57,10 +57,6 @@
|
|||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\packages\Autofac.3.0.1\lib\net40\Autofac.dll</HintPath>
|
<HintPath>..\packages\Autofac.3.0.1\lib\net40\Autofac.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Autofac.Configuration, Version=3.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
|
||||||
<SpecificVersion>False</SpecificVersion>
|
|
||||||
<HintPath>..\packages\Autofac.3.0.1\lib\net40\Autofac.Configuration.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="FizzWare.NBuilder, Version=3.0.1.0, Culture=neutral, PublicKeyToken=5651b03e12e42c12, processorArchitecture=MSIL">
|
<Reference Include="FizzWare.NBuilder, Version=3.0.1.0, Culture=neutral, PublicKeyToken=5651b03e12e42c12, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\NBuilder.3.0.1.1\lib\FizzWare.NBuilder.dll</HintPath>
|
<HintPath>..\packages\NBuilder.3.0.1.1\lib\FizzWare.NBuilder.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
@ -82,9 +78,6 @@
|
|||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.ServiceProcess" />
|
<Reference Include="System.ServiceProcess" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
|
||||||
<Reference Include="Microsoft.CSharp" />
|
|
||||||
<Reference Include="System.Data" />
|
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -106,10 +99,6 @@
|
|||||||
<Project>{CADDFCE0-7509-4430-8364-2074E1EEFCA2}</Project>
|
<Project>{CADDFCE0-7509-4430-8364-2074E1EEFCA2}</Project>
|
||||||
<Name>NzbDrone.Test.Common</Name>
|
<Name>NzbDrone.Test.Common</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\NzbDrone.Test.Dummy\NzbDrone.Test.Dummy.csproj">
|
|
||||||
<Project>{FAFB5948-A222-4CF6-AD14-026BE7564802}</Project>
|
|
||||||
<Name>NzbDrone.Test.Dummy</Name>
|
|
||||||
</ProjectReference>
|
|
||||||
<ProjectReference Include="..\NzbDrone\NzbDrone.csproj">
|
<ProjectReference Include="..\NzbDrone\NzbDrone.csproj">
|
||||||
<Project>{D12F7F2F-8A3C-415F-88FA-6DD061A84869}</Project>
|
<Project>{D12F7F2F-8A3C-415F-88FA-6DD061A84869}</Project>
|
||||||
<Name>NzbDrone</Name>
|
<Name>NzbDrone</Name>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
namespace NzbDrone.Common.Test
|
namespace NzbDrone.Common.Test
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class EnviromentProviderTest : TestBase
|
public class EnvironmentProviderTest : TestBase
|
||||||
{
|
{
|
||||||
readonly EnvironmentProvider environmentProvider = new EnvironmentProvider();
|
readonly EnvironmentProvider environmentProvider = new EnvironmentProvider();
|
||||||
|
|
||||||
|
33
NzbDrone.Common/CommonContainerExtentions.cs
Normal file
33
NzbDrone.Common/CommonContainerExtentions.cs
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using Autofac;
|
||||||
|
|
||||||
|
namespace NzbDrone.Common
|
||||||
|
{
|
||||||
|
public static class CommonContainerExtensions
|
||||||
|
{
|
||||||
|
public static void RegisterCommonServices(this ContainerBuilder containerBuilder)
|
||||||
|
{
|
||||||
|
containerBuilder.RegisterAssemblyTypes("NzbDrone.Common");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void RegisterAssemblyTypes(this ContainerBuilder containerBuilder, string assemblyName)
|
||||||
|
{
|
||||||
|
var apiAssembly = Assembly.Load(assemblyName);
|
||||||
|
|
||||||
|
if (apiAssembly == null)
|
||||||
|
{
|
||||||
|
throw new ApplicationException("Couldn't load assembly " + assemblyName);
|
||||||
|
}
|
||||||
|
|
||||||
|
containerBuilder.RegisterAssemblyTypes(apiAssembly)
|
||||||
|
.AsImplementedInterfaces()
|
||||||
|
.SingleInstance();
|
||||||
|
|
||||||
|
containerBuilder.RegisterAssemblyTypes(apiAssembly)
|
||||||
|
.AsSelf()
|
||||||
|
.SingleInstance();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -75,34 +75,7 @@ public virtual bool IsUserInteractive
|
|||||||
|
|
||||||
public virtual string ApplicationPath
|
public virtual string ApplicationPath
|
||||||
{
|
{
|
||||||
get
|
get { return Directory.GetCurrentDirectory(); }
|
||||||
{
|
|
||||||
|
|
||||||
if(IsMono)
|
|
||||||
{
|
|
||||||
return AppDomain.CurrentDomain.BaseDirectory;
|
|
||||||
}
|
|
||||||
|
|
||||||
string applicationPath;
|
|
||||||
|
|
||||||
applicationPath = CrawlToRoot(StartUpPath);
|
|
||||||
if (!string.IsNullOrWhiteSpace(applicationPath))
|
|
||||||
return applicationPath;
|
|
||||||
|
|
||||||
applicationPath = CrawlToRoot(Environment.CurrentDirectory);
|
|
||||||
if (!string.IsNullOrWhiteSpace(applicationPath))
|
|
||||||
return applicationPath;
|
|
||||||
|
|
||||||
applicationPath = CrawlToRoot(AppDomain.CurrentDomain.BaseDirectory);
|
|
||||||
if (!string.IsNullOrWhiteSpace(applicationPath))
|
|
||||||
return applicationPath;
|
|
||||||
|
|
||||||
applicationPath = CrawlToRoot(NzbDronePathFromEnvironment);
|
|
||||||
if (!string.IsNullOrWhiteSpace(applicationPath))
|
|
||||||
return applicationPath;
|
|
||||||
|
|
||||||
throw new ApplicationException("Can't finds IISExpress folder.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string CrawlToRoot(string dir)
|
public string CrawlToRoot(string dir)
|
||||||
|
@ -89,6 +89,7 @@
|
|||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="CommonContainerExtentions.cs" />
|
||||||
<Compile Include="EnsureThat\Ensure.cs" />
|
<Compile Include="EnsureThat\Ensure.cs" />
|
||||||
<Compile Include="EnsureThat\EnsureBoolExtensions.cs" />
|
<Compile Include="EnsureThat\EnsureBoolExtensions.cs" />
|
||||||
<Compile Include="EnsureThat\EnsureCollectionExtensions.cs" />
|
<Compile Include="EnsureThat\EnsureCollectionExtensions.cs" />
|
||||||
|
@ -10,14 +10,14 @@ public class SysTrayApp : Form
|
|||||||
{
|
{
|
||||||
private readonly ConfigFileProvider _configFileProvider;
|
private readonly ConfigFileProvider _configFileProvider;
|
||||||
private readonly ProcessProvider _processProvider;
|
private readonly ProcessProvider _processProvider;
|
||||||
private readonly HostController _hostController;
|
private readonly IHostController _hostController;
|
||||||
private readonly EnvironmentProvider _environmentProvider;
|
private readonly EnvironmentProvider _environmentProvider;
|
||||||
|
|
||||||
private readonly NotifyIcon _trayIcon = new NotifyIcon();
|
private readonly NotifyIcon _trayIcon = new NotifyIcon();
|
||||||
private readonly ContextMenu _trayMenu = new ContextMenu();
|
private readonly ContextMenu _trayMenu = new ContextMenu();
|
||||||
|
|
||||||
public SysTrayApp(ConfigFileProvider configFileProvider, ProcessProvider processProvider,
|
public SysTrayApp(ConfigFileProvider configFileProvider, ProcessProvider processProvider,
|
||||||
HostController hostController, EnvironmentProvider environmentProvider)
|
IHostController hostController, EnvironmentProvider environmentProvider)
|
||||||
{
|
{
|
||||||
_configFileProvider = configFileProvider;
|
_configFileProvider = configFileProvider;
|
||||||
_processProvider = processProvider;
|
_processProvider = processProvider;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
using FizzWare.NBuilder;
|
using FizzWare.NBuilder;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using Moq;
|
using Moq;
|
||||||
@ -13,12 +12,11 @@
|
|||||||
using NzbDrone.Core.Repository;
|
using NzbDrone.Core.Repository;
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
using NzbDrone.Test.Common.AutoMoq;
|
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.JobTests
|
namespace NzbDrone.Core.Test.JobTests
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class BacklogSearchJobTest : CoreTest
|
public class BacklogSearchJobTest : CoreTest<BacklogSearchJob>
|
||||||
{
|
{
|
||||||
private void WithEnableBacklogSearching()
|
private void WithEnableBacklogSearching()
|
||||||
{
|
{
|
||||||
@ -40,7 +38,7 @@ public void no_missing_epsiodes_should_not_trigger_any_search()
|
|||||||
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
Mocker.Resolve<BacklogSearchJob>().Start(notification, null);
|
Subject.Start(notification, null);
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, new { SeriesId = It.IsAny<int>(), SeasonNumber = It.IsAny<int>() }),
|
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, new { SeriesId = It.IsAny<int>(), SeasonNumber = It.IsAny<int>() }),
|
||||||
@ -75,7 +73,7 @@ public void individual_missing_episode()
|
|||||||
.Setup(s => s.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("EpisodeId") == 1)));
|
.Setup(s => s.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("EpisodeId") == 1)));
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
Mocker.Resolve<BacklogSearchJob>().Start(notification, null);
|
Subject.Start(notification, null);
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("EpisodeId") >= 0)),
|
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("EpisodeId") >= 0)),
|
||||||
@ -104,7 +102,7 @@ public void individual_missing_episodes_only()
|
|||||||
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
Mocker.Resolve<BacklogSearchJob>().Start(notification, null);
|
Subject.Start(notification, null);
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("EpisodeId") >= 0)),
|
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("EpisodeId") >= 0)),
|
||||||
@ -137,7 +135,7 @@ public void series_season_missing_episodes_only_mismatch_count()
|
|||||||
.Setup(s => s.GetEpisodeNumbersBySeason(1, 1)).Returns(new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
|
.Setup(s => s.GetEpisodeNumbersBySeason(1, 1)).Returns(new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
Mocker.Resolve<BacklogSearchJob>().Start(notification, null);
|
Subject.Start(notification, null);
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("EpisodeId") >= 0)),
|
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("EpisodeId") >= 0)),
|
||||||
@ -171,10 +169,10 @@ public void series_season_missing_episodes_only()
|
|||||||
.Setup(s => s.GetEpisodeNumbersBySeason(1, 1)).Returns(episodes.Select(e => e.EpisodeNumber).ToList());
|
.Setup(s => s.GetEpisodeNumbersBySeason(1, 1)).Returns(episodes.Select(e => e.EpisodeNumber).ToList());
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
Mocker.Resolve<BacklogSearchJob>().Start(notification, null);
|
Subject.Start(notification, null);
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") >= 0 &&
|
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") >= 0 &&
|
||||||
d.GetPropertyValue<int>("SeasonNumber") >= 0)),
|
d.GetPropertyValue<int>("SeasonNumber") >= 0)),
|
||||||
Times.Once());
|
Times.Once());
|
||||||
}
|
}
|
||||||
@ -213,7 +211,7 @@ public void multiple_missing_episodes()
|
|||||||
.Setup(s => s.GetEpisodeNumbersBySeason(1, 1)).Returns(new List<int> { 1, 2, 3, 4, 5 });
|
.Setup(s => s.GetEpisodeNumbersBySeason(1, 1)).Returns(new List<int> { 1, 2, 3, 4, 5 });
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
Mocker.Resolve<BacklogSearchJob>().Start(notification, null);
|
Subject.Start(notification, null);
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") >= 0 &&
|
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") >= 0 &&
|
||||||
@ -251,7 +249,7 @@ public void GetMissingForEnabledSeries_should_only_return_episodes_for_monitored
|
|||||||
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
var result = Mocker.Resolve<BacklogSearchJob>().GetMissingForEnabledSeries();
|
var result = Subject.GetMissingForEnabledSeries();
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
result.Should().NotBeEmpty();
|
result.Should().NotBeEmpty();
|
||||||
@ -290,7 +288,7 @@ public void GetMissingForEnabledSeries_should_only_return_explicity_enabled_seri
|
|||||||
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
var result = Mocker.Resolve<BacklogSearchJob>().GetMissingForEnabledSeries();
|
var result = Subject.GetMissingForEnabledSeries();
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
result.Should().NotBeEmpty();
|
result.Should().NotBeEmpty();
|
||||||
@ -330,7 +328,7 @@ public void GetMissingForEnabledSeries_should_return_explicity_enabled_and_inher
|
|||||||
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
var result = Mocker.Resolve<BacklogSearchJob>().GetMissingForEnabledSeries();
|
var result = Subject.GetMissingForEnabledSeries();
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
result.Should().NotBeEmpty();
|
result.Should().NotBeEmpty();
|
||||||
|
@ -22,11 +22,7 @@ public static class ContainerExtentions
|
|||||||
|
|
||||||
public static void RegisterCoreServices(this ContainerBuilder containerBuilder)
|
public static void RegisterCoreServices(this ContainerBuilder containerBuilder)
|
||||||
{
|
{
|
||||||
var core = Assembly.Load("NzbDrone.Core");
|
containerBuilder.RegisterAssembly("NzbDrone.Core");
|
||||||
var common = Assembly.Load("NzbDrone.Common");
|
|
||||||
|
|
||||||
containerBuilder.RegisterAssembly(core);
|
|
||||||
containerBuilder.RegisterAssembly(common);
|
|
||||||
|
|
||||||
containerBuilder.InitDatabase();
|
containerBuilder.InitDatabase();
|
||||||
|
|
||||||
@ -34,17 +30,12 @@ public static void RegisterCoreServices(this ContainerBuilder containerBuilder)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void RegisterAssembly(this ContainerBuilder container, Assembly assembly)
|
private static void RegisterAssembly(this ContainerBuilder container, string assemblyName)
|
||||||
{
|
{
|
||||||
logger.Info("Registering Services from {0}", assembly.FullName);
|
|
||||||
|
|
||||||
container.RegisterAssemblyTypes(assembly)
|
container.RegisterAssemblyTypes(assemblyName);
|
||||||
.AsSelf()
|
|
||||||
.SingleInstance();
|
|
||||||
|
|
||||||
container.RegisterAssemblyTypes(assembly)
|
var assembly = Assembly.Load(assemblyName);
|
||||||
.AsImplementedInterfaces()
|
|
||||||
.SingleInstance();
|
|
||||||
|
|
||||||
container.RegisterAssemblyTypes(assembly)
|
container.RegisterAssemblyTypes(assembly)
|
||||||
.Where(t => t.IsSubclassOf(typeof(IndexerBase)))
|
.Where(t => t.IsSubclassOf(typeof(IndexerBase)))
|
||||||
|
@ -9,11 +9,11 @@ namespace NzbDrone.Core.Lifecycle
|
|||||||
{
|
{
|
||||||
public class AppRestartJob : IJob
|
public class AppRestartJob : IJob
|
||||||
{
|
{
|
||||||
private readonly HostController _hostController;
|
private readonly IHostController _hostController;
|
||||||
|
|
||||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
public AppRestartJob(HostController hostController)
|
public AppRestartJob(IHostController hostController)
|
||||||
{
|
{
|
||||||
_hostController = hostController;
|
_hostController = hostController;
|
||||||
}
|
}
|
||||||
|
@ -75,8 +75,13 @@ public void TestBaseTearDown()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Obsolete("Use Mock.Verify() instead")]
|
||||||
protected void WithStrictMocker()
|
protected void WithStrictMocker()
|
||||||
{
|
{
|
||||||
|
return;
|
||||||
|
|
||||||
|
//TODO: Remove dependency on restrict mocks!
|
||||||
|
|
||||||
if (_mocker != null)
|
if (_mocker != null)
|
||||||
throw new InvalidOperationException("Can not switch to a strict container after container has been used. make sure this is the first call in your test.");
|
throw new InvalidOperationException("Can not switch to a strict container after container has been used. make sure this is the first call in your test.");
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ public void should_stop_orphan_iisexpress_instances()
|
|||||||
Mocker.Resolve<UpdateProvider>().Start(TARGET_FOLDER);
|
Mocker.Resolve<UpdateProvider>().Start(TARGET_FOLDER);
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Mocker.GetMock<HostController>().Verify(c => c.StopServer(), Times.Once());
|
Mocker.GetMock<IHostController>().Verify(c => c.StopServer(), Times.Once());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -12,11 +12,11 @@ public class UpdateProvider
|
|||||||
private readonly ServiceProvider _serviceProvider;
|
private readonly ServiceProvider _serviceProvider;
|
||||||
private readonly ProcessProvider _processProvider;
|
private readonly ProcessProvider _processProvider;
|
||||||
private readonly EnvironmentProvider _environmentProvider;
|
private readonly EnvironmentProvider _environmentProvider;
|
||||||
private readonly HostController _hostController;
|
private readonly IHostController _hostController;
|
||||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
public UpdateProvider(DiskProvider diskProvider, ServiceProvider serviceProvider,
|
public UpdateProvider(DiskProvider diskProvider, ServiceProvider serviceProvider,
|
||||||
ProcessProvider processProvider, EnvironmentProvider environmentProvider, HostController hostController)
|
ProcessProvider processProvider, EnvironmentProvider environmentProvider, IHostController hostController)
|
||||||
{
|
{
|
||||||
_diskProvider = diskProvider;
|
_diskProvider = diskProvider;
|
||||||
_serviceProvider = serviceProvider;
|
_serviceProvider = serviceProvider;
|
||||||
|
@ -15,13 +15,13 @@ public class ApplicationServer : ServiceBase
|
|||||||
|
|
||||||
private readonly ConfigFileProvider _configFileProvider;
|
private readonly ConfigFileProvider _configFileProvider;
|
||||||
private readonly EnvironmentProvider _environmentProvider;
|
private readonly EnvironmentProvider _environmentProvider;
|
||||||
private readonly HostController _hostController;
|
private readonly IHostController _hostController;
|
||||||
private readonly ProcessProvider _processProvider;
|
private readonly ProcessProvider _processProvider;
|
||||||
private readonly MonitoringProvider _monitoringProvider;
|
private readonly MonitoringProvider _monitoringProvider;
|
||||||
private readonly SecurityProvider _securityProvider;
|
private readonly SecurityProvider _securityProvider;
|
||||||
private readonly DiskProvider _diskProvider;
|
private readonly DiskProvider _diskProvider;
|
||||||
|
|
||||||
public ApplicationServer(ConfigFileProvider configFileProvider, HostController hostController,
|
public ApplicationServer(ConfigFileProvider configFileProvider, IHostController hostController,
|
||||||
EnvironmentProvider environmentProvider,
|
EnvironmentProvider environmentProvider,
|
||||||
ProcessProvider processProvider, MonitoringProvider monitoringProvider,
|
ProcessProvider processProvider, MonitoringProvider monitoringProvider,
|
||||||
SecurityProvider securityProvider, DiskProvider diskProvider)
|
SecurityProvider securityProvider, DiskProvider diskProvider)
|
||||||
|
@ -1,23 +1,21 @@
|
|||||||
using Autofac;
|
using Autofac;
|
||||||
using NLog;
|
using NLog;
|
||||||
using Nancy.Bootstrapper;
|
|
||||||
using NzbDrone.Api;
|
using NzbDrone.Api;
|
||||||
using NzbDrone.Common;
|
using NzbDrone.Common;
|
||||||
using NzbDrone.Core.Instrumentation;
|
using NzbDrone.Core.Instrumentation;
|
||||||
using NzbDrone.Providers;
|
|
||||||
|
|
||||||
namespace NzbDrone
|
namespace NzbDrone
|
||||||
{
|
{
|
||||||
public static class CentralDispatch
|
public static class CentralDispatch
|
||||||
{
|
{
|
||||||
private static IContainer _container;
|
private static readonly IContainer container;
|
||||||
private static readonly Logger Logger = LogManager.GetLogger("Host.CentralDispatch");
|
private static readonly Logger logger = LogManager.GetLogger("Host.CentralDispatch");
|
||||||
|
|
||||||
static CentralDispatch()
|
static CentralDispatch()
|
||||||
{
|
{
|
||||||
var builder = new ContainerBuilder();
|
var builder = new ContainerBuilder();
|
||||||
BindKernel(builder);
|
BindKernel(builder);
|
||||||
_container = builder.Build();
|
container = builder.Build();
|
||||||
InitilizeApp();
|
InitilizeApp();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,35 +23,24 @@ public static IContainer Container
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return _container;
|
return container;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void BindKernel(ContainerBuilder builder)
|
private static void BindKernel(ContainerBuilder builder)
|
||||||
{
|
{
|
||||||
builder.RegisterAssemblyTypes(typeof(DiskProvider).Assembly).SingleInstance();
|
|
||||||
builder.RegisterType<Router>();
|
|
||||||
|
|
||||||
builder.RegisterModule<LogInjectionModule>();
|
builder.RegisterModule<LogInjectionModule>();
|
||||||
|
|
||||||
|
builder.RegisterCommonServices();
|
||||||
builder.RegisterType<NancyBootstrapper>().As<INancyBootstrapper>().SingleInstance();
|
builder.RegisterApiServices();
|
||||||
builder.RegisterType<ApplicationServer>().SingleInstance();
|
builder.RegisterAssemblyTypes("NzbDrone");
|
||||||
builder.RegisterType<ConfigFileProvider>().SingleInstance();
|
|
||||||
builder.RegisterType<ConsoleProvider>().SingleInstance();
|
|
||||||
builder.RegisterType<EnvironmentProvider>().SingleInstance();
|
|
||||||
builder.RegisterType<HostController>().SingleInstance();
|
|
||||||
builder.RegisterType<MonitoringProvider>().SingleInstance();
|
|
||||||
builder.RegisterType<ProcessProvider>().SingleInstance();
|
|
||||||
builder.RegisterType<ServiceProvider>().SingleInstance();
|
|
||||||
builder.RegisterType<HttpProvider>().SingleInstance();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void InitilizeApp()
|
private static void InitilizeApp()
|
||||||
{
|
{
|
||||||
var environmentProvider = _container.Resolve<EnvironmentProvider>();
|
var environmentProvider = container.Resolve<EnvironmentProvider>();
|
||||||
|
|
||||||
ReportingService.RestProvider = _container.Resolve<RestProvider>();
|
ReportingService.RestProvider = container.Resolve<RestProvider>();
|
||||||
ReportingService.SetupExceptronDriver();
|
ReportingService.SetupExceptronDriver();
|
||||||
|
|
||||||
LogConfiguration.RegisterRollingFileLogger(environmentProvider.GetLogFileName(), LogLevel.Info);
|
LogConfiguration.RegisterRollingFileLogger(environmentProvider.GetLogFileName(), LogLevel.Info);
|
||||||
@ -61,7 +48,7 @@ private static void InitilizeApp()
|
|||||||
LogConfiguration.RegisterUdpLogger();
|
LogConfiguration.RegisterUdpLogger();
|
||||||
LogConfiguration.RegisterRemote();
|
LogConfiguration.RegisterRemote();
|
||||||
LogConfiguration.Reload();
|
LogConfiguration.Reload();
|
||||||
Logger.Info("Start-up Path:'{0}'", environmentProvider.ApplicationPath);
|
logger.Info("Start-up Path:'{0}'", environmentProvider.ApplicationPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,16 +68,6 @@
|
|||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\packages\Autofac.3.0.1\lib\net40\Autofac.dll</HintPath>
|
<HintPath>..\packages\Autofac.3.0.1\lib\net40\Autofac.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Autofac.Configuration, Version=3.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
|
||||||
<SpecificVersion>False</SpecificVersion>
|
|
||||||
<HintPath>..\packages\Autofac.3.0.1\lib\net40\Autofac.Configuration.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
|
||||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="EnvDTE80, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
|
||||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Nancy">
|
<Reference Include="Nancy">
|
||||||
<HintPath>..\packages\Nancy.0.16.1\lib\net40\Nancy.dll</HintPath>
|
<HintPath>..\packages\Nancy.0.16.1\lib\net40\Nancy.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
@ -12,7 +12,7 @@ public class MonitoringProvider
|
|||||||
{
|
{
|
||||||
private static readonly Logger logger = LogManager.GetLogger("Host.MonitoringProvider");
|
private static readonly Logger logger = LogManager.GetLogger("Host.MonitoringProvider");
|
||||||
|
|
||||||
private readonly HostController _hostController;
|
private readonly IHostController _hostController;
|
||||||
private readonly ProcessProvider _processProvider;
|
private readonly ProcessProvider _processProvider;
|
||||||
private readonly HttpProvider _httpProvider;
|
private readonly HttpProvider _httpProvider;
|
||||||
private readonly ConfigFileProvider _configFileProvider;
|
private readonly ConfigFileProvider _configFileProvider;
|
||||||
@ -21,7 +21,7 @@ public class MonitoringProvider
|
|||||||
private Timer _pingTimer;
|
private Timer _pingTimer;
|
||||||
private Timer _processPriorityCheckTimer;
|
private Timer _processPriorityCheckTimer;
|
||||||
|
|
||||||
public MonitoringProvider(ProcessProvider processProvider, HostController hostController,
|
public MonitoringProvider(ProcessProvider processProvider, IHostController hostController,
|
||||||
HttpProvider httpProvider, ConfigFileProvider configFileProvider)
|
HttpProvider httpProvider, ConfigFileProvider configFileProvider)
|
||||||
{
|
{
|
||||||
_processProvider = processProvider;
|
_processProvider = processProvider;
|
||||||
|
Loading…
Reference in New Issue
Block a user