Exemple #1
0
        public void ContactRemovalTest()
        {
            int ContactLineNumber = 0;                         //contact line number to remove (starting from 0);

            app.Contacts.CreateIfNotExists(ContactLineNumber); //checking if selected contact exists

            List <ContactData> oldContacts = ContactData.GetAllContacts();
            ContactData        toBeRemoved = oldContacts[ContactLineNumber];

            app.Contacts.RemoveByObject(toBeRemoved);//removing requested contact
            Assert.AreEqual(oldContacts.Count - 1, app.Contacts.GetContactsCount());

            List <ContactData> newContacts = ContactData.GetAllContacts();

            oldContacts.RemoveAt(ContactLineNumber);
            oldContacts.Sort();
            newContacts.Sort();

            Assert.AreEqual(oldContacts, newContacts);

            foreach (ContactData contact in newContacts)
            {
                Assert.AreNotEqual(toBeRemoved.Id, contact.Id);
            }
        }
        public void TestDeletingContactFromGroup()
        {
            app.Groups.CheckIfGroupIsPresent();
            app.Contacts.CheckIfContactIsPresent();

            GroupData group = GroupData.GetAllGroups()[0];

            //check that 1 contact is available
            if (group.GetContactsByGroup().Count < 1)
            {
                if (ContactData.GetAllContacts().Count < 1)
                {
                    app.Contacts.CreateNewTempContact();
                }

                app.Contacts.AddContactToGroup(ContactData.GetAllContacts().First(), group);
            }

            List <ContactData> oldList = group.GetContactsByGroup();
            ContactData        contact = oldList[0];

            app.Contacts.DeleteContactFromGroup(contact, group);

            List <ContactData> newList = GroupData.GetAllGroups()[0].GetContactsByGroup();

            oldList.RemoveAt(0);
            oldList.Sort();
            newList.Sort();
            Assert.AreEqual(oldList, newList);
        }
        public void ContactModificationTest()
        {
            ContactData newContactData = new ContactData("Dmitrii" + Stopwatch.GetTimestamp());

            newContactData.Lastname   = "Zhakov" + Stopwatch.GetTimestamp();
            newContactData.Middlename = "Vladimirovich" + Stopwatch.GetTimestamp();

            app.Contacts.CheckIfContactIsPresent();

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

            app.Contacts.Modify(newContactData);

            Assert.AreEqual(oldContacts.Count, app.Contacts.GetCountContact());

            List <ContactData> newContacts = ContactData.GetAllContacts();

            toBeModified.Firstname = newContactData.Firstname;
            toBeModified.Lastname  = newContactData.Lastname;
            oldContacts.Sort();
            newContacts.Sort();
            Assert.AreEqual(oldContacts, newContacts);

            foreach (ContactData contact in newContacts)
            {
                if (contact.Id == toBeModified.Id)
                {
                    Assert.IsTrue((contact.Firstname == newContactData.Firstname) && (contact.Lastname == newContactData.Lastname));
                }
            }
        }
        public void TestAddingContactToGroup()
        {
            app.Groups.CheckIfGroupIsPresent();
            app.Contacts.CheckIfContactIsPresent();

            GroupData          group   = GroupData.GetAllGroups()[0];
            List <ContactData> oldList = group.GetContactsByGroup();

            int i = ContactData.GetAllContacts().Except(oldList).Count();

            if (i == 0)
            {
                app.Contacts.Create(new ContactData(GenerateRandomString(30), GenerateRandomString(30)));
            }

            ContactData contact = ContactData.GetAllContacts().Except(oldList).First();

            app.Contacts.AddContactToGroup(contact, group);

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

            oldList.Add(contact);
            oldList.Sort();
            newList.Sort();
            Assert.AreEqual(oldList, newList);
        }
        public void ContactModificationTest(ContactData newData)
        {
            int ContactLineNumber = 0;                                     //contact line number to modify (starting from 0);

            app.Contacts.CreateIfNotExists(ContactLineNumber);             //checking if such contact exists

            List <ContactData> oldContacts = ContactData.GetAllContacts(); //old contact list recording

            foreach (ContactData c in oldContacts)
            {
                Console.Out.Write("Old contact 1 = " + c.Fullname);
            }
            ;

            ContactData oldData = oldContacts[ContactLineNumber];                //saving state of modified contact

            app.Contacts.ModifyByObject(oldData, newData);                       //сontact modification

            Assert.AreEqual(oldContacts.Count, app.Contacts.GetContactsCount()); //number of contacts hasn't changed

            List <ContactData> newContacts = ContactData.GetAllContacts();       //new contact list recording

            oldContacts[ContactLineNumber].Firstname = newData.Firstname;        //modify contact in collection
            oldContacts[ContactLineNumber].Lastname  = newData.Lastname;         //modify contact in collection

            /*oldData.Address = newData.Address;
             * oldData.EMail = newData.EMail;
             * oldData.EMail2 = newData.EMail2;
             * oldData.EMail3 = newData.EMail3;
             * oldData.Mobile = newData.Mobile;
             * oldData.WorkPhone = newData.WorkPhone;
             * oldData.HomePhone = newData.HomePhone;*/

            oldContacts.Sort();
            foreach (ContactData c in oldContacts)
            {
                Console.Out.Write("Old contact 2 = " + c.Fullname);
            }
            ;

            newContacts.Sort();
            foreach (ContactData c in newContacts)
            {
                Console.Out.Write("New contact = " + c.Fullname);
            }
            ;

            Assert.AreEqual(oldContacts, newContacts);

            foreach (ContactData contact in newContacts)
            {
                if (contact.Id == oldData.Id)
                {
                    Assert.AreEqual(newData.Firstname, contact.Firstname);
                    Assert.AreEqual(newData.Lastname, contact.Lastname);
                }
            }
        }
 public void CompareContactUI_Db()
 {
     if (PERFORM_LONG_UI_CHECKS)
     {
         List <ContactData> fromUi = app.Contacts.GetContactsList();
         List <ContactData> fromDb = ContactData.GetAllContacts();
         fromUi.Sort();
         fromDb.Sort();
         Assert.AreEqual(fromUi, fromDb);
     }
 }
 public void CompareContactsUI_DB()
 {
     if (PERFORM_LONG_UI_CHECKS)
     {
         List <ContactData> fromUI = app.Contacts.GetContactList();
         List <ContactData> fromDB = ContactData.GetAllContacts();
         fromUI.Sort();
         fromDB.Sort();
         Assert.AreEqual(fromUI, fromDB);
     }
 }
        public void AddingContactToGroupTest()
        {
            GroupData          group   = GroupData.GetAll()[0];
            List <ContactData> oldList = group.GetContacts();
            ContactData        contact = ContactData.GetAllContacts().Except(oldList).First();

            app.Contacts.AddContactToGroup(contact, group);

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

            oldList.Add(contact);
            oldList.Sort();
            newList.Sort();
            Assert.AreEqual(oldList, newList);
        }
