public async Task Unmount_Timeout() { // Mount the file system DummyFileSystem dummyFileSystem = new DummyFileSystem(); string mountPoint = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); Directory.CreateDirectory(mountPoint); IFuseMount mount = Fuse.Mount(mountPoint, dummyFileSystem); // Open a file and try to unmount FileStream openedFile = File.OpenRead(Path.Combine(mountPoint, "filename")); long startTime = Stopwatch.GetTimestamp(); const int timeout = 1000; bool unmounted = await mount.UnmountAsync(timeout); long endTime = Stopwatch.GetTimestamp(); // Unmounting times out. Assert.False(unmounted); Assert.True((1000 * (endTime - startTime)) / Stopwatch.Frequency >= timeout); // Close the file and try to unmount openedFile.Close(); // Unmounting succeeds. unmounted = await mount.UnmountAsync(); Assert.True(unmounted); }
public FuseOperationsTests() { _mountPoint = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); Directory.CreateDirectory(_mountPoint); _mount = Fuse.Mount(_mountPoint, new FileSystem()); }
public async Task Unmount_DisposesFileSystem() { DummyFileSystem dummyFileSystem = new DummyFileSystem(); string mountPoint = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); Directory.CreateDirectory(mountPoint); IFuseMount mount = Fuse.Mount(mountPoint, dummyFileSystem); bool unmounted = await mount.UnmountAsync(1000); Assert.True(unmounted); Assert.Equal(1, dummyFileSystem.DisposeCount); }