public Int32 CreateConnection(String server, UInt16 port) { ConnectionProvider connection = new ConnectionProvider(server, port); connection.Connect(); connection.MessageArrived += new ConnectionProvider.MessageArrivedEventHandler(MessageArrived); connections.Add(connection); return connections.Count; }
public void CorrectConnect() { ConnectionProvider provider = new ConnectionProvider(); provider.Server = "localhost"; provider.Port = 6667; provider.Connect(); Assert.AreEqual(1, server.Clients.Count); }
public void IsConnectedAndConnect() { ConnectionProvider provider = new ConnectionProvider(); Assert.IsFalse(provider.IsConnected, "IsConnected should be false"); provider.Server = "localhost"; provider.Port = 6667; provider.Connect(); Assert.IsTrue(provider.IsConnected, "IsConnected should be true"); }
public void MessageArrivedEvent() { ConnectionProvider provider = new ConnectionProvider(); provider.MessageArrived += new ConnectionProvider.MessageArrivedEventHandler(MessageArrivedEvent_MessageArrived); }
public void IsConnectedProperty() { ConnectionProvider provider = new ConnectionProvider(); Assert.IsFalse(provider.IsConnected, "IsConnected should be false"); }
public void ConnectThrowsExceptionForServer() { ConnectionProvider provider = new ConnectionProvider(); provider.Connect(); }
public void ConstructorWithServerAndPort() { ConnectionProvider provider = new ConnectionProvider("localhost", 6667); Assert.AreEqual("localhost", provider.Server, "Server property is not ok"); Assert.AreEqual(6667, provider.Port, "Port property is not ok"); }
public void TerminateConnection() { try { ConnectionProvider provider = new ConnectionProvider("localhost", 6667); provider.Connect(); provider.Disconnect(); } catch { Assert.Fail(); } }
public void ConnectThrowsExceptionForPort() { ConnectionProvider provider = new ConnectionProvider(); provider.Server = "localhost"; provider.Connect(); }
public void ServerProperty() { ConnectionProvider provider = new ConnectionProvider(); provider.Server = "localhost"; Assert.AreEqual("localhost", provider.Server, "Server property is not set right"); }
public void SendNullString() { ConnectionProvider provider = new ConnectionProvider("localhost", 6667); provider.Connect(); try { provider.SendMessage(null); Assert.Fail("Must throw exception"); } catch(ArgumentNullException exception) { Assert.AreEqual("message", exception.ParamName, "Param message must be null"); } catch { Assert.Fail("Invalid exception type"); } }
public void SendMessage() { ConnectionProvider provider = new ConnectionProvider("localhost", 6667); provider.Connect(); provider.SendMessage("Hello"); Assert.AreEqual("Hello", ((ServerConnectionHandler) server.Clients[0]).GetMessage()); }
public void ReceiveMessage() { ConnectionProvider provider = new ConnectionProvider("localhost", 6667); //provider.MessageArrived += new ConnectionProvider.MessageArrivedEventHandler(ReceiveMessage_MessageArrived); provider.Connect(); /* lock(this) { server.SendMessage("Hello"); Monitor.Wait(this); } Assert.IsNotNull(eventArgs, "eventArgs is null"); Assert.AreEqual("Hello", eventArgs.Message, "Invalid message"); eventArgs = null; */ }
public void PortProperty() { ConnectionProvider provider = new ConnectionProvider(); provider.Port = 6667; Assert.AreEqual(6667, provider.Port, "Port property is not set right"); }