public void RemoveContactFromGroupTest()
        {
            app.Groups.GroupCheck();
            app.Contacts.ContactCheck();
            app.Contacts.CheckContactInGroup();

            ContactData      contact = ContactData.GetAll()[0];
            List <GroupData> oldList = contact.GetGroups();
            GroupData        group   = oldList[0];

            app.Contacts.RemoveContactFromGroup(group, contact);

            List <GroupData> newList = contact.GetGroups();

            oldList.Remove(group);
            newList.Sort();
            oldList.Sort();

            Assert.AreEqual(oldList, newList);
        }
Пример #2
0
        public void CheckContactInGroup()
        {
            ContactData      contact = ContactData.GetAll()[0];
            GroupData        group   = GroupData.GetAll()[0];
            List <GroupData> List    = contact.GetGroups();

            if (List.Count() == 0)
            {
                AddContactToGroup(contact, group);
            }
            ;
        }
Пример #3
0
        public void TestDBConnect()
        {
            System.Console.Out.WriteLine("Start:");
            ContactData contact = ContactData.GetAll()[0];

            System.Console.Out.WriteLine(contact.AllName);

            foreach (GroupData group in contact.GetGroups())
            {
                System.Console.Out.WriteLine(group.Name);
            }
        }
Пример #4
0
        public void CheckContactOutOfGroup()
        {
            ContactData c = new ContactData(TestBase.GenerateRandomString(5), TestBase.GenerateRandomString(5));

            ContactData      contact           = ContactData.GetAll()[0];
            List <GroupData> groupsList        = GroupData.GetAll();
            List <GroupData> contactGroupsList = contact.GetGroups();

            groupsList.Sort();
            contactGroupsList.Sort();

            if (groupsList.SequenceEqual(contactGroupsList))
            {
                Create(c);
            }
        }
        public GroupData PrepareRemovingContactFromGroupTest()
        {
            GroupData groups;
            // выбираем первый контакт, который входит хотя бы в 1 группу
            ContactData contact = ContactData.GetContactsInGroup().FirstOrDefault();

            if (contact != null)
            {
                // удаляем контакт из группы
                groups = contact.GetGroups()[0];
                RemovingContactFromGroup(contact, groups);
            }
            else
            {
                // выбираем первую группу из списка групп, если список пустой - добавляем группу
                groups = manager.Groups.FirstOrCreate();
                // создаем контакт
                Create(
                    new ContactData
                {
                    FirstName  = TestBase.GenerateRandomString(20),
                    LastName   = TestBase.GenerateRandomString(50),
                    MiddleName = TestBase.GenerateRandomString(20),

                    Address     = TestBase.GenerateRandomString(300),
                    HomePhone   = TestBase.GenerateRandomPhoneNumeric(),
                    MobilePhone = TestBase.GenerateRandomPhoneNumeric(),
                    WorkPhone   = TestBase.GenerateRandomPhoneNumeric(),


                    Email1 = TestBase.GenerateRandomEmail(20, 5),
                    Email2 = TestBase.GenerateRandomEmail(20, 5),
                    Email3 = TestBase.GenerateRandomEmail(20, 5)
                });

                // ищем в базе этот контакт
                ContactData constact = ContactData.GetAll().Except(groups.GetContacts()).First();
                // добавляем в эту группу контакт
                AddContactToGroup(constact, groups);
            }
            return(groups);
        }
        public void TestRemoveContactFromGroup()
        {
            List <ContactData> contacts = ContactData.GetAll().ToList();

            if (contacts.Count == 0)
            {
                ContactData addContact = new ContactData("Юрий", "Сергеев");
                app.Contacts.Create(addContact);
            }
            List <GroupData> groups = GroupData.GetAll().ToList();

            if (groups.Count == 0)
            {
                GroupData addGroup = new GroupData("my");
                app.Groups.Create(addGroup);
            }

            contacts = ContactData.GetAll().ToList();
            groups   = GroupData.GetAll().ToList();
            foreach (ContactData contact in contacts)
            {
                List <GroupData> contactGroups = ContactData.GetGroups(contact.Id);
                if (contactGroups.Count == 0)
                {
                    app.Contacts.AddContactsToGroup(contact, groups.First());
                    contactGroups = ContactData.GetGroups(contact.Id);
                }

                List <ContactData> oldList = contactGroups.First().GetContacts();
                //actions
                app.Contacts.RemoveContactFromGroup(contact, contactGroups.First());
                //compare

                List <ContactData> newList = contactGroups.First().GetContacts();
                oldList.Remove(contact);
                oldList.Sort();
                newList.Sort();

                Assert.AreEqual(oldList, newList);
            }

            /*
             *
             *          List<GroupData> groups = GroupData.GetAll().ToList();
             *          List<GroupContactRelation> enteredToGroup = contact.ContactEnteredToGroup(contact.Id, groups[groupIndex].Id);
             *
             *          if (enteredToGroup.Count == 0)
             *          {
             *              app.Contacts.AddContactsToGroup(contact, groups[groupIndex]);
             *          }
             *
             *          //for (int i = 0; i < groups.LongCount(); ++i)
             *          //{
             *
             *          //    List<ContactData> groupList = groups[i].GetContacts();
             *                List<ContactData> oldList = groups[groupIndex].GetContacts();
             *          //    foreach (ContactData contact in groupList)
             *          //    {
             *
             *                  //actions
             *                  app.Contacts.RemoveContactFromGroup(contact, groups[groupIndex]);
             *                  //compare
             *
             *                  List<ContactData> newList = groups[groupIndex].GetContacts();
             *                  oldList.Remove(contact);
             *                  oldList.Sort();
             *                  newList.Sort();
             *
             *                  Assert.AreEqual(oldList, newList);
             *          //    }
             *          //}
             */
        }
