public void Persistence() { string outFileName = Path.GetTempFileName(); string srcFileName = Path.GetTempFileName(); bool fNeedToDelete = true; try { CreateTempFile(outFileName); string outHash = m_mgr.GetHash(outFileName); CreateTempFile(srcFileName); string handle = "p_jXrLgQMK7dUx+QMtYfjw==.0"; // m_mgr.GetHash(srcFileName); m_mgr.CacheFile(handle, outFileName); m_mgr.Close(); File.Delete(outFileName); fNeedToDelete = false; m_mgr = new LocalCacheManager(); CachedFile[] resFileName = m_mgr.GetCachedFiles(handle); Assert.AreEqual(1, resFileName.Length); Assert.AreEqual(outHash, m_mgr.GetHash(resFileName[0].CachedFileName)); Assert.AreEqual(Path.GetFileName(outFileName), resFileName[0].OriginalName); } finally { if (fNeedToDelete) { File.Delete(outFileName); } File.Delete(srcFileName); } }
public void Persistence() { string outFileName = Path.GetTempFileName(); string srcFileName = Path.GetTempFileName(); bool fNeedToDelete = true; try { CreateTempFile(outFileName); string outHash = m_mgr.GetHash(outFileName); CreateTempFile(srcFileName); string handle = "p_jXrLgQMK7dUx+QMtYfjw==.0"; // m_mgr.GetHash(srcFileName); m_mgr.CacheFile(handle, outFileName); m_mgr.Close(); File.Delete(outFileName); fNeedToDelete = false; m_mgr = new LocalCacheManager(); CachedFile[] resFileName = m_mgr.GetCachedFiles(handle); Assert.AreEqual(1, resFileName.Length); Assert.AreEqual(outHash, m_mgr.GetHash(resFileName[0].CachedFileName)); Assert.AreEqual(Path.GetFileName(outFileName), resFileName[0].OriginalName); } finally { if (fNeedToDelete) File.Delete(outFileName); File.Delete(srcFileName); } }
public void GetHash_NonexistingFile() { Assert.IsNull(m_mgr.GetHash(Path.GetRandomFileName())); }