diff --git a/Tests/WebSocketTestClient.cs b/Tests/WebSocketTestClient.cs index 65c9a44..b120184 100644 --- a/Tests/WebSocketTestClient.cs +++ b/Tests/WebSocketTestClient.cs @@ -1,4 +1,5 @@ using System.Text.Json; +using api.Events.Global; using lib; using Websocket.Client; @@ -12,12 +13,20 @@ public class WebSocketTestClient public WebSocketTestClient(string? url = null) { Client = url == null ? new WebsocketClient(new Uri("ws://localhost:" + (Environment.GetEnvironmentVariable("FULLSTACK_API_PORT") ?? "8181"))) : new WebsocketClient(new Uri(url)); - Client.MessageReceived.Subscribe((Action) (msg => + Client.MessageReceived.Subscribe(msg => { BaseDto baseDto = JsonSerializer.Deserialize(msg.Text); + + if (baseDto.eventType == "ServerSendsError") + { + var error = JsonSerializer.Deserialize(msg.Text); + throw new Exception(error!.Error); + } + + lock (ReceivedMessages) ReceivedMessages.Add(baseDto); - })); + }); } public async Task ConnectAsync()