public void Refresh_Returns_Model_With_Passed_Pipeline_Count() { var expectedPipelines = new List<DisplayablePipeline> { new DisplayablePipeline("Shared", "bob"){Stages = new List<IStage>(){new PassedStage("", "", DateTime.Now.ToString())}}, new DisplayablePipeline("Shared2", "bob2"){Stages = new List<IStage>(){new FailedStage("", "", DateTime.Now.ToString())}}, new DisplayablePipeline("Shared3", "bob3"){Stages = new List<IStage>(){new PassedStage("", "", DateTime.Now.ToString())}} }; var homeController = new HomeController(new FakeDashboard(expectedPipelines), new FakeXmlProfileLoader()); var result = (ViewResult)homeController.Refresh(""); var viewModel = (IndexViewModel)result.ViewData.Model; Assert.That(viewModel.PassedCount, Is.EqualTo(2)); }
public void Should_Filter_Index_Based_On_Profile_Name() { var expectedPipelines = new List<DisplayablePipeline> { new DisplayablePipeline("Shared", "bob"){Stages = new List<IStage> {new FailedStage("","",DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss"))}}, new DisplayablePipeline("Shared2", "bob"){Stages = new List<IStage> {new PassedStage("","",DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss"))}}, new DisplayablePipeline("Shared3", "bob"){Stages = new List<IStage> {new FailedStage("","",DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss"))}} }; const string ProfilesXmlFile = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><Profiles>" + "<Profile name=\"test\">" + "<WhiteList>" + "<Pipeline>Shared</Pipeline>" + "<Pipeline>Shared2</Pipeline>" + "<Pipeline>Shared3</Pipeline>" + "</WhiteList>" + "<Statuses><Failed/><Passed/></Statuses>" + "</Profile>" + "<Profile name=\"test2\">" + "<WhiteList>" + "<Pipeline>Shared4</Pipeline>" + "<Pipeline>Shared5</Pipeline>" + "<Pipeline>Shared6</Pipeline>" + "</WhiteList>" + "<Statuses><Failed/><Passed/></Statuses>" + "</Profile></Profiles>"; var fakeFileLoader = new FakeFileLoader(ProfilesXmlFile); IXmlProfileRetriever xmlProfileRetriever = new XmlProfileRetriever(fakeFileLoader); var homeController = new HomeController(new FakeDashboard(expectedPipelines), xmlProfileRetriever); var result = (ViewResult)homeController.Index("test"); var viewModel = (IndexViewModel)result.ViewData.Model; var pipelines = viewModel.Pipelines; var pipeline = pipelines.First(); Assert.That(pipelines.Count(), Is.EqualTo(3)); Assert.That(pipeline.Name, Is.EqualTo("Shared")); }
public void Should_Show_Passed_Count() { var expectedPipelines = new List<DisplayablePipeline> { new DisplayablePipeline("Shared", "bob"){Stages = new List<IStage>{new FailedStage("","",DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss"))}}, new DisplayablePipeline("Shared2", "bob"){Stages = new List<IStage>{new PassedStage("","",DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss"))}}, new DisplayablePipeline("Shared3", "bob"){Stages = new List<IStage>{new FailedStage("","",DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss"))}}, new DisplayablePipeline("Shared4", "bob"){Stages = new List<IStage>{new PassedStage("","",DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss"))}} }; const string ProfilesXmlFile = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><Profiles><Profile name=\"test\">" + "<WhiteList><Pipeline>Pipeline1</Pipeline><Pipeline>Pipeline2</Pipeline><Pipeline>Pipeline3</Pipeline><Pipeline>Pipeline4</Pipeline></WhiteList>" + "<Statuses><Failed/><Passed/></Statuses>" + "<ShowPassedCount>true</ShowPassedCount>" + "</Profile></Profiles>"; var fakeFileLoader = new FakeFileLoader(ProfilesXmlFile); IXmlProfileRetriever xmlProfileRetriever = new XmlProfileRetriever(fakeFileLoader); var homeController = new HomeController(new FakeDashboard(expectedPipelines), xmlProfileRetriever); var result = (ViewResult)homeController.Refresh("test"); var viewModel = (IndexViewModel)result.ViewData.Model; Assert.That(viewModel.ShowPassedCount, Is.EqualTo(true)); }
public void IndexReturnsModelWithPipeline() { var expectedPipelines = new List<DisplayablePipeline> { new DisplayablePipeline("Shared", "bob") }; var homeController = new HomeController(new FakeDashboard(expectedPipelines), new FakeXmlProfileLoader()); var result = (ViewResult)homeController.Refresh(""); var viewModel = (IndexViewModel)result.ViewData.Model; var pipeline = viewModel.Pipelines.First(); Assert.That(pipeline.Name, Is.EqualTo("Shared")); }
public void Index_Returns_Model_With_Pipeline_Groups_With_ShowName_Flag() { var expectedPipelines = new List<DisplayablePipeline> { new DisplayablePipeline("Pipeline1", "bob"){Stages = new List<IStage>{new FailedStage("","",DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss"))}}, new DisplayablePipeline("Pipeline2", "bob"){Stages = new List<IStage>{new PassedStage("","",DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss"))}}, new DisplayablePipeline("Pipeline3", "bob"){Stages = new List<IStage>{new FailedStage("","",DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss"))}}, new DisplayablePipeline("Pipeline4", "bob"){Stages = new List<IStage>{new PassedStage("","",DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss"))}} }; const string ProfilesXmlFile = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><Profiles><Profile name=\"test\">" + "<WhiteList>" + "<Group name=\"Group1\" showName=\"true\">" + "<Pipeline>Pipeline1</Pipeline>" + "<Pipeline>Pipeline2</Pipeline>" + "</Group>" + "<Group name=\"Group2\" showName=\"false\">" + "<Pipeline>Pipeline3</Pipeline>" + "<Pipeline>Pipeline4</Pipeline>" + "</Group>" + "<Group name=\"Group3\">" + "<Pipeline>Pipeline5</Pipeline>" + "<Pipeline>Pipeline6</Pipeline>" + "</Group>" + "</WhiteList>" + "<Statuses><Failed/><Passed/></Statuses>" + "</Profile></Profiles>"; var fakeFileLoader = new FakeFileLoader(ProfilesXmlFile); IXmlProfileRetriever xmlProfileRetriever = new XmlProfileRetriever(fakeFileLoader); var homeController = new HomeController(new FakeDashboard(expectedPipelines), xmlProfileRetriever); var result = (ViewResult)homeController.Index("test"); var viewModel = (IndexViewModel)result.ViewData.Model; Assert.That(viewModel.Groups.Count(), Is.EqualTo(3)); Assert.That(viewModel.Groups[0].ShowName, Is.True); Assert.That(viewModel.Groups[1].ShowName, Is.False); Assert.That(viewModel.Groups[2].ShowName, Is.True); }
public void Index_Returns_Model_With_Pipeline() { var expectedPipelines = new List<DisplayablePipeline> { new DisplayablePipeline("Shared", ""){Stages = new List<IStage>{new FailedStage("","",DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss"))}} }; const string ProfilesXmlFile = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><Profiles><Profile name=\"test\">" + "<WhiteList><Group><Pipeline>Shared</Pipeline></Group></WhiteList>" + "<Statuses><Failed/><Passed/></Statuses>" + "<ShowPassedCount>false</ShowPassedCount>" + "</Profile></Profiles>"; var fakeFileLoader = new FakeFileLoader(ProfilesXmlFile); IXmlProfileRetriever xmlProfileRetriever = new XmlProfileRetriever(fakeFileLoader); var homeController = new HomeController(new FakeDashboard(expectedPipelines), xmlProfileRetriever); var result = (ViewResult)homeController.Index(""); var viewModel = (IndexViewModel)result.ViewData.Model; Assert.That(viewModel.Pipelines.First().Name, Is.EqualTo("Shared")); }