76 lines
2.1 KiB
C#
76 lines
2.1 KiB
C#
using System;
|
|
using Paca.Mobile.Core;
|
|
using Xunit;
|
|
|
|
namespace Paca.Tests.Mobile;
|
|
|
|
/// <summary>
|
|
/// Gate 195 ~ 198: 모바일 배터리 발열 가드 & 네이티브 햅틱 피드백 기계적 검증
|
|
/// </summary>
|
|
public class MobileBatteryGuardAndHapticGateTests
|
|
{
|
|
private class MockHapticService : IHapticFeedbackService
|
|
{
|
|
public int SuccessCount { get; private set; }
|
|
public int WarningCount { get; private set; }
|
|
public int ClickCount { get; private set; }
|
|
|
|
public void PerformClick() => ClickCount++;
|
|
public void PerformSuccess() => SuccessCount++;
|
|
public void PerformWarning() => WarningCount++;
|
|
}
|
|
|
|
[Fact]
|
|
public void Gate195_BatteryHealthGuard_PausesOnLowBattery_WhenDischarging()
|
|
{
|
|
// 배터리 15% (0.15), 방전 중 (충전기 미연결)
|
|
var shouldPause = BatteryHealthGuard.ShouldPauseDownload(
|
|
batteryLevel: 0.15,
|
|
isCharging: false,
|
|
lowBatteryThreshold: 0.20
|
|
);
|
|
|
|
Assert.True(shouldPause);
|
|
}
|
|
|
|
[Fact]
|
|
public void Gate196_BatteryHealthGuard_Allows_WhenCharging()
|
|
{
|
|
// 배터리 10% (0.10), 충전기 연결됨
|
|
var shouldPause = BatteryHealthGuard.ShouldPauseDownload(
|
|
batteryLevel: 0.10,
|
|
isCharging: true,
|
|
lowBatteryThreshold: 0.20
|
|
);
|
|
|
|
Assert.False(shouldPause);
|
|
}
|
|
|
|
[Fact]
|
|
public void Gate197_HapticFeedbackService_Invocation_Audit()
|
|
{
|
|
var haptic = new MockHapticService();
|
|
|
|
haptic.PerformClick();
|
|
haptic.PerformSuccess();
|
|
haptic.PerformSuccess();
|
|
haptic.PerformWarning();
|
|
|
|
Assert.Equal(1, haptic.ClickCount);
|
|
Assert.Equal(2, haptic.SuccessCount);
|
|
Assert.Equal(1, haptic.WarningCount);
|
|
}
|
|
|
|
[Fact]
|
|
public void Gate198_BatteryStatusReport_Message_Formatting()
|
|
{
|
|
var message = BatteryHealthGuard.GetStatusMessage(
|
|
batteryLevel: 0.12,
|
|
isCharging: false
|
|
);
|
|
|
|
Assert.Contains("12%", message);
|
|
Assert.Contains("일시 정지", message);
|
|
Assert.Contains("충전기", message);
|
|
}
|
|
}
|