Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/BuildingBlocks/TestBase/TestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@
if (ServiceProvider.GetService<ITestHarness>() is { } harness)
{
await harness.Start();
await Task.Delay(1000);
}
}

Expand Down Expand Up @@ -539,7 +538,7 @@
public TestFixtureCore(
TestFixture<TEntryPoint> integrationTestFixture,
ITestOutputHelper outputHelper,
Type dbContextType = null

Check warning on line 541 in src/BuildingBlocks/TestBase/TestBase.cs

View workflow job for this annotation

GitHub Actions / ci

Cannot convert null literal to non-nullable reference type.
)
{
Fixture = integrationTestFixture;
Expand Down Expand Up @@ -685,14 +684,14 @@
{
protected TestReadBase(
TestReadFixture<TEntryPoint, TRContext> integrationTestFixture,
ITestOutputHelper outputHelper = null

Check warning on line 687 in src/BuildingBlocks/TestBase/TestBase.cs

View workflow job for this annotation

GitHub Actions / ci

Cannot convert null literal to non-nullable reference type.
)
: base(integrationTestFixture, outputHelper)
{
Fixture = integrationTestFixture;
}

public TestReadFixture<TEntryPoint, TRContext> Fixture { get; }

Check warning on line 694 in src/BuildingBlocks/TestBase/TestBase.cs

View workflow job for this annotation

GitHub Actions / ci

'TestReadBase<TEntryPoint, TRContext>.Fixture' hides inherited member 'TestFixtureCore<TEntryPoint>.Fixture'. Use the new keyword if hiding was intended.
}

public abstract class TestWriteBase<TEntryPoint, TWContext> : TestFixtureCore<TEntryPoint>
Expand All @@ -702,14 +701,14 @@
{
protected TestWriteBase(
TestWriteFixture<TEntryPoint, TWContext> integrationTestFixture,
ITestOutputHelper outputHelper = null

Check warning on line 704 in src/BuildingBlocks/TestBase/TestBase.cs

View workflow job for this annotation

GitHub Actions / ci

Cannot convert null literal to non-nullable reference type.
)
: base(integrationTestFixture, outputHelper, typeof(TWContext))
{
Fixture = integrationTestFixture;
}

public TestWriteFixture<TEntryPoint, TWContext> Fixture { get; }

Check warning on line 711 in src/BuildingBlocks/TestBase/TestBase.cs

View workflow job for this annotation

GitHub Actions / ci

'TestWriteBase<TEntryPoint, TWContext>.Fixture' hides inherited member 'TestFixtureCore<TEntryPoint>.Fixture'. Use the new keyword if hiding was intended.
}

public abstract class TestBase<TEntryPoint, TWContext, TRContext> : TestFixtureCore<TEntryPoint>
Expand All @@ -720,11 +719,11 @@
{
protected TestBase(
TestFixture<TEntryPoint, TWContext, TRContext> integrationTestFixture,
ITestOutputHelper outputHelper = null

Check warning on line 722 in src/BuildingBlocks/TestBase/TestBase.cs

View workflow job for this annotation

GitHub Actions / ci

Cannot convert null literal to non-nullable reference type.
)
: base(integrationTestFixture, outputHelper, typeof(TWContext))
{
Fixture = integrationTestFixture;
}

public TestFixture<TEntryPoint, TWContext, TRContext> Fixture { get; }

Check warning on line 729 in src/BuildingBlocks/TestBase/TestBase.cs

View workflow job for this annotation

GitHub Actions / ci

'TestBase<TEntryPoint, TWContext, TRContext>.Fixture' hides inherited member 'TestFixtureCore<TEntryPoint>.Fixture'. Use the new keyword if hiding was intended.
Expand Down
42 changes: 28 additions & 14 deletions src/BuildingBlocks/TestBase/TestContainers.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using DotNet.Testcontainers.Builders;

namespace BuildingBlocks.TestBase;

using Testcontainers.EventStoreDb;
Expand All @@ -18,15 +20,19 @@ static TestContainers()
{
var configuration = ConfigurationHelper.GetConfiguration();

RabbitMqContainerConfiguration =
configuration.GetOptions<RabbitMqContainerOptions>(nameof(RabbitMqContainerOptions));
PostgresContainerConfiguration =
configuration.GetOptions<PostgresContainerOptions>(nameof(PostgresContainerOptions));
PostgresPersistContainerConfiguration =
configuration.GetOptions<PostgresPersistContainerOptions>(nameof(PostgresPersistContainerOptions));
RabbitMqContainerConfiguration = configuration.GetOptions<RabbitMqContainerOptions>(
nameof(RabbitMqContainerOptions)
);
PostgresContainerConfiguration = configuration.GetOptions<PostgresContainerOptions>(
nameof(PostgresContainerOptions)
);
PostgresPersistContainerConfiguration = configuration.GetOptions<PostgresPersistContainerOptions>(
nameof(PostgresPersistContainerOptions)
);
MongoContainerConfiguration = configuration.GetOptions<MongoContainerOptions>(nameof(MongoContainerOptions));
EventStoreContainerConfiguration =
configuration.GetOptions<EventStoreContainerOptions>(nameof(EventStoreContainerOptions));
EventStoreContainerConfiguration = configuration.GetOptions<EventStoreContainerOptions>(
nameof(EventStoreContainerOptions)
);
}

public static PostgreSqlContainer PostgresTestContainer()
Expand Down Expand Up @@ -81,25 +87,33 @@ public static MongoDbContainer MongoTestContainer()

public static RabbitMqContainer RabbitMqTestContainer()
{
var baseBuilder = new RabbitMqBuilder()
var builder = new RabbitMqBuilder()
.WithUsername(RabbitMqContainerConfiguration.UserName)
.WithPassword(RabbitMqContainerConfiguration.Password)
.WithLabel("Key", "Value");

var builder = baseBuilder
.WithImage(RabbitMqContainerConfiguration.ImageName)
.WithName(RabbitMqContainerConfiguration.Name)
.WithPortBinding(RabbitMqContainerConfiguration.ApiPort, true)
.WithPortBinding(RabbitMqContainerConfiguration.Port, true)
.WithWaitStrategy(
Wait.ForUnixContainer()
.UntilHttpRequestIsSucceeded(request =>
request
.ForPort((ushort)RabbitMqContainerConfiguration.ApiPort)
.ForPath("/api/overview")
.WithBasicAuthentication(
RabbitMqContainerConfiguration.UserName,
RabbitMqContainerConfiguration.Password
)
)
)
.Build();

return builder;
}

public static EventStoreDbContainer EventStoreTestContainer()
{
var baseBuilder = new EventStoreDbBuilder()
.WithLabel("Key", "Value");
var baseBuilder = new EventStoreDbBuilder().WithLabel("Key", "Value");

var builder = baseBuilder
.WithImage(EventStoreContainerConfiguration.ImageName)
Expand Down
Loading