diff options
author | crupest <crupest@outlook.com> | 2021-06-02 19:07:48 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-06-02 19:07:48 +0800 |
commit | 9f126dafa8c09737f97bb42b583e3befe7d13c5b (patch) | |
tree | c7248ea3e823f3d519676fffa4eb98d6448a59f5 /BackEnd/Timeline.Tests/IntegratedTests | |
parent | 6e5f1f82c175f44260a8284ec8fbdbff12ca4940 (diff) | |
download | timeline-9f126dafa8c09737f97bb42b583e3befe7d13c5b.tar.gz timeline-9f126dafa8c09737f97bb42b583e3befe7d13c5b.tar.bz2 timeline-9f126dafa8c09737f97bb42b583e3befe7d13c5b.zip |
...
Diffstat (limited to 'BackEnd/Timeline.Tests/IntegratedTests')
-rw-r--r-- | BackEnd/Timeline.Tests/IntegratedTests/TimelineHubTest.cs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/BackEnd/Timeline.Tests/IntegratedTests/TimelineHubTest.cs b/BackEnd/Timeline.Tests/IntegratedTests/TimelineHubTest.cs index 0c4225c6..c9986177 100644 --- a/BackEnd/Timeline.Tests/IntegratedTests/TimelineHubTest.cs +++ b/BackEnd/Timeline.Tests/IntegratedTests/TimelineHubTest.cs @@ -1,6 +1,7 @@ using FluentAssertions;
using Microsoft.AspNetCore.SignalR.Client;
using System;
+using System.Threading;
using System.Threading.Tasks;
using Timeline.SignalRHub;
using Xunit;
@@ -33,12 +34,15 @@ namespace Timeline.Tests.IntegratedTests await using var connection = CreateConnection(token);
+ using SemaphoreSlim semaphore = new SemaphoreSlim(0);
+
var changed = false;
connection.On<string>(nameof(ITimelineClient.OnTimelinePostChanged), (timelineName) =>
{
timelineName.Should().Be(generator(1));
changed = true;
+ semaphore.Release();
});
await connection.StartAsync();
@@ -47,11 +51,13 @@ namespace Timeline.Tests.IntegratedTests using var client = await CreateClientAsUser();
await client.TestPostAsync($"timelines/{generator(1)}/posts", TimelinePostTest.CreateTextPostRequest("aaa"));
+ await semaphore.WaitAsync();
changed.Should().BeFalse();
await connection.InvokeAsync(nameof(TimelineHub.SubscribeTimelinePostChange), generator(1));
await client.TestPostAsync($"timelines/{generator(1)}/posts", TimelinePostTest.CreateTextPostRequest("bbb"));
+ await semaphore.WaitAsync();
changed.Should().BeTrue();
changed = false;
|