예제 #1
0
        public void GetParsedLeads_Works(string delimiter)
        {
            var listOfOne = new List <Lead>
            {
                new Lead
                {
                    FirstName    = "FirstName",
                    LastName     = "LastName",
                    Phone        = "+1(255)123-4567",
                    Project      = "home",
                    PropertyType = "condo",
                    StartDate    = DateTime.Now
                }
            };

            var validationString = new List <string>
            {
                GetValidSerializedString(delimiter)
            };

            File.WriteAllLines(TestFileName, validationString);
            var parsedLeads = LeadParser.GetParsedLeads(TestFileName);

            Assert.AreEqual(listOfOne.First().FirstName, parsedLeads.First().FirstName);
            Assert.AreEqual(listOfOne.First().LastName, parsedLeads.First().LastName);
            Assert.AreEqual(listOfOne.First().Phone, parsedLeads.First().Phone);
            Assert.AreEqual(listOfOne.First().Project, parsedLeads.First().Project);
            Assert.AreEqual(listOfOne.First().PropertyType, parsedLeads.First().PropertyType);
            Assert.AreEqual(listOfOne.First().StartDate.Date, parsedLeads.First().StartDate.Date);
        }
예제 #2
0
        public static int ParseSortAndDisplay(IEnumerable <string> args)
        {
            Console.WriteLine("Parsing test files:");

            foreach (var path in args)
            {
                try
                {
                    var leads = LeadParser.GetParsedLeads(path);

                    Console.WriteLine(Environment.NewLine + "Sorted By PropertyType:");
                    DisplayLeads(leads.OrderBy(x => x.PropertyType).ToList());

                    Console.WriteLine(Environment.NewLine + "Sorted By StartDate:");
                    DisplayLeads(leads.OrderBy(x => x.StartDate).ToList());

                    Console.WriteLine(Environment.NewLine + "Sorted By LastName:");
                    DisplayLeads(leads.OrderByDescending(x => x.LastName).ToList());
                }


                catch (Exception e)
                {
                    Console.WriteLine(@"The lead file {0} could not be parsed:", path);
                    Console.WriteLine(e.Message);

                    return(1);
                }
            }

            return(0);
        }
예제 #3
0
        public void GetParsedLeads_FailsCorrectly()
        {
            var failResult = LeadParser.GetParsedLeads(null);

            Assert.IsNull(failResult);
        }