public void GetMD5ForFileTest() { string fileName = AppDomain.CurrentDomain.BaseDirectory + "\\MD5 test.txt"; // TODO: Initialize to an appropriate value string expected = "E26AC8BB85B704AC5F85DEA83A5ED99B"; // TODO: Initialize to an appropriate value string actual; actual = MD5Maker.GetMD5ForFile(fileName); Assert.AreEqual(expected, actual); }
public void GetMD5ForStringTest() { string value = string.Empty; // TODO: Initialize to an appropriate value string expected = string.Empty; // TODO: Initialize to an appropriate value string actual; actual = MD5Maker.GetMD5ForString(value); Assert.AreEqual(expected, actual); value = "md5 test"; expected = "2E5F9458BCD27E3C2B5908AF0B91551A"; actual = MD5Maker.GetMD5ForString(value); Assert.AreEqual(expected, actual); }
/// <summary> /// Updater a file via Downloader class /// </summary> /// <param name="updateFileName">The file want to update without the path</param> /// <param name="md5InServer">The md5 value from DFUpdateInstruction.xml</param> /// <returns>Updater result: True-success; False-failed</returns> private bool DoUpdate(string updateFileName, string md5InServer) { string fullFileName = this.GetFullFileName(this.FileLocalPath, updateFileName); string url = this.GetFullFileName(this.FileServerPath, updateFileName); bool isUpdated = false; string md5InLocal = string.Empty; if (File.Exists(fullFileName)) { md5InLocal = MD5Maker.GetMD5ForFile(fullFileName); if (md5InLocal != md5InServer) { isUpdated = HttpUtils.DownloadFile(url, fullFileName); } } else { isUpdated = HttpUtils.DownloadFile(url, fullFileName); } return(isUpdated); }