2013-01-19 22:08:03 +01:00
|
|
|
|
using System;
|
2011-07-08 07:41:08 +02:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2013-02-19 02:13:42 +01:00
|
|
|
|
using System.Reflection;
|
2013-01-03 02:09:13 +01:00
|
|
|
|
using Autofac;
|
2011-07-08 07:41:08 +02:00
|
|
|
|
using FluentAssertions;
|
2013-01-19 21:59:36 +01:00
|
|
|
|
using NCrunch.Framework;
|
2011-07-08 07:41:08 +02:00
|
|
|
|
using NUnit.Framework;
|
2013-02-17 00:29:21 +01:00
|
|
|
|
using NzbDrone.Common;
|
2011-12-02 02:33:17 +01:00
|
|
|
|
using NzbDrone.Core.Jobs;
|
2011-07-08 07:41:08 +02:00
|
|
|
|
using NzbDrone.Core.Providers;
|
2013-01-03 05:09:37 +01:00
|
|
|
|
using NzbDrone.Core.Providers.ExternalNotification;
|
2011-07-08 07:41:08 +02:00
|
|
|
|
using NzbDrone.Core.Providers.Indexer;
|
2013-01-03 05:09:37 +01:00
|
|
|
|
using NzbDrone.Core.Providers.Metadata;
|
2011-07-08 07:41:08 +02:00
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test
|
|
|
|
|
{
|
2013-02-19 02:13:42 +01:00
|
|
|
|
[Ignore]
|
2011-07-08 07:41:08 +02:00
|
|
|
|
[TestFixture]
|
2013-01-19 21:59:36 +01:00
|
|
|
|
[ExclusivelyUses("REAL_LOG_FILE")]
|
2013-01-19 22:08:03 +01:00
|
|
|
|
[Serial]
|
2013-02-17 06:44:06 +01:00
|
|
|
|
class CentralDispatchFixture : CoreTest
|
2011-07-08 07:41:08 +02:00
|
|
|
|
{
|
2013-02-19 02:13:42 +01:00
|
|
|
|
static readonly Assembly NzbDroneCore = Assembly.Load("NzbDrone.Core");
|
|
|
|
|
|
|
|
|
|
readonly IList<string> indexers = NzbDroneCore.GetTypes().Where(t => t.IsSubclassOf(typeof(IndexerBase))).Select(c => c.ToString()).ToList();
|
|
|
|
|
readonly IList<string> jobs = NzbDroneCore.GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IJob))).Select(c => c.ToString()).ToList();
|
|
|
|
|
readonly IList<Type> extNotifications = NzbDroneCore.GetTypes().Where(t => t.IsSubclassOf(typeof(ExternalNotificationBase))).ToList();
|
|
|
|
|
readonly IList<Type> metadata = NzbDroneCore.GetTypes().Where(t => t.IsSubclassOf(typeof(MetadataBase))).ToList();
|
|
|
|
|
|
|
|
|
|
|
2011-07-08 07:41:08 +02:00
|
|
|
|
|
2013-01-19 20:42:06 +01:00
|
|
|
|
private readonly IContainer kernel;
|
2011-11-08 21:12:54 +01:00
|
|
|
|
|
2011-11-17 07:40:54 +01:00
|
|
|
|
public CentralDispatchFixture()
|
2011-11-08 21:12:54 +01:00
|
|
|
|
{
|
2013-02-17 00:29:21 +01:00
|
|
|
|
if (EnvironmentProvider.IsMono)
|
|
|
|
|
{
|
|
|
|
|
throw new IgnoreException("SqlCe is not supported");
|
|
|
|
|
}
|
2013-02-16 20:23:31 +01:00
|
|
|
|
|
2011-11-17 07:40:54 +01:00
|
|
|
|
InitLogging();
|
2011-11-08 21:12:54 +01:00
|
|
|
|
}
|
|
|
|
|
|
2011-07-08 07:41:08 +02:00
|
|
|
|
[Test]
|
|
|
|
|
public void InitAppTest()
|
|
|
|
|
{
|
2011-11-17 07:40:54 +01:00
|
|
|
|
kernel.Should().NotBeNull();
|
2011-07-08 07:41:08 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void Resolve_all_providers()
|
|
|
|
|
{
|
2013-02-19 02:13:42 +01:00
|
|
|
|
var providers = NzbDroneCore.GetTypes().Where(t => t.Name.EndsWith("Provider")).ToList();
|
2011-07-08 07:41:08 +02:00
|
|
|
|
|
|
|
|
|
providers.Should().NotBeEmpty();
|
|
|
|
|
|
|
|
|
|
foreach (var provider in providers)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Resolving " + provider.Name);
|
2013-01-03 02:09:13 +01:00
|
|
|
|
kernel.Resolve(provider).Should().NotBeNull();
|
2011-07-08 07:41:08 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void All_jobs_should_be_registered()
|
|
|
|
|
{
|
2013-01-03 02:09:13 +01:00
|
|
|
|
var registeredJobs = kernel.Resolve<IEnumerable<IJob>>();
|
2011-07-08 07:41:08 +02:00
|
|
|
|
|
|
|
|
|
jobs.Should().NotBeEmpty();
|
|
|
|
|
|
|
|
|
|
registeredJobs.Should().HaveSameCount(jobs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void All_indexers_should_be_registered()
|
|
|
|
|
{
|
2013-01-03 02:09:13 +01:00
|
|
|
|
var registeredIndexers = kernel.Resolve<IEnumerable<IndexerBase>>();
|
2011-07-08 07:41:08 +02:00
|
|
|
|
|
|
|
|
|
indexers.Should().NotBeEmpty();
|
|
|
|
|
|
|
|
|
|
registeredIndexers.Should().HaveSameCount(indexers);
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-03 05:09:37 +01:00
|
|
|
|
[Test]
|
|
|
|
|
public void All_externalNotifiers_should_be_registered()
|
|
|
|
|
{
|
|
|
|
|
var externalNotificationBases = kernel.Resolve<IEnumerable<ExternalNotificationBase>>();
|
|
|
|
|
|
|
|
|
|
extNotifications.Should().NotBeEmpty();
|
|
|
|
|
|
|
|
|
|
externalNotificationBases.Should().HaveSameCount(extNotifications);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void All_metadata_clients_should_be_registered()
|
|
|
|
|
{
|
|
|
|
|
var metadataBases = kernel.Resolve<IEnumerable<MetadataBase>>();
|
|
|
|
|
|
|
|
|
|
metadata.Should().NotBeEmpty();
|
|
|
|
|
|
|
|
|
|
metadataBases.Should().HaveSameCount(metadata);
|
|
|
|
|
}
|
2011-07-08 07:41:08 +02:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void jobs_are_initialized()
|
|
|
|
|
{
|
2013-02-18 08:59:43 +01:00
|
|
|
|
kernel.Resolve<IJobRepository>().All().Should().HaveSameCount(jobs);
|
2011-07-08 07:41:08 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void indexers_are_initialized()
|
|
|
|
|
{
|
2013-01-19 20:42:06 +01:00
|
|
|
|
kernel.Resolve<IndexerProvider>().All().Select(c => c.IndexProviderType).Should().BeEquivalentTo(indexers);
|
2011-07-08 07:41:08 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-03 05:09:37 +01:00
|
|
|
|
[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);
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-08 07:41:08 +02:00
|
|
|
|
[Test]
|
|
|
|
|
public void quality_profile_initialized()
|
|
|
|
|
{
|
2013-01-19 21:59:36 +01:00
|
|
|
|
kernel.Resolve<QualityProvider>().All().Should().HaveCount(2);
|
2011-07-08 07:41:08 +02:00
|
|
|
|
}
|
2011-10-23 23:53:24 +02:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void JobProvider_should_be_singletone()
|
|
|
|
|
{
|
2013-02-18 08:59:43 +01:00
|
|
|
|
var first = kernel.Resolve<JobController>();
|
|
|
|
|
var second = kernel.Resolve<JobController>();
|
2011-10-23 23:53:24 +02:00
|
|
|
|
|
|
|
|
|
first.Should().BeSameAs(second);
|
|
|
|
|
}
|
2011-07-08 07:41:08 +02:00
|
|
|
|
}
|
2012-08-14 02:05:01 +02:00
|
|
|
|
}
|