public void ConnectToInvalidServerShouldTimeOut() { bool timedOut = false; var connection = new OnlineServiceConnection(); connection.Connect("localhost", 12345, () => timedOut = true); Thread.Sleep((int)((connection.Timeout + 0.5f)*1000)); Assert.IsTrue(timedOut); Assert.IsFalse(connection.IsLoggedIn); }
public void StartLogServer() { server = new LocalhostLogServer(new TcpServer()); server.Start(); var ready = false; var connection = new OnlineServiceConnection(); connection.DataReceived += o => ready = true; connection.Connect("localhost", LocalhostLogServer.Port); connection.Send(new LoginRequest("", "DeltaEngine.Logging.Tests")); logger = new NetworkLogger(connection); for (int timeoutMs = 1000; timeoutMs > 0 && !ready; timeoutMs -= 10) Thread.Sleep(10); Assert.IsTrue(ready); }
private void ConnectToOnlineServiceAndTryToLogin() { if (tryingToConnect) return; tryingToConnect = true; connection = new OnlineServiceConnection(); connection.Connected += ValidateLogin; connection.Disconnected += ConnectionLost; connection.DataReceived += OnDataReceived; connection.Connect(Settings.Current.OnlineServiceIp, Settings.Current.OnlineServicePort, OnTimeout); }