Exemple #9
0
        public void TestDBConnectivity()
        {
            DateTime           start  = DateTime.Now;
            List <ContactData> fromUi = app.Contacts.GetContactList();
            DateTime           end    = DateTime.Now;

            System.Console.Out.WriteLine(end.Subtract(start));


            start = DateTime.Now;
            List <ContactData> fromDb = ContactData.GetAllContacts();

            end = DateTime.Now;
            System.Console.Out.WriteLine(end.Subtract(start));
        }
        public void ContactCreationTest(ContactData contact)
        {
            List <ContactData> oldContacts = ContactData.GetAllContacts();

            app.Contacts.Create(contact);//Contact data creation
            Assert.AreEqual(oldContacts.Count + 1, app.Contacts.GetContactsCount());
            List <ContactData> newContacts = ContactData.GetAllContacts();

            oldContacts.Add(contact);

            oldContacts.Sort();
            newContacts.Sort();

            Assert.AreEqual(oldContacts, newContacts);
        }
Exemple #11
0
        public void ContactCreationTest(ContactData contact)
        {
            List <ContactData> oldContacts = ContactData.GetAllContacts();

            app.Contacts.Create(contact);

            Assert.AreEqual(oldContacts.Count + 1, app.Contacts.GetCountContact());

            List <ContactData> newContacts = ContactData.GetAllContacts();

            foreach (ContactData oldContact in oldContacts)
            {
                Assert.AreNotEqual(oldContact.Id, contact.Id);
            }

            oldContacts.Add(contact);
            oldContacts.Sort();
            newContacts.Sort();
            Assert.AreEqual(oldContacts, newContacts);
        }
        public void RemoveContactFromGroup()
        {
            app.Groups.CreateIfNotExists(0);

            GroupData group = GroupData.GetAll()[0];


            List <ContactData> oldContactsListInTheGroup = group.GetContacts(); //taking list of contacts in that group

            ContactData contactToRemove = null;

            if (oldContactsListInTheGroup.Count > 0) //if there are some contacts in the group
            {
                contactToRemove = oldContactsListInTheGroup[0];
            }
            else if (ContactData.GetAllContacts().Count > 0) //if there are contacts in the address book, but not in the group
            {
                contactToRemove = ContactData.GetAllContacts().First();
                app.Contacts.AddContactToGroup(contactToRemove, group);
                oldContactsListInTheGroup = group.GetContacts();
            }
            else //there are no contacts in the address book
            {
                app.Contacts.CreateIfNotExists(0);//checking if such contact exists
                contactToRemove = ContactData.GetAllContacts().First();
                app.Contacts.AddContactToGroup(contactToRemove, group);
                oldContactsListInTheGroup = group.GetContacts();
            }

            app.Contacts.RemoveContactFromGroup(contactToRemove, group);

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

            oldContactsListInTheGroup.Remove(contactToRemove);
            oldContactsListInTheGroup.Sort();
            newContactsListInTheGroup.Sort();
            Assert.AreEqual(oldContactsListInTheGroup, oldContactsListInTheGroup);
        }
        public void ContactRemovalTest()
        {
            app.Contacts.CheckIfContactIsPresent();

            List <ContactData> oldContacts = ContactData.GetAllContacts();
            ContactData        toBeRemoved = oldContacts[0];

            app.Contacts.Remove(toBeRemoved);
            Thread.Sleep(1000);

            Assert.AreEqual(oldContacts.Count - 1, app.Contacts.GetCountContact());

            List <ContactData> newContacts = ContactData.GetAllContacts();

            oldContacts.RemoveAt(0);
            oldContacts.Sort();
            newContacts.Sort();
            Assert.AreEqual(oldContacts, newContacts);

            foreach (ContactData contact in newContacts)
            {
                Assert.AreNotEqual(toBeRemoved.Id, contact.Id);
            }
        }