Fixed some tests.

pull/241/merge
Taloth Saldono 10 years ago
parent 2a83088045
commit c08d8252ff

@ -111,6 +111,14 @@
<Project>{95C11A9E-56ED-456A-8447-2C89C1139266}</Project>
<Name>NzbDrone.Host</Name>
</ProjectReference>
<ProjectReference Include="..\NzbDrone.Mono\NzbDrone.Mono.csproj">
<Project>{15ad7579-a314-4626-b556-663f51d97cd1}</Project>
<Name>NzbDrone.Mono</Name>
</ProjectReference>
<ProjectReference Include="..\NzbDrone.Windows\NzbDrone.Windows.csproj">
<Project>{911284d3-f130-459e-836c-2430b6fbf21d}</Project>
<Name>NzbDrone.Windows</Name>
</ProjectReference>
<ProjectReference Include="..\NzbDrone\NzbDrone.csproj">
<Project>{D12F7F2F-8A3C-415F-88FA-6DD061A84869}</Project>
<Name>NzbDrone</Name>

@ -2,6 +2,7 @@
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Lifecycle;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Host;
@ -16,11 +17,12 @@ namespace NzbDrone.Common.Test
public void event_handlers_should_be_unique()
{
var container = MainAppContainerBuilder.BuildContainer(new StartupContext());
container.Register<IMainDatabase>(new MainDatabase(null));
container.Resolve<IAppFolderFactory>().Register();
Mocker.SetConstant(container);
var handlers = Subject.BuildAll<IHandle<ApplicationShutdownRequested>>()
var handlers = Subject.BuildAll<IHandle<ApplicationStartedEvent>>()
.Select(c => c.GetType().FullName);
handlers.Should().OnlyHaveUniqueItems();

@ -88,9 +88,31 @@ namespace NzbDrone.Core.Test.Framework
protected virtual TestDatabase WithTestDb(Action<MigrationBase> beforeMigration)
{
var factory = Mocker.Resolve<DbFactory>();
var database = factory.Create(MigrationType);
var database = factory.Create(MigrationType, beforeMigration);
Mocker.SetConstant(database);
switch (MigrationType)
{
case MigrationType.Main:
{
var mainDb = new MainDatabase(database);
Mocker.SetConstant<IMainDatabase>(mainDb);
break;
}
case MigrationType.Log:
{
var logDb = new LogDatabase(database);
Mocker.SetConstant<ILogDatabase>(logDb);
break;
}
default:
{
throw new ArgumentException("Invalid MigrationType");
}
}
var testDb = new TestDatabase(database);
return testDb;

@ -11,20 +11,13 @@ namespace NzbDrone.Core.Test.Framework
{
protected override TestDatabase WithTestDb(Action<MigrationBase> beforeMigration)
{
var factory = Mocker.Resolve<DbFactory>();
var database = factory.Create(MigrationType, m =>
return base.WithTestDb(m =>
{
if (m.GetType() == typeof(TMigration))
{
beforeMigration(m);
}
});
var testDb = new TestDatabase(database);
Mocker.SetConstant(database);
return testDb;
}
[SetUp]

Loading…
Cancel
Save