Skip to content

Commit

Permalink
Only run startup actions one time
Browse files Browse the repository at this point in the history
  • Loading branch information
ejsmith committed Feb 14, 2024
1 parent 721dca7 commit a95eae7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/Exceptionless.Tests/TestWithServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class TestWithServices : TestWithLoggingBase, IAsyncLifetime
{
private readonly IDisposable _testSystemClock = TestSystemClock.Install();
private readonly IServiceProvider _container;
private static bool _startupActionsRun;

public TestWithServices(ITestOutputHelper output) : base(output)
{
Expand All @@ -33,9 +34,14 @@ public TestWithServices(ITestOutputHelper output) : base(output)

public virtual async Task InitializeAsync()
{
if (_startupActionsRun)
return;

var result = await _container.RunStartupActionsAsync();
if (!result.Success)
throw new ApplicationException($"Startup action \"{result.FailedActionName}\" failed");

_startupActionsRun = true;
}

protected TService GetService<TService>() where TService : class
Expand Down

0 comments on commit a95eae7

Please sign in to comment.