- Remove all // and /// comments from the backend test suite. - Replace hardcoded normalized-form string literals (e.g. NormalizedTitle/ NormalizedName duplicating a title/name in upper case) with a variable plus .ToUpperInvariant(), so the two values can't drift apart.
28 lines
808 B
C#
28 lines
808 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() => 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);
|
|
}
|
|
}
|
|
}
|