Strip comments and dedupe normalized literals in backend tests
- 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.
This commit is contained in:
@@ -4,12 +4,6 @@ using Xunit;
|
||||
|
||||
namespace Musify.Application.Tests.TestSupport
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for handler tests: gives every test method its own empty, isolated
|
||||
/// <see cref="TestDatabase"/> (xUnit creates a new instance of the test class per test method,
|
||||
/// so there is no state to reset between tests) and a no-op logger factory for handlers that
|
||||
/// take an <see cref="ILogger{TCategoryName}"/>.
|
||||
/// </summary>
|
||||
public abstract class HandlerTestBase : IAsyncLifetime
|
||||
{
|
||||
private TestDatabase database = null!;
|
||||
@@ -22,7 +16,6 @@ namespace Musify.Application.Tests.TestSupport
|
||||
|
||||
protected static ILogger<T> NoOpLogger<T>() => NullLogger<T>.Instance;
|
||||
|
||||
/// <summary>Adds the entities and persists them, so handlers under test see committed data.</summary>
|
||||
protected async Task SeedAsync(params object[] entities)
|
||||
{
|
||||
foreach (var entity in entities)
|
||||
|
||||
@@ -2,10 +2,6 @@ using Musify.Application.Configuration;
|
||||
|
||||
namespace Musify.Application.Tests.TestSupport
|
||||
{
|
||||
/// <summary>
|
||||
/// Configuration POCOs with every <c>required</c> member filled and the rest left at their
|
||||
/// production defaults, so handler tests don't have to know which fields matter for them.
|
||||
/// </summary>
|
||||
public static class TestConfigurations
|
||||
{
|
||||
public static ApplicationStorageConfiguration Storage(string bucket = "test-bucket") =>
|
||||
|
||||
@@ -5,25 +5,6 @@ using Musify.Domain.Entities;
|
||||
|
||||
namespace Musify.Application.Tests.TestSupport
|
||||
{
|
||||
/// <summary>
|
||||
/// An <see cref="IDatabase"/> backed by a private, in-memory SQLite database.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// <see cref="IDatabase"/> exposes raw <see cref="DbSet{TEntity}"/> properties, so handlers
|
||||
/// compose real LINQ queries (<c>Where</c>, <c>Select</c>, <c>Include</c>, ...) against it.
|
||||
/// Substituting <see cref="IDatabase"/> with a mock cannot express that — there is no
|
||||
/// <see cref="IQueryable{T}"/> provider behind a mock. SQLite's in-memory mode gives us a real
|
||||
/// relational engine instead: fast, no external dependency, and — unlike the EF Core InMemory
|
||||
/// provider — it actually supports transactions, which two handlers rely on.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// The model mirrors the parts of <c>Musify.Infrastructure.Persistence.Database</c> that affect
|
||||
/// query shape (owned types, table-per-type inheritance, unique indexes). MassTransit outbox/saga
|
||||
/// state and Postgres-specific configuration are left out — the Application layer never touches
|
||||
/// them.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public sealed class TestDatabase : DbContext, IDatabase
|
||||
{
|
||||
private readonly SqliteConnection connection;
|
||||
@@ -34,11 +15,6 @@ namespace Musify.Application.Tests.TestSupport
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a fresh, empty database with its own private connection. Call <see cref="Seed"/>
|
||||
/// (via <see cref="Seeding.EntitySeedExtensions"/>) to populate it, then <see cref="DisposeAsync"/>
|
||||
/// when the test is done.
|
||||
/// </summary>
|
||||
public static async Task<TestDatabase> CreateAsync()
|
||||
{
|
||||
var connection = new SqliteConnection("Filename=:memory:");
|
||||
|
||||
@@ -3,11 +3,6 @@ using Musify.Domain.ValueObjects;
|
||||
|
||||
namespace Musify.Application.Tests.TestSupport
|
||||
{
|
||||
/// <summary>
|
||||
/// Builds fully-populated domain entities for tests, with sensible defaults for every
|
||||
/// <c>required</c> member. Every factory always returns a valid instance — never null — so
|
||||
/// callers never need a null check on what this class hands back.
|
||||
/// </summary>
|
||||
public static class TestEntities
|
||||
{
|
||||
public static User User(
|
||||
|
||||
Reference in New Issue
Block a user