Update search provider sort logic, and added testing for circle search provider.
This commit is contained in:
67
JSMR.Tests/Fixtures/MariaDbFixture.cs
Normal file
67
JSMR.Tests/Fixtures/MariaDbFixture.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using JSMR.Infrastructure.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Testcontainers.MariaDb;
|
||||
|
||||
namespace JSMR.Tests.Fixtures;
|
||||
|
||||
public class MariaDbFixture : IAsyncLifetime
|
||||
{
|
||||
const int MajorVersion = 10;
|
||||
const int MinorVersion = 11;
|
||||
const int Build = 6;
|
||||
|
||||
public MariaDbContainer? MariaDbContainer { get; private set; }
|
||||
|
||||
public string ConnectionString { get; private set; } = default!;
|
||||
|
||||
public async Task InitializeAsync()
|
||||
{
|
||||
MariaDbContainer = new MariaDbBuilder()
|
||||
.WithImage($"mariadb:{MajorVersion}.{MinorVersion}.{Build}")
|
||||
.Build();
|
||||
|
||||
await MariaDbContainer.StartAsync();
|
||||
|
||||
ConnectionString = MariaDbContainer.GetConnectionString();
|
||||
|
||||
await using AppDbContext context = CreateDbContext();
|
||||
await context.Database.EnsureCreatedAsync();
|
||||
|
||||
await OnInitializedAsync(context);
|
||||
}
|
||||
|
||||
protected virtual Task OnInitializedAsync(AppDbContext context)
|
||||
{
|
||||
return Task.FromResult(Task.CompletedTask);
|
||||
}
|
||||
|
||||
public async Task DisposeAsync()
|
||||
{
|
||||
if (MariaDbContainer is not null)
|
||||
{
|
||||
await MariaDbContainer.StopAsync();
|
||||
await MariaDbContainer.DisposeAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public AppDbContext CreateDbContext()
|
||||
{
|
||||
MySqlServerVersion serverVersion = new(new Version(MajorVersion, MinorVersion, Build));
|
||||
|
||||
DbContextOptions<AppDbContext> options = new DbContextOptionsBuilder<AppDbContext>()
|
||||
.UseMySql(ConnectionString, serverVersion,
|
||||
o => o.EnableRetryOnFailure())
|
||||
.EnableSensitiveDataLogging()
|
||||
.Options;
|
||||
|
||||
return new AppDbContext(options);
|
||||
}
|
||||
|
||||
public async Task ResetAsync()
|
||||
{
|
||||
await using AppDbContext context = CreateDbContext();
|
||||
|
||||
await context.Database.EnsureDeletedAsync();
|
||||
await context.Database.EnsureCreatedAsync();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user