using NATS.Server.JetStream.Models;
using NATS.Server.JetStream.Publish;
using NATS.Server.JetStream.Validation;

namespace NATS.Server.JetStream.Tests;

public class JetStreamStreamRuntimeParityTests
{
    [Fact]
    public void Stream_runtime_enforces_retention_and_size_preconditions()
    {
        var invalid = new StreamConfig
        {
            Name = "ORDERS",
            Subjects = ["orders.*"],
            Retention = RetentionPolicy.WorkQueue,
            MaxConsumers = 0,
            MaxMsgSize = -1,
        };

        var result = JetStreamConfigValidator.Validate(invalid);
        result.IsValid.ShouldBeFalse();

        var preconditions = new PublishPreconditions();
        preconditions.Record("m1", 1);
        preconditions.IsDuplicate("m1", duplicateWindowMs: 10_000, out var existing).ShouldBeTrue();
        existing.ShouldBe((ulong)1);
    }
}
