Skip to content

Commit 403477c

Browse files
committed
chore: Remove SharedContainerInstance and use ContainerFixture instead
Now that `Testcontainers.Xunit` is available we can get rid of `SharedContainerInstance` in the `Testcontainers.Commons` project since it serves the same purpose.
1 parent 042b234 commit 403477c

File tree

6 files changed

+11
-35
lines changed

6 files changed

+11
-35
lines changed

tests/Testcontainers.Commons/SharedContainerInstance.cs

Lines changed: 0 additions & 23 deletions
This file was deleted.

tests/Testcontainers.Commons/Testcontainers.Commons.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
</PropertyGroup>
1010
<ItemGroup>
1111
<PackageReference Include="JetBrains.Annotations" VersionOverride="2023.3.0"/>
12-
<PackageReference Include="xunit"/>
1312
</ItemGroup>
1413
<ItemGroup>
1514
<ProjectReference Include="../../src/Testcontainers/Testcontainers.csproj"/>

tests/Testcontainers.Commons/Usings.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,5 @@
22
global using System.Diagnostics;
33
global using System.IO;
44
global using System.Text;
5-
global using System.Threading.Tasks;
6-
global using DotNet.Testcontainers.Containers;
75
global using DotNet.Testcontainers.Images;
8-
global using JetBrains.Annotations;
9-
global using Xunit;
6+
global using JetBrains.Annotations;

tests/Testcontainers.PostgreSql.Tests/PostgreSqlContainerTest.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ public async Task ExecScriptReturnsSuccessful()
4646
}
4747
// # --8<-- [end:UsePostgreSqlContainer]
4848

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

53-
private readonly SharedContainerInstance<PostgreSqlContainer> _fixture;
53+
private readonly PostgreSqlFixture _fixture;
5454

55-
public ReuseContainerTest(SharedPostgreSqlInstance fixture)
55+
public ReuseContainerTest(PostgreSqlFixture fixture)
5656
{
5757
_fixture = fixture;
5858
}
@@ -79,10 +79,10 @@ await _fixture.Container.StartAsync(_cts.Token)
7979
}
8080

8181
[UsedImplicitly]
82-
public sealed class SharedPostgreSqlInstance : SharedContainerInstance<PostgreSqlContainer>
82+
public sealed class PostgreSqlFixture : ContainerFixture<PostgreSqlBuilder, PostgreSqlContainer>
8383
{
84-
public SharedPostgreSqlInstance()
85-
: base(new PostgreSqlBuilder().Build())
84+
public PostgreSqlFixture(IMessageSink messageSink)
85+
: base(messageSink)
8686
{
8787
}
8888
}

tests/Testcontainers.PostgreSql.Tests/Testcontainers.PostgreSql.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
</ItemGroup>
1616
<ItemGroup>
1717
<ProjectReference Include="../../src/Testcontainers.PostgreSql/Testcontainers.PostgreSql.csproj"/>
18+
<ProjectReference Include="../../src/Testcontainers.Xunit/Testcontainers.Xunit.csproj" />
1819
<ProjectReference Include="../Testcontainers.Commons/Testcontainers.Commons.csproj"/>
1920
</ItemGroup>
2021
</Project>

tests/Testcontainers.PostgreSql.Tests/Usings.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
global using System.Data.Common;
44
global using System.Threading;
55
global using System.Threading.Tasks;
6+
global using Testcontainers.Xunit;
67
global using DotNet.Testcontainers.Commons;
78
global using JetBrains.Annotations;
89
global using Npgsql;
9-
global using Xunit;
10+
global using Xunit;
11+
global using Xunit.Abstractions;

0 commit comments

Comments
 (0)