public void ServerStart() { //--------------------------------------------------------------------- //Setup //--------------------------------------------------------------------- TCP_Config config; config.address = "127.0.0.1"; config.port = 4451; ServerLibrary.Server server = new ServerLibrary.Server(); ServerLibrary.ServerConnectionTCP connection = new ServerLibrary.ServerConnectionTCP("Tester"); ServerListenerTCP listener = new ServerListenerTCP(config); connection.AddListener(listener); server.AddConnection(connection); //--------------------------------------------------------------------- //Run Test //--------------------------------------------------------------------- server.Start(); //--------------------------------------------------------------------- //Gather Output //--------------------------------------------------------------------- //--------------------------------------------------------------------- //Assert //--------------------------------------------------------------------- }
public void ServerSendTcpToClient() { //--------------------------------------------------------------------- //Setup //--------------------------------------------------------------------- TCP_Config config; config.address = "127.0.0.1"; config.port = 4448; ServerLibrary.Server server = new ServerLibrary.Server(); ServerLibrary.ServerConnectionTCP connection = new ServerLibrary.ServerConnectionTCP("Tester"); ServerListenerTCP listener = new ServerListenerTCP(config); connection.AddListener(listener); server.AddConnection(connection); server.Start(); ChatMessagePacket packet = new ChatMessagePacket("Hello", "Tester"); //--------------------------------------------------------------------- //Run Test //--------------------------------------------------------------------- server.SendPacketToClient(packet, "Tester", "Bob"); //--------------------------------------------------------------------- //Gather Output //--------------------------------------------------------------------- //--------------------------------------------------------------------- //Assert //--------------------------------------------------------------------- }
public void ServerCollectionOfPackets() { //--------------------------------------------------------------------- //Setup //--------------------------------------------------------------------- TCP_Config config; config.address = "127.0.0.1"; config.port = 4450; ServerLibrary.Server server = new ServerLibrary.Server(); ServerLibrary.ServerConnectionTCP connection = new ServerLibrary.ServerConnectionTCP("Tester"); ServerListenerTCP listener = new ServerListenerTCP(config); connection.AddListener(listener); server.AddConnection(connection); server.Start(); List <Packet> expecetedPackets = new List <Packet>(); //--------------------------------------------------------------------- //Run Test //--------------------------------------------------------------------- List <Packet> packets = server.RecieveMessages("Tester"); //--------------------------------------------------------------------- //Gather Output //--------------------------------------------------------------------- //--------------------------------------------------------------------- //Assert //--------------------------------------------------------------------- Assert.AreEqual(expecetedPackets, packets); }
public void ServerConnectionAcceptTcpClients() { //--------------------------------------------------------------------- //Setup //--------------------------------------------------------------------- TCP_Config config; config.address = "127.0.0.1"; config.port = 4490; ServerListenerTCP listener = new ServerListenerTCP(config); ServerLibrary.ServerConnectionTCP connection = new ServerLibrary.ServerConnectionTCP("Tester"); connection.AddListener(listener); //--------------------------------------------------------------------- //Run Test //--------------------------------------------------------------------- connection.AcceptClients(); //--------------------------------------------------------------------- //Gather Output //--------------------------------------------------------------------- //--------------------------------------------------------------------- //Assert //--------------------------------------------------------------------- }