Beispiel #1
0
        public void ClientDisconnects()
        {
            TestDefaults.SetGlobalDefaults();

            Server S = TestDefaults.GetServer();

            S.StartServer();

            Client c = new Client();

            c.Connect(IPAddress.Loopback, 9090);

            bool eval = false;

            TestDefaults.WaitForCondition(() => S.ClientCount == 1);

            eval = S.ClientCount == 1;

            c.Disconnect();

            TestDefaults.WaitForCondition(() => !S.ReadonlyClients[0].IsConnected);

            eval = eval && !S.ReadonlyClients[0].IsConnected;

            Assert.True(eval);

            S.Close();
        }
Beispiel #2
0
        public async Task ClientConnectsAsync()
        {
            TestDefaults.SetGlobalDefaults();

            Server S = TestDefaults.GetServer();

            S.StartServer();

            Client c = new Client();
            await c.ConnectAsync(IPAddress.Loopback, 9090);

            TestDefaults.WaitForCondition(() => S.ClientCount == 1);

            Assert.True(S.ClientCount == 1);

            S.Close();
        }
Beispiel #3
0
        public void ClientConnectInvokes()
        {
            TestDefaults.SetGlobalDefaults();

            Server S = TestDefaults.GetServer();

            S.StartServer();

            Client c = new Client();

            c.OnConnect += OnConnect;
            c.BeginConnect(IPAddress.Loopback, 9090);

            TestDefaults.WaitForCondition(() => Connections == 1);

            Assert.True(Connections == 1);

            S.Close();
        }
        private void FileTest(Server.RecievedFile t)
        {
            TestDefaults.SetGlobalDefaults();

            Server s = TestDefaults.GetServer();

            s.OnClientRecieveFile = t;
            s.StartServer();

            Client c = new Client();

            c.Connect(IPAddress.Loopback, 9090);

            string path = Directory.GetCurrentDirectory();
            string f    = Directory.GetFiles(path)[0];

            c.SendFile(f);

            Assert.True(TestDefaults.WaitForCondition(() => condition));
        }
Beispiel #5
0
        public void ClientRetrievesQueue()
        {
            TestDefaults.SetGlobalDefaults();

            Server S = TestDefaults.GetServer();

            S.StartServer();

            Client c = new Client();

            c.Connect(IPAddress.Loopback, 9090);

            Exception e = new Exception();
            bool      b = true;
            string    s = "AFagea";

            S.SendToAll(e);
            S.SendToAll(b);
            S.SendToAll(s);
            Thread.Sleep(500);
            Assert.True(TestDefaults.WaitForCondition(() =>
            {
                object[] queue = c.GetQueueObjectsTypeless(true);

                if (!queue[0].GetType().Equals(e.GetType()))
                {
                    return(false);
                }
                if (!queue[1].Equals(b))
                {
                    return(false);
                }
                if (!queue[2].Equals(s))
                {
                    return(false);
                }
                return(true);
            }));

            S.Close();
        }
        public async void ClientSendsFileAsync()
        {
            TestDefaults.SetGlobalDefaults();

            Server s = TestDefaults.GetServer();

            s.OnClientRecieveFile = ServerFileRecieve;
            s.StartServer();

            Client c = new Client();

            c.Connect(IPAddress.Loopback, 9090);

            GlobalDefaults.ClearSentFiles();

            string path = Directory.GetCurrentDirectory();
            string f    = Directory.GetFiles(path)[0];
            await c.SendFileAsync(f);

            Assert.True(TestDefaults.WaitForCondition(() => files == 1));
        }
        public void ServerSendsFiles()
        {
            TestDefaults.SetGlobalDefaults();

            Server s = TestDefaults.GetServer();

            s.StartServer();

            Client c = new Client();

            c.OnFileRecieve += ClientFileReceive;
            c.Connect(IPAddress.Loopback, 9090);

            GlobalDefaults.ClearSentFiles();

            string path = Directory.GetCurrentDirectory();
            string f    = Directory.GetFiles(path)[0];

            s.SendFileToAll(f);

            Assert.True(TestDefaults.WaitForCondition(() => files == 1));
        }
Beispiel #8
0
        public void ClientDisconnectInvokes()
        {
            TestDefaults.SetGlobalDefaults();

            Server S = TestDefaults.GetServer();

            S.StartServer();

            Client c = new Client();

            c.OnDisconnect += OnDisconnect;
            c.BeginConnect(IPAddress.Loopback, 9090);

            TestDefaults.WaitForCondition(() => S.ClientCount == 1, 5000);
            //Thread.Sleep(1000);
            S.DisconnectAllClients();

            TestDefaults.WaitForCondition(() => Disconnections == 1);

            Assert.True(Disconnections == 1);

            S.Close();
        }
Beispiel #9
0
        public void ServerDisconnectInvokes()
        {
            TestDefaults.SetGlobalDefaults();

            Server S = TestDefaults.GetServer();

            S.OnClientDisconnect += OnDisconnect;
            S.StartServer();

            Client c = new Client();

            c.Connect(IPAddress.Loopback, 9090);

            TestDefaults.WaitForCondition(() => S.ClientCount == 1);

            c.Disconnect();

            TestDefaults.WaitForCondition(() => Disconnections == 1);

            Assert.True(Disconnections == 1);

            S.Close();
        }