2011-07-08 07:41:08 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using FluentAssertions;
|
2011-10-24 07:54:09 +02:00
|
|
|
|
using NLog;
|
2011-07-08 07:41:08 +02:00
|
|
|
|
using NUnit.Framework;
|
2011-10-24 07:54:09 +02:00
|
|
|
|
using NzbDrone.Core.Instrumentation;
|
2011-07-08 07:41:08 +02:00
|
|
|
|
using NzbDrone.Core.Providers;
|
|
|
|
|
using NzbDrone.Core.Providers.Indexer;
|
|
|
|
|
using NzbDrone.Core.Providers.Jobs;
|
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
|
using Ninject;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
// ReSharper disable InconsistentNaming
|
|
|
|
|
class CentralDispatchTest : TestBase
|
|
|
|
|
{
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void InitAppTest()
|
|
|
|
|
{
|
|
|
|
|
CentralDispatch.NinjectKernel.Should().NotBeNull();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void Resolve_all_providers()
|
|
|
|
|
{
|
|
|
|
|
var providers = typeof(CentralDispatch).Assembly.GetTypes().Where(t => t.Name.EndsWith("Provider")).ToList();
|
|
|
|
|
|
|
|
|
|
providers.Should().NotBeEmpty();
|
|
|
|
|
|
|
|
|
|
foreach (var provider in providers)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Resolving " + provider.Name);
|
|
|
|
|
CentralDispatch.NinjectKernel.Get(provider).Should().NotBeNull();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void All_jobs_should_be_registered()
|
|
|
|
|
{
|
|
|
|
|
//Assert
|
|
|
|
|
|
|
|
|
|
var registeredJobs = CentralDispatch.NinjectKernel.GetAll<IJob>();
|
|
|
|
|
|
|
|
|
|
jobs.Should().NotBeEmpty();
|
|
|
|
|
|
|
|
|
|
registeredJobs.Should().HaveSameCount(jobs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void All_indexers_should_be_registered()
|
|
|
|
|
{
|
|
|
|
|
//Assert
|
|
|
|
|
|
|
|
|
|
var registeredIndexers = CentralDispatch.NinjectKernel.GetAll<IndexerBase>();
|
|
|
|
|
|
|
|
|
|
indexers.Should().NotBeEmpty();
|
|
|
|
|
|
|
|
|
|
registeredIndexers.Should().HaveSameCount(indexers);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void jobs_are_initialized()
|
|
|
|
|
{
|
|
|
|
|
CentralDispatch.NinjectKernel.Get<JobProvider>().All().Should().HaveSameCount(jobs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void indexers_are_initialized()
|
|
|
|
|
{
|
|
|
|
|
CentralDispatch.NinjectKernel.Get<IndexerProvider>().All().Should().HaveSameCount(indexers);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void quality_profile_initialized()
|
|
|
|
|
{
|
|
|
|
|
CentralDispatch.NinjectKernel.Get<QualityProvider>().All().Should().HaveCount(2);
|
|
|
|
|
}
|
2011-10-23 23:53:24 +02:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void JobProvider_should_be_singletone()
|
|
|
|
|
{
|
|
|
|
|
var first = CentralDispatch.NinjectKernel.Get<JobProvider>();
|
|
|
|
|
var second = CentralDispatch.NinjectKernel.Get<JobProvider>();
|
|
|
|
|
|
|
|
|
|
first.Should().BeSameAs(second);
|
|
|
|
|
}
|
2011-07-08 07:41:08 +02:00
|
|
|
|
}
|
|
|
|
|
}
|