mirror of https://github.com/Squidex/squidex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.6 KiB
49 lines
1.6 KiB
// ==========================================================================
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|
// All rights reserved. Licensed under the MIT license.
|
|
// ==========================================================================
|
|
|
|
using EventStore.Client;
|
|
using Squidex.Infrastructure.TestHelpers;
|
|
|
|
namespace Squidex.Infrastructure.EventSourcing
|
|
{
|
|
public sealed class GetEventStoreFixture : IDisposable
|
|
{
|
|
private readonly EventStoreClientSettings settings;
|
|
|
|
public GetEventStore EventStore { get; }
|
|
|
|
public GetEventStoreFixture()
|
|
{
|
|
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
|
|
|
|
settings = EventStoreClientSettings.Create(TestConfig.Configuration["eventStore:configuration"]);
|
|
|
|
EventStore = new GetEventStore(settings, TestUtils.DefaultSerializer);
|
|
EventStore.InitializeAsync(default).Wait();
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
CleanupAsync().Wait();
|
|
}
|
|
|
|
private async Task CleanupAsync()
|
|
{
|
|
var projectionsManager = new EventStoreProjectionManagementClient(settings);
|
|
|
|
await foreach (var projection in projectionsManager.ListAllAsync())
|
|
{
|
|
var name = projection.Name;
|
|
|
|
if (name.StartsWith("by-squidex-test", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
await projectionsManager.DisableAsync(name);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|