public void TestFtp() { const string CONTENT_SUBSTRING = "FreeBSD"; // receiver var client = new WebClient(); var tfc = new TempFileCollection(); var fileName = tfc.AddExtension("txt"); var command = new FtpGetFileCommand(client, FTP_URI, fileName); var invoker = new Invoker(); invoker.Execute(command); using (var reader = File.OpenText(fileName)) { var content = reader.ReadToEnd(); Assert.IsTrue(content.Contains(CONTENT_SUBSTRING)); } }
public void TestInvokerThreads() { var tfc = new TempFileCollection(); var ftpFileName = tfc.AddExtension("tmp1"); var httpFileName = tfc.AddExtension("tmp2"); var fileName = tfc.AddExtension("txt"); var fileManager = new FileManager(); var randFileCommand = new CreateRandomFileCommand(fileManager, fileName); var ftpClient = new WebClient(); var httpClient = new WebClient(); var ftpCommand = new FtpGetFileCommand(ftpClient, FTP_URI, ftpFileName); var httpCommand = new HttpGetFileCommand(httpClient, HTTP_URI, httpFileName); var invoker = new Invoker(true); invoker.Execute(ftpCommand); invoker.Execute(randFileCommand); invoker.Execute(httpCommand); Thread.Sleep(1000); using (var reader = File.OpenText(ftpFileName)) { var content = reader.ReadToEnd(); Assert.IsFalse(string.IsNullOrEmpty(content)); } using (var reader = File.OpenText(httpFileName)) { var content = reader.ReadToEnd(); Assert.IsFalse(string.IsNullOrEmpty(content)); } using (var reader = File.OpenText(fileName)) { var content = reader.ReadToEnd(); Assert.IsFalse(string.IsNullOrEmpty(content)); } }