1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-14 11:23:42 +02:00

more test fixes.

This commit is contained in:
kay.one 2013-01-19 10:54:00 -08:00
parent edf7cc678d
commit 653f45f10e
4 changed files with 24 additions and 55 deletions

View File

@ -251,30 +251,6 @@ public void Init_Jobs()
timers[0].Enable.Should().BeTrue();
}
[Test]
public void Init_Timers_only_registers_once()
{
for (int i = 0; i < 2; i++)
{
var fakeTimer = new FakeJob();
IEnumerable<IJob> BaseFakeJobs = new List<IJob> { fakeTimer };
Mocker.SetConstant(BaseFakeJobs);
Mocker.Resolve<JobProvider>();
}
var Mocker2 = new AutoMoqer();
Mocker2.SetConstant(Db);
var assertjobProvider = Mocker2.Resolve<JobProvider>();
var timers = assertjobProvider.All();
timers.Should().HaveCount(1);
timers[0].Enable.Should().BeTrue();
}
[Test]
public void inti_should_removed_jobs_that_no_longer_exist()
{

View File

@ -15,7 +15,7 @@ namespace NzbDrone.Core.Test
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class QualityProfileTest : CoreTest
public class QualityProfileTest : CoreTest<QualityProvider>
{
[Test]
public void Test_Storage()
@ -29,11 +29,11 @@ public void Test_Storage()
Allowed = new List<QualityTypes> { QualityTypes.HDTV720p, QualityTypes.DVD },
};
var id = Convert.ToInt32(database.Insert(testProfile));
var fetch = database.SingleOrDefault<QualityProfile>(id);
Assert.AreEqual(id, fetch.QualityProfileId);
Assert.AreEqual(testProfile.Name, fetch.Name);
Assert.AreEqual(testProfile.Cutoff, fetch.Cutoff);
@ -52,11 +52,11 @@ public void Test_Storage_no_allowed()
Cutoff = QualityTypes.SDTV
};
var id = Convert.ToInt32(database.Insert(testProfile));
var fetch = database.SingleOrDefault<QualityProfile>(id);
Assert.AreEqual(id, fetch.QualityProfileId);
Assert.AreEqual(testProfile.Name, fetch.Name);
Assert.AreEqual(testProfile.Cutoff, fetch.Cutoff);
@ -68,7 +68,7 @@ public void Test_Storage_no_allowed()
public void Update_Success()
{
//Arrange
var db = TestDbHelper.GetEmptyDatabase();
Mocker.SetConstant(db);
@ -78,7 +78,7 @@ public void Update_Success()
Cutoff = QualityTypes.SDTV
};
var id = Convert.ToInt32(db.Insert(testProfile));
var currentProfile = db.SingleOrDefault<QualityProfile>(id);
@ -89,7 +89,7 @@ public void Update_Success()
var updated = Mocker.Resolve<QualityProvider>().Get(currentProfile.QualityProfileId);
updated.Name.Should().Be(currentProfile.Name);
updated.Cutoff.Should().Be(QualityTypes.Bluray720p);
updated.AllowedString.Should().Be(currentProfile.AllowedString);
@ -130,14 +130,14 @@ public void Test_Series_Quality()
[Test]
public void SetupInitial_should_add_two_profiles()
{
var db = TestDbHelper.GetEmptyDatabase();
Mocker.SetConstant(db);
Mocker.Resolve<QualityProvider>();
var profiles = Mocker.Resolve<QualityProvider>().All();
@ -152,19 +152,16 @@ public void SetupInitial_should_add_two_profiles()
//We don't want to keep adding them back if a user deleted them on purpose.
public void SetupInitial_should_skip_if_any_profile_exists()
{
var db = TestDbHelper.GetEmptyDatabase();
Mocker.SetConstant(db);
var fakeProfile = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
WithRealDb();
Mocker.Resolve<QualityProvider>().Add(fakeProfile);
InitiateSubject();
var profiles = Mocker.Resolve<QualityProvider>().All();
var profiles = Subject.All();
Subject.Delete(profiles[0].QualityProfileId);
InitiateSubject();
profiles.Should().HaveCount(1);
Subject.All().Should().HaveCount(profiles.Count - 1);
}
}
}

View File

@ -18,14 +18,13 @@ namespace NzbDrone.Core
public static class ContainerExtentions
{
private static readonly Logger _logger = LogManager.GetLogger("ServiceRegistration");
private static readonly Logger logger = LogManager.GetLogger("ServiceRegistration");
public static void RegisterCoreServices(this ContainerBuilder container)
{
var core = Assembly.Load("NzbDrone.Core");
var common = Assembly.Load("NzbDrone.Common");
container.RegisterAssembly(core);
container.RegisterAssembly(common);
@ -44,27 +43,25 @@ private static void RegisterAssembly(this ContainerBuilder container, Assembly a
.SingleInstance();
container.RegisterAssemblyTypes(assembly)
.Where(t => t.BaseType == typeof(IndexerBase))
.Where(t => t.IsSubclassOf(typeof(IndexerBase)))
.As<IndexerBase>().SingleInstance();
container.RegisterAssemblyTypes(assembly)
.Where(t => t.BaseType == typeof(SearchBase))
.Where(t => t.IsSubclassOf(typeof(SearchBase)))
.As<SearchBase>().SingleInstance();
container.RegisterAssemblyTypes(assembly)
.Where(t => t.BaseType == typeof(ExternalNotificationBase))
.Where(t => t.IsSubclassOf(typeof(ExternalNotificationBase)))
.As<ExternalNotificationBase>().SingleInstance();
container.RegisterAssemblyTypes(assembly)
.Where(t => t.BaseType == typeof(MetadataBase))
.Where(t => t.IsSubclassOf(typeof(MetadataBase)))
.As<MetadataBase>().SingleInstance();
}
private static void InitDatabase(this ContainerBuilder container)
{
_logger.Info("Registering Database...");
logger.Info("Registering Database...");
var appDataPath = new EnvironmentProvider().GetAppDataPath();
if (!Directory.Exists(appDataPath)) Directory.CreateDirectory(appDataPath);

View File

@ -3,7 +3,6 @@
using System.Linq;
using System.Net;
using NLog;
using NzbDrone.Core.Providers.Indexer;
using NzbDrone.Core.Repository;
using PetaPoco;