mirror of https://github.com/Squidex/squidex.git
15 changed files with 273 additions and 82 deletions
@ -0,0 +1,62 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System; |
|||
using System.Linq; |
|||
using System.Net; |
|||
using System.Net.Sockets; |
|||
using System.Threading.Tasks; |
|||
using EventStore.ClientAPI; |
|||
using EventStore.ClientAPI.Projections; |
|||
using Squidex.Infrastructure.TestHelpers; |
|||
|
|||
namespace Squidex.Infrastructure.EventSourcing |
|||
{ |
|||
public sealed class GetEventStoreFixture : IDisposable |
|||
{ |
|||
private readonly IEventStoreConnection connection; |
|||
|
|||
public GetEventStore EventStore { get; } |
|||
|
|||
public GetEventStoreFixture() |
|||
{ |
|||
connection = EventStoreConnection.Create("ConnectTo=tcp://admin:changeit@localhost:1113; HeartBeatTimeout=500; MaxReconnections=-1"); |
|||
|
|||
EventStore = new GetEventStore(connection, JsonHelper.DefaultSerializer, "test", "localhost"); |
|||
EventStore.InitializeAsync().Wait(); |
|||
} |
|||
|
|||
public void Dispose() |
|||
{ |
|||
CleanupAsync().Wait(); |
|||
} |
|||
|
|||
private async Task CleanupAsync() |
|||
{ |
|||
var endpoints = await Dns.GetHostAddressesAsync("localhost"); |
|||
var endpoint = new IPEndPoint(endpoints.First(x => x.AddressFamily == AddressFamily.InterNetwork), 2113); |
|||
|
|||
var credentials = connection.Settings.DefaultUserCredentials; |
|||
|
|||
var projectionsManager = |
|||
new ProjectionsManager( |
|||
connection.Settings.Log, endpoint, |
|||
connection.Settings.OperationTimeout); |
|||
|
|||
foreach (var projection in await projectionsManager.ListAllAsync(credentials)) |
|||
{ |
|||
var name = projection.Name; |
|||
|
|||
if (name.StartsWith("by-test", StringComparison.OrdinalIgnoreCase)) |
|||
{ |
|||
await projectionsManager.DisableAsync(name, credentials); |
|||
await projectionsManager.DeleteAsync(name, true, credentials); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using Xunit; |
|||
|
|||
namespace Squidex.Infrastructure.EventSourcing |
|||
{ |
|||
[Trait("Category", "Dependencies")] |
|||
public class GetEventStoreTests : EventStoreTests<GetEventStore>, IClassFixture<GetEventStoreFixture> |
|||
{ |
|||
private readonly GetEventStoreFixture fixture; |
|||
|
|||
protected override int SubscriptionDelayInMs { get; } = 1000; |
|||
|
|||
public GetEventStoreTests(GetEventStoreFixture fixture) |
|||
{ |
|||
this.fixture = fixture; |
|||
} |
|||
|
|||
public override GetEventStore CreateStore() |
|||
{ |
|||
return fixture.EventStore; |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue