Send service info on WebSocket connect

This commit is contained in:
Misaka
2026-05-17 16:42:29 +08:00
parent 4f6c1e2060
commit ad9a9021cc
2 changed files with 45 additions and 1 deletions

View File

@@ -74,6 +74,20 @@ public sealed class SyncMessageTests
Assert.AreEqual(8181, root.GetProperty("port").GetInt32());
}
[TestMethod]
public void WebSocketServiceInfoContainsDeviceName()
{
using var server = new WebSocketServerService(new SyncMessageHandler(new RecordingKeyboardInjectionService()), "Desktop-WIN11");
using var document = JsonDocument.Parse(server.BuildServiceInfoJson());
var root = document.RootElement;
Assert.AreEqual("wirelessTextSyncer.service", root.GetProperty("type").GetString());
Assert.AreEqual(1, root.GetProperty("version").GetInt32());
Assert.AreEqual("Desktop-WIN11", root.GetProperty("name").GetString());
Assert.AreEqual(8181, root.GetProperty("port").GetInt32());
}
private sealed class RecordingKeyboardInjectionService : IKeyboardInjectionService
{
public List<string> Calls { get; } = [];