public void CanAddToArray()
        {
            const int COUNT = 10;

            double[] test = new double[0];

            for (int i = 0; i < COUNT; i++)
            {
                test = (double[])ArrayHelpers.Add(test, i);
            }

            Assert.AreEqual(COUNT, test.Length);
            for (int i = 0; i < COUNT; i++)
            {
                Assert.AreEqual(test[i], i, "The value is wrong at index#{0}", i);
            }
        }
예제 #2
0
        protected override string OnProcess(string message)
        {
            SocketHelpers.Send(ConnectionObject.Socket, "150 Opening data connection for LIST\r\n");

            string[] asFiles       = null;
            string[] asDirectories = null;

            message = message.Trim();

            var path = GetPath(string.Empty);

            if (message.Length == 0 || message[0] == '-')
            {
                asFiles       = ConnectionObject.FileSystemObject.GetFiles(path);
                asDirectories = ConnectionObject.FileSystemObject.GetDirectories(path);
            }
            else
            {
                asFiles       = ConnectionObject.FileSystemObject.GetFiles(path, message);
                asDirectories = ConnectionObject.FileSystemObject.GetDirectories(path, message);
            }

            var asAll    = ArrayHelpers.Add(asDirectories, asFiles) as string[];
            var fileList = BuildReply(message, asAll);

            var socketReply = new FtpReplySocket(ConnectionObject);

            if (!socketReply.Loaded)
            {
                return(GetMessage(550, "LIST unable to establish return connection."));
            }

            socketReply.Send(fileList);
            socketReply.Close();

            return(GetMessage(226, "LIST successful."));
        }