public void Delete_LambdaPredicate_AllContactsUpdated() { var deleteName = "1234"; var notDeleteName = "13"; var book = new PhoneBook { new Contact { FirstName = deleteName }, new Contact { FirstName = deleteName }, new Contact { FirstName = notDeleteName } }; book.Delete(x => x.FirstName == deleteName); Assert.Contains(book, x => x.FirstName == notDeleteName); Assert.DoesNotContain(book, x => x.FirstName == deleteName); }
public void PhoneBookWorkCorrect(int requestsCount, string[] commands, string[] responses) { // Arrange var listResult = new List <string>(); // Act var sut = new PhoneBook(); for (int i = 0; i < requestsCount; i++) { var command = commands[i].Split(' '); switch (command[0]) { case "add": //sut.Add(new PhoneBookOnLists.Contact(command[1],command[2])); sut.Add(command[1], command[2]); break; case "find": listResult.Add(sut.Find(command[1])); break; case "del": sut.Delete(command[1]); break; default: break; } } // Assert Assert.AreEqual(responses, listResult.ToArray()); }
public void Delete_Contact_ContactDeleted() { var deleteContact = new Contact(); var book = new PhoneBook { new Contact(), new Contact(), new Contact(), deleteContact }; book.Delete(deleteContact); var contactsCount = book.Count(); Assert.Equal(contactsCount, 3); Assert.DoesNotContain(deleteContact, book); }