private IndexViewModel GetViewModel(string profileName, string status) { var pipelines = _dashboard.Pipelines(); var passedCount = pipelines.Count(p => p.ActualStatus == PipelineStatus.Passed); var showPassedCount = false; IList<GroupedDisplayablePipeline> groups = new List<GroupedDisplayablePipeline>(); var statuses = new List<PipelineStatus>(); if (!string.IsNullOrEmpty(status)) { statuses = status.Split(',') .Select(ParseStatus) .ToList(); } if (!string.IsNullOrEmpty(profileName)) { var profileXml = _xmlProfileRetriever.GetProfileXml(profileName); var profile = new ProfileXmlLoader().Load(profileXml, statuses); var pipelineFilter = new PipelineFilter(pipelines); groups = pipelineFilter.Filter(profile); showPassedCount = profile.ShowPassedCount; } return new IndexViewModel { Pipelines = pipelines, PassedCount = passedCount, Groups = groups, ShowPassedCount = showPassedCount }; }
public void Should_Filter_By_Pipeline_Status_Failed() { var profile = new Profile { Statuses = new List<PipelineStatus> { PipelineStatus.Failed }, PipelineGroups = {new GroupedPipeline{ Name = "Group", ProfilePipelines = new List<ProfilePipeline> { new ProfilePipeline{HideBuildInfo = true, Name = "Pipeline1"}, new ProfilePipeline{HideBuildInfo = true, Name = "Pipeline2"} }, }} }; var pipelines = new List<DisplayablePipeline> { new DisplayablePipeline("Pipeline1", "0000"){Stages = new List<IStage>{new PassedStage("","",DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss"))}}, new DisplayablePipeline("Pipeline2", "0000"){Stages = new List<IStage>{new FailedStage("","",DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss"))}} }; var pipelineFilter = new PipelineFilter(pipelines); var filteredPipelines = pipelineFilter.Filter(profile); Assert.That(filteredPipelines.Count(), Is.EqualTo(1)); Assert.That(filteredPipelines[0].Pipelines.Count, Is.EqualTo(1)); Assert.That(filteredPipelines[0].Pipelines[0].Name, Is.EqualTo("Pipeline2")); }
public void Should_Filter_All_Pipelines_By_Status_If_No_Whitelist() { var profile = new Profile { Statuses = new List<PipelineStatus> { PipelineStatus.Failed } }; var pipelines = new List<DisplayablePipeline> { new DisplayablePipeline("Pipeline1", "passed"){Stages = new List<IStage>(){new PassedStage("", "", DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss"))}}, new DisplayablePipeline("Pipeline2", "failed"){Stages = new List<IStage>(){new FailedStage("", "", DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss"))}}, new DisplayablePipeline("Pipeline3", "passed"){Stages = new List<IStage>(){new PassedStage("", "", DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss"))}} }; var pipelineFilter = new PipelineFilter(pipelines); var filteredPipelines = pipelineFilter.Filter(profile); Assert.That(filteredPipelines.Count(), Is.EqualTo(1)); Assert.That(filteredPipelines[0].Pipelines[0].Name, Is.EqualTo("Pipeline2")); }
public void Should_WhiteList_By_Pipeline_Names() { var group = new GroupedPipeline { Name = "Name", ProfilePipelines = new List<ProfilePipeline> { new ProfilePipeline{HideBuildInfo = true, Name = "Pipeline1"}, new ProfilePipeline{HideBuildInfo = true, Name = "Pipeline2"} } }; var profile = new Profile { PipelineGroups = new List<GroupedPipeline> { group } }; var pipelines = new List<DisplayablePipeline> { new DisplayablePipeline("Pipeline1", "passed"){Stages = new List<IStage>(){new FailedStage("", "", DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss"))}}, new DisplayablePipeline("Pipeline2", "failed"){Stages = new List<IStage>(){new FailedStage("", "", DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss"))}}, new DisplayablePipeline("Pipeline3", "passed"){Stages = new List<IStage>(){new FailedStage("", "", DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss"))}}, new DisplayablePipeline("Pipeline4", "passed"){Stages = new List<IStage>(){new FailedStage("", "", DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss"))}} }; var pipelineFilter = new PipelineFilter(pipelines); var filteredPipelines = pipelineFilter.Filter(profile); Assert.That(filteredPipelines[0].Pipelines.Count, Is.EqualTo(2)); Assert.That(filteredPipelines[0].Pipelines[0].Name, Is.EqualTo("Pipeline1")); Assert.That(filteredPipelines[0].Pipelines[1].Name, Is.EqualTo("Pipeline2")); }