示例#1
0
        public async Task DefaultRazorProjectHost_BackgroundThread_CreateAndDispose_Succeeds()
        {
            // Arrange
            var services = new TestProjectSystemServices("Test.csproj");
            var host     = new DefaultRazorProjectHost(services, Workspace, ProjectManager);

            // Act & Assert
            await Task.Run(async() => await host.LoadAsync());

            Assert.Empty(ProjectManager.Projects);

            await Task.Run(async() => await host.DisposeAsync());

            Assert.Empty(ProjectManager.Projects);
        }
示例#2
0
        public async Task DefaultRazorProjectHost_ForegroundThread_CreateAndDispose_Succeeds()
        {
            // Arrange
            var services = new TestProjectSystemServices(TestProjectData.SomeProject.FilePath);
            var host     = new DefaultRazorProjectHost(services, Workspace, ProjectManager);

            // Act & Assert
            await host.LoadAsync();

            Assert.Empty(ProjectManager.Projects);

            await host.DisposeAsync();

            Assert.Empty(ProjectManager.Projects);
        }
示例#3
0
        public async Task OnProjectRenamed_RemovesHostProject_CopiesConfiguration()
        {
            // Arrange
            var changes = new TestProjectChangeDescription[]
            {
                new TestProjectChangeDescription()
                {
                    RuleName = Rules.RazorGeneral.SchemaName,
                    After    = TestProjectRuleSnapshot.CreateProperties(Rules.RazorGeneral.SchemaName, new Dictionary <string, string>()
                    {
                        { Rules.RazorGeneral.RazorLangVersionProperty, "2.1" },
                        { Rules.RazorGeneral.RazorDefaultConfigurationProperty, "MVC-2.1" },
                    }),
                },
                new TestProjectChangeDescription()
                {
                    RuleName = Rules.RazorConfiguration.SchemaName,
                    After    = TestProjectRuleSnapshot.CreateItems(Rules.RazorConfiguration.SchemaName, new Dictionary <string, Dictionary <string, string> >()
                    {
                        { "MVC-2.1", new Dictionary <string, string>()
                          {
                              { "Extensions", "MVC-2.1;Another-Thing" },
                          } },
                    })
                },
                new TestProjectChangeDescription()
                {
                    RuleName = Rules.RazorExtension.SchemaName,
                    After    = TestProjectRuleSnapshot.CreateItems(Rules.RazorExtension.SchemaName, new Dictionary <string, Dictionary <string, string> >()
                    {
                        { "MVC-2.1", new Dictionary <string, string>()
                          {
                          } },
                        { "Another-Thing", new Dictionary <string, string>()
                          {
                          } },
                    })
                }
            };

            var services = new TestProjectSystemServices("Test.csproj");

            var host = new DefaultRazorProjectHost(services, Workspace, ProjectManager);

            await Task.Run(async() => await host.LoadAsync());

            Assert.Empty(ProjectManager.Projects);

            // Act - 1
            await Task.Run(async() => await host.OnProjectChanged(services.CreateUpdate(changes)));

            // Assert - 1
            var snapshot = Assert.Single(ProjectManager.Projects);

            Assert.Equal("Test.csproj", snapshot.FilePath);
            Assert.Same("MVC-2.1", snapshot.Configuration.ConfigurationName);

            // Act - 2
            services.UnconfiguredProject.FullPath = "Test2.csproj";
            await Task.Run(async() => await host.OnProjectRenamingAsync());

            // Assert - 1
            snapshot = Assert.Single(ProjectManager.Projects);
            Assert.Equal("Test2.csproj", snapshot.FilePath);
            Assert.Same("MVC-2.1", snapshot.Configuration.ConfigurationName);

            await Task.Run(async() => await host.DisposeAsync());

            Assert.Empty(ProjectManager.Projects);
        }