public void TestMethod4() { var allLines = new List <string>(); allLines.Add("a =>"); allLines.Add("b => c"); allLines.Add("c => f"); allLines.Add("d => a"); allLines.Add("e => b"); allLines.Add("f =>"); var parser = ParserFactory.Create(); IJobTree tree = new JobTree(); foreach (var item in allLines) { tree.Add(parser.Parse(item)); } var result = tree.GetJobs(); foreach (var item in result) { Console.Write(item); } }
static void Main(string[] args) { Console.WriteLine("START INPUT on the format A => B. type 'exit' to end inputs"); IJobParser parser = ParserFactory.Create(); IJobTree tree = new JobTree(); do { var line = Console.ReadLine(); if (line == "exit") { break; } tree.Add(parser.Parse(line)); } while (true); var result = tree.GetJobs(); foreach (var item in result) { Console.Write(item + " "); } Console.WriteLine(""); Console.WriteLine("Press any key to exit"); Console.ReadLine(); }
public void JobTreeAdd_WithSameChildAndParent_Throws() { IJobTree jobTree = new JobTree(); var job = new Job("A"); job.DependantJobId = "A"; jobTree.Add(job); }
public void JobTreeAdd_ValidArgs_Success() { IJobTree jobTree = new JobTree(); jobTree.Add(new Job("A")); jobTree.Add(new Job("B")); var jobs = jobTree.GetJobs(); Assert.IsTrue(jobs.Contains("A")); Assert.IsTrue(jobs.Contains("B")); }
public void TestMethod5() { var allLines = @"a => b => c c => c"; var parser = ParserFactory.Create(); IJobTree tree = new JobTree(); foreach (var item in allLines.Split('\n')) { tree.Add(parser.Parse(item)); } }
public void JobTreeGetJobs_WithParentAndChild_ReturnsChildThenParent() { IJobTree jobTree = new JobTree(); jobTree.Add(new Job("A")); jobTree.Add(new Job("B")); jobTree.Add(new Job("C") { DependantJobId = "B" }); var jobs = jobTree.GetJobs(); Assert.IsTrue(jobs.Contains("A")); Assert.IsTrue(jobs.Contains("B")); Assert.IsTrue(jobs.Contains("C")); Assert.IsTrue(jobs.IndexOf("C") > jobs.IndexOf("B")); }
public void JobTreeAdd_WithCircular_Throws() { IJobTree jobTree = new JobTree(); //jobTree.Add(new Job("B")); jobTree.Add(new Job("B") { DependantJobId = "C" }); jobTree.Add(new Job("C") { DependantJobId = "F" }); jobTree.Add(new Job("F") { DependantJobId = "B" }); }
public void TestMethod2() { var allLines = @"a => b => c =>"; var parser = ParserFactory.Create(); IJobTree tree = new JobTree(); foreach (var item in allLines.Split('\n')) { tree.Add(parser.Parse(item)); } var result = tree.GetJobs(); Assert.IsTrue(result.Contains("a")); Assert.IsTrue(result.Contains("b")); Assert.IsTrue(result.Contains("c")); }
public void JobTreeAdd_WithNoJobId_Throws() { IJobTree jobTree = new JobTree(); jobTree.Add(new Job("")); }