rama creada apartir de master en j

This commit is contained in:
jrojas
2026-06-26 10:29:23 +02:00
parent 319fd3dfb0
commit c1517fda87
2810 changed files with 1927392 additions and 25392 deletions
+99 -81
View File
@@ -10,26 +10,31 @@ namespace adas_core.Test.Services;
[TestFixture]
public class SendAlertServiceTest
{
/// <summary>
/// Initializes test dependencies for <see cref="SendAlertService"/> unit tests, including
/// RabbitMQ options, a mocked logger, an instance of the service under test, and the set
/// of Windows platform identifiers used to validate platform-specific behavior.
/// </summary>
[SetUp]
public void Setup()
{
_optionsRabbitMqSettings = Options.Create(_rabbitMqSettings);
_logger = new Mock<ILogger<SendAlertService>>();
_sendAlertService = new SendAlertService(
_optionsRabbitMqSettings,
_logger.Object
);
_windowsPlatforms =
[
PlatformID.Win32NT,
PlatformID.Win32S,
PlatformID.Win32Windows,
PlatformID.WinCE
];
}
public void Setup()
{
_optionsRabbitMqSettings = Options.Create(_rabbitMqSettings);
_logger = new Mock<ILogger<SendAlertService>>();
_sendAlertService = new SendAlertService(
_optionsRabbitMqSettings,
_logger.Object
);
_windowsPlatforms =
[
PlatformID.Win32NT,
PlatformID.Win32S,
PlatformID.Win32Windows,
PlatformID.WinCE
];
}
private SendAlertService _sendAlertService = null!;
@@ -40,76 +45,89 @@ public class SendAlertServiceTest
private PlatformID[] _windowsPlatforms = null!;
/// <summary>
/// Verifies that <see cref="_sendAlertService"/>.<c>GetConsumedCpu</c> returns a valid performance CPU
/// reading (non-null with a positive <c>ValueTotal</c>) when executed on a Windows platform. When the
/// host operating system is not Windows, the test is skipped with an ignore notice.
/// </summary>
[Ignore("Integration test to pull request")]
[Test]
public void GetConsumedCpu_Return_PerformanceCpu_data()
{
if (_windowsPlatforms.Contains(Environment.OSVersion.Platform))
[Test]
public void GetConsumedCpu_Return_PerformanceCpu_data()
{
var result = _sendAlertService.GetConsumedCpu();
//result = await sendAlertService.GetConsumedCpu();
Assert.That(result, Is.Not.Null);
Assert.That(result.ValueTotal, Is.GreaterThan(0));
}
else
{
Assert.Ignore("This test can only be run on Windows.");
}
}
[Ignore("Integration test to pull request")]
[Test]
public void GetConsumedRAM_Return_PerformanceRAM_data()
{
if (_windowsPlatforms.Contains(Environment.OSVersion.Platform))
{
var result = _sendAlertService.GetConsumedRam();
//result = await sendAlertService.GetConsumedRAM();
Assert.That(result, Is.Not.Null);
using (Assert.EnterMultipleScope())
if (_windowsPlatforms.Contains(Environment.OSVersion.Platform))
{
Assert.That(result.PercentageConsumed, Is.GreaterThan(0));
Assert.That(result.ValueConsumed, Is.GreaterThan(0));
var result = _sendAlertService.GetConsumedCpu();
//result = await sendAlertService.GetConsumedCpu();
Assert.That(result, Is.Not.Null);
Assert.That(result.ValueTotal, Is.GreaterThan(0));
}
}
else
{
Assert.Ignore("This test can only be run on Windows.");
}
}
[Ignore("Integration test to pull request")]
[Test]
public void GetConsumedStorage_Return_PerformanceStorage_data()
{
if (_windowsPlatforms.Contains(Environment.OSVersion.Platform))
{
List<Performance> performanceList = [];
foreach (var drive in DriveInfo.GetDrives())
if (drive.IsReady)
{
var performance = _sendAlertService.GetConsumedStorage(drive);
performanceList.Add(performance);
}
Assert.That(performanceList, Is.Not.Null);
using (Assert.EnterMultipleScope())
else
{
Assert.That(performanceList, Is.Not.Empty);
Assert.That(performanceList[0].PercentageConsumed, Is.GreaterThan(0));
Assert.That(performanceList[0].ValueConsumed, Is.GreaterThan(0));
Assert.That(performanceList[0].ValueTotal, Is.GreaterThan(0));
Assert.Ignore("This test can only be run on Windows.");
}
}
else
/// <summary>
/// Verifies that <c>GetConsumedRam</c> returns a non-null performance RAM data object with positive values
/// for <c>PercentageConsumed</c>, <c>ValueConsumed</c>, and <c>ValueTotal</c>. The test only executes on
/// Windows platforms and is ignored on other operating systems.
/// </summary>
[Ignore("Integration test to pull request")]
[Test]
public void GetConsumedRAM_Return_PerformanceRAM_data()
{
Assert.Ignore("This test can only be run on Windows.");
if (_windowsPlatforms.Contains(Environment.OSVersion.Platform))
{
var result = _sendAlertService.GetConsumedRam();
//result = await sendAlertService.GetConsumedRAM();
Assert.That(result, Is.Not.Null);
using (Assert.EnterMultipleScope())
{
Assert.That(result.PercentageConsumed, Is.GreaterThan(0));
Assert.That(result.ValueConsumed, Is.GreaterThan(0));
Assert.That(result.ValueTotal, Is.GreaterThan(0));
}
}
else
{
Assert.Ignore("This test can only be run on Windows.");
}
}
/// <summary>
/// Integration test that verifies the GetConsumedStorage method returns valid Performance data with positive percentage and value metrics for all ready drives on Windows platforms. The test is ignored when executed on a non-Windows platform.
/// </summary>
[Ignore("Integration test to pull request")]
[Test]
public void GetConsumedStorage_Return_PerformanceStorage_data()
{
if (_windowsPlatforms.Contains(Environment.OSVersion.Platform))
{
List<Performance> performanceList = [];
foreach (var drive in DriveInfo.GetDrives())
if (drive.IsReady)
{
var performance = _sendAlertService.GetConsumedStorage(drive);
performanceList.Add(performance);
}
Assert.That(performanceList, Is.Not.Null);
using (Assert.EnterMultipleScope())
{
Assert.That(performanceList, Is.Not.Empty);
Assert.That(performanceList[0].PercentageConsumed, Is.GreaterThan(0));
Assert.That(performanceList[0].ValueConsumed, Is.GreaterThan(0));
Assert.That(performanceList[0].ValueTotal, Is.GreaterThan(0));
}
}
else
{
Assert.Ignore("This test can only be run on Windows.");
}
}
}
}