mirror of https://github.com/lidarr/Lidarr
More CentralDispatch Tests (bug caught!)
This commit is contained in:
parent
c4e886a8f8
commit
120758bf02
|
@ -8,7 +8,9 @@ using NUnit.Framework;
|
|||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Jobs;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.ExternalNotification;
|
||||
using NzbDrone.Core.Providers.Indexer;
|
||||
using NzbDrone.Core.Providers.Metadata;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test
|
||||
|
@ -18,6 +20,8 @@ namespace NzbDrone.Core.Test
|
|||
{
|
||||
readonly IList<Type> indexers = typeof(CentralDispatch).Assembly.GetTypes().Where(t => t.IsSubclassOf(typeof(IndexerBase))).ToList();
|
||||
readonly IList<Type> jobs = typeof(CentralDispatch).Assembly.GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IJob))).ToList();
|
||||
readonly IList<Type> extNotifications = typeof(CentralDispatch).Assembly.GetTypes().Where(t => t.IsSubclassOf(typeof(ExternalNotificationBase))).ToList();
|
||||
readonly IList<Type> metadata = typeof(CentralDispatch).Assembly.GetTypes().Where(t => t.IsSubclassOf(typeof(MetadataBase))).ToList();
|
||||
|
||||
private IContainer kernel;
|
||||
|
||||
|
@ -50,7 +54,6 @@ namespace NzbDrone.Core.Test
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void All_jobs_should_be_registered()
|
||||
{
|
||||
|
@ -63,7 +66,6 @@ namespace NzbDrone.Core.Test
|
|||
registeredJobs.Should().HaveSameCount(jobs);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void All_indexers_should_be_registered()
|
||||
{
|
||||
|
@ -76,6 +78,29 @@ namespace NzbDrone.Core.Test
|
|||
registeredIndexers.Should().HaveSameCount(indexers);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void All_externalNotifiers_should_be_registered()
|
||||
{
|
||||
//Assert
|
||||
|
||||
var externalNotificationBases = kernel.Resolve<IEnumerable<ExternalNotificationBase>>();
|
||||
|
||||
extNotifications.Should().NotBeEmpty();
|
||||
|
||||
externalNotificationBases.Should().HaveSameCount(extNotifications);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void All_metadata_clients_should_be_registered()
|
||||
{
|
||||
//Assert
|
||||
|
||||
var metadataBases = kernel.Resolve<IEnumerable<MetadataBase>>();
|
||||
|
||||
metadata.Should().NotBeEmpty();
|
||||
|
||||
metadataBases.Should().HaveSameCount(metadata);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void jobs_are_initialized()
|
||||
|
@ -89,6 +114,18 @@ namespace NzbDrone.Core.Test
|
|||
kernel.Resolve<IndexerProvider>().All().Should().HaveSameCount(indexers);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void externalNotifiers_are_initialized()
|
||||
{
|
||||
kernel.Resolve<ExternalNotificationProvider>().All().Should().HaveSameCount(extNotifications);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void metadata_clients_are_initialized()
|
||||
{
|
||||
kernel.Resolve<MetadataProvider>().All().Should().HaveSameCount(metadata);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void quality_profile_initialized()
|
||||
{
|
||||
|
|
|
@ -45,9 +45,9 @@ namespace NzbDrone.Core
|
|||
ContainerBuilder.RegisterType<EnvironmentProvider>();
|
||||
|
||||
InitDatabase();
|
||||
InitExternalNotifications();
|
||||
InitMetadataProviders();
|
||||
InitIndexers();
|
||||
RegisterExternalNotifications();
|
||||
RegisterMetadataProviders();
|
||||
RegisterIndexers();
|
||||
RegisterJobs();
|
||||
}
|
||||
|
||||
|
@ -76,22 +76,13 @@ namespace NzbDrone.Core
|
|||
ContainerBuilder.RegisterType<LogProvider>().WithParameter(ResolvedParameter.ForNamed<IDatabase>("LogProvider"));
|
||||
}
|
||||
|
||||
private void InitIndexers()
|
||||
private void RegisterIndexers()
|
||||
{
|
||||
logger.Debug("Registering Indexers...");
|
||||
|
||||
ContainerBuilder.RegisterAssemblyTypes(typeof(CentralDispatch).Assembly)
|
||||
.Where(t => t.BaseType == typeof(IndexerBase))
|
||||
.As<IndexerBase>();
|
||||
|
||||
//ContainerBuilder.Bind<IndexerBase>().To<NzbsRUs>();
|
||||
//ContainerBuilder.Bind<IndexerBase>().To<Newznab>();
|
||||
//ContainerBuilder.Bind<IndexerBase>().To<Wombles>();
|
||||
//ContainerBuilder.Bind<IndexerBase>().To<FileSharingTalk>();
|
||||
//ContainerBuilder.Bind<IndexerBase>().To<NzbIndex>();
|
||||
//ContainerBuilder.Bind<IndexerBase>().To<NzbClub>();
|
||||
//ContainerBuilder.Bind<IndexerBase>().To<Omgwtfnzbs>();
|
||||
//ContainerBuilder.Bind<IndexerBase>().To<Nzbx>();
|
||||
}
|
||||
|
||||
private void RegisterJobs()
|
||||
|
@ -100,40 +91,47 @@ namespace NzbDrone.Core
|
|||
|
||||
ContainerBuilder.RegisterType<JobProvider>().SingleInstance();
|
||||
|
||||
ContainerBuilder.RegisterType<Xbmc>().As<ExternalNotificationBase>().SingleInstance();
|
||||
|
||||
ContainerBuilder.RegisterAssemblyTypes(typeof(CentralDispatch).Assembly)
|
||||
.Where(t => t.GetInterfaces().Contains(typeof(IJob)))
|
||||
.As<IJob>()
|
||||
.SingleInstance();
|
||||
}
|
||||
|
||||
private void InitExternalNotifications()
|
||||
private void RegisterExternalNotifications()
|
||||
{
|
||||
logger.Debug("Registering External Notifications...");
|
||||
ContainerBuilder.RegisterType<Xbmc>().As<ExternalNotificationBase>().SingleInstance();
|
||||
ContainerBuilder.RegisterType<Smtp>().As<ExternalNotificationBase>().SingleInstance();
|
||||
ContainerBuilder.RegisterType<Twitter>().As<ExternalNotificationBase>().SingleInstance();
|
||||
ContainerBuilder.RegisterType<Providers.ExternalNotification.Growl>().As<ExternalNotificationBase>().SingleInstance();
|
||||
ContainerBuilder.RegisterType<Prowl>().As<ExternalNotificationBase>().SingleInstance();
|
||||
ContainerBuilder.RegisterType<Plex>().As<ExternalNotificationBase>().SingleInstance();
|
||||
|
||||
ContainerBuilder.RegisterAssemblyTypes(typeof(CentralDispatch).Assembly)
|
||||
.Where(t => t.BaseType == typeof(ExternalNotificationBase))
|
||||
.As<ExternalNotificationBase>();
|
||||
|
||||
//ContainerBuilder.RegisterType<Xbmc>().As<ExternalNotificationBase>().SingleInstance();
|
||||
//ContainerBuilder.RegisterType<Smtp>().As<ExternalNotificationBase>().SingleInstance();
|
||||
//ContainerBuilder.RegisterType<Twitter>().As<ExternalNotificationBase>().SingleInstance();
|
||||
//ContainerBuilder.RegisterType<Providers.ExternalNotification.Growl>().As<ExternalNotificationBase>().SingleInstance();
|
||||
//ContainerBuilder.RegisterType<Prowl>().As<ExternalNotificationBase>().SingleInstance();
|
||||
//ContainerBuilder.RegisterType<Plex>().As<ExternalNotificationBase>().SingleInstance();
|
||||
}
|
||||
|
||||
private void InitMetadataProviders()
|
||||
private void RegisterMetadataProviders()
|
||||
{
|
||||
logger.Debug("Registering Metadata Providers...");
|
||||
|
||||
ContainerBuilder.RegisterType<Providers.Metadata.Xbmc>().As<MetadataBase>().SingleInstance();
|
||||
ContainerBuilder.RegisterAssemblyTypes(typeof(CentralDispatch).Assembly)
|
||||
.Where(t => t.IsSubclassOf(typeof(MetadataBase)))
|
||||
.As<MetadataBase>();
|
||||
|
||||
//ContainerBuilder.RegisterType<Providers.Metadata.Xbmc>().As<MetadataBase>().SingleInstance();
|
||||
}
|
||||
|
||||
private void InitReporting(IContainer container)
|
||||
private void RegisterReporting(IContainer container)
|
||||
{
|
||||
EnvironmentProvider.UGuid = container.Resolve<ConfigProvider>().UGuid;
|
||||
ReportingService.RestProvider = container.Resolve<RestProvider>();
|
||||
ReportingService.SetupExceptronDriver();
|
||||
}
|
||||
|
||||
private void InitQuality(IContainer container)
|
||||
private void RegisterQuality(IContainer container)
|
||||
{
|
||||
logger.Debug("Initializing Quality...");
|
||||
container.Resolve<QualityProvider>().SetupDefaultProfiles();
|
||||
|
@ -174,8 +172,8 @@ namespace NzbDrone.Core
|
|||
container.Resolve<DatabaseTarget>().Register();
|
||||
LogConfiguration.Reload();
|
||||
|
||||
InitReporting(container);
|
||||
InitQuality(container);
|
||||
RegisterReporting(container);
|
||||
RegisterQuality(container);
|
||||
|
||||
var indexers = container.Resolve<IEnumerable<IndexerBase>>();
|
||||
container.Resolve<IndexerProvider>().InitializeIndexers(indexers.ToList());
|
||||
|
|
Loading…
Reference in New Issue