public void Should_Load_Xml_For_Name_without_caring_about_case() { const string profilesXml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + "<Profiles><Profile name=\"test\">" + "<WhiteList>" + "<Pipeline>Pipeline1</Pipeline>" + "<Pipeline>Pipeline2</Pipeline>" + "</WhiteList>" + "<Statuses>" + "<Failed/></Statuses></Profile></Profiles>"; IFileLoader fakeFileLoader = new FakeFileLoader(profilesXml); var xmlProfileRetriever = new XmlProfileRetriever(fakeFileLoader); var profileXml = xmlProfileRetriever.GetProfileXml("Test"); Assert.That(profileXml.ToString(), Is.EqualTo(XElement.Parse("<Profile name=\"test\">" + "<WhiteList>" + "<Pipeline>Pipeline1</Pipeline>" + "<Pipeline>Pipeline2</Pipeline>" + "</WhiteList>" + "<Statuses><Failed/></Statuses>" + "</Profile>").ToString())); }
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")); }
public void Index_Returns_Model_With_Pipeline_Groups() { 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\">" + "<Pipeline>Pipeline1</Pipeline>" + "<Pipeline>Pipeline2</Pipeline>" + "</Group>" + "<Group name=\"Group2\">" + "<Pipeline>Pipeline3</Pipeline>" + "<Pipeline>Pipeline4</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(2)); Assert.That(viewModel.Groups[0].Pipelines.Count, Is.EqualTo(2)); Assert.That(viewModel.Groups[1].Pipelines.Count, 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_Count_Passed_Based_On_Profile_Name() { 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><Pipeline>Pipeline1</Pipeline><Pipeline>Pipeline2</Pipeline><Pipeline>Pipeline3</Pipeline><Pipeline>Pipeline4</Pipeline></Group></WhiteList>" + "<Statuses>" + "<Failed/><Passed/>" + "</Statuses>" + "</Profile>" + "<Profile name=\"test2\">" + "<WhiteList><Group><Pipeline>Pipeline5</Pipeline><Pipeline>Pipeline6</Pipeline><Pipeline>Pipeline7</Pipeline><Pipeline>Pipeline8</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.Refresh("test"); var viewModel = (IndexViewModel)result.ViewData.Model; Assert.That(viewModel.PassedCount, Is.EqualTo(2)); }
public void Should_Return_Null_for_NonExistant_Profile() { const string profilesXml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><Profiles><Profile name=\"test\">" + "<WhiteList>" + "<Pipeline>Pipeline1</Pipeline>" + "<Pipeline>Pipeline2</Pipeline>" + "</WhiteList>" + "<Statuses><Failed/></Statuses>" + "</Profile></Profiles>"; IFileLoader fakeFileLoader = new FakeFileLoader(profilesXml); var xmlProfileRetriever = new XmlProfileRetriever(fakeFileLoader); var profileXml = xmlProfileRetriever.GetProfileXml("aaa"); Assert.That(profileXml, Is.Null); }