private IFileSystem CreateFileSystem() { var lowerLayerFs = new InMemoryFileSystem(); var upperLayerFs = new InMemoryFileSystem(); var layeredFs = new LayeredFileSystem(lowerLayerFs, upperLayerFs); lowerLayerFs.CreateDirectory("/dir".ToU8Span()).ThrowIfFailure(); upperLayerFs.CreateDirectory("/dir".ToU8Span()).ThrowIfFailure(); lowerLayerFs.CreateDirectory("/dir2".ToU8Span()).ThrowIfFailure(); upperLayerFs.CreateDirectory("/dir2".ToU8Span()).ThrowIfFailure(); lowerLayerFs.CreateDirectory("/dir3".ToU8Span()).ThrowIfFailure(); upperLayerFs.CreateDirectory("/dir3".ToU8Span()).ThrowIfFailure(); lowerLayerFs.CreateDirectory("/lowerDir".ToU8Span()).ThrowIfFailure(); upperLayerFs.CreateDirectory("/upperDir".ToU8Span()).ThrowIfFailure(); lowerLayerFs.CreateFile("/dir/replacedFile".ToU8Span(), 1, CreateFileOptions.None).ThrowIfFailure(); upperLayerFs.CreateFile("/dir/replacedFile".ToU8Span(), 2, CreateFileOptions.None).ThrowIfFailure(); lowerLayerFs.CreateFile("/dir2/lowerFile".ToU8Span(), 0, CreateFileOptions.None).ThrowIfFailure(); upperLayerFs.CreateFile("/dir2/upperFile".ToU8Span(), 0, CreateFileOptions.None).ThrowIfFailure(); lowerLayerFs.CreateFile("/dir3/lowerFile".ToU8Span(), 0, CreateFileOptions.None).ThrowIfFailure(); upperLayerFs.CreateFile("/dir3/upperFile".ToU8Span(), 2, CreateFileOptions.None).ThrowIfFailure(); lowerLayerFs.CreateFile("/dir3/replacedFile".ToU8Span(), 1, CreateFileOptions.None).ThrowIfFailure(); upperLayerFs.CreateFile("/dir3/replacedFile".ToU8Span(), 2, CreateFileOptions.None).ThrowIfFailure(); lowerLayerFs.CreateFile("/replacedWithDir".ToU8Span(), 0, CreateFileOptions.None).ThrowIfFailure(); upperLayerFs.CreateDirectory("/replacedWithDir".ToU8Span()).ThrowIfFailure(); upperLayerFs.CreateFile("/replacedWithDir/subFile".ToU8Span(), 0, CreateFileOptions.None).ThrowIfFailure(); return(layeredFs); }
private (IFileSystem baseFs, IFileSystem subDirFs) CreateFileSystemInternal() { var baseFs = new InMemoryFileSystem(); baseFs.CreateDirectory("/sub".ToU8Span()); baseFs.CreateDirectory("/sub/path".ToU8Span()); SubdirectoryFileSystem.CreateNew(out SubdirectoryFileSystem subFs, baseFs, "/sub/path".ToU8String()).ThrowIfFailure(); return(baseFs, subFs); }
public void Initialize_InterruptedAfterCommitPart1_UsesWorkingData() { var baseFs = new InMemoryFileSystem(); baseFs.CreateDirectory("/_".ToU8Span()).ThrowIfFailure(); baseFs.CreateDirectory("/1".ToU8Span()).ThrowIfFailure(); // Set the existing files before initializing the save FS baseFs.CreateFile("/_/file1".ToU8Span(), 0, CreateFileOptions.None).ThrowIfFailure(); baseFs.CreateFile("/1/file2".ToU8Span(), 0, CreateFileOptions.None).ThrowIfFailure(); DirectorySaveDataFileSystem.CreateNew(out DirectorySaveDataFileSystem saveFs, baseFs, true, true) .ThrowIfFailure(); Assert.Result(ResultFs.PathNotFound, saveFs.GetEntryType(out _, "/file1".ToU8Span())); Assert.Success(saveFs.GetEntryType(out _, "/file2".ToU8Span())); }
protected override async Task <IStorage> CreateStorage() { var root = Guid.NewGuid().ToString(); var fs = new InMemoryFileSystem(); await fs.CreateDirectory(root); return(new FileSystemStorage(fs, root)); }
public new void TestCreateDirectory1() { _fileSystem.ExistsDirectory("foo").Should().BeFalse(); _fileSystem.CreateDirectory("foo"); _fileSystem.ExistsDirectory("foo").Should().BeTrue(); }
protected override async Task <IStorageSession> CreateSession() { await _fs.CreateDirectory(Root); return(new FileSystemSession(_fs, Builders, Projections, Root)); }