public string GetBuildLogDirectory(string projectName) { IProjectIntegrator integrator = projectIntegrators[projectName]; if (integrator == null) { throw new InvalidOperationException(string.Format("Unable to find an integrator for project name: '{0}'.", projectName)); } Project project = (Project)integrator.Project; XmlLogPublisher XmlPublisher = null; foreach (ITask CandidatePublisher in project.Publishers) { if (CandidatePublisher is XmlLogPublisher) { XmlPublisher = (XmlLogPublisher)CandidatePublisher; break; } } if (XmlPublisher == null) { throw new InvalidOperationException("There is no xml log publisher!"); } return(XmlPublisher.LogDirectory(project.ArtifactDirectory)); }
public ProjectStatus GetProjectStatusLite(string projectName) { IProjectIntegrator integrator = projectIntegrators[projectName]; if (integrator == null) { throw new InvalidOperationException(string.Format("Unable to find an integrator for project name: '{0}'.", projectName)); } Project project = (Project)integrator.Project; string forcee = string.Empty; if (integrator.CurrentIntegrationResult.IntegrationProperties.Contains("CCNetForcedBy")) { forcee = (string)integrator.CurrentIntegrationResult.IntegrationProperties["CCNetForcedBy"]; } return(new ProjectStatus(integrator.State, project.LatestBuildStatus, project.CurrentActivity, project.Name, project.WebURL, project.LastIntegrationResult.StartTime, project.LastIntegrationResult.TotalIntegrationTime, project.LastIntegrationResult.Label, project.LastIntegrationResult.LastSuccessfulIntegrationLabel, integrator.Trigger.NextBuild, forcee, new Modification[] {}, integrator.CurrentIntegrationResult.StartTime, integrator.CurrentIntegrationResult.BuildCondition)); }
private IProjectIntegrator GetIntegrator(string projectName) { IProjectIntegrator integrator = projectIntegrators[projectName]; if (integrator == null) { throw new CruiseControlException("Specified project does not exist: " + projectName); } return(integrator); }
public ProjectStatus GetProjectStatus(string projectName) { IProjectIntegrator integrator = projectIntegrators[projectName]; Project project = (Project)integrator.Project; return(new ProjectStatus(integrator.State, project.LatestBuildStatus, project.CurrentActivity, project.Name, project.WebURL, project.LastIntegrationResult.StartTime, project.LastIntegrationResult.Label, project.LastIntegrationResult.LastSuccessfulIntegrationLabel, integrator.Trigger.NextBuild)); }
/// <summary> /// Gets the integrator. /// </summary> /// <param name="projectName">Name of the project.</param> /// <returns></returns> /// <remarks></remarks> public IProjectIntegrator GetIntegrator(string projectName) { if (string.IsNullOrEmpty(projectName)) { throw new NoSuchProjectException(projectName); } IProjectIntegrator integrator = projectIntegrators[projectName]; if (integrator == null) { throw new NoSuchProjectException(projectName); } return(integrator); }
/// <summary> /// Stop integrator for specified project. /// </summary> public void Stop(string project) { IProjectIntegrator integrator = GetIntegrator(project); integrator.Stop(); }
protected void SetUp() { projectSerializerMock = new DynamicMock(typeof(IProjectSerializer)); integratorMock1 = new DynamicMock(typeof(IProjectIntegrator)); integratorMock2 = new DynamicMock(typeof(IProjectIntegrator)); integratorMock3 = new DynamicMock(typeof(IProjectIntegrator)); integrator1 = (IProjectIntegrator)integratorMock1.MockInstance; integrator2 = (IProjectIntegrator)integratorMock2.MockInstance; integrator3 = (IProjectIntegrator)integratorMock3.MockInstance; integratorMock1.SetupResult("Name", "Project 1"); integratorMock2.SetupResult("Name", "Project 2"); integratorMock3.SetupResult("Name", "Project 3"); fileSystem = mocks.DynamicMock <IFileSystem>(); executionEnvironment = mocks.DynamicMock <IExecutionEnvironment>(); SetupResult.For(executionEnvironment.IsRunningOnWindows).Return(true); SetupResult.For(executionEnvironment.GetDefaultProgramDataFolder(ApplicationType.Server)).Return(applicationDataPath); SetupResult.For(fileSystem.DirectoryExists(applicationDataPath)).Return(true); mocks.ReplayAll(); integrationQueue = null; // We have no way of injecting currently. configuration = new Configuration(); project1 = new Project(); project1.Name = "Project 1"; integratorMock1.SetupResult("Project", project1); project2 = new Project(); project2.Name = "Project 2"; integratorMock2.SetupResult("Project", project1); mockProject = new DynamicMock(typeof(IProject)); mockProject.SetupResult("Name", "Project 3"); mockProject.SetupResult("QueueName", "Project 3"); mockProject.SetupResult("QueueName", "Project 3"); mockProjectInstance = (IProject)mockProject.MockInstance; mockProject.SetupResult("Name", "Project 3"); mockProject.SetupResult("StartupMode", ProjectStartupMode.UseLastState); integratorMock3.SetupResult("Project", mockProjectInstance); configuration.AddProject(project1); configuration.AddProject(project2); configuration.AddProject(mockProjectInstance); integratorList = new ProjectIntegratorList(); integratorList.Add(integrator1); integratorList.Add(integrator2); integratorList.Add(integrator3); configServiceMock = new DynamicMock(typeof(IConfigurationService)); configServiceMock.ExpectAndReturn("Load", configuration); projectIntegratorListFactoryMock = new DynamicMock(typeof(IProjectIntegratorListFactory)); projectIntegratorListFactoryMock.ExpectAndReturn("CreateProjectIntegrators", integratorList, configuration.Projects, integrationQueue); stateManagerMock = new DynamicMock(typeof(IProjectStateManager)); stateManagerMock.SetupResult("CheckIfProjectCanStart", true, typeof(string)); server = new CruiseServer((IConfigurationService)configServiceMock.MockInstance, (IProjectIntegratorListFactory)projectIntegratorListFactoryMock.MockInstance, (IProjectSerializer)projectSerializerMock.MockInstance, (IProjectStateManager)stateManagerMock.MockInstance, fileSystem, executionEnvironment, null); }
/// <summary> /// Creates the project status. /// </summary> /// <param name="integrator">The integrator.</param> /// <returns></returns> /// <remarks></remarks> public ProjectStatus CreateProjectStatus(IProjectIntegrator integrator) { var lastIntegration = this.LastIntegration; ProjectStatus status = new ProjectStatus( this.Name, this.Category, this.CurrentActivity, lastIntegration.Status, integrator.State, this.WebURL, lastIntegration.StartTime, lastIntegration.Label, lastIntegration.LastSuccessfulIntegrationLabel, this.Triggers.NextBuild, this.CurrentBuildStage(), this.QueueName, this.QueuePriority); status.Description = this.Description; status.Messages = this.messages.ToArray(); status.ShowForceBuildButton = this.ShowForceBuildButton; status.ShowStartStopButton = this.ShowStartStopButton; return status; }
public void Add(string name, IProjectIntegrator integrator) { _integrators[name] = integrator; }
public void Add(IProjectIntegrator integrator) { Add(integrator.Name, integrator); }
public ProjectStatus CreateProjectStatus(IProjectIntegrator integrator) { throw new NotImplementedException(); }
private Project GetProjectInstance(string projectName) { IProjectIntegrator pi = this.GetIntegrator(projectName); return((Project)pi.Project); }
protected void SetUp() { projectSerializerMock = new Mock <IProjectSerializer>(); integratorMock1 = new Mock <IProjectIntegrator>(); integratorMock2 = new Mock <IProjectIntegrator>(); integratorMock3 = new Mock <IProjectIntegrator>(); integrator1 = (IProjectIntegrator)integratorMock1.Object; integrator2 = (IProjectIntegrator)integratorMock2.Object; integrator3 = (IProjectIntegrator)integratorMock3.Object; integratorMock1.SetupGet(integrator => integrator.Name).Returns("Project 1"); integratorMock2.SetupGet(integrator => integrator.Name).Returns("Project 2"); integratorMock3.SetupGet(integrator => integrator.Name).Returns("Project 3"); fileSystem = mocks.Create <IFileSystem>().Object; executionEnvironment = mocks.Create <IExecutionEnvironment>().Object; Mock.Get(executionEnvironment).SetupGet(_executionEnvironment => _executionEnvironment.IsRunningOnWindows).Returns(true); Mock.Get(executionEnvironment).Setup(_executionEnvironment => _executionEnvironment.GetDefaultProgramDataFolder(ApplicationType.Server)).Returns(applicationDataPath); Mock.Get(fileSystem).Setup(_fileSystem => _fileSystem.DirectoryExists(applicationDataPath)).Returns(true); configuration = new Configuration(); project1 = new Project(); project1.Name = "Project 1"; integratorMock1.SetupGet(integrator => integrator.Project).Returns(project1); project2 = new Project(); project2.Name = "Project 2"; integratorMock2.SetupGet(integrator => integrator.Project).Returns(project1); mockProject = new Mock <IProject>(); mockProjectInstance = (IProject)mockProject.Object; mockProject.SetupGet(project => project.Name).Returns("Project 3"); mockProject.SetupGet(project => project.QueueName).Returns("Project 3"); mockProject.SetupGet(project => project.StartupMode).Returns(ProjectStartupMode.UseLastState); integratorMock3.SetupGet(integrator => integrator.Project).Returns(mockProjectInstance); configuration.AddProject(project1); configuration.AddProject(project2); configuration.AddProject(mockProjectInstance); integratorList = new ProjectIntegratorList(); integratorList.Add(integrator1); integratorList.Add(integrator2); integratorList.Add(integrator3); configServiceMock = new Mock <IConfigurationService>(); configServiceMock.Setup(service => service.Load()).Returns(configuration).Verifiable(); projectIntegratorListFactoryMock = new Mock <IProjectIntegratorListFactory>(); projectIntegratorListFactoryMock.Setup(factory => factory.CreateProjectIntegrators(configuration.Projects, It.IsAny <IntegrationQueueSet>())) .Returns(integratorList).Verifiable(); stateManagerMock = new Mock <IProjectStateManager>(); stateManagerMock.Setup(_manager => _manager.CheckIfProjectCanStart(It.IsAny <string>())).Returns(true); server = new CruiseServer((IConfigurationService)configServiceMock.Object, (IProjectIntegratorListFactory)projectIntegratorListFactoryMock.Object, (IProjectSerializer)projectSerializerMock.Object, (IProjectStateManager)stateManagerMock.Object, fileSystem, executionEnvironment, null); }
protected void SetUp() { projectSerializerMock = new DynamicMock(typeof (IProjectSerializer)); integratorMock1 = new DynamicMock(typeof (IProjectIntegrator)); integratorMock2 = new DynamicMock(typeof (IProjectIntegrator)); integratorMock3 = new DynamicMock(typeof (IProjectIntegrator)); integrator1 = (IProjectIntegrator) integratorMock1.MockInstance; integrator2 = (IProjectIntegrator) integratorMock2.MockInstance; integrator3 = (IProjectIntegrator) integratorMock3.MockInstance; integratorMock1.SetupResult("Name", "Project 1"); integratorMock2.SetupResult("Name", "Project 2"); integratorMock3.SetupResult("Name", "Project 3"); fileSystem = mocks.DynamicMock<IFileSystem>(); executionEnvironment = mocks.DynamicMock<IExecutionEnvironment>(); SetupResult.For(executionEnvironment.IsRunningOnWindows).Return(true); SetupResult.For(executionEnvironment.GetDefaultProgramDataFolder(ApplicationType.Server)).Return(applicationDataPath); SetupResult.For(fileSystem.DirectoryExists(applicationDataPath)).Return(true); mocks.ReplayAll(); integrationQueue = null; // We have no way of injecting currently. configuration = new Configuration(); project1 = new Project(); project1.Name = "Project 1"; integratorMock1.SetupResult("Project", project1); project2 = new Project(); project2.Name = "Project 2"; integratorMock2.SetupResult("Project", project1); mockProject = new DynamicMock(typeof(IProject)); mockProject.SetupResult("Name", "Project 3"); mockProject.SetupResult("QueueName", "Project 3"); mockProject.SetupResult("QueueName", "Project 3"); mockProjectInstance = (IProject)mockProject.MockInstance; mockProject.SetupResult("Name", "Project 3"); mockProject.SetupResult("StartupMode", ProjectStartupMode.UseLastState); integratorMock3.SetupResult("Project", mockProjectInstance); configuration.AddProject(project1); configuration.AddProject(project2); configuration.AddProject(mockProjectInstance); integratorList = new ProjectIntegratorList(); integratorList.Add(integrator1); integratorList.Add(integrator2); integratorList.Add(integrator3); configServiceMock = new DynamicMock(typeof (IConfigurationService)); configServiceMock.ExpectAndReturn("Load", configuration); projectIntegratorListFactoryMock = new DynamicMock(typeof (IProjectIntegratorListFactory)); projectIntegratorListFactoryMock.ExpectAndReturn("CreateProjectIntegrators", integratorList, configuration.Projects, integrationQueue); stateManagerMock = new DynamicMock(typeof(IProjectStateManager)); stateManagerMock.SetupResult("CheckIfProjectCanStart", true, typeof(string)); server = new CruiseServer((IConfigurationService) configServiceMock.MockInstance, (IProjectIntegratorListFactory) projectIntegratorListFactoryMock.MockInstance, (IProjectSerializer) projectSerializerMock.MockInstance, (IProjectStateManager)stateManagerMock.MockInstance, fileSystem, executionEnvironment, null); }