56 lines
1.6 KiB
C#
56 lines
1.6 KiB
C#
using Heimdall.Agent.Services;
|
|||
|
|
|
||
|
|
namespace Heimdall.Agent.Tests;
|
||
|
|
|
||
|
|
public class AdaptiveSnapshotIntervalTests
|
||
|
|
{
|
||
|
|
private readonly AdaptiveSnapshotInterval _interval = new();
|
||
|
|
|
||
|
|
[Fact]
|
||
|
|
public void Idle_Returns1000ms()
|
||
|
|
{
|
||
|
|
_interval.GetInterval(SceneState.Idle, cpuPercent: null).ShouldBe(TimeSpan.FromMilliseconds(1000));
|
||
|
|
}
|
||
|
|
|
||
|
|
[Fact]
|
||
|
|
public void Motion_Returns500ms()
|
||
|
|
{
|
||
|
|
_interval.GetInterval(SceneState.Motion, cpuPercent: null).ShouldBe(TimeSpan.FromMilliseconds(500));
|
||
|
|
}
|
||
|
|
|
||
|
|
[Fact]
|
||
|
|
public void ObjectDetected_Returns200ms()
|
||
|
|
{
|
||
|
|
_interval.GetInterval(SceneState.ObjectDetected, cpuPercent: null).ShouldBe(TimeSpan.FromMilliseconds(200));
|
||
|
|
}
|
||
|
|
|
||
|
|
[Fact]
|
||
|
|
public void HighCpu_DoublesIdleInterval()
|
||
|
|
{
|
||
|
|
_interval.GetInterval(SceneState.Idle, cpuPercent: 85.0).ShouldBe(TimeSpan.FromMilliseconds(2000));
|
||
|
|
}
|
||
|
|
|
||
|
|
[Fact]
|
||
|
|
public void HighCpu_DoublesObjectDetectedInterval()
|
||
|
|
{
|
||
|
|
_interval.GetInterval(SceneState.ObjectDetected, cpuPercent: 95.0).ShouldBe(TimeSpan.FromMilliseconds(400));
|
||
|
|
}
|
||
|
|
|
||
|
|
[Fact]
|
||
|
|
public void CpuBelowThreshold_NoThrottle()
|
||
|
|
{
|
||
|
|
_interval.GetInterval(SceneState.Motion, cpuPercent: 50.0).ShouldBe(TimeSpan.FromMilliseconds(500));
|
||
|
|
}
|
||
|
|
|
||
|
|
[Fact]
|
||
|
|
public void CpuExactlyAtThreshold_Throttles()
|
||
|
|
{
|
||
|
|
_interval.GetInterval(SceneState.Motion, cpuPercent: 80.0).ShouldBe(TimeSpan.FromMilliseconds(1000));
|
||
|
|
}
|
||
|
|
|
||
|
|
[Fact]
|
||
|
|
public void NullCpu_NoThrottle()
|
||
|
|
{
|
||
|
|
_interval.GetInterval(SceneState.Idle, cpuPercent: null).ShouldBe(TimeSpan.FromMilliseconds(1000));
|
||
|
|
}
|
||
|
|
}
|