save checkpoint
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
using FluentAssertions;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using StellaOps.Eventing.Storage;
|
||||
using StellaOps.HybridLogicalClock;
|
||||
using Xunit;
|
||||
|
||||
namespace StellaOps.Eventing.Tests;
|
||||
|
||||
[Trait("Category", "Unit")]
|
||||
public sealed class ServiceCollectionExtensionsTests
|
||||
{
|
||||
[Fact]
|
||||
public void AddStellaOpsEventing_InMemoryStore_RegistersEmitterAndClock()
|
||||
{
|
||||
var configuration = new ConfigurationBuilder()
|
||||
.AddInMemoryCollection(new Dictionary<string, string?>
|
||||
{
|
||||
["Eventing:ServiceName"] = "TimelineTests",
|
||||
["Eventing:UseInMemoryStore"] = "true",
|
||||
})
|
||||
.Build();
|
||||
|
||||
var services = new ServiceCollection();
|
||||
services.AddLogging();
|
||||
|
||||
services.AddStellaOpsEventing(configuration);
|
||||
|
||||
using var provider = services.BuildServiceProvider();
|
||||
|
||||
provider.GetRequiredService<IHybridLogicalClock>().Should().NotBeNull();
|
||||
provider.GetRequiredService<ITimelineEventStore>().Should().BeOfType<InMemoryTimelineEventStore>();
|
||||
provider.GetRequiredService<ITimelineEventEmitter>().Should().NotBeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddStellaOpsEventing_PostgresStore_RegistersEmitterClockAndStore()
|
||||
{
|
||||
var configuration = new ConfigurationBuilder()
|
||||
.AddInMemoryCollection(new Dictionary<string, string?>
|
||||
{
|
||||
["Eventing:ServiceName"] = "TimelineTests",
|
||||
["Eventing:UseInMemoryStore"] = "false",
|
||||
["Eventing:ConnectionString"] = "Host=localhost;Port=5432;Database=timeline;Username=postgres;Password=postgres",
|
||||
})
|
||||
.Build();
|
||||
|
||||
var services = new ServiceCollection();
|
||||
services.AddLogging();
|
||||
|
||||
services.AddStellaOpsEventing(configuration);
|
||||
|
||||
using var provider = services.BuildServiceProvider();
|
||||
|
||||
provider.GetRequiredService<IHybridLogicalClock>().Should().NotBeNull();
|
||||
provider.GetRequiredService<ITimelineEventStore>().Should().BeOfType<PostgresTimelineEventStore>();
|
||||
provider.GetRequiredService<ITimelineEventEmitter>().Should().NotBeNull();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user