public void FileAndFolderCallbacksScheduleBackgroundTasks() { using (MockBackgroundFileSystemTaskRunner backgroundTaskRunner = new MockBackgroundFileSystemTaskRunner()) using (FileSystemCallbacks fileSystemCallbacks = new FileSystemCallbacks( this.Repo.Context, this.Repo.GitObjects, RepoMetadata.Instance, new MockBlobSizes(), gitIndexProjection: null, backgroundFileSystemTaskRunner: backgroundTaskRunner, fileSystemVirtualizer: null)) { this.CallbackSchedulesBackgroundTask( backgroundTaskRunner, (path) => fileSystemCallbacks.OnFileConvertedToFull(path), "OnFileConvertedToFull.txt", FileSystemTask.OperationType.OnFileConvertedToFull); this.CallbackSchedulesBackgroundTask( backgroundTaskRunner, (path) => fileSystemCallbacks.OnFileCreated(path), "OnFileCreated.txt", FileSystemTask.OperationType.OnFileCreated); this.CallbackSchedulesBackgroundTask( backgroundTaskRunner, (path) => fileSystemCallbacks.OnFileDeleted(path), "OnFileDeleted.txt", FileSystemTask.OperationType.OnFileDeleted); this.CallbackSchedulesBackgroundTask( backgroundTaskRunner, (path) => fileSystemCallbacks.OnFileOverwritten(path), "OnFileOverwritten.txt", FileSystemTask.OperationType.OnFileOverwritten); this.CallbackSchedulesBackgroundTask( backgroundTaskRunner, (oldPath, newPath) => fileSystemCallbacks.OnFileRenamed(oldPath, newPath), "OnFileRenamed.txt", "OnFileRenamed2.txt", FileSystemTask.OperationType.OnFileRenamed); this.CallbackSchedulesBackgroundTask( backgroundTaskRunner, (path) => fileSystemCallbacks.OnFileSuperseded(path), "OnFileSuperseded.txt", FileSystemTask.OperationType.OnFileSuperseded); this.CallbackSchedulesBackgroundTask( backgroundTaskRunner, (path) => fileSystemCallbacks.OnFolderCreated(path), "OnFolderCreated.txt", FileSystemTask.OperationType.OnFolderCreated); this.CallbackSchedulesBackgroundTask( backgroundTaskRunner, (path) => fileSystemCallbacks.OnFolderDeleted(path), "OnFolderDeleted.txt", FileSystemTask.OperationType.OnFolderDeleted); this.CallbackSchedulesBackgroundTask( backgroundTaskRunner, (oldPath, newPath) => fileSystemCallbacks.OnFolderRenamed(oldPath, newPath), "OnFolderRenamed.txt", "OnFolderRenamed2.txt", FileSystemTask.OperationType.OnFolderRenamed); } }
public void FileAndFolderCallbacksScheduleBackgroundTasks() { Mock <IPlaceholderCollection> mockPlaceholderDb = new Mock <IPlaceholderCollection>(MockBehavior.Strict); mockPlaceholderDb.Setup(x => x.GetCount()).Returns(1); Mock <ISparseCollection> mockSparseDb = new Mock <ISparseCollection>(MockBehavior.Strict); mockSparseDb.Setup(x => x.GetAll()).Returns(new HashSet <string>()); using (MockBackgroundFileSystemTaskRunner backgroundTaskRunner = new MockBackgroundFileSystemTaskRunner()) using (FileSystemCallbacks fileSystemCallbacks = new FileSystemCallbacks( this.Repo.Context, this.Repo.GitObjects, RepoMetadata.Instance, new MockBlobSizes(), gitIndexProjection: null, backgroundFileSystemTaskRunner: backgroundTaskRunner, fileSystemVirtualizer: null, placeholderDatabase: mockPlaceholderDb.Object, sparseCollection: mockSparseDb.Object)) { this.CallbackSchedulesBackgroundTask( backgroundTaskRunner, (path) => fileSystemCallbacks.OnFileConvertedToFull(path), "OnFileConvertedToFull.txt", FileSystemTask.OperationType.OnFileConvertedToFull); this.CallbackSchedulesBackgroundTask( backgroundTaskRunner, (path) => fileSystemCallbacks.OnFileCreated(path), "OnFileCreated.txt", FileSystemTask.OperationType.OnFileCreated); this.CallbackSchedulesBackgroundTask( backgroundTaskRunner, (path) => fileSystemCallbacks.OnFileDeleted(path), "OnFileDeleted.txt", FileSystemTask.OperationType.OnFileDeleted); this.CallbackSchedulesBackgroundTask( backgroundTaskRunner, (path) => fileSystemCallbacks.OnFileOverwritten(path), "OnFileOverwritten.txt", FileSystemTask.OperationType.OnFileOverwritten); this.CallbackSchedulesBackgroundTask( backgroundTaskRunner, (oldPath, newPath) => fileSystemCallbacks.OnFileRenamed(oldPath, newPath), "OnFileRenamed.txt", "OnFileRenamed2.txt", FileSystemTask.OperationType.OnFileRenamed); this.CallbackSchedulesBackgroundTask( backgroundTaskRunner, (existingPath, newLink) => fileSystemCallbacks.OnFileHardLinkCreated(newLink, existingPath), string.Empty, "OnFileHardLinkCreated.txt", FileSystemTask.OperationType.OnFileHardLinkCreated); this.CallbackSchedulesBackgroundTask( backgroundTaskRunner, (path) => fileSystemCallbacks.OnFileSuperseded(path), "OnFileSuperseded.txt", FileSystemTask.OperationType.OnFileSuperseded); this.CallbackSchedulesBackgroundTask( backgroundTaskRunner, (path) => fileSystemCallbacks.OnFolderCreated(path, out _), "OnFolderCreated.txt", FileSystemTask.OperationType.OnFolderCreated); this.CallbackSchedulesBackgroundTask( backgroundTaskRunner, (path) => fileSystemCallbacks.OnFolderDeleted(path), "OnFolderDeleted.txt", FileSystemTask.OperationType.OnFolderDeleted); this.CallbackSchedulesBackgroundTask( backgroundTaskRunner, (oldPath, newPath) => fileSystemCallbacks.OnFolderRenamed(oldPath, newPath), "OnFolderRenamed.txt", "OnFolderRenamed2.txt", FileSystemTask.OperationType.OnFolderRenamed); } mockPlaceholderDb.VerifyAll(); mockSparseDb.VerifyAll(); }