feat: added Sdn repo and added some initial tests
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
namespace SanctionsSearch.Worker.Persistence;
|
||||
|
||||
class AppDbContext(DbOptions options) : DbContext
|
||||
class AppDbContext(DbOptions options, TimeProvider timeProvider) : DbContext
|
||||
{
|
||||
private readonly DbOptions _options = options;
|
||||
private readonly TimeProvider _timeProvider = timeProvider;
|
||||
private SqliteConnection? _connection;
|
||||
internal string DatabasePath { get; private set; } = string.Empty;
|
||||
public DbSet<Sdn> Sdns { get; set; } = default!;
|
||||
@@ -32,8 +33,7 @@ class AppDbContext(DbOptions options) : DbContext
|
||||
|
||||
public async override Task<int> SaveChangesAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
// TODO: Use TimeProvider instead of DateTime.UtcNow
|
||||
var now = DateTime.UtcNow;
|
||||
var now = _timeProvider.GetUtcNow().DateTime;
|
||||
|
||||
foreach (var changedEntity in ChangeTracker.Entries())
|
||||
{
|
||||
|
||||
@@ -2,10 +2,10 @@ namespace SanctionsSearch.Worker.Persistence;
|
||||
|
||||
class EfRepository<T> : IRepository<T> where T : Entity
|
||||
{
|
||||
protected readonly AppDbContext _context;
|
||||
protected readonly DbContext _context;
|
||||
protected readonly ILogger<EfRepository<T>> _logger;
|
||||
|
||||
public EfRepository(AppDbContext context, ILogger<EfRepository<T>> logger)
|
||||
public EfRepository(DbContext context, ILogger<EfRepository<T>> logger)
|
||||
{
|
||||
_context = context;
|
||||
_logger = logger;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
namespace SanctionsSearch.Worker.Persistence;
|
||||
|
||||
class SdnRepository(
|
||||
AppDbContext dbContext,
|
||||
DbContext dbContext,
|
||||
ILogger<SdnRepository> logger
|
||||
) : EfRepository<Sdn>(dbContext, logger), ISdnRepository
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user