using adas_core.Application.Repositories.Interfaces;
using adas_core.Application.Services.Interfaces;
using adas_core.Domain.Enums;
using adas_core.Domain.Models.AppSettings;
using adas_core.Domain.Models.MongoModels;
using adas_core.module.LightBeacons.Services;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using MongoDB.Bson;
using Moq;
using Options = Microsoft.Extensions.Options.Options;
namespace adas_core.Test.Services;
[TestFixture]
public class LightBeaconServiceTest
{
///
/// Initializes the test fixture by creating mock instances of the service's dependencies
/// and instantiating the under test with those mocks.
/// This setup runs before each test to ensure a clean, isolated test environment.
///
[SetUp]
public void Setup()
{
_optionsApiSettings = Options.Create(_apiSettings);
_pocService = new Mock();
_clientMessageService = new Mock();
_subscribersService = new Mock();
_logger = new Mock>();
_lightBeaconRepository = new Mock();
_lightBeaconService = new LightBeaconService(
_optionsApiSettings,
_logger.Object,
_clientMessageService.Object,
_subscribersService.Object,
_pocService.Object,
_lightBeaconRepository.Object
);
}
private LightBeaconService _lightBeaconService = null!;
private readonly ApiSettings _apiSettings = new()
{
BalizaUrl = "http://localhost/info.html",
BalizaPassword = "password"
};
private IOptions _optionsApiSettings = null!;
private Mock> _logger = null!;
private Mock _pocService = null!;
private Mock _clientMessageService = null!;
private Mock _subscribersService = null!;
private Mock _lightBeaconRepository = null!;
///
/// Integration test that verifies the light beacon service returns for a given point of care when the patient has no associated beacon color.
///
[Ignore("Integration test")]
[Test]
public async Task GetBeaconColor()
{
var patient = new Patient
{
UnitId = ObjectId.GenerateNewId(),
PointOfCareId = ObjectId.GenerateNewId()
};
var color = await _lightBeaconService.GetColor(patient.PointOfCareId.Value);
Assert.That(color, Is.EqualTo(
LightBeaconColor.Off));
}
}