-
Notifications
You must be signed in to change notification settings - Fork 459
Expand file tree
/
Copy pathTransportTests.cs
More file actions
47 lines (35 loc) · 1.91 KB
/
TransportTests.cs
File metadata and controls
47 lines (35 loc) · 1.91 KB
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
using System.Collections;
using NUnit.Framework;
using Unity.Netcode.TestHelpers.Runtime;
using UnityEngine.TestTools;
namespace Unity.Netcode.RuntimeTests
{
[TestFixture(HostOrServer.Server)]
[TestFixture(HostOrServer.Host)]
internal class TransportTests : NetcodeIntegrationTest
{
protected override int NumberOfClients => 2;
protected override bool m_UseMockTransport => true;
public TransportTests(HostOrServer hostOrServer) : base(hostOrServer) { }
[UnityTest]
public IEnumerator MultipleDisconnectEventsNoop()
{
var clientToDisconnect = GetNonAuthorityNetworkManager(0);
var clientTransport = clientToDisconnect.NetworkConfig.NetworkTransport;
var otherClient = GetNonAuthorityNetworkManager(1);
// Send multiple disconnect events
clientTransport.DisconnectLocalClient();
clientTransport.DisconnectLocalClient();
// completely stop and clean up the client
yield return StopOneClient(clientToDisconnect);
var expectedConnectedClients = m_UseHost ? NumberOfClients : NumberOfClients - 1;
yield return WaitForConditionOrTimeOut(() => otherClient.ConnectedClientsIds.Count == expectedConnectedClients);
AssertOnTimeout($"Incorrect number of connected clients. Expected: {expectedConnectedClients}, have: {otherClient.ConnectedClientsIds.Count}");
// Start a new client to ensure everything is still working
yield return CreateAndStartNewClient();
var newExpectedClients = m_UseHost ? NumberOfClients + 1 : NumberOfClients;
yield return WaitForConditionOrTimeOut(() => otherClient.ConnectedClientsIds.Count == newExpectedClients);
AssertOnTimeout($"Incorrect number of connected clients. Expected: {newExpectedClients}, have: {otherClient.ConnectedClientsIds.Count}");
}
}
}