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(); /// /// Initializes the test environment for by configuring RabbitMQ settings, creating a mocked logger, and instantiating the service under test. /// [SetUp] public void Setup() { //advancedBusMock = new Mock(); _optionsRabbitMqSettings = Options.Create(_rabbitMqSettings); _logger = new Mock>(); _publisherService = new PublisherService( _optionsRabbitMqSettings, _logger.Object); } private PublisherService _publisherService = null!; //private Mock advancedBusMock; private readonly RabbitMqSettings _rabbitMqSettings = new() { ObservationsQueue = "Observations" }; private IOptions _optionsRabbitMqSettings = null!; private Mock> _logger = null!; /// /// Verifies that the publisher service's SendMessage method returns a non-null result when sending a message to the observations queue. /// [Test] public void SendMessage_Return_true() { var newMessage = new Message(); var result = _publisherService.SendMessage(newMessage, _rabbitMqSettings.ObservationsQueue); Assert.That(result, Is.Not.Null); } /// /// Verifies that SendMessageError returns a non-null result when publishing a new to the observations queue. /// [Test] public void SendMessage_Error_Return_true() { var newMessage = new Message(); var result = _publisherService.SendMessageError(newMessage, _rabbitMqSettings.ObservationsQueue); Assert.That(result, Is.Not.Null); } }