public void TestDownloadedFileExists() { string fileName = "fileName.txt"; HTTPFileDownloader fileDownloader = new HTTPFileDownloader(); fileDownloader.DownloadFile("https://wordpress.org/plugins/about/readme.txt", fileName); Assert.IsTrue(File.Exists(fileName)); File.Delete(fileName); }
public void TestFileContentIsCorrect() { string fileName = "fileName.txt"; HTTPFileDownloader fileDownloader = new HTTPFileDownloader(); fileDownloader.DownloadFile("https://wordpress.org/plugins/about/readme.txt", fileName); using (StreamReader sr = new StreamReader(fileName)) { Assert.AreEqual(sr.ReadLine(), "=== Plugin Name ==="); } File.Delete(fileName); }
public HttpResponseMessage Get(string address, string filetype) { var path = @"C:\Users\student\Desktop\web." + filetype; HTTPFileDownloader downloader = new HTTPFileDownloader(); downloader.DownloadFile(address, path); HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK); var stream = new FileStream(path, FileMode.Open); result.Content = new StreamContent(stream); result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); return(result); }