Skip to content

Commit

Permalink
test multiple parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
vis2k committed Apr 8, 2023
1 parent c21b290 commit f4db500
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions Assets/Mirror/Tests/Editor/CommandTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@ namespace Mirror.Tests.RemoteAttrributeTest
class AuthorityBehaviour : NetworkBehaviour
{
public event Action<int> onSendInt;
public event Action<int, string, bool> onSendMulti;

[Command]
public void SendInt(int someInt) =>
onSendInt?.Invoke(someInt);

[Command]
public void SendMulti(int someInt, string someString, bool someBool) =>
onSendMulti?.Invoke(someInt, someString, someBool);
}

class IgnoreAuthorityBehaviour : NetworkBehaviour
Expand Down Expand Up @@ -301,18 +306,22 @@ public void CommandCalledWhenServerOnly()
CreateNetworked(out _, out _, out AuthorityBehaviour serverComponent);

// set up a callback and check
const int someInt = 20;
int callCount = 0;
serverComponent.onSendInt += incomingInt =>
serverComponent.onSendMulti += (a, b, c) =>
{
callCount++;
Assert.That(incomingInt, Is.EqualTo(someInt));
Assert.That(a, Is.EqualTo(42));
Assert.That(b, Is.EqualTo("test"));
Assert.That(c, Is.EqualTo(true));
};

// call [Command] on server.
// should call the function immediately,
// test multiple parameters to ensure weaver properly injects all
// LdArg0,1,2, etc. instructions.
//
// this should call the function immediately,
// without processing messages.
serverComponent.SendInt(someInt);
serverComponent.SendMulti(42, "test", true);
// ProcessMessages();
Assert.That(callCount, Is.EqualTo(1));
}
Expand Down

0 comments on commit f4db500

Please sign in to comment.