public ExtractedContent Extract(string[] allLines)
        {
            var header       = allLines[0];
            var contentLines = allLines.Skip(1);
            var headerValues = header.Split(Comma);
            var indexValues  = new ContentIndexValues(headerValues);

            var extractedContent = new ExtractedContent();

            foreach (var line in contentLines)
            {
                var splittedLine = line.Split(Comma);
                var contentItem  = new ContentItem()
                {
                    FirstName   = splittedLine[indexValues.FirstNameIndex],
                    LastName    = splittedLine[indexValues.LastNameIndex],
                    Address     = splittedLine[indexValues.AddressIndex],
                    PhoneNumber = splittedLine[indexValues.PhoneNumberIndex]
                };

                extractedContent.Add(contentItem);
            }

            return(extractedContent);
        }
Example #2
0
 public void SetUp()
 {
     _extractedContent = new ExtractedContent();
     _extractedContent.Add(new ContentItem()
     {
         FirstName = "John",
         LastName  = "John",
         Address   = "111 Street C"
     });
     _extractedContent.Add(new ContentItem()
     {
         FirstName = "John",
         LastName  = "NotJohn",
         Address   = "777 Street B"
     });
 }
        public NameWithFrequency[] GetOrderedNamesWithFrequency(NamesWithFrequencyTestCase testCase)
        {
            var extractedContent = new ExtractedContent();

            foreach (var name in testCase.Names)
            {
                extractedContent.Add(new ContentItem
                {
                    FirstName = name.FirstName,
                    LastName  = name.LastName
                });
            }

            return(extractedContent.GetOrderedNamesWithFrequency().ToArray());
        }
        public string[] GetContentItemsOrderedByStreetName(AddressTestCase addressTestCase)
        {
            var extractedContent = new ExtractedContent();

            foreach (var address in addressTestCase.Addresses)
            {
                extractedContent.Add(new ContentItem
                {
                    FirstName = string.Empty,
                    LastName  = string.Empty,
                    Address   = address
                });
            }
            return(extractedContent.GetContentItemsOrderedByStreetName().Select(x => x.Address).ToArray());
        }