mirror of
https://github.com/lidarr/Lidarr
synced 2025-02-22 14:00:42 +00:00
Fixed some tests.
This commit is contained in:
parent
2a83088045
commit
c08d8252ff
4 changed files with 35 additions and 10 deletions
|
@ -111,6 +111,14 @@
|
||||||
<Project>{95C11A9E-56ED-456A-8447-2C89C1139266}</Project>
|
<Project>{95C11A9E-56ED-456A-8447-2C89C1139266}</Project>
|
||||||
<Name>NzbDrone.Host</Name>
|
<Name>NzbDrone.Host</Name>
|
||||||
</ProjectReference>
|
</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">
|
<ProjectReference Include="..\NzbDrone\NzbDrone.csproj">
|
||||||
<Project>{D12F7F2F-8A3C-415F-88FA-6DD061A84869}</Project>
|
<Project>{D12F7F2F-8A3C-415F-88FA-6DD061A84869}</Project>
|
||||||
<Name>NzbDrone</Name>
|
<Name>NzbDrone</Name>
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Common.EnvironmentInfo;
|
using NzbDrone.Common.EnvironmentInfo;
|
||||||
|
using NzbDrone.Core.Datastore;
|
||||||
using NzbDrone.Core.Lifecycle;
|
using NzbDrone.Core.Lifecycle;
|
||||||
using NzbDrone.Core.Messaging.Events;
|
using NzbDrone.Core.Messaging.Events;
|
||||||
using NzbDrone.Host;
|
using NzbDrone.Host;
|
||||||
|
@ -16,11 +17,12 @@ public class ServiceFactoryFixture : TestBase<ServiceFactory>
|
||||||
public void event_handlers_should_be_unique()
|
public void event_handlers_should_be_unique()
|
||||||
{
|
{
|
||||||
var container = MainAppContainerBuilder.BuildContainer(new StartupContext());
|
var container = MainAppContainerBuilder.BuildContainer(new StartupContext());
|
||||||
|
container.Register<IMainDatabase>(new MainDatabase(null));
|
||||||
container.Resolve<IAppFolderFactory>().Register();
|
container.Resolve<IAppFolderFactory>().Register();
|
||||||
|
|
||||||
Mocker.SetConstant(container);
|
Mocker.SetConstant(container);
|
||||||
|
|
||||||
var handlers = Subject.BuildAll<IHandle<ApplicationShutdownRequested>>()
|
var handlers = Subject.BuildAll<IHandle<ApplicationStartedEvent>>()
|
||||||
.Select(c => c.GetType().FullName);
|
.Select(c => c.GetType().FullName);
|
||||||
|
|
||||||
handlers.Should().OnlyHaveUniqueItems();
|
handlers.Should().OnlyHaveUniqueItems();
|
||||||
|
|
|
@ -88,9 +88,31 @@ protected ITestDatabase Db
|
||||||
protected virtual TestDatabase WithTestDb(Action<MigrationBase> beforeMigration)
|
protected virtual TestDatabase WithTestDb(Action<MigrationBase> beforeMigration)
|
||||||
{
|
{
|
||||||
var factory = Mocker.Resolve<DbFactory>();
|
var factory = Mocker.Resolve<DbFactory>();
|
||||||
var database = factory.Create(MigrationType);
|
var database = factory.Create(MigrationType, beforeMigration);
|
||||||
Mocker.SetConstant(database);
|
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);
|
var testDb = new TestDatabase(database);
|
||||||
|
|
||||||
return testDb;
|
return testDb;
|
||||||
|
|
|
@ -11,20 +11,13 @@ public abstract class MigrationTest<TMigration> : DbTest where TMigration : Migr
|
||||||
{
|
{
|
||||||
protected override TestDatabase WithTestDb(Action<MigrationBase> beforeMigration)
|
protected override TestDatabase WithTestDb(Action<MigrationBase> beforeMigration)
|
||||||
{
|
{
|
||||||
var factory = Mocker.Resolve<DbFactory>();
|
return base.WithTestDb(m =>
|
||||||
|
|
||||||
var database = factory.Create(MigrationType, m =>
|
|
||||||
{
|
{
|
||||||
if (m.GetType() == typeof(TMigration))
|
if (m.GetType() == typeof(TMigration))
|
||||||
{
|
{
|
||||||
beforeMigration(m);
|
beforeMigration(m);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var testDb = new TestDatabase(database);
|
|
||||||
Mocker.SetConstant(database);
|
|
||||||
|
|
||||||
return testDb;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
|
|
Loading…
Reference in a new issue