1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00

fixed broken tests.

This commit is contained in:
kay.one 2013-01-18 21:14:12 -08:00
parent c184595935
commit fd8ad73476
9 changed files with 33 additions and 53 deletions

View File

@ -28,9 +28,9 @@ public void Init_indexer_test()
Mocker.SetConstant(TestDbHelper.GetEmptyDatabase());
//Act
Mocker.SetConstant<IEnumerable<IndexerBase>>(new List<IndexerBase> { Mocker.Resolve<MockIndexer>() });
var indexerProvider = Mocker.Resolve<IndexerProvider>();
indexerProvider.InitializeIndexers(new List<IndexerBase> { Mocker.Resolve<MockIndexer>() });
var settings = indexerProvider.GetSettings(typeof(MockIndexer));
settings.Enable = true;
indexerProvider.SaveSettings(settings);
@ -48,9 +48,10 @@ public void Init_indexer_with_disabled_job()
{
Mocker.SetConstant(TestDbHelper.GetEmptyDatabase());
//Act
Mocker.SetConstant<IEnumerable<IndexerBase>>(new List<IndexerBase> { Mocker.Resolve<MockIndexer>() });
var indexerProvider = Mocker.Resolve<IndexerProvider>();
indexerProvider.InitializeIndexers(new List<IndexerBase> { Mocker.Resolve<MockIndexer>() });
var settings = indexerProvider.GetSettings(typeof(MockIndexer));
settings.Enable = false;
indexerProvider.SaveSettings(settings);
@ -66,9 +67,10 @@ public void Init_indexer_should_enable_indexer_that_is_enabled_by_default()
{
Mocker.SetConstant(TestDbHelper.GetEmptyDatabase());
//Act
Mocker.SetConstant<IEnumerable<IndexerBase>>(new List<IndexerBase> { Mocker.Resolve<DefaultEnabledIndexer>() });
var indexerProvider = Mocker.Resolve<IndexerProvider>();
indexerProvider.InitializeIndexers(new List<IndexerBase> { Mocker.Resolve<DefaultEnabledIndexer>() });
//Assert
indexerProvider.All();
@ -82,9 +84,10 @@ public void Init_indexer_should_not_enable_indexer_that_is_not_enabled_by_defaul
{
Mocker.SetConstant(TestDbHelper.GetEmptyDatabase());
//Act
Mocker.SetConstant<IEnumerable<IndexerBase>>(new List<IndexerBase> { Mocker.Resolve<MockIndexer>() });
var indexerProvider = Mocker.Resolve<IndexerProvider>();
indexerProvider.InitializeIndexers(new List<IndexerBase> { Mocker.Resolve<MockIndexer>() });
//Assert
indexerProvider.All();

View File

@ -45,7 +45,6 @@ public void TearDown()
private void ResetLastExecution()
{
var jobProvider = Mocker.Resolve<JobProvider>();
jobProvider.Initialize();
var jobs = jobProvider.All();
foreach (var jobDefinition in jobs)
@ -130,7 +129,7 @@ public void can_run_async_job_again()
Mocker.SetConstant(BaseFakeJobs);
var jobProvider = Mocker.Resolve<JobProvider>();
jobProvider.Initialize();
//Act
jobProvider.QueueJob(typeof(FakeJob));
@ -150,7 +149,6 @@ public void no_concurent_jobs()
Mocker.SetConstant(BaseFakeJobs);
var jobProvider = Mocker.Resolve<JobProvider>();
jobProvider.Initialize();
jobProvider.QueueJob(typeof(SlowJob), 1);
jobProvider.QueueJob(typeof(SlowJob), 2);
jobProvider.QueueJob(typeof(SlowJob), 3);
@ -171,7 +169,6 @@ public void can_run_broken_job_again()
Mocker.SetConstant(BaseFakeJobs);
var jobProvider = Mocker.Resolve<JobProvider>();
jobProvider.Initialize();
//Act
jobProvider.QueueJob(typeof(BrokenJob));
@ -193,7 +190,6 @@ public void schedule_hit_should_be_ignored_if_queue_is_running()
Mocker.SetConstant(fakeJobs);
var jobProvider = Mocker.Resolve<JobProvider>();
jobProvider.Initialize();
//Act
@ -214,7 +210,6 @@ public void can_queue_jobs_at_the_same_time()
Mocker.SetConstant(BaseFakeJobs);
var jobProvider = Mocker.Resolve<JobProvider>();
jobProvider.Initialize();
jobProvider.QueueJob(typeof(SlowJob));
@ -243,8 +238,6 @@ public void Init_Jobs()
var jobProvider = Mocker.Resolve<JobProvider>();
//Act
jobProvider.Initialize();
//assert
var timers = jobProvider.All();
@ -269,7 +262,6 @@ public void Init_Timers_only_registers_once()
Mocker.SetConstant(BaseFakeJobs);
var jobProvider = Mocker.Resolve<JobProvider>();
jobProvider.Initialize();
}
var Mocker2 = new AutoMoqer();
@ -294,10 +286,6 @@ public void inti_should_removed_jobs_that_no_longer_exist()
Db.Insert(deletedJob);
var jobProvider = Mocker.Resolve<JobProvider>();
//Act
jobProvider.Initialize();
//Assert
var registeredJobs = Db.Fetch<JobDefinition>();
registeredJobs.Should().HaveCount(1);
registeredJobs.Should().NotContain(c => c.TypeName == deletedJob.TypeName);
@ -316,10 +304,6 @@ public void inti_should_removed_jobs_that_no_longer_exist_even_with_same_name()
Db.Insert(deletedJob);
var jobProvider = Mocker.Resolve<JobProvider>();
//Act
jobProvider.Initialize();
//Assert
var registeredJobs = Db.Fetch<JobDefinition>();
registeredJobs.Should().HaveCount(1);
registeredJobs.Should().NotContain(c => c.TypeName == deletedJob.TypeName);
@ -343,10 +327,8 @@ public void init_should_update_existing_job()
var id = Convert.ToInt32(Db.Insert(initialFakeJob));
var jobProvider = Mocker.Resolve<JobProvider>();
Mocker.Resolve<JobProvider>();
//Act
jobProvider.Initialize();
//Assert
var registeredJobs = Db.Fetch<JobDefinition>();
@ -367,7 +349,6 @@ public void jobs_with_zero_interval_are_registered_as_disabled()
Mocker.SetConstant(fakeJobs);
var jobProvider = Mocker.Resolve<JobProvider>();
jobProvider.Initialize();
//Assert
jobProvider.All().Should().HaveCount(1);
@ -381,7 +362,6 @@ public void disabled_jobs_arent_run_by_scheduler()
Mocker.SetConstant(BaseFakeJobs);
var jobProvider = Mocker.Resolve<JobProvider>();
jobProvider.Initialize();
jobProvider.QueueScheduled();
WaitForQueue();
@ -398,7 +378,6 @@ public void job_with_specific_target_should_not_update_last_execution()
//Act
var jobProvider = Mocker.Resolve<JobProvider>();
jobProvider.Initialize();
ResetLastExecution();
jobProvider.QueueJob(typeof(FakeJob), 10);
@ -416,7 +395,6 @@ public void job_with_specific_target_should_not_set_success_flag()
//Act
var jobProvider = Mocker.Resolve<JobProvider>();
jobProvider.Initialize();
jobProvider.QueueJob(typeof(FakeJob), 10);
WaitForQueue();
@ -440,7 +418,6 @@ public void duplicated_queue_item_should_start_queue_if_its_not_running()
//Act
var jobProvider = Mocker.Resolve<JobProvider>();
jobProvider.Initialize();
jobProvider.Queue.Add(stuckQueueItem);
WaitForQueue();
@ -481,7 +458,6 @@ public void trygin_to_queue_unregistered_job_should_fail()
var jobProvider = Mocker.Resolve<JobProvider>();
jobProvider.Initialize();
jobProvider.QueueJob(typeof(string));
WaitForQueue();
@ -495,7 +471,6 @@ public void scheduled_job_should_have_scheduler_as_source()
Mocker.SetConstant(BaseFakeJobs);
var jobProvider = Mocker.Resolve<JobProvider>();
jobProvider.Initialize();
ResetLastExecution();
jobProvider.QueueScheduled();

View File

@ -4,14 +4,11 @@
using System.Net.Sockets;
using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common;
using NzbDrone.Test.Common.AutoMoq;
namespace NzbDrone.Core.Test.ProviderTests
{
@ -214,8 +211,10 @@ public void InitializeNewznabIndexers_should_initialize_new_indexers()
var db = TestDbHelper.GetEmptyDatabase();
Mocker.SetConstant(db);
Mocker.SetConstant<IEnumerable<NewznabDefinition>>(definitions);
//Act
Mocker.Resolve<NewznabProvider>().InitializeNewznabIndexers(definitions);
Mocker.Resolve<NewznabProvider>();
//Assert
var result = db.Fetch<NewznabDefinition>();
@ -243,8 +242,11 @@ public void InitializeNewznabIndexers_should_initialize_new_indexers_only()
db.Insert(definitions[0]);
db.Insert(definitions[2]);
Mocker.SetConstant<IEnumerable<NewznabDefinition>>(definitions);
//Act
Mocker.Resolve<NewznabProvider>().InitializeNewznabIndexers(definitions);
Mocker.Resolve<NewznabProvider>();
//Assert
var result = db.Fetch<NewznabDefinition>();
@ -267,8 +269,10 @@ public void InitializeNewznabIndexers_should_update_matching_indexer_to_be_built
db.Insert(definition);
Mocker.SetConstant<IEnumerable<NewznabDefinition>>(new List<NewznabDefinition> { definition });
//Act
Mocker.Resolve<NewznabProvider>().InitializeNewznabIndexers(new List<NewznabDefinition>{ definition });
Mocker.Resolve<NewznabProvider>();
//Assert
var result = db.Fetch<NewznabDefinition>();
@ -291,8 +295,12 @@ public void InitializeNewznabIndexers_should_not_blow_up_if_more_than_one_indexe
db.Insert(definition);
db.Insert(definition);
Mocker.SetConstant<IEnumerable<NewznabDefinition>>(new List<NewznabDefinition> { definition });
//Act
Mocker.Resolve<NewznabProvider>().InitializeNewznabIndexers(new List<NewznabDefinition> { definition });
Mocker.Resolve<NewznabProvider>();
//Assert
var result = db.Fetch<NewznabDefinition>();

View File

@ -24,7 +24,7 @@ public void SetupDefault_should_add_all_profiles()
Mocker.SetConstant(db);
//Act
Mocker.Resolve<QualityTypeProvider>().SetupDefault();
Mocker.Resolve<QualityTypeProvider>();
//Assert
var types = Mocker.Resolve<QualityTypeProvider>().All();
@ -52,7 +52,7 @@ public void SetupDefault_already_exists_should_insert_missing()
db.Insert(new QualityType { QualityTypeId = 1, Name = "SDTV", MinSize = 0, MaxSize = 100 });
//Act
Mocker.Resolve<QualityTypeProvider>().SetupDefault();
Mocker.Resolve<QualityTypeProvider>();
//Assert
var types = Mocker.Resolve<QualityTypeProvider>().All();

View File

@ -135,7 +135,7 @@ public void SetupInitial_should_add_two_profiles()
Mocker.SetConstant(db);
//Act
Mocker.Resolve<QualityProvider>().SetupDefaultProfiles();
Mocker.Resolve<QualityProvider>();
//Assert
var profiles = Mocker.Resolve<QualityProvider>().All();
@ -159,7 +159,6 @@ public void SetupInitial_should_skip_if_any_profile_exists()
//Act
Mocker.Resolve<QualityProvider>().Add(fakeProfile);
Mocker.Resolve<QualityProvider>().SetupDefaultProfiles();
//Assert
var profiles = Mocker.Resolve<QualityProvider>().All();

View File

@ -27,7 +27,7 @@ public CentralDispatch()
}
private void RegisterReporting(IContainer container)
private void RegisterReporting(IComponentContext container)
{
EnvironmentProvider.UGuid = container.Resolve<ConfigProvider>().UGuid;
ReportingService.RestProvider = container.Resolve<RestProvider>();

View File

@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NzbDrone.Core.Repository;
namespace NzbDrone.Core.Datastore.PetaPoco

View File

@ -614,7 +614,6 @@
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="ClassDiagram1.cd" />
<None Include="packages.config" />
<None Include="Properties\AnalysisRules.ruleset" />
</ItemGroup>

View File

@ -33,7 +33,6 @@
<customErrors mode="Off" />
<httpHandlers>
<!--<add path="*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*"/>-->
<add path="api*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" />
<add path="cassette.axd" verb="*" type="Cassette.Aspnet.CassetteHttpHandler, Cassette.Aspnet" />
</httpHandlers>
<httpModules>
@ -50,7 +49,6 @@
<remove name="MvcHttpHandler" />
<remove name="UrlRoutingHandler" />
<add name="MvcHttpHandler" preCondition="integratedMode" verb="" path=".mvc" type="System.Web.Mvc.MvcHttpHandler" />
<add path="api*" name="ServiceStack.Factory" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />
<add name="CassetteHttpHandler" path="cassette.axd" preCondition="integratedMode" verb="*" allowPathInfo="true" type="Cassette.Aspnet.CassetteHttpHandler, Cassette.Aspnet" />
</handlers>
<directoryBrowse enabled="false" />