예제 #1
0
        public void ListEntries_WorksOnCountLessThanActualAndIsSorted()
        {
            Phonebook book = new Phonebook();

            List<string> phones = new List<string>();
            phones.Add("+3592221431");
            phones.Add("+3593484374");
            phones.Add("+3598438748");

            book.AddPhone("John", phones);

            List<string> davePhones = new List<string>();

            davePhones.Add("+3593484374"); // equal to John's second
            davePhones.Add("+35932378439");
            davePhones.Add("+3590034884");

            List<string> adamPhones = new List<string>();

            adamPhones.Add("+3593484374"); // equal to John's second
            adamPhones.Add("+35932378439");
            adamPhones.Add("+3590034884");

            book.AddPhone("Adam", davePhones);

            PhonebookEntry[] entries = book.ListEntries(0, 1);

            string name = entries[0].Name;
            int count = entries.Length;

            Assert.AreEqual(1, count);
            Assert.AreEqual("Adam", name);
        }
예제 #2
0
        public void ListEntries_WorksOnCountEqualToCurrentPhonebookCount()
        {
            Phonebook book = new Phonebook();

            List<string> phones = new List<string>();
            phones.Add("+3592221431");
            phones.Add("+3593484374");
            phones.Add("+3598438748");

            book.AddPhone("John", phones);

            List<string> davePhones = new List<string>();

            davePhones.Add("+3593484374"); // equal to John's second
            davePhones.Add("+35932378439");
            davePhones.Add("+3590034884");

            book.AddPhone("Dave", davePhones);

            int entriesCount = book.ListEntries(0, 2).Length;

            Assert.AreEqual(2, entriesCount);
        }
예제 #3
0
        public void ListEntries_ThrowsExceptionOnNegativeStartIndex()
        {
            Phonebook book = new Phonebook();

            book.ListEntries(-1, 4);
        }
예제 #4
0
        public void ListEntries_ThrowsExceptionOnCountBiggerThanActual()
        {
            Phonebook book = new Phonebook();

            List<string> phones = new List<string>();
            phones.Add("+3592221431");
            phones.Add("+3593484374");
            phones.Add("+3598438748");

            book.AddPhone("John", phones);

            List<string> davePhones = new List<string>();

            davePhones.Add("+3593484374"); // equal to John's second
            davePhones.Add("+35932378439");
            davePhones.Add("+3590034884");

            book.AddPhone("Dave", davePhones);

            int entriesCount = book.ListEntries(0, 10).Length;
        }
예제 #5
0
        public void ListEntries_ThrowsExceptionOnBigIndex()
        {
            Phonebook book = new Phonebook();

            book.ListEntries(100, 4);
        }
예제 #6
0
        public void ListEntries_ReturnsEmptyArrayOnZeroCount()
        {
            Phonebook book = new Phonebook();

            PhonebookEntry[] entries = book.ListEntries(0, 0);

            Assert.AreEqual(0, entries.Length);
        }