mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-17 15:02:34 +02:00
Fixed some tests.
This commit is contained in:
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 @@ public class ServiceFactoryFixture : TestBase<ServiceFactory>
|
||||
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 @@ protected ITestDatabase Db
|
||||
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 @@ public abstract class MigrationTest<TMigration> : DbTest where TMigration : Migr
|
||||
{
|
||||
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…
Reference in New Issue
Block a user