public void AddingContactToGroup()
        {
            GroupData                 group              = GroupData.GetAll()[0];
            List <ContactData>        oldList            = group.GetContacts();
            IEnumerable <ContactData> contactsNotInGroup = ContactData.GetAll().Except(oldList);

            if (!contactsNotInGroup.Any())
            {
                app.Contacts.InitContactCreation();
                app.Contacts.Create(new ContactData("test", "contact"));
            }
            ContactData contact = ContactData.GetAll().Except(oldList).First();

            app.Contacts.AddContactDataToGroup(contact, group);

            List <ContactData> newList = group.GetContacts();

            oldList.Add(contact);
            newList.Sort();
            oldList.Sort();
            Assert.AreEqual(oldList, newList);
        }
        public void AddingContactToGroupTest()
        {
            ContactData tempData  = new ContactData("q", "q");
            GroupData   tempGroup = new GroupData("z", "z", "z");

            app.ContactH.CheckCountContacts(tempData);
            app.GroupH.CheckCountGroups(tempGroup);

            //-------------------
            GroupData group = new GroupData();

            ContactData             contact       = ContactData.GetAll().First();
            List <GroupData>        contactGroups = contact.GetGroups();
            IEnumerable <GroupData> freeGroups    = GroupData.GetAll().Except(contactGroups);

            if (freeGroups.Count() == 0)
            {
                app.ContactH.Create(tempData);
                contact    = ContactData.GetAll().Last();
                freeGroups = GroupData.GetAll();
            }
            group = freeGroups.First();

            List <ContactData> oldCont = group.GetContacts();

            //-------------------

            app.ContactH.AddContactToGroup(contact, group);


            List <ContactData> newCont = group.GetContacts();

            oldCont.Add(contact);
            oldCont.Sort();
            newCont.Sort();

            Assert.AreEqual(oldCont, newCont);
        }
        public void DeleteContactFromGroupTest()
        {
            ContactData tempData  = new ContactData("q", "q");
            GroupData   tempGroup = new GroupData("z", "z", "z");

            app.ContactH.CheckCountContacts(tempData);
            app.GroupH.CheckCountGroups(tempGroup);

            //-----------------
            GroupData group = new GroupData();

            ContactData      contact       = ContactData.GetAll().First();
            List <GroupData> contactGroups = contact.GetGroups();

            if (contactGroups.Count() == 0)
            {
                group = GroupData.GetAll().First();
                app.ContactH.AddContactToGroup(contact, group);
            }
            else
            {
                group = contactGroups.First();
            }

            List <ContactData> oldCont = group.GetContacts();

            //-----------------

            app.ContactH.RemoveContactFromGroup(contact, group);

            List <ContactData> newCont = group.GetContacts();

            oldCont.Remove(contact);
            oldCont.Sort();
            newCont.Sort();

            Assert.AreEqual(oldCont, newCont);
        }
Esempio n. 4
0
        public void ContactModificationTest()
        {
            //prepare
            ContactData newcontact = new ContactData("test", "test");

            app.Contacts.CreateContactIfDoesntExists(newcontact);


            List <ContactData> oldContacts  = ContactData.GetAll();
            ContactData        toBeModified = oldContacts[0];

            //action
            ContactData newData = new ContactData("Hal", "Bor");

            newData.Middlename = "";
            app.Contacts.Modify(toBeModified, newData);

            //verification
            List <ContactData> newContacts = ContactData.GetAll();

            Assert.AreEqual(oldContacts.Count, newContacts.Count); //compare count
            toBeModified.Firstname  = newData.Firstname;
            toBeModified.Lastname   = newData.Lastname;
            toBeModified.Middlename = newData.Middlename;
            oldContacts.Sort();
            newContacts.Sort();
            Console.WriteLine(string.Join("\n", oldContacts));
            Console.WriteLine(string.Join("\n", newContacts));
            Assert.AreEqual(oldContacts, newContacts); //compare data
            foreach (ContactData contact in newContacts)
            {
                if (contact.Id == toBeModified.Id)
                {
                    Assert.AreEqual(newData.Lastname + newData.Firstname, contact.Lastname + contact.Firstname);
                }
            }
        }
        public void ContactModificationTest()
        {
            ContactData tempData = new ContactData("z", "z");
            ContactData newData  = new ContactData("11", "22");
            int         index    = 0;

            if (app.ContactH.CountContactItems() == 0)
            {
                app.ContactH.Create(tempData);
            }
            List <ContactData> oldContact   = ContactData.GetAll();
            ContactData        modifiedCont = oldContact[index];

            oldContact[index].FirstName = newData.FirstName;
            oldContact[index].LastName  = newData.LastName;

            app.ContactH.Modify(modifiedCont, newData);

            List <ContactData> newContact = ContactData.GetAll();

            oldContact.Sort();
            newContact.Sort();
            Assert.AreEqual(oldContact, newContact);
        }