public async Task OnProjectChanged_ReadsProperties_InitializesProject() { // Arrange ReferenceItems.Item("c:\\nuget\\Microsoft.AspNetCore.Mvc.razor.dll"); ContentItems.Item("Index.cshtml", new Dictionary <string, string>() { [ItemReference.FullPathPropertyName] = "C:\\Path\\Index.cshtml", }); NoneItems.Item("About.cshtml", new Dictionary <string, string>() { [ItemReference.FullPathPropertyName] = "C:\\Path\\About.cshtml", }); var changes = new TestProjectChangeDescription[] { ReferenceItems.ToChange(), ContentItems.ToChange(), NoneItems.ToChange(), }; var services = new TestProjectSystemServices("C:\\Path\\Test.csproj"); var host = new TestFallbackRazorProjectHost(services, Workspace, ProjectManager) { AssemblyVersion = new Version(2, 0), // Mock for reading the assembly's version }; await Task.Run(async() => await host.LoadAsync()); Assert.Empty(ProjectManager.Projects); // Act await Task.Run(async() => await host.OnProjectChanged(services.CreateUpdate(changes))); // Assert var snapshot = Assert.Single(ProjectManager.Projects); Assert.Equal("C:\\Path\\Test.csproj", snapshot.FilePath); Assert.Same(FallbackRazorConfiguration.MVC_2_0, snapshot.Configuration); Assert.Collection( snapshot.DocumentFilePaths, filePath => Assert.Equal("C:\\Path\\Index.cshtml", filePath), filePath => Assert.Equal("C:\\Path\\About.cshtml", filePath)); await Task.Run(async() => await host.DisposeAsync()); Assert.Empty(ProjectManager.Projects); }
public void GetCurrentDocuments_ReturnsContentAndNoneItems() { // Arrange ContentItems.Item("Index.cshtml", new Dictionary <string, string>() { [ItemReference.LinkPropertyName] = "NewIndex.cshtml", [ItemReference.FullPathPropertyName] = "C:\\From\\Index.cshtml", }); NoneItems.Item("About.cshtml", new Dictionary <string, string>() { [ItemReference.LinkPropertyName] = "NewAbout.cshtml", [ItemReference.FullPathPropertyName] = "C:\\From\\About.cshtml", }); var services = new TestProjectSystemServices("C:\\To\\Test.csproj"); var host = new TestFallbackRazorProjectHost(services, Workspace, RazorProjectChangePublisher, ProjectManager); var changes = new TestProjectChangeDescription[] { ContentItems.ToChange(), NoneItems.ToChange(), }; var update = services.CreateUpdate(changes).Value; // Act var result = host.GetCurrentDocuments(update); // Assert Assert.Collection( result, document => { Assert.Equal("C:\\From\\Index.cshtml", document.FilePath); Assert.Equal("C:\\To\\NewIndex.cshtml", document.TargetPath); }, document => { Assert.Equal("C:\\From\\About.cshtml", document.FilePath); Assert.Equal("C:\\To\\NewAbout.cshtml", document.TargetPath); }); }