Adding test containers with kafka and mongo
This commit is contained in:
parent
4570c43453
commit
e75c10d6f0
@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "consumer", "consumer\consum
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "shared", "shared\shared.csproj", "{6958D7C2-23D8-4383-9F03-6395DE86FD63}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "integration-test", "integration-test\integration-test.csproj", "{5EE89BB0-1679-4301-817C-A22C5B400C2A}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -30,5 +32,9 @@ Global
|
||||
{6958D7C2-23D8-4383-9F03-6395DE86FD63}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6958D7C2-23D8-4383-9F03-6395DE86FD63}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6958D7C2-23D8-4383-9F03-6395DE86FD63}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{5EE89BB0-1679-4301-817C-A22C5B400C2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{5EE89BB0-1679-4301-817C-A22C5B400C2A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5EE89BB0-1679-4301-817C-A22C5B400C2A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5EE89BB0-1679-4301-817C-A22C5B400C2A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
1
integration-test/GlobalUsings.cs
Normal file
1
integration-test/GlobalUsings.cs
Normal file
@ -0,0 +1 @@
|
||||
global using Xunit;
|
38
integration-test/IntegrationTests.cs
Normal file
38
integration-test/IntegrationTests.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using DotNet.Testcontainers.Builders;
|
||||
using Testcontainers.Kafka;
|
||||
using Testcontainers.MongoDb;
|
||||
|
||||
namespace integration_test;
|
||||
|
||||
public sealed class UnitTest1 : IAsyncLifetime
|
||||
{
|
||||
private readonly MongoDbContainer _mongoDbContainer = new MongoDbBuilder().Build();
|
||||
private readonly KafkaContainer _kafkaContainer = new KafkaBuilder().WithImage("confluentinc/cp-kafka:latest").Build();
|
||||
|
||||
public Task DisposeAsync()
|
||||
{
|
||||
Task[] tasks = new Task[]
|
||||
{
|
||||
_mongoDbContainer.DisposeAsync().AsTask(),
|
||||
_kafkaContainer.DisposeAsync().AsTask()
|
||||
};
|
||||
return Task.WhenAll(tasks);
|
||||
|
||||
}
|
||||
|
||||
public Task InitializeAsync()
|
||||
{
|
||||
Task[] tasks = new Task[] {
|
||||
_mongoDbContainer.StartAsync(),
|
||||
_kafkaContainer.StartAsync()
|
||||
};
|
||||
return Task.WhenAll(tasks);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ShouldProcessMessage()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
35
integration-test/integration-test.csproj
Normal file
35
integration-test/integration-test.csproj
Normal file
@ -0,0 +1,35 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<RootNamespace>integration_test</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
|
||||
<PackageReference Include="MongoDB.Driver" Version="2.26.0" />
|
||||
<PackageReference Include="Testcontainers" Version="3.8.0" />
|
||||
<PackageReference Include="Testcontainers.Kafka" Version="3.8.0" />
|
||||
<PackageReference Include="Testcontainers.MongoDb" Version="3.8.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.2" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.0">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\consumer\consumer.csproj" />
|
||||
<ProjectReference Include="..\producer\producer.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user