2011-07-08 05:41:08 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using FluentAssertions;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
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
|
2011-11-08 07:01:52 +00:00
|
|
|
|
class CentralDispatchFixture : TestBase
|
2011-07-08 05:41:08 +00:00
|
|
|
|
{
|
|
|
|
|
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();
|
|
|
|
|
|
2011-11-08 20:12:54 +00:00
|
|
|
|
private CentralDispatch centralDispatch;
|
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
|
public void Setup()
|
|
|
|
|
{
|
|
|
|
|
centralDispatch = new CentralDispatch();
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-08 05:41:08 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void InitAppTest()
|
|
|
|
|
{
|
2011-11-08 20:12:54 +00:00
|
|
|
|
centralDispatch.Kernel.Should().NotBeNull();
|
2011-07-08 05:41:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[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);
|
2011-11-08 20:12:54 +00:00
|
|
|
|
centralDispatch.Kernel.Get(provider).Should().NotBeNull();
|
2011-07-08 05:41:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void All_jobs_should_be_registered()
|
|
|
|
|
{
|
|
|
|
|
//Assert
|
|
|
|
|
|
2011-11-08 20:12:54 +00:00
|
|
|
|
var registeredJobs = centralDispatch.Kernel.GetAll<IJob>();
|
2011-07-08 05:41:08 +00:00
|
|
|
|
|
|
|
|
|
jobs.Should().NotBeEmpty();
|
|
|
|
|
|
|
|
|
|
registeredJobs.Should().HaveSameCount(jobs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void All_indexers_should_be_registered()
|
|
|
|
|
{
|
|
|
|
|
//Assert
|
|
|
|
|
|
2011-11-08 20:12:54 +00:00
|
|
|
|
var registeredIndexers = centralDispatch.Kernel.GetAll<IndexerBase>();
|
2011-07-08 05:41:08 +00:00
|
|
|
|
|
|
|
|
|
indexers.Should().NotBeEmpty();
|
|
|
|
|
|
|
|
|
|
registeredIndexers.Should().HaveSameCount(indexers);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void jobs_are_initialized()
|
|
|
|
|
{
|
2011-11-08 20:12:54 +00:00
|
|
|
|
centralDispatch.Kernel.Get<JobProvider>().All().Should().HaveSameCount(jobs);
|
2011-07-08 05:41:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void indexers_are_initialized()
|
|
|
|
|
{
|
2011-11-08 20:12:54 +00:00
|
|
|
|
centralDispatch.Kernel.Get<IndexerProvider>().All().Should().HaveSameCount(indexers);
|
2011-07-08 05:41:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void quality_profile_initialized()
|
|
|
|
|
{
|
2011-11-08 20:12:54 +00:00
|
|
|
|
centralDispatch.Kernel.Get<QualityProvider>().All().Should().HaveCount(2);
|
2011-07-08 05:41:08 +00:00
|
|
|
|
}
|
2011-10-23 21:53:24 +00:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void JobProvider_should_be_singletone()
|
|
|
|
|
{
|
2011-11-08 20:12:54 +00:00
|
|
|
|
var first = centralDispatch.Kernel.Get<JobProvider>();
|
|
|
|
|
var second = centralDispatch.Kernel.Get<JobProvider>();
|
2011-10-23 21:53:24 +00:00
|
|
|
|
|
|
|
|
|
first.Should().BeSameAs(second);
|
|
|
|
|
}
|
2011-07-08 05:41:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|