mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
NetworkServerTests: OnConnectedOnlyAllowsGreaterZeroConnectionIdsTest
This commit is contained in:
parent
47a4ac7ff7
commit
9c325abbd8
@ -136,6 +136,37 @@ public void ConnectionsDictTest()
|
||||
NetworkServer.Shutdown();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void OnConnectedOnlyAllowsGreaterZeroConnectionIdsTest()
|
||||
{
|
||||
// OnConnected should only allow connectionIds >= 0
|
||||
// 0 is for local player
|
||||
// <0 is never used
|
||||
|
||||
// message handlers
|
||||
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => {}, false);
|
||||
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => {}, false);
|
||||
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => {}, false);
|
||||
|
||||
// listen
|
||||
NetworkServer.Listen(2);
|
||||
Assert.That(NetworkServer.connections.Count, Is.EqualTo(0));
|
||||
|
||||
// connect 0
|
||||
// (it will show an error message, which is expected)
|
||||
LogAssert.ignoreFailingMessages = true;
|
||||
Transport.activeTransport.OnServerConnected.Invoke(0);
|
||||
Assert.That(NetworkServer.connections.Count, Is.EqualTo(0));
|
||||
|
||||
// connect <0
|
||||
Transport.activeTransport.OnServerConnected.Invoke(-1);
|
||||
Assert.That(NetworkServer.connections.Count, Is.EqualTo(0));
|
||||
LogAssert.ignoreFailingMessages = false;
|
||||
|
||||
// shutdown
|
||||
NetworkServer.Shutdown();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetLocalConnectionTest()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user