-
Notifications
You must be signed in to change notification settings - Fork 459
Expand file tree
/
Copy pathNetworkLogTests.cs
More file actions
47 lines (42 loc) · 1.7 KB
/
NetworkLogTests.cs
File metadata and controls
47 lines (42 loc) · 1.7 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 Unity.Netcode.TestHelpers.Runtime;
using UnityEngine.TestTools;
namespace Unity.Netcode.RuntimeTests
{
/// <summary>
/// Validates edge cases with <see cref="NetworkLog"/>
/// </summary>
internal class NetworkLogTests : NetcodeIntegrationTest
{
protected override int NumberOfClients => 0;
private bool m_ServerStopped;
/// <summary>
/// Validates that if no <see cref="NetworkManager"/> exists,
/// you can still use NetworkLog with the caveat when one does
/// not exist it will only log locally.
/// (is topology agnostic)
/// </summary>
[UnityTest]
public IEnumerator UseNetworkLogWithNoNetworkManager()
{
m_ServerStopped = false;
var authority = GetAuthorityNetworkManager();
authority.OnServerStopped += OnServerStopped;
authority.Shutdown();
yield return WaitForConditionOrTimeOut(() => m_ServerStopped);
AssertOnTimeout($"Timed out waiting for {nameof(NetworkManager)} to stop!");
// Assure it is destroyed.
UnityEngine.Object.Destroy(authority);
authority = null;
// Clear out the singleton to assure NetworkLog has no references to a NetworkManager
NetworkManager.ResetSingleton();
// Validate you can use NetworkLog without any NetworkManager instance.
NetworkLog.LogInfoServer($"Test a message to the server with no {nameof(NetworkManager)}.");
// No exceptions thrown is considered passing.
}
private void OnServerStopped(bool obj)
{
m_ServerStopped = true;
}
}
}