Skip to content

Commit f4db500

Browse files
author
vis2k
committed
test multiple parameters
1 parent c21b290 commit f4db500

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

Assets/Mirror/Tests/Editor/CommandTest.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,15 @@ namespace Mirror.Tests.RemoteAttrributeTest
99
class AuthorityBehaviour : NetworkBehaviour
1010
{
1111
public event Action<int> onSendInt;
12+
public event Action<int, string, bool> onSendMulti;
1213

1314
[Command]
1415
public void SendInt(int someInt) =>
1516
onSendInt?.Invoke(someInt);
17+
18+
[Command]
19+
public void SendMulti(int someInt, string someString, bool someBool) =>
20+
onSendMulti?.Invoke(someInt, someString, someBool);
1621
}
1722

1823
class IgnoreAuthorityBehaviour : NetworkBehaviour
@@ -301,18 +306,22 @@ public void CommandCalledWhenServerOnly()
301306
CreateNetworked(out _, out _, out AuthorityBehaviour serverComponent);
302307

303308
// set up a callback and check
304-
const int someInt = 20;
305309
int callCount = 0;
306-
serverComponent.onSendInt += incomingInt =>
310+
serverComponent.onSendMulti += (a, b, c) =>
307311
{
308312
callCount++;
309-
Assert.That(incomingInt, Is.EqualTo(someInt));
313+
Assert.That(a, Is.EqualTo(42));
314+
Assert.That(b, Is.EqualTo("test"));
315+
Assert.That(c, Is.EqualTo(true));
310316
};
311317

312318
// call [Command] on server.
313-
// should call the function immediately,
319+
// test multiple parameters to ensure weaver properly injects all
320+
// LdArg0,1,2, etc. instructions.
321+
//
322+
// this should call the function immediately,
314323
// without processing messages.
315-
serverComponent.SendInt(someInt);
324+
serverComponent.SendMulti(42, "test", true);
316325
// ProcessMessages();
317326
Assert.That(callCount, Is.EqualTo(1));
318327
}

0 commit comments

Comments
 (0)