Beispiel #1
0
        public void ProjectOperations_EndBuild_ProjectWithoutWorkspaceProject_Noops()
        {
            // Arrange
            var expectedPath   = "Path/To/Project.csproj";
            var projectService = CreateProjectService(expectedPath);

            var args            = new BuildEventArgs(monitor: null, success: true);
            var projectSnapshot = new DefaultProjectSnapshot(
                ProjectState.Create(
                    Workspace.Services,
                    new HostProject(expectedPath, RazorConfiguration.Default)));

            var projectManager = new Mock <ProjectSnapshotManagerBase>();

            projectManager.SetupGet(p => p.Workspace).Returns(Workspace);
            projectManager
            .Setup(p => p.GetLoadedProject(expectedPath))
            .Returns(projectSnapshot);
            var workspaceStateGenerator = new TestProjectWorkspaceStateGenerator();
            var trigger = new ProjectBuildChangeTrigger(Dispatcher, projectService, workspaceStateGenerator, projectManager.Object);

            // Act
            trigger.ProjectOperations_EndBuild(null, args);

            // Assert
            Assert.Empty(workspaceStateGenerator.UpdateQueue);
        }
Beispiel #2
0
        public void ProjectOperations_EndBuild_Invokes_ProjectBuildComplete()
        {
            // Arrange
            var args = new BuildEventArgs(monitor: null, success: true);
            var expectedProjectPath = "Path/To/Project";
            var projectService      = CreateProjectService(expectedProjectPath);
            var projectSnapshots    = new[]
            {
                Mock.Of <ProjectSnapshot>(p => p.FilePath == expectedProjectPath && p.HostProject == new HostProject(expectedProjectPath, RazorConfiguration.Default)),
                Mock.Of <ProjectSnapshot>(p => p.FilePath == "Test2.csproj" && p.HostProject == new HostProject("Test2.csproj", RazorConfiguration.Default)),
            };

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

            projectManager.SetupGet(p => p.Projects).Returns(projectSnapshots);
            projectManager
            .Setup(p => p.HostProjectBuildComplete(It.IsAny <HostProject>()))
            .Callback <HostProject>(c => Assert.Equal(expectedProjectPath, c.FilePath));
            var trigger = new ProjectBuildChangeTrigger(Dispatcher, projectService, projectManager.Object);

            // Act
            trigger.ProjectOperations_EndBuild(null, args);

            // Assert
            projectManager.VerifyAll();
        }
Beispiel #3
0
        public void ProjectOperations_EndBuild_EnqueuesProjectStateUpdate()
        {
            // Arrange
            var expectedProjectPath = SomeProject.FilePath;
            var projectService      = CreateProjectService(expectedProjectPath);

            var args            = new BuildEventArgs(monitor: null, success: true);
            var projectSnapshot = new DefaultProjectSnapshot(ProjectState.Create(Workspace.Services, SomeProject));

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

            projectManager.SetupGet(p => p.Workspace).Returns(Workspace);
            projectManager
            .Setup(p => p.GetLoadedProject(SomeProject.FilePath))
            .Returns(projectSnapshot);
            var workspaceStateGenerator = new TestProjectWorkspaceStateGenerator();
            var trigger = new ProjectBuildChangeTrigger(Dispatcher, projectService, workspaceStateGenerator, projectManager.Object);

            // Act
            trigger.ProjectOperations_EndBuild(null, args);

            // Assert
            var update = Assert.Single(workspaceStateGenerator.UpdateQueue);

            Assert.Equal(SomeWorkspaceProject, update.workspaceProject);
        }
Beispiel #4
0
        public void ProjectOperations_EndBuild_Invokes_ProjectBuildComplete()
        {
            // Arrange
            var args = new BuildEventArgs(monitor: null, success: true);
            var expectedProjectName = "Test1";
            var expectedProjectPath = "Path/To/Project";
            var projectService      = CreateProjectService(expectedProjectName, expectedProjectPath);
            var workspace           = TestWorkspace.Create(ws =>
            {
                CreateProjectInWorkspace(ws, expectedProjectName, expectedProjectPath);
                CreateProjectInWorkspace(ws, "Test2", "Path/To/AnotherProject");
            });

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

            projectManager.SetupGet(p => p.Workspace).Returns(workspace);
            projectManager
            .Setup(p => p.ProjectBuildComplete(It.IsAny <Project>()))
            .Callback <Project>(c => Assert.Equal(expectedProjectName, c.Name));
            var trigger = new ProjectBuildChangeTrigger(Dispatcher, projectService, projectManager.Object);

            // Act
            trigger.ProjectOperations_EndBuild(null, args);

            // Assert
            projectManager.VerifyAll();
        }
        public void ProjectOperations_EndBuild_UnsupportedProject_Noops()
        {
            // Arrange
            var args           = new BuildEventArgs(monitor: null, success: true);
            var projectService = new Mock <TextBufferProjectService>();

            projectService.Setup(p => p.IsSupportedProject(null)).Returns(false);
            var projectManager = new Mock <ProjectSnapshotManagerBase>();

            projectManager.SetupGet(p => p.Workspace).Throws <InvalidOperationException>();
            var trigger = new ProjectBuildChangeTrigger(Dispatcher, projectService.Object, projectManager.Object);

            // Act & Assert
            trigger.ProjectOperations_EndBuild(null, args);
        }
