Skip to content

Commit

Permalink
fix: Remove Sonar code smells
Browse files Browse the repository at this point in the history
  • Loading branch information
HofmeisterAn committed Nov 26, 2024
1 parent 1cf48b2 commit 2e15016
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
12 changes: 9 additions & 3 deletions src/Testcontainers.Xunit/ContainerLifetime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,16 @@ public TContainerEntity Container

#if !XUNIT_V3
/// <inheritdoc />
LifetimeTask IAsyncLifetime.DisposeAsync() => DisposeAsync();
LifetimeTask IAsyncLifetime.DisposeAsync() => DisposeAsyncCore();
#else
/// <inheritdoc />
LifetimeTask IAsyncDisposable.DisposeAsync() => DisposeAsync();
async LifetimeTask IAsyncDisposable.DisposeAsync()
{
await DisposeAsyncCore()
.ConfigureAwait(false);

GC.SuppressFinalize(this);
}
#endif

/// <summary>
Expand Down Expand Up @@ -80,7 +86,7 @@ await Container.StartAsync()
}

/// <inheritdoc cref="IAsyncLifetime" />
protected virtual async LifetimeTask DisposeAsync()
protected virtual async LifetimeTask DisposeAsyncCore()
{
if (_exception == null)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Testcontainers.Xunit/DbContainerFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ await base.InitializeAsync()
}

/// <inheritdoc />
protected override async LifetimeTask DisposeAsync()
protected override async LifetimeTask DisposeAsyncCore()
{
if (_testMethods != null)
{
await _testMethods.DisposeAsync()
.ConfigureAwait(true);
}

await base.DisposeAsync()
await base.DisposeAsyncCore()
.ConfigureAwait(true);
}

Expand Down
5 changes: 2 additions & 3 deletions src/Testcontainers.Xunit/DbContainerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ public abstract class DbContainerTest<TBuilderEntity, TContainerEntity>(ITestOut
where TBuilderEntity : IContainerBuilder<TBuilderEntity, TContainerEntity>, new()
where TContainerEntity : IContainer, IDatabaseContainer
{
private readonly CancellationTokenSource _cts = new CancellationTokenSource();
private DbContainerTestMethods _testMethods;

/// <inheritdoc />
Expand All @@ -25,15 +24,15 @@ await base.InitializeAsync()
}

/// <inheritdoc />
protected override async LifetimeTask DisposeAsync()
protected override async LifetimeTask DisposeAsyncCore()
{
if (_testMethods != null)
{
await _testMethods.DisposeAsync()
.ConfigureAwait(true);
}

await base.DisposeAsync()
await base.DisposeAsyncCore()
.ConfigureAwait(true);
}

Expand Down

0 comments on commit 2e15016

Please sign in to comment.