public IEnumerable <string> GetLeadsByStartDate() { List <Lead> result = leadList.SortByStartDate(); List <string> finalResults = GenerateResult(result); yield return(JsonConvert.SerializeObject(finalResults)); }
public void SortLeadsByStartDate() { foreach (string line in File.ReadLines("TestInput1.txt")) { leads.AddLead(line); } List <Lead> sortedResult = leads.SortByStartDate(); List <Lead> expectedResult = new List <Lead>(); expectedResult.Add(new Lead("Rusty", "Shackleford", "House", "Bunker", new DateTime(2018, 5, 15))); expectedResult.Add(new Lead("Dante", "Hicks", "Trailer", "Plumbing", new DateTime(2018, 5, 27))); expectedResult.Add(new Lead("Homer", "Simpson", "House", "Foundation", new DateTime(2018, 6, 1))); expectedResult.Add(new Lead("Jim", "Harbaugh", "House", "Siding", new DateTime(2018, 7, 19))); expectedResult.Add(new Lead("Phillip", "Fry", "Condo", "Plumbing", new DateTime(2018, 10, 21))); CollectionAssert.AreEqual(expectedResult, sortedResult); }
static void Main(string[] args) { LeadList leads = new LeadList(); try { foreach (string line in File.ReadLines(args[0])) { leads.AddLead(line); } Console.WriteLine(""); Console.WriteLine("Sorted by Property Type Then Project:"); foreach (Lead l in leads.SortByPropertyTypeThenProject()) { Console.WriteLine(l.StringToPrint()); } Console.WriteLine(""); Console.WriteLine("Sorted by Start Date:"); foreach (Lead l in leads.SortByStartDate()) { Console.WriteLine(l.StringToPrint()); } Console.WriteLine(""); Console.WriteLine("Sorted by Last Name Descending:"); foreach (Lead l in leads.SortByLastNameDescending()) { Console.WriteLine(l.StringToPrint()); } Console.ReadLine(); } catch { Console.WriteLine("Please Specify the file in the command line"); } }