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 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 SendUdpToClient() { //--------------------------------------------------------------------- //Setup //--------------------------------------------------------------------- UDP_Config config; config.address = "127.0.0.1"; config.port = 4440; ServerLibrary.Server server = new ServerLibrary.Server(); ServerLibrary.ServerConnectionUDP connection = new ServerLibrary.ServerConnectionUDP("TesterUdpClient"); ServerListenerUDP listener = new ServerListenerUDP(config); connection.AddListener(listener); server.AddConnection(connection); server.Start(); ChatMessagePacket packet = new ChatMessagePacket("Hello", "Tester"); //--------------------------------------------------------------------- //Run Test //--------------------------------------------------------------------- server.SendPacketToClient(packet, "TesterUdpClient", "Bob"); //--------------------------------------------------------------------- //Gather Output //--------------------------------------------------------------------- //--------------------------------------------------------------------- //Assert //--------------------------------------------------------------------- }
public void ServerSendTcpToAll() { //--------------------------------------------------------------------- //Setup //--------------------------------------------------------------------- TCP_Config config; config.address = "127.0.0.1"; config.port = 4447; 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.SendPacketToAll(packet, "Tester"); //--------------------------------------------------------------------- //Gather Output //--------------------------------------------------------------------- //--------------------------------------------------------------------- //Assert //--------------------------------------------------------------------- }
public void ServerConstructor() { //--------------------------------------------------------------------- //Setup //--------------------------------------------------------------------- ServerLibrary.Server server; //--------------------------------------------------------------------- //Run Test //--------------------------------------------------------------------- server = new ServerLibrary.Server(); //--------------------------------------------------------------------- //Gather Output //--------------------------------------------------------------------- //--------------------------------------------------------------------- //Assert //--------------------------------------------------------------------- Assert.IsNotNull(server); }
public void ServerAddConnection() { //--------------------------------------------------------------------- //Setup //--------------------------------------------------------------------- ServerLibrary.Server server = new ServerLibrary.Server(); ServerLibrary.ServerConnectionUDP connection = new ServerLibrary.ServerConnectionUDP("Tester"); //--------------------------------------------------------------------- //Run Test //--------------------------------------------------------------------- server.AddConnection(connection); //--------------------------------------------------------------------- //Gather Output //--------------------------------------------------------------------- List <Packet> packets = server.RecieveMessages("Tester"); //--------------------------------------------------------------------- //Assert //--------------------------------------------------------------------- Assert.IsNotNull(packets); }