コード例 #1
0
        public void LogInTest()
        {
            var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            socket.Connect(Host, Port);
            var operationPerformer = new OperationPerformer(socket);

            operationPerformer.OmitWelcomeResponse();
            operationPerformer.LogIn(Username, Password);
            Assert.IsTrue(true);
        }
コード例 #2
0
        public void DownloadFileTest()
        {
            var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            socket.Connect(Host, Port);
            var operationPerformer = new OperationPerformer(socket);

            operationPerformer.OmitWelcomeResponse();
            operationPerformer.LogIn(Username, Password);
            operationPerformer.ActiveMode = false;
            operationPerformer.DownloadFile("FTP.txt", "G:\\hp\\Desktop\\test1.txt");
            operationPerformer.ActiveMode = true;
            operationPerformer.DownloadFile("FTP.txt", "G:\\hp\\Desktop\\test2.txt");
            operationPerformer.LogOut();
            Assert.IsTrue(true);
        }
コード例 #3
0
        public void ListFilesTest()
        {
            var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            socket.Connect(Host, Port);
            var operationPerformer = new OperationPerformer(socket);

            operationPerformer.OmitWelcomeResponse();
            operationPerformer.LogIn(Username, Password);
            operationPerformer.ActiveMode = false;
            operationPerformer.ListFiles("/").ForEach(x => Console.WriteLine(x));
            operationPerformer.ActiveMode = true;
            operationPerformer.ListFiles("/").ForEach(x => Console.WriteLine(x));
            operationPerformer.LogOut();
            Assert.IsTrue(true);
        }
コード例 #4
0
        public void RenameFileTest()
        {
            var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            socket.Connect(Host, Port);
            var operationPerformer = new OperationPerformer(socket);

            operationPerformer.OmitWelcomeResponse();
            operationPerformer.LogIn(Username, Password);

            operationPerformer.DownloadFile("FTP.txt", "haha.txt");
            operationPerformer.UploadFile("haha.txt", "haha.txt");
            operationPerformer.RenameFile("haha.txt", "hehe.txt");

            Assert.IsTrue(true);
        }
コード例 #5
0
        public void ChangeDirectoryTest()
        {
            var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            socket.Connect(Host, Port);
            var operationPerformer = new OperationPerformer(socket);

            operationPerformer.OmitWelcomeResponse();
            operationPerformer.LogIn(Username, Password);
            operationPerformer.ChangeDirectory("..");
            operationPerformer.ChangeDirectory(".");
            operationPerformer.ChangeDirectory(".settings");
            operationPerformer.ChangeDirectory(".././../.settings/../.");
            operationPerformer.LogOut();

            Assert.IsTrue(true);
        }
コード例 #6
0
        public void RemoveDirectoryTest()
        {
            var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            socket.Connect(Host, Port);
            var operationPerformer = new OperationPerformer(socket);

            operationPerformer.OmitWelcomeResponse();
            operationPerformer.LogIn(Username, Password);

            try
            {
                operationPerformer.RemoveDirectory("testDir/testR");
            }
            catch (Exception)
            {
                // ignored
            }

            try
            {
                operationPerformer.RemoveDirectory("testDir");
            }
            catch (Exception)
            {
                // ignored
            }

            operationPerformer.MakeDirectory("testDir");
            operationPerformer.MakeDirectory("testDir/testR");
            operationPerformer.ChangeDirectory("testDir");
            operationPerformer.RemoveDirectory("testR");
            Assert.IsTrue(operationPerformer.ListFiles().Count == 2);
            operationPerformer.ChangeDirectory("..");
            operationPerformer.RemoveDirectory("testDir");
            Assert.IsTrue(operationPerformer.ListFiles().FindIndex(x => x.Name == "testDir") == -1);

            operationPerformer.LogOut();
            Assert.IsTrue(true);
        }
コード例 #7
0
        public void UploadFileTest()
        {
            var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            socket.Connect(Host, Port);
            var operationPerformer = new OperationPerformer(socket);

            operationPerformer.OmitWelcomeResponse();
            operationPerformer.LogIn(Username, Password);

            operationPerformer.ActiveMode = false;
            operationPerformer.UploadFile("haha.txt", "G:\\hp\\Desktop\\test1.txt");
            var fileList = operationPerformer.ListFiles("/");

            Assert.IsTrue(fileList.FindIndex(x => x.Name == "haha.txt") >= 0);

            operationPerformer.ActiveMode = true;
            operationPerformer.UploadFile("hehe.txt", "G:\\hp\\Desktop\\test1.txt");
            fileList = operationPerformer.ListFiles("/");
            Assert.IsTrue(fileList.FindIndex(x => x.Name == "hehe.txt") >= 0);

            operationPerformer.LogOut();
            Assert.IsTrue(true);
        }