mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2026-04-22 22:34:53 -04:00
cac2729230
* Allow configuring postgres with environment variables (cherry picked from commit 8439df78fea25656a9a1275d2a2fe3f0df0528c7) * Fix process provider when environment variables alread exist [common] (cherry picked from commit 66e5b4025974e081c1406f01a860b1ac52949c22) * First bash at running integration tests on postgres (cherry picked from commit f950e80c7e4f9b088ec6a149386160eab83b61c3) * Postgres integration tests running as part of the build pipeline (cherry picked from commit 9ca8616f5098778e9b5e6ce09d2aa11224018fab) * Fixed: Register PostgresOptions when running in utility mode * fixup! * fixup! * fixup! * fixup! * fixup! Co-authored-by: ta264 <ta264@users.noreply.github.com> Co-authored-by: Qstick <qstick@gmail.com>
50 lines
1.6 KiB
C#
50 lines
1.6 KiB
C#
using System.Linq;
|
|
using DryIoc;
|
|
using DryIoc.Microsoft.DependencyInjection;
|
|
using FluentAssertions;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Microsoft.Extensions.Options;
|
|
using Moq;
|
|
using NUnit.Framework;
|
|
using NzbDrone.Common.Composition.Extensions;
|
|
using NzbDrone.Common.EnvironmentInfo;
|
|
using NzbDrone.Common.Instrumentation.Extensions;
|
|
using NzbDrone.Core.Datastore;
|
|
using NzbDrone.Core.Datastore.Extensions;
|
|
using NzbDrone.Core.Lifecycle;
|
|
using NzbDrone.Core.Messaging.Events;
|
|
using NzbDrone.Host;
|
|
using NzbDrone.Test.Common;
|
|
|
|
namespace NzbDrone.Common.Test
|
|
{
|
|
[TestFixture]
|
|
public class ServiceFactoryFixture : TestBase<ServiceFactory>
|
|
{
|
|
[Test]
|
|
public void event_handlers_should_be_unique()
|
|
{
|
|
var container = new Container(rules => rules.WithNzbDroneRules())
|
|
.AddNzbDroneLogger()
|
|
.AutoAddServices(Bootstrap.ASSEMBLIES)
|
|
.AddDummyDatabase()
|
|
.AddStartupContext(new StartupContext("first", "second"));
|
|
|
|
container.RegisterInstance(new Mock<IHostLifetime>().Object);
|
|
container.RegisterInstance(new Mock<IOptions<PostgresOptions>>().Object);
|
|
|
|
var serviceProvider = container.GetServiceProvider();
|
|
|
|
serviceProvider.GetRequiredService<IAppFolderFactory>().Register();
|
|
|
|
Mocker.SetConstant<System.IServiceProvider>(serviceProvider);
|
|
|
|
var handlers = Subject.BuildAll<IHandle<ApplicationStartedEvent>>()
|
|
.Select(c => c.GetType().FullName);
|
|
|
|
handlers.Should().OnlyHaveUniqueItems();
|
|
}
|
|
}
|
|
}
|