NetworkServerTest: DisconnectAllTest

This commit is contained in:
vis2k 2020-02-23 11:43:08 +01:00
parent 357ad0ffb6
commit 1cce3164b9

View File

@ -286,6 +286,37 @@ public void DisconnectAllConnectionsTest()
NetworkServer.Shutdown();
}
[Test]
public void DisconnectAllTest()
{
// message handlers
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => {}, false);
// listen
NetworkServer.Listen(1);
Assert.That(NetworkServer.connections.Count, Is.EqualTo(0));
// set local connection
ULocalConnectionToClient localConnection = new ULocalConnectionToClient();
NetworkServer.SetLocalConnection(localConnection);
Assert.That(NetworkServer.localConnection, Is.EqualTo(localConnection));
// add connection
NetworkConnectionToClient conn42 = new NetworkConnectionToClient(42);
NetworkServer.AddConnection(conn42);
Assert.That(NetworkServer.connections.Count, Is.EqualTo(1));
// disconnect all connections and local connection
NetworkServer.DisconnectAll();
Assert.That(NetworkServer.connections.Count, Is.EqualTo(0));
Assert.That(NetworkServer.localConnection, Is.Null);
// shutdown
NetworkServer.Shutdown();
}
[Test]
public void ShutdownCleanupTest()
{