public void AddPhone_AddOneNumber() { PhonebookRepository phonebook = new PhonebookRepository(); List<string> oneNumber = new List<string> { "+359899777236" }; bool isAdded = phonebook.AddPhone("Kalina", oneNumber); Assert.IsTrue(isAdded); }
public void ListTests_Exception() { SortedSet<string> phoneNumbers = new SortedSet<string> { "+35929811111" }; PhonebookRepository phonebook = new PhonebookRepository(); phonebook.AddPhone("Kalina", phoneNumbers); phonebook.ListEntries(10, 10); }
public void AddPhone_AddDifferentCaseName_CheckIfMerge() { List<string> phoneNumbers = new List<string> { "+35929811111" }; PhonebookRepository phonebook = new PhonebookRepository(); phonebook.AddPhone("Kalina", phoneNumbers); List<string> otherNumber = new List<string> { "+359899777236" }; bool isMerge = phonebook.AddPhone("KALINA", otherNumber); Assert.IsFalse(isMerge); }
public void AddPhone_AddDifferentCaseName_CheckIfNew() { List<string> phoneNumbers = new List<string> { "+35929811111" }; PhonebookRepository phonebook = new PhonebookRepository(); phonebook.AddPhone("Kalina", phoneNumbers); List<string> otherNumber = new List<string> { "+359899777236" }; bool isNew = phonebook.AddPhone("Ivan", otherNumber); Assert.IsTrue(isNew); }
public void ChangePhone_CheckOldNumber() { List<string> phoneNumbers = new List<string> { "+35929811111" }; PhonebookRepository phonebook = new PhonebookRepository(); phonebook.AddPhone("Kalina", phoneNumbers); phonebook.ChangePhone("+35929811000", "+359899777236"); SortedSet<string> sortedNumbers = phonebook.PhoneEntries[0].PhoneNumbers; string actual = string.Join(", ", sortedNumbers); Assert.AreEqual("+35929811111", actual); }
public void AddPhone_AddOneNumber_CheckForNumbers() { List<string> phoneNumbers = new List<string> { "+35929811111" }; PhonebookRepository phonebook = new PhonebookRepository(); phonebook.AddPhone("Kalina", phoneNumbers); string numbers = "+35929811111"; SortedSet<string> sortedNumbers = phonebook.PhoneEntries[0].PhoneNumbers; string actual = string.Join(", ", sortedNumbers); Assert.AreEqual(numbers, actual); }
public void ListTests_TestOneChangedNumber() { SortedSet<string> phoneNumbers = new SortedSet<string> { "+35929811111" }; PhonebookRepository phonebook = new PhonebookRepository(); phonebook.AddPhone("Ivan", phoneNumbers); phonebook.ChangePhone("+35929811111", "+359899777235"); PhoneEntry[] entries = phonebook.ListEntries(0, 1); string output = entries[0].ToString(); string excepted = "[Ivan: +359899777235]"; Assert.AreEqual(excepted, output); }
public void ChangePhone_ChangePart() { List<string> phoneNumbers = new List<string> { "+35929811111" }; List<string> phoneNumbersTwo = new List<string> { "+35929811199" }; PhonebookRepository phonebook = new PhonebookRepository(); phonebook.AddPhone("Kalina", phoneNumbers); phonebook.AddPhone("Ivan", phoneNumbersTwo); phonebook.AddPhone("Pesho", phoneNumbers); phonebook.AddPhone("Gosho", phoneNumbersTwo); int numbersChanged = phonebook.ChangePhone("+35929811111", "+359899777236"); Assert.AreEqual(2, numbersChanged); }
public void ChangePhone_AddChangeMultipleToOne() { List<string> phoneNumbers = new List<string> { "+35929811111" }; PhonebookRepository phonebook = new PhonebookRepository(); List<string> phoneNumbersTwo = new List<string> { "+35929811199" }; phonebook.AddPhone("Kalina", phoneNumbers); phonebook.AddPhone("Ivan", phoneNumbersTwo); phonebook.ChangePhone("+35929811111", "+359899777236"); phonebook.ChangePhone("+35929811199", "+359899777236"); SortedSet<string> sortedNumbers = phonebook.PhoneEntries[0].PhoneNumbers; SortedSet<string> sortedNumbersTwo = phonebook.PhoneEntries[1].PhoneNumbers; string actual = string.Join(", ", sortedNumbers); string actualTwo = string.Join(", ", sortedNumbersTwo); bool hasChangeTwo = actual == actualTwo; bool isChanged = "+359899777236" == actual; Assert.AreEqual(isChanged, hasChangeTwo); }
public void ListTests_TestDifferentNumberOfListedNumber() { SortedSet<string> phoneNumbers = new SortedSet<string> { "+35929811111" }; PhonebookRepository phonebook = new PhonebookRepository(); phonebook.AddPhone("Ivan", phoneNumbers); phonebook.AddPhone("Pesho", phoneNumbers); PhoneEntry[] entries = phonebook.ListEntries(0, 2); bool areAllTrue = true; string output = entries[0].ToString(); string excepted = "[Ivan: +359899777235]"; string output1 = entries[1].ToString(); string excepted1 = "[Pesho: +359899777235]"; if ((output == excepted) && (output1 == excepted1)) { areAllTrue = false; } Assert.IsTrue(areAllTrue); }
public void ListTests_TestThreeNumbers() { SortedSet<string> phoneNumbers = new SortedSet<string> { "+35929811111", "+359899777235", "+359899777236" }; PhonebookRepository phonebook = new PhonebookRepository(); phonebook.AddPhone("Kalina", phoneNumbers); PhoneEntry[] entries = phonebook.ListEntries(0, 1); string output = entries[0].ToString(); string excepted = "[Kalina: +35929811111, +359899777235, +359899777236]"; Assert.AreEqual(excepted, output); }
public void ChangePhone_HaveTwoOldPhones() { List<string> phoneNumbers = new List<string> { "+35929811111" }; PhonebookRepository phonebook = new PhonebookRepository(); phonebook.AddPhone("Kalina", phoneNumbers); phonebook.AddPhone("Ivan", phoneNumbers); int numbersChanged = phonebook.ChangePhone("+35929811111", "+359899777236"); Assert.AreEqual(2, numbersChanged); }
public void AddPhone_AddSameNumber() { List<string> phoneNumbers = new List<string> { "+35929811111" }; PhonebookRepository phonebook = new PhonebookRepository(); phonebook.AddPhone("Kalina", phoneNumbers); List<string> sameNumber = new List<string> { "+359899777236" }; bool isSameAdded = phonebook.AddPhone("Kalina", sameNumber); Assert.IsFalse(isSameAdded); }
public void AddPhone_AddNullNumber() { PhonebookRepository phonebook = new PhonebookRepository(); bool isAdded = phonebook.AddPhone("Kalina", null); }
public void AddPhone_AddEmptyNumber() { List<string> phoneNumbers = new List<string> { "" }; PhonebookRepository phonebook = new PhonebookRepository(); bool isAdded = phonebook.AddPhone("Kalina", phoneNumbers); }
public void ChangePhone_GiveNullAsParams() { List<string> phoneNumbers = new List<string> { "+35929811111" }; PhonebookRepository phonebook = new PhonebookRepository(); phonebook.AddPhone("Kalina", phoneNumbers); int numbersChanged = phonebook.ChangePhone(null, "+359899777236"); }
public void AddPhone_MergeTest() { List<string> phoneNumbers = new List<string> { "+35929811111" }; PhonebookRepository phonebook = new PhonebookRepository(); phonebook.AddPhone("Kalina", phoneNumbers); List<string> mergeOne = new List<string> { "+359899123236" }; List<string> difNumber = new List<string> { "+359899900006" }; phonebook.AddPhone("Kalina", mergeOne); bool isMerged = phonebook.AddPhone("Kalina", difNumber); Assert.IsFalse(isMerged); }