Files
monorepo/LCU.API.Internal.Document/LCU.API.Internal.DocumentLibTest/TestDoubles/FakeMongoCollectionFactory.cs
T
2026-03-13 09:11:35 -05:00

19 lines
537 B
C#

using LCU.API.Internal.DocumentLib.Utilities;
using Mongo2Go;
using MongoDB.Driver;
namespace LCU.API.Internal.DocumentLibTest.TestDoubles;
public class FakeMongoCollectionFactory : IMongoCollectionFactory, IDisposable
{
private readonly MongoDbRunner _runner = MongoDbRunner.Start();
public IMongoCollection<T> GetCollection<T>() => new MongoClient(_runner.ConnectionString)
.GetDatabase(typeof(T).Name)
.GetCollection<T>(typeof(T).Name);
public void Dispose()
{
_runner.Dispose();
}
}