Esempio n. 1
0
        public void TestClientRequestFileRealConnectionSuccess()
        {
            Client.Connection temp = new Client.Connection(client);
            client.connection = temp;
            temp.sock         = mockSocket;

            using (mocks.Record())
            {
                mockSocket.send(iSocket.aSocket.stringToBytes("RequestFile generic.txt"));

                // File Name
                mockSocket.receive(iSocket.constants.MAXPACKETSIZE);
                LastCall.Return(iSocket.aSocket.stringToBytes("generic.txt", iSocket.constants.MAXPACKETSIZE)).Repeat.Once();
                // Number of transfers (1)
                mockSocket.receive(iSocket.constants.MAXPACKETSIZE);
                LastCall.Return(iSocket.aSocket.stringToBytes("1", iSocket.constants.MAXPACKETSIZE)).Repeat.Once();
                // Length of a transfer
                mockSocket.receive(iSocket.constants.MAXPACKETSIZE);
                LastCall.Return(iSocket.aSocket.stringToBytes("18", iSocket.constants.MAXPACKETSIZE)).Repeat.Once();
                // Transfer
                mockSocket.receive(iSocket.constants.MAXPACKETSIZE);
                LastCall.Return(iSocket.aSocket.stringToBytes("This here is a text file", iSocket.constants.MAXPACKETSIZE)).Repeat.Once();
            }

            //Assert.IsTrue(client.requestFile("generic.txt"));
            mocks.VerifyAll();
        }
Esempio n. 2
0
        public void TestClientConnectionLoginSuccess()
        {
            using (mocks.Record())
            {
                mockSocket.connect(iSocket.constants.host, iSocket.constants.defaultPort);
                LastCall.On(mockSocket).Repeat.Once();
                // Caesura
                mockSocket.send(iSocket.aSocket.stringToBytes("Caesura" + "\0", iSocket.constants.MAXPACKETSIZE));
                LastCall.On(mockSocket).Repeat.Once();
                // Major
                mockSocket.send(iSocket.aSocket.stringToBytes(iSocket.constants.MajorNumber, iSocket.constants.MAXPACKETSIZE));
                LastCall.On(mockSocket).Repeat.Once();
                // Minor
                mockSocket.send(iSocket.aSocket.stringToBytes(iSocket.constants.MinorNumber, iSocket.constants.MAXPACKETSIZE));
                LastCall.On(mockSocket).Repeat.Once();
                // Username
                mockSocket.send(iSocket.aSocket.stringToBytes("TestUser" + "\0", iSocket.constants.MAXPACKETSIZE));
                LastCall.On(mockSocket).Repeat.Once();
                // Password
                mockSocket.send(iSocket.aSocket.stringToBytes("TestPass" + "\0", iSocket.constants.MAXPACKETSIZE));
                LastCall.On(mockSocket).Repeat.Once();

                mockSocket.receive(iSocket.constants.MAXPACKETSIZE);
                LastCall.Return(iSocket.aSocket.stringToBytes("True", iSocket.constants.MAXPACKETSIZE));
            }

            Assert.True(connection.login("TestUser", "TestPass"));
            mocks.VerifyAll();
        }
Esempio n. 3
0
        public bool login(string username, string password)
        {
            //sock.send(iSocket.aSocket.stringToBytes(iSocket.constants.Requests.Login + ' ' + username + ' ' + password, iSocket.constants.MAXPACKETSIZE));
            sock.send(iSocket.aSocket.stringToBytes("login" + ' ' + username + ' ' + password, iSocket.constants.MAXPACKETSIZE));


            String recv = iSocket.aSocket.bytesToMessage(sock.receive(iSocket.constants.MAXPACKETSIZE));

            bool forDebugger = "True".Equals(recv);

            return(forDebugger);
        }