fixed broken tests.

pull/4/head
kay.one 12 years ago
parent c184595935
commit fd8ad73476

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

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

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

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

@ -135,7 +135,7 @@ namespace NzbDrone.Core.Test
Mocker.SetConstant(db); Mocker.SetConstant(db);
//Act //Act
Mocker.Resolve<QualityProvider>().SetupDefaultProfiles(); Mocker.Resolve<QualityProvider>();
//Assert //Assert
var profiles = Mocker.Resolve<QualityProvider>().All(); var profiles = Mocker.Resolve<QualityProvider>().All();
@ -159,7 +159,6 @@ namespace NzbDrone.Core.Test
//Act //Act
Mocker.Resolve<QualityProvider>().Add(fakeProfile); Mocker.Resolve<QualityProvider>().Add(fakeProfile);
Mocker.Resolve<QualityProvider>().SetupDefaultProfiles();
//Assert //Assert
var profiles = Mocker.Resolve<QualityProvider>().All(); var profiles = Mocker.Resolve<QualityProvider>().All();

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

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

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

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

Loading…
Cancel
Save