public ContactListBuilder(ArrayList fullContactRegistry) { var boundsDetector = new ContactBoundsDetector(); while(boundsDetector.NextBoundary(fullContactRegistry) > 0) { ArrayList contactDetails = new ArrayList(); int boundary = boundsDetector.NextBoundary(fullContactRegistry); if (boundary > fullContactRegistry.Count) { contacts.Add(new Contact(fullContactRegistry)); return; } for (int i=0; i<boundary; i++) { contactDetails.Add(fullContactRegistry[i]); } contacts.Add(new Contact(contactDetails)); fullContactRegistry.RemoveRange(0, boundary); } }
public void TestFindAddressIndex() { ArrayList contactInfo = new ArrayList(); contactInfo.Add("George Jefferson"); contactInfo.Add("Dr. Of Funk"); contactInfo.Add("School of Hard Knocks"); contactInfo.Add("Okabojie, IA 32232"); contactInfo.Add("Spongebob Squarepants"); contactInfo.Add("Pineapple Under Sea"); var boundaryLimits = new ContactBoundsDetector(); int contactBoundary = boundaryLimits.NextBoundary(contactInfo); Assert.That(contactBoundary, Is.EqualTo(4)); }