using System.Net;
using System.Text;
using adas_core.Application.Services;
using adas_core.Application.Services.Interfaces;
using adas_core.Domain.Models;
using adas_core.Domain.Models.AppSettings;
using adas_core.Domain.Models.Recording;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Moq;
using Moq.Protected;
using Newtonsoft.Json;
using Error = EasyNetQ.SystemMessages.Error;
using Options = Microsoft.Extensions.Options.Options;
namespace adas_core.Test.Services;
[TestFixture]
public class RecordingServiceTest
{
///
/// Sets up the test environment for by initializing configuration options, creating mock
/// dependencies (logger, HTTP client factory, publisher, authentication, client message, subscribers, and patient services),
/// and configuring the publisher mock to successfully send both regular messages and errors.
///
[SetUp]
public void Setup()
{
_optionsApiSettings = Options.Create(_apiSettings);
_optionsRabbitMqSettings = Options.Create(_rabbitMqSettings);
_optionsRecordingSettings = Options.Create(_recordingSettings);
_publisherServiceMock = new Mock();
_logger = new Mock>();
_authServiceMock = new Mock();
_httpClientFactoryMock = new Mock();
_httpMessageHandlerMock = new Mock();
_clientMessageServiceMock = new Mock();
_subscribersServiceMock = new Mock();
_patientServiceMock = new Mock>();
var client = new HttpClient(_httpMessageHandlerMock.Object);
_httpClientFactoryMock.Setup(c => c.CreateClient(It.IsAny())).Returns(client);
_recordingService = new RecordingService(
_optionsRabbitMqSettings,
_optionsRecordingSettings,
_logger.Object,
_httpClientFactoryMock.Object,
_publisherServiceMock.Object,
_authServiceMock.Object,
_optionsApiSettings,
_clientMessageServiceMock.Object,
_subscribersServiceMock.Object,
_patientServiceMock.Object
);
// Set up the mock object to return a specific value when a method is called
_publisherServiceMock.Setup(x => x.SendMessage(It.IsAny