public void OnGetFileStreamReturnsInternalErrorWhenPlaceholderVersionDoesNotMatchExpected() { using (MockVirtualizationInstance mockGvFlt = new MockVirtualizationInstance()) using (MockGitIndexProjection gitIndexProjection = new MockGitIndexProjection(new[] { "test.txt" })) { GVFltCallbacks callbacks = new GVFltCallbacks( this.Repo.Context, this.Repo.GitObjects, RepoMetadata.Instance, blobSizes: null, gvflt: mockGvFlt, gitIndexProjection: gitIndexProjection, reliableBackgroundOperations: new MockReliableBackgroundOperations()); string error; callbacks.TryStart(out error).ShouldEqual(true); Guid enumerationGuid = Guid.NewGuid(); byte[] contentId = GVFltCallbacks.ConvertShaToContentId("0123456789012345678901234567890123456789"); byte[] epochId = new byte[] { GVFltCallbacks.PlaceholderVersion + 1 }; mockGvFlt.OnGetFileStream( commandId: 1, relativePath: "test.txt", byteOffset: 0, length: 100, streamGuid: Guid.NewGuid(), contentId: contentId, epochId: epochId, triggeringProcessId: 2, triggeringProcessImageFileName: "UnitTest").ShouldEqual(NtStatus.InternalError); } }
public void OnGetFileStreamHandlesCancellationDuringWriteAction() { using (MockVirtualizationInstance mockGvFlt = new MockVirtualizationInstance()) using (MockGitIndexProjection gitIndexProjection = new MockGitIndexProjection(new[] { "test.txt" })) { GVFltCallbacks callbacks = new GVFltCallbacks( this.Repo.Context, this.Repo.GitObjects, RepoMetadata.Instance, new MockBlobSizes(), gvflt: mockGvFlt, gitIndexProjection: gitIndexProjection, reliableBackgroundOperations: new MockReliableBackgroundOperations()); string error; callbacks.TryStart(out error).ShouldEqual(true); Guid enumerationGuid = Guid.NewGuid(); byte[] contentId = GVFltCallbacks.ConvertShaToContentId("0123456789012345678901234567890123456789"); byte[] placeholderVersion = GVFltCallbacks.GetPlaceholderVersionId(); uint fileLength = 100; MockGVFSGitObjects mockGVFSGitObjects = this.Repo.GitObjects as MockGVFSGitObjects; mockGVFSGitObjects.FileLength = fileLength; MockTracer mockTracker = this.Repo.Context.Tracer as MockTracer; mockTracker.WaitRelatedEventName = "GVFltGetFileStreamHandlerAsyncHandler_OperationCancelled"; mockGvFlt.BlockCreateWriteBuffer(willWaitForRequest: true); mockGvFlt.OnGetFileStream( commandId: 1, relativePath: "test.txt", byteOffset: 0, length: fileLength, streamGuid: Guid.NewGuid(), contentId: contentId, providerId: placeholderVersion, triggeringProcessId: 2, triggeringProcessImageFileName: "UnitTest").ShouldEqual(HResult.Pending); mockGvFlt.WaitForCreateWriteBuffer(); mockGvFlt.OnCancelCommand(1); mockGvFlt.UnblockCreateWriteBuffer(); mockTracker.WaitForRelatedEvent(); callbacks.Stop(); } }
public void OnGetFileStreamHandlesGvWriteFailure() { using (MockVirtualizationInstance mockGvFlt = new MockVirtualizationInstance()) using (MockGitIndexProjection gitIndexProjection = new MockGitIndexProjection(new[] { "test.txt" })) { GVFltCallbacks callbacks = new GVFltCallbacks( this.Repo.Context, this.Repo.GitObjects, RepoMetadata.Instance, blobSizes: null, gvflt: mockGvFlt, gitIndexProjection: gitIndexProjection, reliableBackgroundOperations: new MockReliableBackgroundOperations()); string error; callbacks.TryStart(out error).ShouldEqual(true); Guid enumerationGuid = Guid.NewGuid(); byte[] contentId = GVFltCallbacks.ConvertShaToContentId("0123456789012345678901234567890123456789"); byte[] epochId = GVFltCallbacks.GetEpochId(); uint fileLength = 100; MockGVFSGitObjects mockGVFSGitObjects = this.Repo.GitObjects as MockGVFSGitObjects; mockGVFSGitObjects.FileLength = fileLength; MockTracer mockTracker = this.Repo.Context.Tracer as MockTracer; mockTracker.WaitRelatedEventName = "GVFltGetFileStreamHandlerAsyncHandler_OperationCancelled"; mockGvFlt.WriteFileReturnStatus = NtStatus.InternalError; mockGvFlt.OnGetFileStream( commandId: 1, relativePath: "test.txt", byteOffset: 0, length: fileLength, streamGuid: Guid.NewGuid(), contentId: contentId, epochId: epochId, triggeringProcessId: 2, triggeringProcessImageFileName: "UnitTest").ShouldEqual(NtStatus.Pending); mockGvFlt.WaitForCompletionStatus().ShouldEqual(mockGvFlt.WriteFileReturnStatus); callbacks.Stop(); } }
public void OnGetFileStreamReturnsPendingAndCompletesWithSuccessWhenNoFailures() { using (MockVirtualizationInstance mockGvFlt = new MockVirtualizationInstance()) using (MockGitIndexProjection gitIndexProjection = new MockGitIndexProjection(new[] { "test.txt" })) { GVFltCallbacks callbacks = new GVFltCallbacks( this.Repo.Context, this.Repo.GitObjects, RepoMetadata.Instance, new MockBlobSizes(), gvflt: mockGvFlt, gitIndexProjection: gitIndexProjection, reliableBackgroundOperations: new MockReliableBackgroundOperations()); string error; callbacks.TryStart(out error).ShouldEqual(true); Guid enumerationGuid = Guid.NewGuid(); byte[] contentId = GVFltCallbacks.ConvertShaToContentId("0123456789012345678901234567890123456789"); byte[] placeholderVersion = GVFltCallbacks.GetPlaceholderVersionId(); uint fileLength = 100; MockGVFSGitObjects mockGVFSGitObjects = this.Repo.GitObjects as MockGVFSGitObjects; mockGVFSGitObjects.FileLength = fileLength; mockGvFlt.WriteFileReturnResult = HResult.Ok; mockGvFlt.OnGetFileStream( commandId: 1, relativePath: "test.txt", byteOffset: 0, length: fileLength, streamGuid: Guid.NewGuid(), contentId: contentId, providerId: placeholderVersion, triggeringProcessId: 2, triggeringProcessImageFileName: "UnitTest").ShouldEqual(HResult.Pending); mockGvFlt.WaitForCompletionStatus().ShouldEqual(HResult.Ok); callbacks.Stop(); } }