public void UpdateProjectCfg_Done_WithoutWorkspaceProject_DoesNotEnqueueUpdate()
        {
            // Arrange
            uint cookie;
            var  buildManager = new Mock <IVsSolutionBuildManager>(MockBehavior.Strict);

            buildManager
            .Setup(b => b.AdviseUpdateSolutionEvents(It.IsAny <VsSolutionUpdatesProjectSnapshotChangeTrigger>(), out cookie))
            .Returns(VSConstants.S_OK);

            var services = new Mock <IServiceProvider>(MockBehavior.Strict);

            services.Setup(s => s.GetService(It.Is <Type>(f => f == typeof(SVsSolutionBuildManager)))).Returns(buildManager.Object);
            var projectSnapshot = new DefaultProjectSnapshot(
                ProjectState.Create(
                    Workspace.Services,
                    new HostProject("/Some/Unknown/Path.csproj", RazorConfiguration.Default, "Path")));
            var expectedProjectPath = projectSnapshot.FilePath;

            var projectService = new Mock <TextBufferProjectService>(MockBehavior.Strict);

            projectService.Setup(p => p.GetProjectPath(It.IsAny <IVsHierarchy>())).Returns(expectedProjectPath);

            var projectManager = new Mock <ProjectSnapshotManagerBase>(MockBehavior.Strict);

            projectManager.SetupGet(p => p.Workspace).Returns(Workspace);
            projectManager
            .Setup(p => p.GetLoadedProject(expectedProjectPath))
            .Returns(projectSnapshot);
            var workspaceStateGenerator = new TestProjectWorkspaceStateGenerator();

            var trigger = new VsSolutionUpdatesProjectSnapshotChangeTrigger(services.Object, projectService.Object, workspaceStateGenerator);

            trigger.Initialize(projectManager.Object);

            // Act
            trigger.UpdateProjectCfg_Done(Mock.Of <IVsHierarchy>(MockBehavior.Strict), Mock.Of <IVsCfg>(MockBehavior.Strict), Mock.Of <IVsCfg>(MockBehavior.Strict), 0, 0, 0);

            // Assert
            Assert.Empty(workspaceStateGenerator.UpdateQueue);
        }
Пример #2
0
        private bool UpdateProjectStates()
        {
            ProjectState state = null;

            if (_appPath.WasAssigned || _configure.WasAssigned || _filesChanged.WasAssigned || _refreshDependencies.WasAssigned)
            {
                _appPath.ClearAssigned();
                _configure.ClearAssigned();
                _filesChanged.ClearAssigned();
                _refreshDependencies.ClearAssigned();

                state = ProjectState.Create(_appPath.Value, _configure.Value, _workspaceContext, _remote.ProjectSearchPaths);
            }

            if (state == null)
            {
                return(false);
            }

            _local = Snapshot.CreateFromProject(state.Project);
            _local.ProjectDiagnostics = state.Diagnostics;

            foreach (var projectInfo in state.Projects)
            {
                var projectWorkd = new ProjectSnapshot
                {
                    RootDependency        = projectInfo.RootDependency,
                    TargetFramework       = projectInfo.Framework,
                    SourceFiles           = new List <string>(projectInfo.SourceFiles),
                    CompilerOptions       = projectInfo.CompilerOptions,
                    ProjectReferences     = projectInfo.ProjectReferences,
                    FileReferences        = projectInfo.CompilationAssembiles,
                    DependencyDiagnostics = projectInfo.DependencyDiagnostics,
                    Dependencies          = projectInfo.Dependencies
                };

                _local.Projects[projectInfo.Framework] = projectWorkd;
            }

            return(true);
        }
Пример #3
0
        public DefaultProjectSnapshotManagerProxyTest()
        {
            Workspace = TestWorkspace.Create();
            var projectWorkspaceState1 = new ProjectWorkspaceState(new[]
            {
                TagHelperDescriptorBuilder.Create("test1", "TestAssembly1").Build(),
            }, default);

            ProjectSnapshot1 = new DefaultProjectSnapshot(
                ProjectState.Create(
                    Workspace.Services,
                    new HostProject("/host/path/to/project1.csproj", RazorConfiguration.Default, "project1"),
                    projectWorkspaceState1));
            var projectWorkspaceState2 = new ProjectWorkspaceState(new[]
            {
                TagHelperDescriptorBuilder.Create("test2", "TestAssembly2").Build(),
            }, default);

            ProjectSnapshot2 = new DefaultProjectSnapshot(
                ProjectState.Create(
                    Workspace.Services,
                    new HostProject("/host/path/to/project2.csproj", RazorConfiguration.Default, "project2"),
                    projectWorkspaceState2));
        }