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); }
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); }
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); }