using adas_core.Domain.Models.AppSettings;
using adas_core.Infrastructure.Services;
using EasyNetQ;
using EasyNetQ.SystemMessages;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Moq;

namespace adas_core.Test.Services;

[TestFixture]
public class PublisherServiceTest
{
    //private static readonly DateTime now = DateTime.Now;
    //private static readonly ObjectId patientId = ObjectId.GenerateNewId();

    [SetUp]
    public void Setup()
    {
        //advancedBusMock = new Mock<IAdvancedBus>();

        _optionsRabbitMqSettings = Options.Create(_rabbitMqSettings);

        _logger = new Mock<ILogger<PublisherService>>();

        _publisherService = new PublisherService(
            _optionsRabbitMqSettings,
            _logger.Object);
    }

    private PublisherService _publisherService = null!;
    //private Mock<IAdvancedBus> advancedBusMock;

    private readonly RabbitMqSettings _rabbitMqSettings = new()
    {
        ObservationsQueue = "Observations"
    };

    private IOptions<RabbitMqSettings> _optionsRabbitMqSettings = null!;

    private Mock<ILogger<PublisherService>> _logger = null!;

    [Test]
    public void SendMessage_Return_true()
    {
        var newMessage = new Message<string>();

        var result = _publisherService.SendMessage(newMessage, _rabbitMqSettings.ObservationsQueue);

        Assert.That(result, Is.Not.Null);
    }

    [Test]
    public void SendMessage_Error_Return_true()
    {
        var newMessage = new Message<Error>();

        var result = _publisherService.SendMessageError(newMessage, _rabbitMqSettings.ObservationsQueue);

        Assert.That(result, Is.Not.Null);
    }
}