Пример #7
0
        public void TestAddingContactToGroup()
        {
            List <ContactData> contacts = ContactData.GetAll().ToList();

            if (contacts.Count == 0)
            {
                ContactData addContact = new ContactData("Юрий", "Сергеев");
                app.Contacts.Create(addContact);
            }
            List <GroupData> groups = GroupData.GetAll().ToList();

            if (groups.Count == 0)
            {
                GroupData addGroup = new GroupData("my");
                app.Groups.Create(addGroup);
            }

            contacts = ContactData.GetAll().ToList();
            groups   = GroupData.GetAll().ToList();

            foreach (ContactData contact in contacts)
            {
                ContactData      newContact       = contact;
                GroupData        groupForAdding   = groups.First();
                List <GroupData> contactGroups    = ContactData.GetGroups(contact.Id);
                List <GroupData> contactNewGroups = GroupData.GetAll().Except(contactGroups).ToList();
                if (contactNewGroups.Count == 0)
                {
                    // add new contact
                    ContactData addContact = new ContactData("Мамай", "Сергеев");
                    app.Contacts.Create(addContact);
                    newContact = ContactData.GetLastContact();
                }
                else
                {
                    groupForAdding = contactNewGroups.First();
                }

                List <ContactData> oldList = groupForAdding.GetContacts();
                //actions
                app.Contacts.AddContactsToGroup(newContact, groupForAdding);

                //compare
                List <ContactData> newList = groupForAdding.GetContacts();
                oldList.Add(newContact);
                oldList.Sort();
                newList.Sort();

                Assert.AreEqual(oldList, newList);
            }

/*
 *          ContactData contact = ContactData.GetAll()[contactIndex];
 *
 *          GroupData addData = new GroupData("my");
 *          app.Groups.IsGroupPresent(groupIndex, app.Groups.bySelected, addData);
 *
 *          List<GroupData> groups = GroupData.GetAll().ToList();
 *          GroupData group = groups[groupIndex];
 *
 *          if (group.ContactEnteredToGroup(contact.Id, group.Id))
 *          {
 *              app.Contacts.Create(addContact);
 *              contact = ContactData.GetLastContact();
 *          }
 *
 *          List<ContactData> oldList = group.GetContacts();
 *          //           List<ContactData> oldList = group.GetContact(contact.Id);
 *          //           ContactData contact = ContactData.GetAll().Except(oldList).First();
 *
 *          //actions
 *          app.Contacts.AddContactsToGroup(contact, group);
 *
 *          //compare
 *          List<ContactData> newList = group.GetContacts();
 *          oldList.Add(contact);
 *          oldList.Sort();
 *          newList.Sort();
 *
 *          Assert.AreEqual(oldList, newList);
 */
        }