mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
Tests: Mirrortest isClient check and make sure it's actually set (#3094)
* Tests: guarantee isClient == true * fix
This commit is contained in:
parent
39632fc5e5
commit
2610dfc1b3
@ -182,6 +182,11 @@ protected void CreateNetworkedAndSpawn(
|
||||
NetworkServer.Spawn(serverGO, ownerConnection);
|
||||
ProcessMessages();
|
||||
|
||||
// double check that client object's isClient is really true!
|
||||
// previously a test magically failed because isClient was false
|
||||
// even though it should've been true!
|
||||
Assert.That(clientIdentity.isClient, Is.True);
|
||||
|
||||
// double check that we have authority if we passed an owner connection
|
||||
if (ownerConnection != null)
|
||||
Debug.Assert(clientIdentity.hasAuthority == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
@ -237,6 +242,11 @@ protected void CreateNetworkedAndSpawn<T>(
|
||||
NetworkServer.Spawn(serverGO, ownerConnection);
|
||||
ProcessMessages();
|
||||
|
||||
// double check that client object's isClient is really true!
|
||||
// previously a test magically failed because isClient was false
|
||||
// even though it should've been true!
|
||||
Assert.That(clientIdentity.isClient, Is.True);
|
||||
|
||||
// double check that we have authority if we passed an owner connection
|
||||
if (ownerConnection != null)
|
||||
Debug.Assert(clientComponent.hasAuthority == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
@ -297,6 +307,11 @@ protected void CreateNetworkedAndSpawn<T, U>(
|
||||
NetworkServer.Spawn(serverGO, ownerConnection);
|
||||
ProcessMessages();
|
||||
|
||||
// double check that client object's isClient is really true!
|
||||
// previously a test magically failed because isClient was false
|
||||
// even though it should've been true!
|
||||
Assert.That(clientIdentity.isClient, Is.True);
|
||||
|
||||
// double check that we have authority if we passed an owner connection
|
||||
if (ownerConnection != null)
|
||||
{
|
||||
@ -363,6 +378,11 @@ protected void CreateNetworkedAndSpawn<T, U, V>(
|
||||
NetworkServer.Spawn(serverGO, ownerConnection);
|
||||
ProcessMessages();
|
||||
|
||||
// double check that client object's isClient is really true!
|
||||
// previously a test magically failed because isClient was false
|
||||
// even though it should've been true!
|
||||
Assert.That(clientIdentity.isClient, Is.True);
|
||||
|
||||
// double check that we have authority if we passed an owner connection
|
||||
if (ownerConnection != null)
|
||||
{
|
||||
@ -428,6 +448,11 @@ protected void CreateNetworkedAndSpawnPlayer(
|
||||
// make sure the client really spawned it.
|
||||
Assert.That(clientGO.activeSelf, Is.True);
|
||||
Assert.That(NetworkClient.spawned.ContainsKey(serverIdentity.netId));
|
||||
|
||||
// double check that client object's isClient is really true!
|
||||
// previously a test magically failed because isClient was false
|
||||
// even though it should've been true!
|
||||
Assert.That(clientIdentity.isClient, Is.True);
|
||||
}
|
||||
|
||||
// create GameObject + NetworkIdentity + NetworkBehaviour & SPAWN PLAYER.
|
||||
@ -485,6 +510,11 @@ protected void CreateNetworkedAndSpawnPlayer<T>(
|
||||
// make sure the client really spawned it.
|
||||
Assert.That(clientGO.activeSelf, Is.True);
|
||||
Assert.That(NetworkClient.spawned.ContainsKey(serverIdentity.netId));
|
||||
|
||||
// double check that client object's isClient is really true!
|
||||
// previously a test magically failed because isClient was false
|
||||
// even though it should've been true!
|
||||
Assert.That(clientIdentity.isClient, Is.True);
|
||||
}
|
||||
|
||||
// fully connect client to local server
|
||||
@ -496,6 +526,13 @@ protected void ConnectClientBlocking(out NetworkConnectionToClient connectionToC
|
||||
|
||||
Assert.That(NetworkServer.connections.Count, Is.EqualTo(1));
|
||||
connectionToClient = NetworkServer.connections.Values.First();
|
||||
|
||||
// set isSpawnFinished flag.
|
||||
// so that any Spawn() calls will call OnStartClient and set isClient=true
|
||||
// for the client objects.
|
||||
// otherwise this would only happen after AddPlayerForConnection.
|
||||
// but not all tests have a player.
|
||||
NetworkClient.isSpawnFinished = true;
|
||||
}
|
||||
|
||||
// fully connect client to local server & authenticate
|
||||
@ -531,6 +568,13 @@ protected void ConnectHostClientBlocking()
|
||||
NetworkClient.ConnectLocalServer();
|
||||
UpdateTransport();
|
||||
Assert.That(NetworkServer.connections.Count, Is.EqualTo(1));
|
||||
|
||||
// set isSpawnFinished flag.
|
||||
// so that any Spawn() calls will call OnStartClient and set isClient=true
|
||||
// for the client objects.
|
||||
// otherwise this would only happen after AddPlayerForConnection.
|
||||
// but not all tests have a player.
|
||||
NetworkClient.isSpawnFinished = true;
|
||||
}
|
||||
|
||||
// fully connect client to local server & authenticate & set read
|
||||
|
Loading…
Reference in New Issue
Block a user