public void ChangeNonExistingPhoneNumberShouldNotAffectToTheRepository() { var phonebookRepository = new PhonebookRepositoryFast(); phonebookRepository.AddPhone("John", new List<string>() { "111", "222" }); var matchedPhoneEntries = phonebookRepository.ChangePhone("333", "444"); Assert.AreEqual(0, matchedPhoneEntries); Assert.AreEqual(2, phonebookRepository.ListEntries(0, 1).First().PhoneNumbers.Count); CollectionAssert.AreEqual(new List<string>() { "111", "222" }, phonebookRepository.ListEntries(0, 1).First().PhoneNumbers.ToList()); }
public void ChangeExistingPhoneNumberShouldRemoveOldAndAddNewPhoneNumber() { var phonebookRepository = new PhonebookRepositoryFast(); phonebookRepository.AddPhone("John", new List<string>() { "111", "222" }); var matchedPhoneEntries = phonebookRepository.ChangePhone("111", "333"); Assert.AreEqual(1, matchedPhoneEntries); Assert.AreEqual(2, phonebookRepository.ListEntries(0, 1).First().PhoneNumbers.Count); Assert.IsTrue(phonebookRepository.ListEntries(0, 1).First().PhoneNumbers.Contains("333")); Assert.IsFalse(phonebookRepository.ListEntries(0, 1).First().PhoneNumbers.Contains("111")); }
public void ChangePhoneWithMergeAndDuplicates() { var phonebookRepository = new PhonebookRepositoryFast(); phonebookRepository.AddPhone("John", new List<string>() { "111", "222" }); phonebookRepository.AddPhone("John1", new List<string>() { "333", "444" }); phonebookRepository.AddPhone("John2", new List<string>() { "555", "666" }); phonebookRepository.ChangePhone("111", "333"); Assert.AreEqual(2, phonebookRepository.ListEntries(0, 3).Where(a => a.PhoneNumbers.Contains("333")).Count()); Assert.AreEqual(0, phonebookRepository.ListEntries(0, 3).Where(a => a.PhoneNumbers.Contains("111")).Count()); Assert.AreEqual(1, phonebookRepository.ListEntries(0, 3).Where(a => a.Name == "John").Count()); Assert.AreEqual(1, phonebookRepository.ListEntries(0, 3).Where(a => a.Name == "John1").Count()); }
public void ChangedSharedPhoneNumber() { var phonebookRepository = new PhonebookRepositoryFast(); phonebookRepository.AddPhone("John", new List<string>() { "111", "222" }); phonebookRepository.AddPhone("Smith", new List<string>() { "222", "333" }); var matchedPhoneEntries = phonebookRepository.ChangePhone("222", "444"); Assert.AreEqual(2, matchedPhoneEntries); Assert.AreEqual(2, phonebookRepository.ListEntries(0, 2).First().PhoneNumbers.Count); Assert.AreEqual(2, phonebookRepository.ListEntries(0, 2).Skip(1).First().PhoneNumbers.Count); Assert.IsTrue(phonebookRepository.ListEntries(0, 2).First().PhoneNumbers.Contains("444")); Assert.IsFalse(phonebookRepository.ListEntries(0, 2).First().PhoneNumbers.Contains("222")); Assert.IsTrue(phonebookRepository.ListEntries(0, 2).Skip(1).First().PhoneNumbers.Contains("444")); Assert.IsFalse(phonebookRepository.ListEntries(0, 2).Skip(1).First().PhoneNumbers.Contains("222")); }
public void ChangePhoneOnEmptyNewPhoneNumberShouldThrowException() { var phonebookRepository = new PhonebookRepositoryFast(); phonebookRepository.ChangePhone("", null); }
public void ChangePhoneOnEmptyOldPhoneNumberShouldThrowException() { var phonebookRepository = new PhonebookRepositoryFast(); phonebookRepository.ChangePhone(null, "111"); }