using System.Reflection;
using KArtSell.Modules.ModelOperations.Infrastructure;

namespace KArtSell.ModelOperations.UnitTests;

public sealed class DapperModelScheduleRepositoryContractTests
{
    [Theory]
    [InlineData("DispatchedSql")]
    [InlineData("AdvanceSql")]
    [InlineData("ReleaseSql")]
    public void Every_next_due_mutation_requires_the_acquired_dispatch_revision(string fieldName)
    {
        var sql = (string?)typeof(DapperModelScheduleRepository)
            .GetField(fieldName, BindingFlags.NonPublic | BindingFlags.Static)
            ?.GetRawConstantValue();

        Assert.NotNull(sql);
        Assert.Contains("dispatch_revision = @ExpectedDispatchRevision", sql, StringComparison.Ordinal);
        Assert.Contains("lease_owner = @LeaseOwner", sql, StringComparison.Ordinal);
    }
}
