-
Notifications
You must be signed in to change notification settings - Fork 427
/
RobustIntegrationTestSetup.cs
51 lines (42 loc) · 1.58 KB
/
RobustIntegrationTestSetup.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System.Collections.Concurrent;
using NUnit.Framework;
using static Robust.UnitTesting.RobustIntegrationTest;
[SetUpFixture]
// ReSharper disable once CheckNamespace
public sealed class RobustIntegrationTestSetup
{
public void Shutdown()
{
foreach (var client in ClientsReady)
{
client.Dispose();
}
ClientsReady.Clear();
foreach (var server in ServersReady)
{
server.Dispose();
}
ServersReady.Clear();
}
public void PrintTestPoolingInfo()
{
string QueueToString(ConcurrentQueue<string> queue, int total)
{
return $"({queue.Count}/{total}):\n{string.Join("\n", queue)}\n\n";
}
var totalClients = ClientsPooled.Count + ClientsNotPooled.Count;
TestContext.Out.WriteLine($"Clients created {QueueToString(ClientsCreated, totalClients)}");
TestContext.Out.WriteLine($"Clients pooled {QueueToString(ClientsPooled, totalClients)}");
TestContext.Out.WriteLine($"Clients not pooled {QueueToString(ClientsNotPooled, totalClients)}");
var totalServers = ServersPooled.Count + ServersNotPooled.Count;
TestContext.Out.WriteLine($"Servers created {QueueToString(ServersCreated, totalServers)}");
TestContext.Out.WriteLine($"Servers pooled {QueueToString(ServersPooled, totalServers)}");
TestContext.Out.WriteLine($"Servers not pooled {QueueToString(ServersNotPooled, totalServers)}");
}
[OneTimeTearDown]
public void TearDown()
{
Shutdown();
PrintTestPoolingInfo();
}
}