public BindingDemo() { InitializeComponent(); pb = new PhoneBook(); pb.AddContact(new Contact() { Name = "Contac1", Number = "Num1" }); pb.AddContact(new Contact() { Name = "Contac2", Number = "Num2" }); this.listItems.ItemsSource = pb.GetAllContacts(); // template list this.listTemplate.Items.Add(new Contact() { Name = "Alpha", Number = "+9232323232" }); this.listTemplate.Items.Add(new Contact() { Name = "Bravo" }); //this.listTemplate.Items.Clear(); //this.listTemplate.ItemsSource = pb.GetAllContacts(); }
public void AddEntriesTest() { PhoneBook book = new PhoneBook(); book.AddContact(new Contact("Jorko Barborko", "Dupnica", "088123456")); book.AddContact(new Contact("Jorko Barborko", "Dupnica", "088123458")); book.AddContact(new Contact("Jorko Barborko", "Sofia", "088123456")); Assert.AreEqual(3, book.Count); }
public void FindTwoParams() { PhoneBook book = new PhoneBook(); book.AddContact(new Contact("Jorko Barborko", "Dupnica", "088123456")); book.AddContact(new Contact("Jorko Barborko", "Dupnica", "088123458")); book.AddContact(new Contact("Jorko Barborko", "Sofia", "088123456")); var matched = book.Find("Jorko Barborko", "Dupnica"); Assert.AreEqual(2, matched.Count); }
static void Add(PhoneBook contact) { Console.Write("Nhap ten: "); string name = Console.ReadLine(); Console.Write("Nhap so dien thoai"); string phonenumber = Console.ReadLine(); Contact contact1 = new Contact(name, phonenumber); contact.AddContact(contact1); }
static void Main(string[] args) { Console.WriteLine("Welcome to Phone Book Application"); Console.WriteLine("Select Operation"); Console.WriteLine("1. Add Contact"); Console.WriteLine("2. Display Contact by no"); Console.WriteLine("3. Display all contacts"); Console.WriteLine("4. Search contacts for a given name "); Console.WriteLine("5. Press x for exit"); var userInput = Console.ReadLine(); var phoneBook = new PhoneBook(); while (true) { switch (userInput) { case "1": Console.WriteLine("Contact Name:"); var name = Console.ReadLine(); Console.WriteLine("Contact Number:"); var number = Console.ReadLine(); var newContact = new Contact(name, number); phoneBook.AddContact(newContact); break; case "2": Console.WriteLine("Contact Number to search:"); var searchNumber = Console.ReadLine(); phoneBook.DisplayContact(searchNumber); break; case "3": phoneBook.DisplayAllContact(); break; case "4": Console.WriteLine("Contact name to search:"); var searchName = Console.ReadLine(); phoneBook.DisplayMatchingContacts(searchName); break; case "x": return; default: Console.WriteLine("Number Invalid"); break; } Console.WriteLine("Select Operation"); userInput = Console.ReadLine(); } }
public void should_add_new_contact() { // Arrange var phoneBook = new PhoneBook(TestHelper.RetrieveContacts()); Contact newContact = new Contact("Jack Napier", "0777777777"); // Act bool contactWasAdded = phoneBook.AddContact(newContact); if (contactWasAdded) { TestHelper.StoreContacts(phoneBook.Contacts); } // Assert contactWasAdded.Should().BeTrue(); }
public void AddContactTest() { PhoneBook book = new PhoneBook(); using (StringWriter sw = new StringWriter()) { Console.SetOut(sw); using (StringReader sr = new StringReader(string.Format("Михаил{0}404571{0}Зеленый Лог 15{0}", Environment.NewLine))) { Console.SetIn(sr); book.AddContact(); string expected = string.Format("Ввведите Имя:{0}Ввведите Телефон:{0}Ввведите Адрес:{0}Данные добавлены!{0}", Environment.NewLine); Assert.AreEqual(expected, sw.ToString()); } } }
public static void Main(string[] args) { ConsoleHandler handler = new ConsoleHandler(); PhoneBook phonebook = new PhoneBook(); Contact contact = new Contact(); int option = handler.selectMenutItem(); actOnSelectMenu(option); phonebook.PrintContactList(); phonebook.addfile(); void actOnSelectMenu(int option) { switch (option) { case 1: Contact contactToAdd = handler.getContact(); phonebook.AddContact(contactToAdd); break; case 2: Contact contactToDelete = handler.deleteContact(phonebook.display()); phonebook.DeleteContact(contactToDelete); break; case 3: phonebook.EditContact(); break; //case 4: phonebook.searchContact(); //break; } } }