public OmniSharpProjectWorkspaceStateGenerator(OmniSharpForegroundDispatcher foregroundDispatcher) { if (foregroundDispatcher == null) { throw new ArgumentNullException(nameof(foregroundDispatcher)); } InternalWorkspaceStateGenerator = new DefaultProjectWorkspaceStateGenerator(foregroundDispatcher.InternalDispatcher); }
public OmniSharpProjectWorkspaceStateGenerator(OmniSharpProjectSnapshotManagerDispatcher projectSnapshotManagerDispatcher) { if (projectSnapshotManagerDispatcher is null) { throw new ArgumentNullException(nameof(projectSnapshotManagerDispatcher)); } InternalWorkspaceStateGenerator = new DefaultProjectWorkspaceStateGenerator(projectSnapshotManagerDispatcher.InternalDispatcher); }
public void Update_StartsUpdateTask() { // Arrange using (var stateGenerator = new DefaultProjectWorkspaceStateGenerator(Dispatcher)) { stateGenerator.BlockBackgroundWorkStart = new ManualResetEventSlim(initialState: false); // Act stateGenerator.Update(WorkspaceProject, ProjectSnapshot, CancellationToken.None); // Assert var update = Assert.Single(stateGenerator._updates); Assert.False(update.Value.Task.IsCompleted); } }
public void Dispose_MakesUpdateNoop() { // Arrange using (var stateGenerator = new DefaultProjectWorkspaceStateGenerator(Dispatcher)) { stateGenerator.BlockBackgroundWorkStart = new ManualResetEventSlim(initialState: false); // Act stateGenerator.Dispose(); stateGenerator.Update(WorkspaceProject, ProjectSnapshot, CancellationToken.None); // Assert Assert.Empty(stateGenerator._updates); } }
public void Update_SoftCancelsIncompleteTaskForSameProject() { // Arrange using (var stateGenerator = new DefaultProjectWorkspaceStateGenerator(Dispatcher)) { stateGenerator.BlockBackgroundWorkStart = new ManualResetEventSlim(initialState: false); stateGenerator.Update(WorkspaceProject, ProjectSnapshot, CancellationToken.None); var initialUpdate = stateGenerator._updates.Single().Value; // Act stateGenerator.Update(WorkspaceProject, ProjectSnapshot, CancellationToken.None); // Assert Assert.True(initialUpdate.Cts.IsCancellationRequested); } }
public async Task Update_ResolvesTagHelpersAndUpdatesWorkspaceState() { // Arrange using (var stateGenerator = new DefaultProjectWorkspaceStateGenerator(Dispatcher)) { stateGenerator.NotifyBackgroundWorkCompleted = new ManualResetEventSlim(initialState: false); var projectManager = new TestProjectSnapshotManager(Dispatcher, Workspace); stateGenerator.Initialize(projectManager); projectManager.ProjectAdded(ProjectSnapshot.HostProject); // Act stateGenerator.Update(WorkspaceProject, ProjectSnapshot, CancellationToken.None); // Jump off the foreground thread so the background work can complete. await Task.Run(() => stateGenerator.NotifyBackgroundWorkCompleted.Wait(TimeSpan.FromSeconds(3))); // Assert var newProjectSnapshot = projectManager.GetLoadedProject(ProjectSnapshot.FilePath); Assert.Equal(ResolvableTagHelpers, newProjectSnapshot.TagHelpers); } }
public async Task Update_NullWorkspaceProject_ClearsProjectWorkspaceState() { // Arrange using (var stateGenerator = new DefaultProjectWorkspaceStateGenerator(Dispatcher)) { stateGenerator.NotifyBackgroundWorkCompleted = new ManualResetEventSlim(initialState: false); var projectManager = new TestProjectSnapshotManager(Dispatcher, Workspace); stateGenerator.Initialize(projectManager); projectManager.ProjectAdded(ProjectSnapshot.HostProject); projectManager.ProjectWorkspaceStateChanged(ProjectSnapshot.FilePath, ProjectWorkspaceStateWithTagHelpers); // Act stateGenerator.Update(workspaceProject: null, ProjectSnapshot); // Jump off the foreground thread so the background work can complete. await Task.Run(() => stateGenerator.NotifyBackgroundWorkCompleted.Wait(TimeSpan.FromSeconds(3))); // Assert var newProjectSnapshot = projectManager.GetLoadedProject(ProjectSnapshot.FilePath); Assert.Empty(newProjectSnapshot.TagHelpers); } }