public void TerminateConnection() { IRCConnection connection = new IRCConnection("localhost", 6667); TcpClient client = listener.AcceptTcpClient(); connection.Close(); client.Close(); Assert.IsFalse(listener.Pending()); }
public void CreateClientNICKCommand() { IRCConnection connection = new IRCConnection("localhost", 6667); TcpClient client = listener.AcceptTcpClient(); StreamReader reader = new StreamReader(client.GetStream(), Encoding.ASCII); connection.SendNickCommand("xpto"); Assert.AreEqual("NICK xpto", reader.ReadLine()); connection.Close(); }
public void CreateRegistrationCommand() { IRCConnection connection = new IRCConnection("localhost", 6667); TcpClient client = listener.AcceptTcpClient(); StreamReader reader = new StreamReader(client.GetStream(), Encoding.ASCII); connection.RegisterUser("HelloWorld", "p1", "p2", "p3", "p4"); Assert.AreEqual("NICK HelloWorld", reader.ReadLine()); Assert.AreEqual("USER p1 p2 p3 :p4", reader.ReadLine()); connection.Close(); }
public void CreateServerNICKCommand() { IRCConnection connection = new IRCConnection("localhost", 6667); connection.CommandArrived += new Connection.CommandArrivedDelegate(CreateNICKCommand_CommandArrived); TcpClient client = listener.AcceptTcpClient(); StreamWriter writer = new StreamWriter(client.GetStream(), Encoding.ASCII); try { writer.NewLine = "\r\n"; writer.WriteLine(":xpto NICK xpto2"); writer.Flush(); lock(this) { Assert.IsTrue(Monitor.Wait(this), "Event wasn't called."); } } finally { writer.Close(); client.Close(); connection.Close(); } }