feat: harden recording lifecycle and refresh fnOS UI

This commit is contained in:
2026-08-03 23:45:26 +08:00
parent e5b50ea85c
commit ecc737f0bd
90 changed files with 6995 additions and 1826 deletions
@@ -0,0 +1,71 @@
using LiveRecorder.Domain.Entities;
using LiveRecorder.Domain.Enums;
using LiveRecorder.Infrastructure.Services;
namespace LiveRecorder.Tests;
public sealed class LiveRoomPollingDecisionTests
{
private const string ActiveCode = "skipped_active_session";
private const string ActiveSummary = "Auto-start skipped because an active recording session already exists.";
[Fact]
public void HasAutoStartDecisionChanged_ReturnsFalseForSameActiveSession()
{
var room = CreateRoom();
var sessionId = Guid.NewGuid();
room.SetLastAutoStartDecision(
ActiveCode,
ActiveSummary,
$"activeSessionId={sessionId}",
DateTimeOffset.UtcNow.AddMinutes(-1));
var changed = LiveRoomPollingBackgroundService.HasAutoStartDecisionChanged(
room,
ActiveCode,
ActiveSummary,
$"activeSessionId={sessionId}");
Assert.False(changed);
}
[Fact]
public void HasAutoStartDecisionChanged_ReturnsTrueForNewActiveSession()
{
var room = CreateRoom();
room.SetLastAutoStartDecision(
ActiveCode,
ActiveSummary,
$"activeSessionId={Guid.NewGuid()}",
DateTimeOffset.UtcNow.AddMinutes(-1));
var changed = LiveRoomPollingBackgroundService.HasAutoStartDecisionChanged(
room,
ActiveCode,
ActiveSummary,
$"activeSessionId={Guid.NewGuid()}");
Assert.True(changed);
}
[Fact]
public void HasAutoStartDecisionChanged_ReturnsTrueForFirstSkipDecision()
{
var room = CreateRoom();
var changed = LiveRoomPollingBackgroundService.HasAutoStartDecisionChanged(
room,
ActiveCode,
ActiveSummary,
$"activeSessionId={Guid.NewGuid()}");
Assert.True(changed);
}
private static LiveRoom CreateRoom() => new(
LivePlatformType.Douyin,
"https://live.douyin.com/123456",
"123456",
"https://live.douyin.com/123456",
DateTimeOffset.UtcNow);
}