using NATS.Server.JetStream;
using NATS.Server.JetStream.Api;

namespace NATS.Server.Tests;

public class JetStreamApiRouterCoverageTests
{
    [Theory]
    [InlineData("$JS.API.STREAM.UPDATE.ORDERS")]
    [InlineData("$JS.API.STREAM.DELETE.ORDERS")]
    [InlineData("$JS.API.STREAM.PURGE.ORDERS")]
    [InlineData("$JS.API.CONSUMER.DELETE.ORDERS.DUR")]
    [InlineData("$JS.API.CONSUMER.MSG.NEXT.ORDERS.DUR")]
    public void Router_recognizes_remaining_subject_families(string subject)
    {
        var streams = new StreamManager();
        _ = streams.CreateOrUpdate(new NATS.Server.JetStream.Models.StreamConfig
        {
            Name = "ORDERS",
            Subjects = ["orders.*"],
        });
        var consumers = new ConsumerManager();
        _ = consumers.CreateOrUpdate("ORDERS", new NATS.Server.JetStream.Models.ConsumerConfig
        {
            DurableName = "DUR",
        });

        var router = new JetStreamApiRouter(streams, consumers);
        var response = router.Route(subject, "{}"u8);
        response.Error.ShouldBeNull();
    }
}
