public void IndexExpectCorrectRunMapping() { const string definitionName = "Definition"; const string projectName = "Project Name"; const string status = "Success"; DateTime start = DateTime.Now.AddMinutes(-4d); DateTime end = DateTime.Now; var buildStatus = new BuildStatus(); var project = new Project(); var run = new Project { DefinitionName = definitionName, Name = projectName, Status = status, StartTime = start, FinishTime = end }; project.Runs.Add(run); buildStatus.Projects.Add(project); this.buildCommunicator .Stub(bc => bc.GetBuildInformation(2, 4, "*", string.Empty)) .Return(buildStatus); var buildsController = new BuildsController(buildCommunicator, 2, 4); var result = buildsController.Index() as ViewResult; Assert.IsNotNull(result); Assert.IsNotNull(result.Model); var model = result.Model as BuildStatusModel; Assert.AreEqual(definitionName, model.Projects[0].PreviousRuns[0].DefinitionName); Assert.AreEqual(projectName, model.Projects[0].PreviousRuns[0].Name); Assert.AreEqual(status, model.Projects[0].PreviousRuns[0].Status); Assert.AreEqual(start, model.Projects[0].PreviousRuns[0].StartTime); Assert.AreEqual(end, model.Projects[0].PreviousRuns[0].FinishTime); }
public static ProjectModel Map(Project project) { var projectModel = new ProjectModel { DefinitionName = project.DefinitionName, Name = project.Name, Status = project.Status, StartTime = project.StartTime, FinishTime = project.FinishTime, BuildNumber = project.BuildNumber, RequestedFor = project.RequestedFor }; foreach (var run in project.Runs) { projectModel.Runs.Add(ProjectModel.Map(run)); } projectModel.Runs = projectModel.Runs.OrderBy(r => r.FinishTime).ToList(); return projectModel; }
private void AddBuildToParentProject(BuildStatus buildStatus, string definitionName, Project project, int maxRuns) { var parent = buildStatus.Projects.First(p => p.DefinitionName == definitionName); if (parent.Runs.Count < maxRuns) { parent.Runs.Add(project); } }
private static Project MapBuildToProject(IBuildDetail build, string definitionName) { var project = new Project { DefinitionName = definitionName, Name = build.TeamProject, Status = build.Status.ToString(), StartTime = build.StartTime, FinishTime = build.FinishTime, BuildNumber = build.BuildNumber, RequestedFor = build.RequestedFor }; return project; }
private static void AddBuild(BuildStatus buildStatus, Project project) { buildStatus.Projects.Add(project); }