public void TestFileWrapperWithDefaultPath() { string filePath; using (var file = new TempData.TempFile()) { filePath = file.Path; NAssert.NotNull(file.Info, "Info is null"); Assert.IsFalse(file.Info.Exists, "File should not exist"); using (File.Create(filePath)) { } file.Info.Refresh(); Assert.IsTrue(file.Info.Exists, "File should exist"); } Assert.IsFalse(File.Exists(filePath), "File should NOT exist"); }
public void TestFileWrapperWithCustomPath() { var tempPath = Path.GetTempPath(); var fileName = TempData.GetTempName(); var filePath = Path.Combine(tempPath, fileName); using (var file = new TempData.TempFile(filePath)) { Assert.AreEqual(filePath, file.Path); NAssert.NotNull(file.Info, "Info is null"); Assert.IsFalse(file.Info.Exists, "File should not exist"); using (File.Create(filePath)) { } file.Info.Refresh(); Assert.IsTrue(file.Info.Exists, "File should exist"); } Assert.IsFalse(File.Exists(filePath), "File should NOT exist"); }