public void DeleteContact()
        {
            DataNewContact newuser = new DataNewContact("Tony", "Stark");

            if (!app.Contacts.FindUsers())
            {
                app.Contacts.New(newuser);
            }

            List <DataNewContact> oldConts    = DataNewContact.GetAllContact();
            DataNewContact        toBeRemoved = oldConts[0];

            app.Contacts.DeleteById(toBeRemoved);

            Assert.AreEqual(oldConts.Count - 1, app.Contacts.GetContactCount());

            List <DataNewContact> newConts = DataNewContact.GetAllContact();

            oldConts.RemoveAt(0);
            Assert.AreEqual(oldConts, newConts);

            foreach (DataNewContact user in newConts)
            {
                Assert.AreNotEqual(user.Id, toBeRemoved.Id);
            }
        }
Exemple #2
0
 public void CompareContactsUI_DB()
 {
     if (PERFORM_LONG_UI_CHECKS)
     {
         List <DataNewContact> fromUI = app.Contacts.GetContactList();
         List <DataNewContact> fromDB = DataNewContact.GetAllContact();
         fromUI.Sort();
         fromDB.Sort();
         Assert.AreEqual(fromUI, fromDB);
     }
 }
Exemple #3
0
        public void CreationContact(DataNewContact newuser)
        {
            List <DataNewContact> oldConts = DataNewContact.GetAllContact();

            app.Contacts.New(newuser);

            Assert.AreEqual(oldConts.Count + 1, app.Contacts.GetContactCount());

            List <DataNewContact> newConts = DataNewContact.GetAllContact();

            oldConts.Add(newuser);
            oldConts.Sort();
            newConts.Sort();
            Assert.AreEqual(oldConts, newConts);
        }
        public void TestAddContactToGroup()
        {
            DataNewContact newuser  = new DataNewContact("Tony", "Stark");
            DataGroup      newGroup = new DataGroup("test");

            if (!app.Contacts.FindUsers())
            {
                app.Contacts.New(newuser);
            }

            if (!app.Groups.FindGroups())
            {
                app.Groups.Create(newGroup);
            }
            List <DataGroup> countGroups = DataGroup.GetAllGroup();
            var contWithoutGroups        = new List <DataNewContact>();
            int count = countGroups.Count;

            for (int i = 0; i < count; i++)
            {
                DataGroup      gr   = DataGroup.GetAllGroup()[i];
                DataNewContact cont = DataNewContact.GetAllContact().Except(gr.GetContactInGroup()).FirstOrDefault();
                if (!contWithoutGroups.Contains(cont))
                {
                    contWithoutGroups.Add(cont);
                }
            }
            if (contWithoutGroups.Count == 0)
            {
                app.Contacts.New(newuser);
            }

            DataGroup             group   = DataGroup.GetAllGroup()[0];
            DataNewContact        contact = contWithoutGroups[0];
            List <DataNewContact> oldLIst = group.GetContactInGroup();

            app.Contacts.AddContactToGroups(contact, group);

            List <DataNewContact> newList = group.GetContactInGroup();

            oldLIst.Add(contact);
            newList.Sort();
            oldLIst.Sort();
            Assert.AreEqual(oldLIst, newList);
        }
        public void TestDeleteContactFromGroup()
        {
            DataNewContact newuser  = new DataNewContact("Tony", "Stark");
            DataGroup      newGroup = new DataGroup("test");

            if (!app.Contacts.FindUsers())
            {
                app.Contacts.New(newuser);
            }

            if (!app.Groups.FindGroups())
            {
                app.Groups.Create(newGroup);
            }

            List <DataGroup> countGroups = DataGroup.GetAllGroup();

            DataGroup             group   = DataGroup.GetAllGroup()[0];
            List <DataNewContact> oldLIst = group.GetContactInGroup();

            if (oldLIst == null)
            {
                DataNewContact cnt = DataNewContact.GetAllContact().Except(oldLIst).First();
                app.Contacts.AddContactToGroups(cnt, group);
            }
            DataNewContact contact = oldLIst[0];

            app.Contacts.DeleteContactFromGroups(contact, group);

            List <DataNewContact> newList = group.GetContactInGroup();

            oldLIst.Remove(contact);
            newList.Sort();
            oldLIst.Sort();
            Assert.AreEqual(oldLIst, newList);
        }
        public void UpdateContact()
        {
            DataNewContact newuser = new DataNewContact("Tony", "Stark");
            DataNewContact edit    = new DataNewContact("Virginia", "Potts");

            edit.HomePhone   = "555-7720";
            edit.MobilePhone = "777-3564";

            if (!app.Contacts.FindUsers())
            {
                app.Contacts.New(newuser);
            }

            List <DataNewContact> oldConts = DataNewContact.GetAllContact();
            DataNewContact        oldUser  = oldConts[0];

            app.Contacts.Update(edit, 0);

            Assert.AreEqual(oldConts.Count, app.Contacts.GetContactCount());

            List <DataNewContact> newConts = DataNewContact.GetAllContact();

            oldConts[0].Firstname = edit.Firstname;
            oldConts[0].Lastname  = edit.Lastname;
            oldConts.Sort();
            newConts.Sort();
            Assert.AreEqual(oldConts, newConts);

            foreach (DataNewContact user in newConts)
            {
                if (user.Id == oldUser.Id)
                {
                    Assert.AreEqual(edit.Firstname, user.Firstname);
                }
            }
        }