Example #1
0
        public void LogOutTest()
        {
            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.LogOut();
            Assert.IsTrue(true);
        }
Example #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);
        }
Example #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);
        }
Example #4
0
        public void GetCurrentDirectoryTest()
        {
            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(operationPerformer.GetCurrentDirectory() == "/");
            operationPerformer.ChangeDirectory(".settings");
            Assert.IsTrue(operationPerformer.GetCurrentDirectory() == "/.settings");
            operationPerformer.ChangeDirectory("../.././../.settings/../.");
            Assert.IsTrue(operationPerformer.GetCurrentDirectory() == "/");
            operationPerformer.LogOut();

            Assert.IsTrue(true);
        }
Example #5
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);
        }
Example #6
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);
        }