2022-12-02 20:24:30 +01:00
|
|
|
|
using Bit.Infrastructure.EntityFramework.Repositories;
|
|
|
|
|
|
|
|
|
|
namespace Bit.Infrastructure.IntegrationTest;
|
|
|
|
|
|
|
|
|
|
public interface ITestDatabaseHelper
|
|
|
|
|
{
|
2023-05-30 19:25:55 +02:00
|
|
|
|
Database Info { get; }
|
2022-12-02 20:24:30 +01:00
|
|
|
|
void ClearTracker();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class EfTestDatabaseHelper : ITestDatabaseHelper
|
|
|
|
|
{
|
|
|
|
|
private readonly DatabaseContext _databaseContext;
|
|
|
|
|
|
2023-05-30 19:25:55 +02:00
|
|
|
|
public EfTestDatabaseHelper(DatabaseContext databaseContext, Database database)
|
2022-12-02 20:24:30 +01:00
|
|
|
|
{
|
|
|
|
|
_databaseContext = databaseContext;
|
2023-05-30 19:25:55 +02:00
|
|
|
|
Info = database;
|
2022-12-02 20:24:30 +01:00
|
|
|
|
}
|
|
|
|
|
|
2023-05-30 19:25:55 +02:00
|
|
|
|
public Database Info { get; }
|
|
|
|
|
|
2022-12-02 20:24:30 +01:00
|
|
|
|
public void ClearTracker()
|
|
|
|
|
{
|
|
|
|
|
_databaseContext.ChangeTracker.Clear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class DapperSqlServerTestDatabaseHelper : ITestDatabaseHelper
|
|
|
|
|
{
|
2023-05-30 19:25:55 +02:00
|
|
|
|
public DapperSqlServerTestDatabaseHelper(Database database)
|
2022-12-02 20:24:30 +01:00
|
|
|
|
{
|
2023-05-30 19:25:55 +02:00
|
|
|
|
Info = database;
|
2022-12-02 20:24:30 +01:00
|
|
|
|
}
|
|
|
|
|
|
2023-05-30 19:25:55 +02:00
|
|
|
|
public Database Info { get; }
|
|
|
|
|
|
2022-12-02 20:24:30 +01:00
|
|
|
|
public void ClearTracker()
|
|
|
|
|
{
|
|
|
|
|
// There are no tracked entities in Dapper SQL Server
|
|
|
|
|
}
|
|
|
|
|
}
|