public void MyTestCleanup() { _client.Disconnect(); while (_client.Status != NetConnectionStatus.Disconnected) { Thread.Sleep(10); } _client.TestableHook.StopUpdateThread(); }
public void TestConnecting() { //setup a default server ServerUtils.SetupDefaultServer(); ServerUtils.StartServerOnNewThread(); var client = new TestablePNet(); client.TestableHook.StartUpdateThread(); client.OnFailedToConnect += s => Assert.Fail("Failed to connect: {0}", s); //the client should connect and disconnect quickly client.Connect(TestablePNet.GetTestConnectionConfig()); Thread.Sleep(200); Assert.AreEqual(client.Status, NetConnectionStatus.Connected, "The client took longer than 200 ms to connect"); client.Disconnect(); Thread.Sleep(200); Assert.AreEqual(client.Status, NetConnectionStatus.Disconnected, "The client took longer than 200 ms to disconnect"); //some cleanup ServerUtils.TeardownServer(); }