elsa-core/test/Elsa.ProtoCluster.ComponentTests/AzureContainerAppTests/RedisFixture.cs
gurkanguran 90e560bc73
Redis proto cluster member store (#4241)
* Implemented redis as a proto cluster member store

* Added component tests for redis protocluster member store

---------

Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
2023-07-14 19:29:43 +02:00

32 lines
825 B
C#

using DotNet.Testcontainers.Builders;
using Testcontainers.Redis;
namespace Elsa.ProtoCluster.ComponentTests.AzureContainerAppTests;
public class RedisFixture : IAsyncLifetime
{
private RedisContainer? _redisContainer;
public async Task InitializeAsync()
{
_redisContainer = new RedisBuilder()
.WithPortBinding(6379, true)
.Build();
await _redisContainer.StartAsync().ConfigureAwait(false);
}
public string GetConnectionString()
{
return _redisContainer != null ?
_redisContainer.GetConnectionString() :
throw new InvalidOperationException("Redis container not initialized.");
}
public async Task DisposeAsync()
{
if(_redisContainer != null)
await _redisContainer.StopAsync();
}
}