using Baya.Application.Features.Messaging.Commands.AutoCreateCoordinationTicket;
using Baya.Application.Features.Messaging.Commands.OpenTicket;
using Baya.Application.Models.Common;
using Baya.Application.Models.Messaging;
using Mediator;
using NSubstitute;

namespace Baya.Test.Foundation;

/// <summary>
/// Builds an <see cref="ISender"/> substitute that satisfies the b15 ticket hooks the money-path handlers now
/// dispatch — <c>OpenTicket</c> (the refund's auto-anchored ticket) and <c>AutoCreateCoordinationTicket</c> (on
/// booking confirmation) — so foundation unit tests can construct those handlers without wiring the real mediator.
/// </summary>
public static class TestSenders
{
    public static ISender WithTicketHooks()
    {
        var sender = Substitute.For<ISender>();
        sender.Send(Arg.Any<OpenTicketCommand>(), Arg.Any<CancellationToken>())
            .Returns(ValueTask.FromResult(OperationResult<OpenTicketResult>.SuccessResult(
                new OpenTicketResult(1, "TKT-TEST01", "open", "refund"))));
        sender.Send(Arg.Any<AutoCreateCoordinationTicketCommand>(), Arg.Any<CancellationToken>())
            .Returns(ValueTask.FromResult(OperationResult<bool>.SuccessResult(true)));
        return sender;
    }
}