Beispiel #6
0
        public void ProjectOperations_EndBuild_BuildFailed_Noops()
        {
            // Arrange
            var args           = new BuildEventArgs(monitor: null, success: false);
            var projectService = new Mock <TextBufferProjectService>();

            projectService.Setup(p => p.IsSupportedProject(null)).Throws <InvalidOperationException>();
            var projectManager = new Mock <ProjectSnapshotManagerBase>();

            projectManager.SetupGet(p => p.Workspace).Throws <InvalidOperationException>();
            var workspaceStateGenerator = new TestProjectWorkspaceStateGenerator();
            var trigger = new ProjectBuildChangeTrigger(Dispatcher, projectService.Object, workspaceStateGenerator, projectManager.Object);

            // Act
            trigger.ProjectOperations_EndBuild(null, args);

            // Assert
            Assert.Empty(workspaceStateGenerator.UpdateQueue);
        }
Beispiel #7
0
        public void ProjectOperations_EndBuild_UntrackedProject_Noops()
        {
            // Arrange
            var args           = new BuildEventArgs(monitor: null, success: true);
            var projectService = CreateProjectService("Test1", "Path/To/Project");
            var workspace      = new AdhocWorkspace();

            CreateProjectInWorkspace(workspace, "Test2", "Path/To/AnotherProject");
            var projectManager = new Mock <ProjectSnapshotManagerBase>();

            projectManager.SetupGet(p => p.Workspace).Returns(workspace);
            projectManager
            .Setup(p => p.ProjectBuildComplete(It.IsAny <Project>()))
            .Throws <InvalidOperationException>();
            var trigger = new ProjectBuildChangeTrigger(Dispatcher, projectService, projectManager.Object);

            // Act & Assert
            trigger.ProjectOperations_EndBuild(null, args);
        }
Beispiel #8
0
        public void ProjectOperations_EndBuild_UntrackedProject_Noops()
        {
            // Arrange
            var args             = new BuildEventArgs(monitor: null, success: true);
            var projectService   = CreateProjectService("Path/To/Project");
            var projectSnapshots = new[]
            {
                Mock.Of <ProjectSnapshot>(p => p.FilePath == "Path/To/AnotherProject" && p.HostProject == new HostProject("Path/To/AnotherProject", RazorConfiguration.Default)),
            };
            var projectManager = new Mock <ProjectSnapshotManagerBase>();

            projectManager.SetupGet(p => p.Projects).Returns(projectSnapshots);
            projectManager
            .Setup(p => p.HostProjectBuildComplete(It.IsAny <HostProject>()))
            .Throws <InvalidOperationException>();
            var trigger = new ProjectBuildChangeTrigger(Dispatcher, projectService, projectManager.Object);

            // Act & Assert
            trigger.ProjectOperations_EndBuild(null, args);
        }
Beispiel #9
0
        public void ProjectOperations_EndBuild_UntrackedProject_Noops()
        {
            // Arrange
            var projectService = CreateProjectService(SomeProject.FilePath);

            var args = new BuildEventArgs(monitor: null, success: true);

            var projectManager = new Mock <ProjectSnapshotManagerBase>();

            projectManager.SetupGet(p => p.Workspace).Returns(Workspace);
            projectManager
            .Setup(p => p.GetLoadedProject(SomeProject.FilePath))
            .Returns <ProjectSnapshot>(null);
            var workspaceStateGenerator = new TestProjectWorkspaceStateGenerator();
            var trigger = new ProjectBuildChangeTrigger(Dispatcher, projectService, workspaceStateGenerator, projectManager.Object);

            // Act
            trigger.ProjectOperations_EndBuild(null, args);

            // Assert
            Assert.Empty(workspaceStateGenerator.UpdateQueue);
        }