releases/tests/Paca.Tests/App/DesktopTrayAndGatewayPushGateTests.cs

61 lines
2.1 KiB
C#

using System;
using System.IO;
using System.Text.Json;
using Paca.App;
using Paca.Server.Gateway;
using Paca.Tests.Infrastructure;
using Xunit;
namespace Paca.Tests.App;
/// <summary>
/// Gate 164 ~ 166: 데스크톱 트레이 알림 및 모바일 양방향 실시간 게이트웨이 푸시 스트림 기계적 검증
/// </summary>
public class DesktopTrayAndGatewayPushGateTests
{
[Fact]
public void Gate164_DesktopTrayNotification_Event_Payload()
{
var payload = new DesktopTrayNotificationPayload(
Title: "모바일에서 다운로드 수신",
Message: "Galaxy S24에서 '4K 여행 브이로그' 다운로드를 전송했습니다.",
Type: TrayNotificationType.Info,
Timestamp: DateTimeOffset.UtcNow
);
Assert.Equal("모바일에서 다운로드 수신", payload.Title);
Assert.Equal(TrayNotificationType.Info, payload.Type);
Assert.False(string.IsNullOrWhiteSpace(payload.Message));
}
[Fact]
public void Gate165_GatewayPushEvent_Serialization_And_Types()
{
var pushEvent = new GatewayPushEvent(
EventId: "evt-901",
EventType: GatewayEventType.DownloadFinished,
Title: "다운로드 완료",
PayloadJson: "{\"id\":\"job-12\",\"fileName\":\"Nature_4K.mp4\"}",
OccurredAt: DateTimeOffset.UtcNow
);
var json = JsonSerializer.Serialize(pushEvent);
var deserialized = JsonSerializer.Deserialize<GatewayPushEvent>(json);
Assert.NotNull(deserialized);
Assert.Equal("evt-901", deserialized.EventId);
Assert.Equal(GatewayEventType.DownloadFinished, deserialized.EventType);
Assert.Contains("Nature_4K.mp4", deserialized.PayloadJson);
}
[Fact]
public void Gate166_ServerHost_GatewayEvents_Endpoint_Registered()
{
var serverHostPath = Path.Combine(SourceTree.Root, "src", "Paca.Server", "ServerHost.cs");
Assert.True(File.Exists(serverHostPath), "ServerHost.cs must exist");
var code = File.ReadAllText(serverHostPath);
Assert.Contains("/api/gateway/events", code);
}
}