NetworkBehaviourTests: GetRpcHandler

This commit is contained in:
vis2k 2020-03-07 13:56:09 +01:00
parent cdd7055b66
commit 3acdd97fee

View File

@ -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