Skip to content

Commit

Permalink
chore: Remove SharedContainerInstance and use ContainerFixture in…
Browse files Browse the repository at this point in the history
…stead

Now that `Testcontainers.Xunit` is available we can get rid of `SharedContainerInstance` in the `Testcontainers.Commons` project since it serves the same purpose.
  • Loading branch information
0xced committed Feb 20, 2025
1 parent 042b234 commit 403477c
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 35 deletions.
23 changes: 0 additions & 23 deletions tests/Testcontainers.Commons/SharedContainerInstance.cs

This file was deleted.

1 change: 0 additions & 1 deletion tests/Testcontainers.Commons/Testcontainers.Commons.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" VersionOverride="2023.3.0"/>
<PackageReference Include="xunit"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="../../src/Testcontainers/Testcontainers.csproj"/>
Expand Down
5 changes: 1 addition & 4 deletions tests/Testcontainers.Commons/Usings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@
global using System.Diagnostics;
global using System.IO;
global using System.Text;
global using System.Threading.Tasks;
global using DotNet.Testcontainers.Containers;
global using DotNet.Testcontainers.Images;
global using JetBrains.Annotations;
global using Xunit;
global using JetBrains.Annotations;
12 changes: 6 additions & 6 deletions tests/Testcontainers.PostgreSql.Tests/PostgreSqlContainerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ public async Task ExecScriptReturnsSuccessful()
}
// # --8<-- [end:UsePostgreSqlContainer]

public sealed class ReuseContainerTest : IClassFixture<SharedPostgreSqlInstance>, IDisposable
public sealed class ReuseContainerTest : IClassFixture<PostgreSqlFixture>, IDisposable
{
private readonly CancellationTokenSource _cts = new CancellationTokenSource(TimeSpan.FromMinutes(1));

private readonly SharedContainerInstance<PostgreSqlContainer> _fixture;
private readonly PostgreSqlFixture _fixture;

public ReuseContainerTest(SharedPostgreSqlInstance fixture)
public ReuseContainerTest(PostgreSqlFixture fixture)
{
_fixture = fixture;
}
Expand All @@ -79,10 +79,10 @@ await _fixture.Container.StartAsync(_cts.Token)
}

[UsedImplicitly]
public sealed class SharedPostgreSqlInstance : SharedContainerInstance<PostgreSqlContainer>
public sealed class PostgreSqlFixture : ContainerFixture<PostgreSqlBuilder, PostgreSqlContainer>
{
public SharedPostgreSqlInstance()
: base(new PostgreSqlBuilder().Build())
public PostgreSqlFixture(IMessageSink messageSink)
: base(messageSink)
{
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="../../src/Testcontainers.PostgreSql/Testcontainers.PostgreSql.csproj"/>
<ProjectReference Include="../../src/Testcontainers.Xunit/Testcontainers.Xunit.csproj" />
<ProjectReference Include="../Testcontainers.Commons/Testcontainers.Commons.csproj"/>
</ItemGroup>
</Project>
4 changes: 3 additions & 1 deletion tests/Testcontainers.PostgreSql.Tests/Usings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
global using System.Data.Common;
global using System.Threading;
global using System.Threading.Tasks;
global using Testcontainers.Xunit;
global using DotNet.Testcontainers.Commons;
global using JetBrains.Annotations;
global using Npgsql;
global using Xunit;
global using Xunit;
global using Xunit.Abstractions;

0 comments on commit 403477c

Please sign in to comment.