public void List_NoItemsInArray_HeadersProperlyDisplayed() { IListable[] contacts = {}; string expected = "Header1Header2"; IntelliTect.TestTools.Console.ConsoleAssert.Expect( expected, _ => { ConsoleListControl.List(new[] { "Header1", "Header2" }, contacts); }); }
public void List_HeadersAndItemsNotOfSameLength_ArgumentOutOfRangeException() { IListable[] contacts = { new Contact( "Dick", "Traci", "123 Main St., Spokane, WA 99037", "123-123-1234") }; ConsoleListControl.List(new[] { "Header1", "Header2" }, contacts); }
public static void Main() { Contact[] contacts = new Contact[] { new Contact( "Dick", "Traci", "123 Main St., Spokane, WA 99037", "123-123-1234"), new Contact( "Andrew", "Littman", "1417 Palmary St., Dallas, TX 55555", "555-123-4567"), new Contact( "Mary", "Hartfelt", "1520 Thunder Way, Elizabethton, PA 44444", "444-123-4567"), new Contact( "John", "Lindherst", "1 Aerial Way Dr., Monteray, NH 88888", "222-987-6543"), new Contact( "Pat", "Wilson", "565 Irving Dr., Parksdale, FL 22222", "123-456-7890"), new Contact( "Jane", "Doe", "123 Main St., Aurora, IL 66666", "333-345-6789") }; // Classes are cast implicitly to // their supported interfaces ConsoleListControl.List(Contact.Headers, contacts); Console.WriteLine(); Publication[] publications = new Publication[3] { new Publication( "The End of Poverty: Economic Possibilities for Our Time", "Jeffrey Sachs", 2006), new Publication("Orthodoxy", "G.K. Chesterton", 1908), new Publication( "The Hitchhiker's Guide to the Galaxy", "Douglas Adams", 1979) }; ConsoleListControl.List( Publication.Headers, publications); }
public static void Main() { Contact[] contacts = new Contact[6]; contacts[0] = new Contact( "Dick", "Traci", "123 Main St., Spokane, WA 99037", "123-123-1234" ); contacts[1] = new Contact( "Lee", "Littman", "123 Main St., Spokane, WA 99037", "123-123-1234" ); contacts[2] = new Contact( "Park", "Hartfilt", "123 Main St., Spokane, WA 99037", "123-123-1234" ); contacts[3] = new Contact( "Kim", "Lindherst", "123 Main St., Spokane, WA 99037", "123-123-1234" ); contacts[4] = new Contact( "Jang", "Wilson", "123 Main St., Spokane, WA 99037", "123-123-1234" ); contacts[5] = new Contact( "Gi", "Doe", "123 Main St., Spokane, WA 99037", "123-123-1234" ); //클래스에서 지원하는 인터페이스로 암시적인 캐스팅이 일어난다. ConsoleListControl.List(Contact.Headers, contacts); Console.WriteLine(); Publication[] publications = new Publication[3] { new Publication("Celebration of Discipline", "Richard Foster", 1978), new Publication("Orthodoxy", "G.K. Chesterton", 1908), new Publication("The Hitchhiker's Guide to the Galaxy", "Douglas Adams", 1979) }; ConsoleListControl.List(Publication.Headers, publications); }
public void List_SingleItemInArrayUsingContactHeaders_ItemProperlyDisplayed() { IListable[] contacts = { new Contact( "Inigo", "Montoya", "123 Main St., Spokane, WA 99037", "123-123-1234") }; const string expected = @"First NameLast Name Phone Address Inigo Montoya 123-123-1234123 Main St., Spokane, WA 99037"; IntelliTect.TestTools.Console.ConsoleAssert.Expect( expected, _ => { ConsoleListControl.List(Contact.Headers, contacts); }); }