Radarr/NzbDrone.Core.Test/CentralDispatchFixture.cs

114 lines
2.9 KiB
C#
Raw Normal View History

// ReSharper disable InconsistentNaming
using System;
2011-07-08 05:41:08 +00:00
using System.Collections.Generic;
using System.Linq;
using FluentAssertions;
using NUnit.Framework;
2012-01-25 03:09:49 +00:00
using NzbDrone.Common;
2011-12-02 01:33:17 +00:00
using NzbDrone.Core.Jobs;
2011-07-08 05:41:08 +00:00
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Indexer;
using NzbDrone.Core.Test.Framework;
using Ninject;
namespace NzbDrone.Core.Test
{
[TestFixture]
2011-11-13 07:27:16 +00:00
class CentralDispatchFixture : CoreTest
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-17 06:40:54 +00:00
private IKernel kernel;
2011-11-08 20:12:54 +00:00
2011-11-17 06:40:54 +00:00
public CentralDispatchFixture()
2011-11-08 20:12:54 +00:00
{
2011-11-17 06:40:54 +00:00
InitLogging();
kernel = new CentralDispatch().Kernel;
WebTimer.Stop();
2011-11-08 20:12:54 +00:00
}
2011-07-08 05:41:08 +00:00
[Test]
public void InitAppTest()
{
2011-11-17 06:40:54 +00:00
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-17 06:40:54 +00:00
kernel.Get(provider).Should().NotBeNull();
2011-07-08 05:41:08 +00:00
}
}
[Test]
public void All_jobs_should_be_registered()
{
//Assert
2011-11-17 06:40:54 +00:00
var registeredJobs = 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-17 06:40:54 +00:00
var registeredIndexers = 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-17 06:40:54 +00:00
kernel.Get<JobProvider>().All().Should().HaveSameCount(jobs);
2011-07-08 05:41:08 +00:00
}
[Test]
public void indexers_are_initialized()
{
2011-11-17 06:40:54 +00:00
kernel.Get<IndexerProvider>().All().Should().HaveSameCount(indexers);
2011-07-08 05:41:08 +00:00
}
[Test]
public void quality_profile_initialized()
{
2011-11-17 06:40:54 +00:00
kernel.Get<QualityProvider>().All().Should().HaveCount(2);
2011-07-08 05:41:08 +00:00
}
[Test]
public void JobProvider_should_be_singletone()
{
2011-11-17 06:40:54 +00:00
var first = kernel.Get<JobProvider>();
var second = kernel.Get<JobProvider>();
first.Should().BeSameAs(second);
}
2011-11-13 07:27:16 +00:00
2012-01-25 03:09:49 +00:00
[Test]
public void app_should_be_marked_as_new_install_if_db_is_initilized_for_the_first_time()
{
WithRealDb();
EnviromentProvider.IsNewInstall.Should().Be(true);
}
2011-07-08 05:41:08 +00:00
}
}