public void RemoveTest() { SearchablePhoneBook spb = new SearchablePhoneBook(); Contact c = new Contact("John Johansson"); Contact c2 = new Contact("Karl Johansson"); Contact c3 = new Contact("Peter Johansson"); Contact c4 = new Contact("Hans Johansson"); spb.addContact(c); spb.addContact(c2); spb.addContact(c3); spb.addContact(c4); spb.removeContact(c2); spb.removeContact(c4); Assert.AreEqual(spb.Contacts.Count, 2); Assert.IsTrue(spb.Contacts.Any(x => x.Name.StartsWith("John"))); Assert.IsTrue(spb.Contacts.Any(x => x.Name.StartsWith("Peter"))); }
public void DuplicityTest() { SearchablePhoneBook spb = new SearchablePhoneBook(); Contact c = new Contact("John Johansson"); Contact c1 = new Contact("John Johansson"); Contact c2 = new Contact("John Johansson"); spb.addContact(c); spb.addContact(c1); spb.addContact(c2); spb.removeContact(c1); Assert.AreEqual(spb.Contacts.Count, 2); Assert.IsTrue(spb.Contacts.Contains(c)); Assert.IsTrue(!spb.Contacts.Contains(c1)); Assert.IsTrue(spb.Contacts.Contains(c2)); }