private void DumpRefresh(bool isLocal) { #region Setup Console.WriteLine("\n=== TEST {0} ===", isLocal ? Local : Network); string tempPathSysIo = Path.GetTempPath("FileInfo.Refresh()-file-SysIo-" + Path.GetRandomFileName()); string tempPath = Path.GetTempPath("FileInfo.Refresh()-file-AlphaFS-" + Path.GetRandomFileName()); if (!isLocal) { tempPathSysIo = Path.LocalToUnc(tempPathSysIo); } if (!isLocal) { tempPath = Path.LocalToUnc(tempPath); } Console.WriteLine("\nInput File Path: [{0}]", tempPath); #endregion // Setup #region Refresh try { System.IO.FileInfo fiSysIo = new System.IO.FileInfo(tempPathSysIo); FileInfo fi = new FileInfo(tempPath); bool existsSysIo = fiSysIo.Exists; bool exists = fi.Exists; Console.WriteLine("\nnew FileInfo(): Exists (Should be {0}): [{1}]", existsSysIo, exists); // false Assert.AreEqual(existsSysIo, exists); FileStream fsSysIo = fiSysIo.Create(); FileStream fs = fi.Create(); existsSysIo = fiSysIo.Exists; exists = fi.Exists; Console.WriteLine("\nfi.Create(): Exists (Should be {0}): [{1}]", existsSysIo, exists); // false Assert.AreEqual(existsSysIo, exists); fiSysIo.Refresh(); fi.Refresh(); existsSysIo = fiSysIo.Exists; exists = fi.Exists; Console.WriteLine("\nfi.Refresh(): Exists (Should be {0}): [{1}]", existsSysIo, exists); // true Assert.AreEqual(existsSysIo, exists); fsSysIo.Close(); fs.Close(); existsSysIo = fiSysIo.Exists; exists = fi.Exists; Console.WriteLine("\nfi.Close(): Exists (Should be {0}): [{1}]", existsSysIo, exists); // true Assert.AreEqual(existsSysIo, exists); fiSysIo.Delete(); fi.Delete(); existsSysIo = fiSysIo.Exists; exists = fi.Exists; Console.WriteLine("\nfi.Delete(): Exists (Should be {0}): [{1}]", existsSysIo, exists); // true Assert.AreEqual(existsSysIo, exists); fiSysIo.Refresh(); fi.Refresh(); existsSysIo = fiSysIo.Exists; exists = fi.Exists; Console.WriteLine("\nfi.Refresh(): Exists (Should be False): [{0}]", exists); // false Assert.AreEqual(existsSysIo, exists); } finally { File.Delete(tempPath); Assert.IsFalse(File.Exists(tempPath), "Cleanup failed: File should have been removed."); File.Delete(tempPathSysIo); Assert.IsFalse(File.Exists(tempPath), "Cleanup failed: File should have been removed."); Console.WriteLine(); } #endregion // Refresh }
public override string GetRandomFileName() { return(AfsPath.GetRandomFileName()); }