Use invariant culture when formatting ids, put cancellation tokens last in endpoint handlers, remove the CS8618 pragmas and keep only the analyzer overrides that still apply.
31 lines
809 B
C#
31 lines
809 B
C#
using Microsoft.Extensions.Logging;
|
|
using Microsoft.Extensions.Logging.Abstractions;
|
|
using Xunit;
|
|
|
|
namespace Musify.Application.Tests.TestSupport;
|
|
|
|
public abstract class HandlerTestBase : IAsyncLifetime
|
|
{
|
|
private TestDatabase database = null!;
|
|
|
|
protected TestDatabase Database => database;
|
|
|
|
public async ValueTask InitializeAsync() => database = await TestDatabase.CreateAsync();
|
|
|
|
public ValueTask DisposeAsync()
|
|
{
|
|
GC.SuppressFinalize(this);
|
|
return database.DisposeAsync();
|
|
}
|
|
|
|
protected static ILogger<T> NoOpLogger<T>() => NullLogger<T>.Instance;
|
|
|
|
protected async Task SeedAsync(params object[] entities)
|
|
{
|
|
foreach (var entity in entities)
|
|
Database.Add(entity);
|
|
|
|
await Database.SaveChangesAsync(CancellationToken.None);
|
|
}
|
|
}
|