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.
64 lines
1.9 KiB
64 lines
1.9 KiB
// ==========================================================================
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|
// All rights reserved. Licensed under the MIT license.
|
|
// ==========================================================================
|
|
|
|
using System;
|
|
using FakeItEasy;
|
|
using MongoDB.Driver;
|
|
using Newtonsoft.Json;
|
|
using Squidex.Infrastructure.MongoDb;
|
|
using Squidex.Infrastructure.TestHelpers;
|
|
|
|
namespace Squidex.Infrastructure.EventSourcing
|
|
{
|
|
public abstract class MongoEventStoreFixture : IDisposable
|
|
{
|
|
private readonly IMongoClient mongoClient;
|
|
private readonly IMongoDatabase mongoDatabase;
|
|
private readonly IEventNotifier notifier = A.Fake<IEventNotifier>();
|
|
|
|
public MongoEventStore EventStore { get; }
|
|
|
|
protected MongoEventStoreFixture(string connectionString)
|
|
{
|
|
mongoClient = new MongoClient(connectionString);
|
|
mongoDatabase = mongoClient.GetDatabase($"EventStoreTest");
|
|
|
|
Cleanup();
|
|
|
|
BsonJsonConvention.Register(JsonSerializer.Create(JsonHelper.DefaultSettings()));
|
|
|
|
EventStore = new MongoEventStore(mongoDatabase, notifier);
|
|
EventStore.InitializeAsync().Wait();
|
|
}
|
|
|
|
public void Cleanup()
|
|
{
|
|
mongoClient.DropDatabase("EventStoreTest");
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
Cleanup();
|
|
}
|
|
}
|
|
|
|
public sealed class MongoEventStoreDirectFixture : MongoEventStoreFixture
|
|
{
|
|
public MongoEventStoreDirectFixture()
|
|
: base("mongodb://localhost:27019")
|
|
{
|
|
}
|
|
}
|
|
|
|
public sealed class MongoEventStoreReplicaSetFixture : MongoEventStoreFixture
|
|
{
|
|
public MongoEventStoreReplicaSetFixture()
|
|
: base("mongodb://localhost:27017")
|
|
{
|
|
}
|
|
}
|
|
}
|
|
|