public void TestStopServer() { NetworkTestHelper.SetupSingleConnectionTest( out testListener, out testRemoteSocketState, out testLocalSocketState, 2200); Networking.StopServer(testListener); SocketState newState = new SocketState(null, null); Networking.ConnectToServer(s => newState = s, "localhost", 2200); NetworkTestHelper.WaitForOrTimeout(() => false, 3000); Assert.IsTrue(newState.ErrorOccured); }
public void TestStopServer() { void saveServerState(SocketState x) { testLocalSocketState = x; } void saveClientState(SocketState x) { testLocalSocketState = x; } testListener = Networking.StartServer(saveServerState, 2112); Networking.ConnectToServer(saveClientState, "localhost", 2112); Assert.IsTrue(testLocalSocketState.TheSocket.Connected); Networking.StopServer(testListener); }
public void TestClose() { NetworkTestHelper.SetupSingleConnectionTest(out testListener, out testLocalSocketState, out testRemoteSocketState); Networking.StopServer(testListener); SocketState client = null; void SaveClient(SocketState s) { client = s; } //Using port 2112 because it is the same port being used in SetupSingleConnectionTest method use //Should produce a ErrorOccured SocketState because we have closed hearing any incoming connections Networking.ConnectToServer(SaveClient, "localhost", 2112); Assert.IsTrue(client.ErrorOccured); }
public void TestConnectStartAndStopNoServer() { bool isCalled = false; void saveClientState(SocketState x) { isCalled = true; testLocalSocketState = x; } NetworkTestHelper.SetupSingleConnectionTest(out testListener, out testLocalSocketState, out testRemoteSocketState); Networking.StopServer(testListener); // Try to connect without setting up a server first. Networking.ConnectToServer(saveClientState, "localhost", 2112); NetworkTestHelper.WaitForOrTimeout(() => isCalled, NetworkTestHelper.timeout); Assert.IsTrue(isCalled); Assert.IsTrue(testLocalSocketState.ErrorOccured); }
public void StopServer_NullTcpListener_ShouldDoNothing() { // this should not throw an exception Networking.StopServer(null); }