mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
NetworkBehaviourTests: GetRpcHandler
This commit is contained in:
parent
cdd7055b66
commit
3acdd97fee
@ -647,6 +647,26 @@ public void RegisterDelegateDoesntOverwrite()
|
||||
// clean up
|
||||
NetworkBehaviour.ClearDelegates();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetRpcHandler()
|
||||
{
|
||||
// registerdelegate is protected, but we can use
|
||||
// RegisterCommandDelegate which calls RegisterDelegate
|
||||
NetworkBehaviour.RegisterCommandDelegate(
|
||||
typeof(NetworkBehaviourDelegateComponent),
|
||||
nameof(NetworkBehaviourDelegateComponent.Delegate),
|
||||
NetworkBehaviourDelegateComponent.Delegate);
|
||||
|
||||
// get handler
|
||||
int cmdHash = NetworkBehaviour.GetMethodHash(typeof(NetworkBehaviourDelegateComponent), nameof(NetworkBehaviourDelegateComponent.Delegate));
|
||||
NetworkBehaviour.CmdDelegate func = NetworkBehaviour.GetRpcHandler(cmdHash);
|
||||
NetworkBehaviour.CmdDelegate expected = NetworkBehaviourDelegateComponent.Delegate;
|
||||
Assert.That(func, Is.EqualTo(expected));
|
||||
|
||||
// clean up
|
||||
NetworkBehaviour.ClearDelegates();
|
||||
}
|
||||
}
|
||||
|
||||
// we need to inherit from networkbehaviour to test protected functions
|
||||
|
Loading…
Reference in New Issue
Block a user