NetworkServerTests: Command tests: use host mode to prepare for easier .spawned split

This commit is contained in:
vis2k 2021-08-11 19:42:59 +08:00
parent 45f9bbd80e
commit 811f1fadfc

View File

@ -733,12 +733,12 @@ public void SendCommand()
{ {
// listen & connect // listen & connect
NetworkServer.Listen(1); NetworkServer.Listen(1);
ConnectClientBlockingAuthenticatedAndReady(out NetworkConnectionToClient connectionToClient); ConnectHostClientBlockingAuthenticatedAndReady();
// add an identity with two networkbehaviour components // add an identity with two networkbehaviour components
// spawned, otherwise command handler won't find it in .spawned. // spawned, otherwise command handler won't find it in .spawned.
// WITH OWNER = WITH AUTHORITY // WITH OWNER = WITH AUTHORITY
CreateNetworkedAndSpawn(out GameObject _, out NetworkIdentity _, out CommandTestNetworkBehaviour comp, connectionToClient); CreateNetworkedAndSpawn(out GameObject _, out NetworkIdentity _, out CommandTestNetworkBehaviour comp, NetworkServer.localConnection);
// call the command // call the command
comp.TestCommand(); comp.TestCommand();
@ -753,12 +753,12 @@ public void SendCommand_CalledOnCorrectComponent()
{ {
// listen & connect // listen & connect
NetworkServer.Listen(1); NetworkServer.Listen(1);
ConnectClientBlockingAuthenticatedAndReady(out NetworkConnectionToClient connectionToClient); ConnectHostClientBlockingAuthenticatedAndReady();
// add an identity with two networkbehaviour components. // add an identity with two networkbehaviour components.
// spawned, otherwise command handler won't find it in .spawned. // spawned, otherwise command handler won't find it in .spawned.
// WITH OWNER = WITH AUTHORITY // WITH OWNER = WITH AUTHORITY
CreateNetworkedAndSpawn(out GameObject _, out NetworkIdentity _, out CommandTestNetworkBehaviour comp0, out CommandTestNetworkBehaviour comp1, connectionToClient); CreateNetworkedAndSpawn(out GameObject _, out NetworkIdentity _, out CommandTestNetworkBehaviour comp0, out CommandTestNetworkBehaviour comp1, NetworkServer.localConnection);
// call the command // call the command
comp1.TestCommand(); comp1.TestCommand();
@ -772,12 +772,12 @@ public void SendCommand_OnlyAllowedOnOwnedObjects()
{ {
// listen & connect // listen & connect
NetworkServer.Listen(1); NetworkServer.Listen(1);
ConnectClientBlockingAuthenticatedAndReady(out NetworkConnectionToClient connectionToClient); ConnectHostClientBlockingAuthenticatedAndReady();
// add an identity with two networkbehaviour components // add an identity with two networkbehaviour components
// spawned, otherwise command handler won't find it in .spawned. // spawned, otherwise command handler won't find it in .spawned.
// WITH OWNER = WITH AUTHORITY // WITH OWNER = WITH AUTHORITY
CreateNetworkedAndSpawn(out GameObject _, out NetworkIdentity identity, out CommandTestNetworkBehaviour comp, connectionToClient); CreateNetworkedAndSpawn(out GameObject _, out NetworkIdentity identity, out CommandTestNetworkBehaviour comp, NetworkServer.localConnection);
// change identity's owner connection so we can't call [Commands] on it // change identity's owner connection so we can't call [Commands] on it
identity.connectionToClient = new LocalConnectionToClient(); identity.connectionToClient = new LocalConnectionToClient();
@ -793,7 +793,7 @@ public void SendCommand_RequiresAuthority()
{ {
// listen & connect // listen & connect
NetworkServer.Listen(1); NetworkServer.Listen(1);
ConnectClientBlockingAuthenticatedAndReady(out NetworkConnectionToClient connectionToClient); ConnectHostClientBlockingAuthenticatedAndReady();
// add an identity with two networkbehaviour components // add an identity with two networkbehaviour components
// spawned, otherwise command handler won't find it in .spawned. // spawned, otherwise command handler won't find it in .spawned.