public async Task IsComponentFile_Component_ReturnsTrue() { // Arrange var projectManager = CreateProjectSnapshotManager(); var refreshTrigger = CreateRefreshTrigger(); refreshTrigger.Initialize(projectManager); var hostProject = new OmniSharpHostProject("/path/to/project.csproj", RazorConfiguration.Default, "TestRootNamespace"); var hostDocument = new OmniSharpHostDocument("file.cshtml", "file.cshtml", FileKinds.Component); await RunOnDispatcherThreadAsync(() => { projectManager.ProjectAdded(hostProject); projectManager.DocumentAdded(hostProject, hostDocument); }).ConfigureAwait(false); // Act var result = await RunOnDispatcherThreadAsync(() => refreshTrigger.IsComponentFile(hostDocument.FilePath, hostProject.FilePath)).ConfigureAwait(false); // Assert Assert.True(result); }
public async Task RazorDocumentChangedAsync_Changed_NotComponent_Noops() { // Arrange var projectInstance = new ProjectInstance(ProjectRootElement.Create()); var projectManager = CreateProjectSnapshotManager(); var refreshTrigger = CreateTestComponentRefreshTrigger(); refreshTrigger.Initialize(projectManager); await RunOnForegroundAsync(() => { var hostProject = new OmniSharpHostProject("/path/to/project.csproj", RazorConfiguration.Default, "TestRootNamespace"); projectManager.ProjectAdded(hostProject); var hostDocument = new OmniSharpHostDocument("file.cshtml", "file.cshtml", FileKinds.Legacy); projectManager.DocumentAdded(hostProject, hostDocument); }); var args = new RazorFileChangeEventArgs("file.cshtml", "file.cshtml", projectInstance, RazorFileChangeKind.Changed); // Act & Assert await refreshTrigger.RazorDocumentChangedAsync(args); }
public async Task PSM_DocumentRemoved_NoBackgroundDocument_Noops() { // Arrange var projectSnapshotManager = CreateProjectSnapshotManager(allowNotifyListeners: true); var hostProject = new OmniSharpHostProject(Project.FilePath, RazorConfiguration.Default, rootNamespace: "TestRootNamespace"); var hostDocument = new OmniSharpHostDocument("/path/to/Counter.razor", "/path/to/Counter.razor", FileKinds.Component); await RunOnForegroundAsync(() => { projectSnapshotManager.ProjectAdded(hostProject); projectSnapshotManager.DocumentAdded(hostProject, hostDocument); }); var originalSolution = Workspace.CurrentSolution; var processedPublisher = new BackgroundDocumentProcessedPublisher(Dispatcher, Workspace, LoggerFactory); processedPublisher.Initialize(projectSnapshotManager); // Act await RunOnForegroundAsync(() => projectSnapshotManager.DocumentRemoved(hostProject, hostDocument)); // Assert Assert.Same(originalSolution, Workspace.CurrentSolution); }
public abstract void DocumentRemoved(OmniSharpHostProject hostProject, OmniSharpHostDocument hostDocument);
public override void DocumentRemoved(OmniSharpHostProject hostProject, OmniSharpHostDocument hostDocument) { InternalProjectSnapshotManager.DocumentRemoved(hostProject.InternalHostProject, hostDocument.InternalHostDocument); }
public override void DocumentAdded(OmniSharpHostProject hostProject, OmniSharpHostDocument hostDocument) { InternalProjectSnapshotManager.DocumentAdded(hostProject.InternalHostProject, hostDocument.InternalHostDocument, textLoader: null); }
public override void DocumentAdded(OmniSharpHostProject hostProject, OmniSharpHostDocument hostDocument) { var textLoader = _remoteTextLoaderFactory.Create(hostDocument.FilePath); InternalProjectSnapshotManager.DocumentAdded(hostProject.InternalHostProject, hostDocument.InternalHostDocument, textLoader); }