Files
Heimdall/tests/Heimdall.Agent.Tests/SystemInfoTests.cs
T

39 lines
1.0 KiB
C#

using Heimdall.Agent.Services;
namespace Heimdall.Agent.Tests;
public class SystemInfoTests
{
[Fact]
public void GetPhysicalMemory_ReturnsNonNegativeValue()
{
var mem = SystemInfo.GetPhysicalMemory();
mem.ShouldBeGreaterThanOrEqualTo(0);
}
[Fact]
public void GetPhysicalMemory_OnNonMacOS_FallsBackToZero()
{
// On non-macOS platforms, sysctl may not exist → returns 0
// On macOS with sysctl working, returns actual memory
var mem = SystemInfo.GetPhysicalMemory();
if (OperatingSystem.IsMacOS())
{
// Should return actual physical memory (> 0)
mem.ShouldBeGreaterThan(0);
}
// On Linux returns 0 because sysctl either doesn't exist or hw.memsize is unknown
}
[Fact]
public void GetPhysicalMemory_CalledMultipleTimes_DoesNotThrow()
{
for (int i = 0; i < 5; i++)
{
var mem = SystemInfo.GetPhysicalMemory();
mem.ShouldBeGreaterThanOrEqualTo(0);
}
}
}