Ejemplo n.º 1
0
        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
            //---------------------------------------------------------------------
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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
            //---------------------------------------------------------------------
        }
Ejemplo n.º 4
0
        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
            //---------------------------------------------------------------------
        }
Ejemplo n.º 5
0
        public void ServerConstructor()
        {
            //---------------------------------------------------------------------
            //Setup
            //---------------------------------------------------------------------
            ServerLibrary.Server server;

            //---------------------------------------------------------------------
            //Run Test
            //---------------------------------------------------------------------
            server = new ServerLibrary.Server();

            //---------------------------------------------------------------------
            //Gather Output
            //---------------------------------------------------------------------

            //---------------------------------------------------------------------
            //Assert
            //---------------------------------------------------------------------
            Assert.IsNotNull(server);
        }
Ejemplo n.º 6
0
        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);
        }