public void AddressbookInitialize() { adb = new Adressbook("testbook"); c1 = new Contact("Jarno", "*****@*****.**"); c2 = new Contact("Bas", "*****@*****.**"); c3 = new Contact("C.A.R.Hoare", "*****@*****.**"); c4 = new Contact("name4", "email4"); adb.Add(c1); adb.Add(c2); adb.Add(c3); adb.Add(c4); }
private Contact addContact(Adressbook a, string name) { Contact c = new Contact(name, name + "@gmail.com"); a.Add(c); return(c); }
public void DeleteTest() { string n = "test"; Adressbook target = new Adressbook(n); Contact[] contacts = { new Contact("name1", "email1"), new Contact("name2", "email2"), new Contact("name3", "email3"), new Contact("name4", "email4") }; for (int i = 0; i < contacts.Length; i++) { target.Add(contacts[i]); } for (int i = 0; i < contacts.Length; i++) { target.Delete(contacts[i]); Assert.IsTrue(target.contacts.Count == contacts.Length - i - 1); } // Check if adressbook crashes when an non existend contact is trying to be deleted Contact nonexistend = new Contact("name", "email"); try { target.Delete(nonexistend); Assert.IsTrue(true); } catch { throw new ArgumentOutOfRangeException(); } }
public void AddTest() { string n = "test"; Adressbook target = new Adressbook(n); Contact[] contacts = { new Contact("name1", "email1"), new Contact("name2", "email2"), new Contact("name3", "email3"), new Contact("name4", "email4") }; foreach (Contact c in contacts) { target.Add(c); } for (int i = 0; i < contacts.Length; i++) { Assert.AreEqual(contacts[i], target.contacts[i]); } }