public async Task キャンセルテスト() { await Assert.ThrowsExceptionAsync <TaskCanceledException>(() => { return(DiscoveryUtil.GetRoom("TestRoom", 500)); }, "タイムアウトがあるのでキャンセルされる"); }
public async Task ConnectHost(string roomName, CancellationToken token) { InitConnect(token); var room = await DiscoveryUtil.GetRoom(roomName, token); SetConnection(await Connection.ConnectToRoom(room, token: m_Cancellation.Token)); }
public async Task ルーム取得の簡易関数テスト() { byte[] data = Random.GenBytes(64); using var server = new UdpClient(); server.Client.Bind(new IPEndPoint(IPAddress.Any, 0)); var serverIP = server.Client.LocalEndPoint as IPEndPoint; using (var service = new DiscoveryService("FastGetRoom", serverIP, data)) { service.Start(); var room = await DiscoveryUtil.GetRoom("FastGetRoom"); Assert.AreEqual("FastGetRoom", room.Name, "ルーム名が一致"); Assert.AreEqual(To(data), To(room.Data), "設定したデータを受け取れる"); } }