示例#1
0
            public void ConnectToIncorrectPort()
            {
                TcpNetworkServer server = new TcpNetworkServer();
                TcpNetworkClient client = new TcpNetworkClient();

                Assert.IsTrue(server.Bind(m_CorrectPort));
                Assert.IsFalse(client.Connect(m_CorrectAddress, m_IncorrectPort));
                Assert.IsTrue(server.Disconnect());
            }
示例#2
0
            public void ReadHappyPath()
            {
                TcpNetworkServer server = new TcpNetworkServer();
                TcpNetworkClient client = new TcpNetworkClient();

                Assert.IsTrue(server.Bind(m_CorrectPort, ServerReadCallback));
                Assert.IsTrue(client.Connect(m_CorrectAddress, m_CorrectPort, ClientReadCallback));

                System.Threading.Thread.Sleep(1000);
                m_ReadResult = false;
                Assert.AreEqual(server.SendPacket(( IPEndPoint )client.GetHandle().Client.LocalEndPoint,
                                                  m_ClientTestData,
                                                  ( UInt32 )m_ClientTestData.Length),
                                ( UInt32 )m_ClientTestData.Length);
                System.Threading.Thread.Sleep(1000);
                Assert.IsTrue(m_ReadResult);
                m_ReadResult = false;
                Assert.AreEqual(client.SendPacket(m_ServerTestData, ( UInt32 )m_ServerTestData.Length), ( UInt32 )m_ServerTestData.Length);
                System.Threading.Thread.Sleep(1000);
                Assert.IsTrue(m_ReadResult);
                Assert.IsTrue(client.Disconnect());
                Assert.IsTrue(server.Disconnect());
            }