public void DeleteTest()
        {
            string     n      = "test";
            Adressbook target = new Adressbook(n);

            Contact[] contacts = { new Contact("name1", "email1"), new Contact("name2", "email2"), new Contact("name3", "email3"), new Contact("name4", "email4") };
            for (int i = 0; i < contacts.Length; i++)
            {
                target.Add(contacts[i]);
            }
            for (int i = 0; i < contacts.Length; i++)
            {
                target.Delete(contacts[i]);
                Assert.IsTrue(target.contacts.Count == contacts.Length - i - 1);
            }

            // Check if adressbook crashes when an non existend contact is trying to be deleted
            Contact nonexistend = new Contact("name", "email");

            try
            {
                target.Delete(nonexistend);
                Assert.IsTrue(true);
            }
            catch
            {
                throw new ArgumentOutOfRangeException();
            }
        }
Example #2
0
        private Contact addContact(Adressbook a, string name)
        {
            Contact c = new Contact(name, name + "@gmail.com");

            a.Add(c);
            return(c);
        }
Example #3
0
        private void removeContact(Viewer2_Accessor view, Adressbook a, Contact contact)
        {
            changeAddressbook(view, a);
            EventArgs e = new EventArgs();
            object    o = new object();

            view.delete_Click(o, e, contact);
        }
Example #4
0
        // prime path 4: [b, f1, f2, c, i, d]
        private void path_4(Viewer2_Accessor view)
        {
            clear(view);

            Adressbook a1 = addAddressbook(view, "adb1");
            Contact    c1 = addContact(a1, "c1");

            removeContact(view, a1, c1);

            Assert.AreEqual(a1.Contacts.Count, 0);
        }
Example #5
0
 private void changeAddressbook(Viewer2_Accessor view, Adressbook a)
 {
     for (int i = 0; i < view.adressbooks.Count; i++)
     {
         if (view.adressbooks[i] == a)
         {
             view.current = i;
         }
     }
     view.changeToAddressbook(a);
 }
 public void AddressbookInitialize()
 {
     adb = new Adressbook("testbook");
     c1  = new Contact("Jarno", "*****@*****.**");
     c2  = new Contact("Bas", "*****@*****.**");
     c3  = new Contact("C.A.R.Hoare", "*****@*****.**");
     c4  = new Contact("name4", "email4");
     adb.Add(c1);
     adb.Add(c2);
     adb.Add(c3);
     adb.Add(c4);
 }
Example #7
0
        // prime path 10: [g1, g2, g1]
        // prime path 11: [g2, g1, g2]
        private void path_10_11(Viewer2_Accessor view)
        {
            clear(view);

            Adressbook a1 = addAddressbook(view, "adb1");
            Contact    c1 = addContact(a1, "c1");
            Contact    c2 = addContact(a1, "c2");
            Contact    c3 = addContact(a1, "c3");

            removeContact(view, a1, c3);

            Assert.AreEqual(a1.Contacts.Count, 2);
        }
Example #8
0
        // prime path 19: [f2, f1, g1, g2, f2]
        private void path_19(Viewer2_Accessor view)
        {
            clear(view);

            Adressbook a1 = addAddressbook(view, "adb1");
            Adressbook a2 = addAddressbook(view, "adb2");
            Contact    c1 = addContact(a2, "c1");
            Contact    c2 = addContact(a2, "c2");

            removeContact(view, a2, c2);

            Assert.AreEqual(a1.Contacts.Count, 0);
            Assert.AreEqual(a2.Contacts.Count, 1);
        }
        public void AddTest()
        {
            string     n      = "test";
            Adressbook target = new Adressbook(n);

            Contact[] contacts = { new Contact("name1", "email1"), new Contact("name2", "email2"), new Contact("name3", "email3"), new Contact("name4", "email4") };
            foreach (Contact c in contacts)
            {
                target.Add(c);
            }
            for (int i = 0; i < contacts.Length; i++)
            {
                Assert.AreEqual(contacts[i], target.contacts[i]);
            }
        }
Example #10
0
        // prime path 22: [h, g2, f2, f1, g1, h]
        private void path_22(Viewer2_Accessor view)
        {
            clear(view);

            Adressbook a1  = addAddressbook(view, "adb1");
            Contact    c1  = addContact(a1, "c1");
            Adressbook a2  = addAddressbook(view, "adb2");
            Contact    c1b = addContact(a2, "c1");
            Adressbook a3  = addAddressbook(view, "adb3");
            Contact    c1c = addContact(a3, "c1");

            removeContact(view, a3, c1c);

            Assert.AreEqual(a1.Contacts.Count, 1);
            Assert.AreEqual(a2.Contacts.Count, 1);
            Assert.AreEqual(a3.Contacts.Count, 0);
        }