Skip to content

Commit bcbb26f

Browse files
committed
adapt test to create 2 subscriptions as simultaneously as possible
1 parent 9e4e2d7 commit bcbb26f

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

src/GraphQL.Client/Websocket/GraphQLHttpWebSocket.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.Net.Http;
55
using System.Net.WebSockets;
66
using System.Reactive;
7-
using System.Reactive.Concurrency;
87
using System.Reactive.Disposables;
98
using System.Reactive.Linq;
109
using System.Reactive.Subjects;

tests/GraphQL.Integration.Tests/WebsocketTests/Base.cs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Concurrent;
3+
using System.Collections.Generic;
34
using System.Diagnostics;
45
using System.Linq;
56
using System.Net.WebSockets;
@@ -257,8 +258,26 @@ public async void CanConnectTwoSubscriptionsSimultaneously()
257258
var observable2 = ChatClient.CreateSubscriptionStream<UserJoinedSubscriptionResult>(_subscriptionRequest2, callbackTester2.Invoke);
258259

259260
Debug.WriteLine("subscribing...");
260-
var messagesMonitor = observable1.Observe();
261-
var joinedMonitor = observable2.Observe();
261+
var blocker = new ManualResetEventSlim(false);
262+
FluentTestObserver<GraphQLResponse<MessageAddedSubscriptionResult>> messagesMonitor = null;
263+
FluentTestObserver<GraphQLResponse<UserJoinedSubscriptionResult>> joinedMonitor = null;
264+
265+
var tasks = new List<Task>
266+
{
267+
Task.Run(() =>
268+
{
269+
blocker.Wait();
270+
messagesMonitor = observable1.Observe();
271+
}),
272+
Task.Run(() =>
273+
{
274+
blocker.Wait();
275+
joinedMonitor = observable2.Observe();
276+
})
277+
};
278+
279+
blocker.Set();
280+
await Task.WhenAll(tasks);
262281

263282
await messagesMonitor.Should().PushAsync(1);
264283
messagesMonitor.RecordedMessages.Last().Data.MessageAdded.Content.Should().Be(InitialMessage.Content);

0 commit comments

Comments
 (0)