1
- // Copyright (c) .NET Foundation. All rights reserved.
1
+ // Copyright (c) .NET Foundation. All rights reserved.
2
2
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3
3
4
- using System ;
5
- using System . Threading ;
6
4
using System . Threading . Tasks ;
7
5
using Microsoft . AspNetCore . SignalR . Protocol ;
8
6
using Microsoft . AspNetCore . SignalR . Tests ;
9
7
using Xunit ;
10
8
11
9
namespace Microsoft . AspNetCore . SignalR . Specification . Tests
12
10
{
13
- public abstract class ScaleoutHubLifetimeManagerTests < TBackplane > : HubLifetimeManagerTestsBase < MyHub >
11
+ /// <summary>
12
+ /// Base test class for lifetime manager implementations that support server scale-out.
13
+ /// </summary>
14
+ /// <typeparam name="TBackplane">An in-memory implementation of the backplane that <see cref="HubLifetimeManager{THub}"/>s communicate with.</typeparam>
15
+ public abstract class ScaleoutHubLifetimeManagerTests < TBackplane > : HubLifetimeManagerTestsBase < Hub >
14
16
{
17
+ /// <summary>
18
+ /// Method to create an implementation of an in-memory backplane for use in tests.
19
+ /// </summary>
20
+ /// <returns>The backplane implementation.</returns>
15
21
public abstract TBackplane CreateBackplane ( ) ;
16
- public abstract HubLifetimeManager < MyHub > CreateNewHubLifetimeManager ( TBackplane backplane ) ;
22
+
23
+ /// <summary>
24
+ /// Method to create an implementation of <see cref="HubLifetimeManager{THub}"/> that uses the backplane from <see cref="CreateBackplane"/>.
25
+ /// </summary>
26
+ /// <param name="backplane">The backplane implementation for use in the <see cref="HubLifetimeManager{THub}"/>.</param>
27
+ /// <returns></returns>
28
+ public abstract HubLifetimeManager < Hub > CreateNewHubLifetimeManager ( TBackplane backplane ) ;
17
29
18
30
private async Task AssertMessageAsync ( TestClient client )
19
31
{
@@ -23,9 +35,12 @@ private async Task AssertMessageAsync(TestClient client)
23
35
Assert . Equal ( "World" , ( string ) message . Arguments [ 0 ] ) ;
24
36
}
25
37
38
+ /// <summary>
39
+ /// Specification test for SignalR HubLifetimeManager.
40
+ /// </summary>
41
+ /// <returns>A <see cref="Task"/> representing the asynchronous completion of the test.</returns>
26
42
[ Fact ]
27
43
public async Task InvokeAllAsyncWithMultipleServersWritesToAllConnectionsOutput ( )
28
-
29
44
{
30
45
var backplane = CreateBackplane ( ) ;
31
46
var manager1 = CreateNewHubLifetimeManager ( backplane ) ;
@@ -47,6 +62,10 @@ public async Task InvokeAllAsyncWithMultipleServersWritesToAllConnectionsOutput(
47
62
}
48
63
}
49
64
65
+ /// <summary>
66
+ /// Specification test for SignalR HubLifetimeManager.
67
+ /// </summary>
68
+ /// <returns>A <see cref="Task"/> representing the asynchronous completion of the test.</returns>
50
69
[ Fact ]
51
70
public async Task InvokeAllAsyncWithMultipleServersDoesNotWriteToDisconnectedConnectionsOutput ( )
52
71
{
@@ -73,6 +92,10 @@ public async Task InvokeAllAsyncWithMultipleServersDoesNotWriteToDisconnectedCon
73
92
}
74
93
}
75
94
95
+ /// <summary>
96
+ /// Specification test for SignalR HubLifetimeManager.
97
+ /// </summary>
98
+ /// <returns>A <see cref="Task"/> representing the asynchronous completion of the test.</returns>
76
99
[ Fact ]
77
100
public async Task InvokeConnectionAsyncOnServerWithoutConnectionWritesOutputToConnection ( )
78
101
{
@@ -93,6 +116,10 @@ public async Task InvokeConnectionAsyncOnServerWithoutConnectionWritesOutputToCo
93
116
}
94
117
}
95
118
119
+ /// <summary>
120
+ /// Specification test for SignalR HubLifetimeManager.
121
+ /// </summary>
122
+ /// <returns>A <see cref="Task"/> representing the asynchronous completion of the test.</returns>
96
123
[ Fact ]
97
124
public async Task InvokeGroupAsyncOnServerWithoutConnectionWritesOutputToGroupConnection ( )
98
125
{
@@ -115,6 +142,10 @@ public async Task InvokeGroupAsyncOnServerWithoutConnectionWritesOutputToGroupCo
115
142
}
116
143
}
117
144
145
+ /// <summary>
146
+ /// Specification test for SignalR HubLifetimeManager.
147
+ /// </summary>
148
+ /// <returns>A <see cref="Task"/> representing the asynchronous completion of the test.</returns>
118
149
[ Fact ]
119
150
public async Task DisconnectConnectionRemovesConnectionFromGroup ( )
120
151
{
@@ -137,6 +168,10 @@ public async Task DisconnectConnectionRemovesConnectionFromGroup()
137
168
}
138
169
}
139
170
171
+ /// <summary>
172
+ /// Specification test for SignalR HubLifetimeManager.
173
+ /// </summary>
174
+ /// <returns>A <see cref="Task"/> representing the asynchronous completion of the test.</returns>
140
175
[ Fact ]
141
176
public async Task RemoveGroupFromLocalConnectionNotInGroupDoesNothing ( )
142
177
{
@@ -153,6 +188,10 @@ public async Task RemoveGroupFromLocalConnectionNotInGroupDoesNothing()
153
188
}
154
189
}
155
190
191
+ /// <summary>
192
+ /// Specification test for SignalR HubLifetimeManager.
193
+ /// </summary>
194
+ /// <returns>A <see cref="Task"/> representing the asynchronous completion of the test.</returns>
156
195
[ Fact ]
157
196
public async Task RemoveGroupFromConnectionOnDifferentServerNotInGroupDoesNothing ( )
158
197
{
@@ -170,6 +209,10 @@ public async Task RemoveGroupFromConnectionOnDifferentServerNotInGroupDoesNothin
170
209
}
171
210
}
172
211
212
+ /// <summary>
213
+ /// Specification test for SignalR HubLifetimeManager.
214
+ /// </summary>
215
+ /// <returns>A <see cref="Task"/> representing the asynchronous completion of the test.</returns>
173
216
[ Fact ]
174
217
public async Task AddGroupAsyncForConnectionOnDifferentServerWorks ( )
175
218
{
@@ -191,6 +234,10 @@ public async Task AddGroupAsyncForConnectionOnDifferentServerWorks()
191
234
}
192
235
}
193
236
237
+ /// <summary>
238
+ /// Specification test for SignalR HubLifetimeManager.
239
+ /// </summary>
240
+ /// <returns>A <see cref="Task"/> representing the asynchronous completion of the test.</returns>
194
241
[ Fact ]
195
242
public async Task AddGroupAsyncForLocalConnectionAlreadyInGroupDoesNothing ( )
196
243
{
@@ -213,6 +260,10 @@ public async Task AddGroupAsyncForLocalConnectionAlreadyInGroupDoesNothing()
213
260
}
214
261
}
215
262
263
+ /// <summary>
264
+ /// Specification test for SignalR HubLifetimeManager.
265
+ /// </summary>
266
+ /// <returns>A <see cref="Task"/> representing the asynchronous completion of the test.</returns>
216
267
[ Fact ]
217
268
public async Task AddGroupAsyncForConnectionOnDifferentServerAlreadyInGroupDoesNothing ( )
218
269
{
@@ -236,6 +287,10 @@ public async Task AddGroupAsyncForConnectionOnDifferentServerAlreadyInGroupDoesN
236
287
}
237
288
}
238
289
290
+ /// <summary>
291
+ /// Specification test for SignalR HubLifetimeManager.
292
+ /// </summary>
293
+ /// <returns>A <see cref="Task"/> representing the asynchronous completion of the test.</returns>
239
294
[ Fact ]
240
295
public async Task RemoveGroupAsyncForConnectionOnDifferentServerWorks ( )
241
296
{
@@ -263,6 +318,10 @@ public async Task RemoveGroupAsyncForConnectionOnDifferentServerWorks()
263
318
}
264
319
}
265
320
321
+ /// <summary>
322
+ /// Specification test for SignalR HubLifetimeManager.
323
+ /// </summary>
324
+ /// <returns>A <see cref="Task"/> representing the asynchronous completion of the test.</returns>
266
325
[ Fact ]
267
326
public async Task InvokeConnectionAsyncForLocalConnectionDoesNotPublishToBackplane ( )
268
327
{
@@ -285,6 +344,10 @@ public async Task InvokeConnectionAsyncForLocalConnectionDoesNotPublishToBackpla
285
344
}
286
345
}
287
346
347
+ /// <summary>
348
+ /// Specification test for SignalR HubLifetimeManager.
349
+ /// </summary>
350
+ /// <returns>A <see cref="Task"/> representing the asynchronous completion of the test.</returns>
288
351
[ Fact ]
289
352
public async Task WritingToRemoteConnectionThatFailsDoesNotThrow ( )
290
353
{
@@ -305,6 +368,10 @@ public async Task WritingToRemoteConnectionThatFailsDoesNotThrow()
305
368
}
306
369
}
307
370
371
+ /// <summary>
372
+ /// Specification test for SignalR HubLifetimeManager.
373
+ /// </summary>
374
+ /// <returns>A <see cref="Task"/> representing the asynchronous completion of the test.</returns>
308
375
[ Fact ]
309
376
public async Task WritingToGroupWithOneConnectionFailingSecondConnectionStillReceivesMessage ( )
310
377
{
@@ -336,6 +403,10 @@ public async Task WritingToGroupWithOneConnectionFailingSecondConnectionStillRec
336
403
}
337
404
}
338
405
406
+ /// <summary>
407
+ /// Specification test for SignalR HubLifetimeManager.
408
+ /// </summary>
409
+ /// <returns>A <see cref="Task"/> representing the asynchronous completion of the test.</returns>
339
410
[ Fact ]
340
411
public async Task InvokeUserSendsToAllConnectionsForUser ( )
341
412
{
@@ -360,6 +431,10 @@ public async Task InvokeUserSendsToAllConnectionsForUser()
360
431
}
361
432
}
362
433
434
+ /// <summary>
435
+ /// Specification test for SignalR HubLifetimeManager.
436
+ /// </summary>
437
+ /// <returns>A <see cref="Task"/> representing the asynchronous completion of the test.</returns>
363
438
[ Fact ]
364
439
public async Task StillSubscribedToUserAfterOneOfMultipleConnectionsAssociatedWithUserDisconnects ( )
365
440
{
@@ -389,7 +464,4 @@ public async Task StillSubscribedToUserAfterOneOfMultipleConnectionsAssociatedWi
389
464
}
390
465
}
391
466
}
392
- public class MyHub : Hub
393
- {
394
- }
395
467
}
0 commit comments