mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
NetworkServerTest: ConnectionsDictTest
This commit is contained in:
parent
933ce4a3d5
commit
ab98846566
@ -99,5 +99,40 @@ public void DisconnectMessageHandlerTest()
|
||||
// shutdown
|
||||
NetworkServer.Shutdown();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConnectionsDictTest()
|
||||
{
|
||||
// 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 first
|
||||
Transport.activeTransport.OnServerConnected.Invoke(42);
|
||||
Assert.That(NetworkServer.connections.Count, Is.EqualTo(1));
|
||||
Assert.That(NetworkServer.connections.ContainsKey(42), Is.True);
|
||||
|
||||
// connect second
|
||||
Transport.activeTransport.OnServerConnected.Invoke(43);
|
||||
Assert.That(NetworkServer.connections.Count, Is.EqualTo(2));
|
||||
Assert.That(NetworkServer.connections.ContainsKey(43), Is.True);
|
||||
|
||||
// disconnect second
|
||||
Transport.activeTransport.OnServerDisconnected.Invoke(43);
|
||||
Assert.That(NetworkServer.connections.Count, Is.EqualTo(1));
|
||||
Assert.That(NetworkServer.connections.ContainsKey(42), Is.True);
|
||||
|
||||
// disconnect first
|
||||
Transport.activeTransport.OnServerDisconnected.Invoke(42);
|
||||
Assert.That(NetworkServer.connections.Count, Is.EqualTo(0));
|
||||
|
||||
// shutdown
|
||||
NetworkServer.Shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user