public void TestRemovingContactFromGroup() { // Preparation section GroupData group = GroupData.GetNonEmptyGroup(); if (group == null) { // We can't say for sure if any of these objects' instance exists, // so we need to check this out and to create if necessary CreateGroupForTestIfNecessary(); CreateContactForTestIfNecessary(); group = GroupData.GetAllRecordsFromDB()[0]; ContactData contactCreated = ContactData.GetActiveRecordsFromDB()[0]; app.Contacts.AddContactToGroup(contactCreated, group); } // Test section List <ContactData> oldContactsList = group.GetContacts(); ContactData contact = oldContactsList[0]; app.Contacts.RemoveContactFromGroup(contact, group); List <ContactData> newContactsList = group.GetContacts(); oldContactsList.Remove(contact); oldContactsList.Sort(); newContactsList.Sort(); Assert.AreEqual(oldContactsList, newContactsList); }
public void ContactModificationTest() { CreateContactForTestIfNecessary(); int contactNumToModify = 0; string postfix = DateTime.Now.ToString(); ContactData contact = new ContactData() { FirstName = "New FirstName - " + postfix, LastName = "New LastName - " + postfix, PrimaryAddress = "Test Primary Addr" }; List <ContactData> oldContacts = ContactData.GetActiveRecordsFromDB(); contact.Id = oldContacts[contactNumToModify].Id; app.Contacts.EditById(contact); List <ContactData> newContacts = ContactData.GetActiveRecordsFromDB(); // Perform contact modification in old list oldContacts[contactNumToModify].FirstName = contact.FirstName; oldContacts[contactNumToModify].LastName = contact.LastName; oldContacts[contactNumToModify].PrimaryAddress = contact.PrimaryAddress; // Compare results oldContacts.Sort(); newContacts.Sort(); Assert.AreEqual(oldContacts, newContacts); }
public void CompareContactsUI_DB() { if (PERFORM_LONG_UI_CHECKS) { List <ContactData> fromUI = app.Contacts.GetContactsList(); List <ContactData> fromDB = ContactData.GetActiveRecordsFromDB(); fromUI.Sort(); fromDB.Sort(); Assert.AreEqual(fromUI, fromDB); } }
public void ContactCreationTest(ContactData contact) { List <ContactData> oldContacts = ContactData.GetActiveRecordsFromDB(); app.Contacts.Create(contact); List <ContactData> newContacts = ContactData.GetActiveRecordsFromDB(); oldContacts.Add(contact); oldContacts.Sort(); newContacts.Sort(); Assert.AreEqual(oldContacts, newContacts); }
public void ContactRemovalTest() { CreateContactForTestIfNecessary(); int contactNumToRemove = 0; List <ContactData> oldContacts = ContactData.GetActiveRecordsFromDB(); ContactData contactToRemove = oldContacts[contactNumToRemove]; app.Contacts.DeleteById(contactToRemove.Id); List <ContactData> newContacts = ContactData.GetActiveRecordsFromDB(); oldContacts.RemoveAt(contactNumToRemove); oldContacts.Sort(); newContacts.Sort(); Assert.AreEqual(oldContacts, newContacts); }
public void TestDBConnectivity() { DateTime start = DateTime.Now; List <ContactData> fromUI = app.Contacts.GetContactsList(); DateTime end = DateTime.Now; Console.WriteLine(end.Subtract(start)); start = DateTime.Now; List <ContactData> fromDb = ContactData.GetActiveRecordsFromDB(); end = DateTime.Now; Console.WriteLine(end.Subtract(start)); fromDb.Sort(); fromUI.Sort(); Assert.AreEqual(fromDb, fromUI); }
public void TestAddingContactToGroup() { // Preparation section CreateGroupForTestIfNecessary(); CreateContactForTestIfNecessary(); GroupData group = GroupData.GetAllRecordsFromDB()[0]; List <ContactData> oldContactsList = group.GetContacts(); ContactData contact; if (oldContactsList.Count() == 0) { // if group doesn't contain any contact then just take first existing // to add to (nothing to exclude) contact = ContactData.GetActiveRecordsFromDB().First(); } else { if (ContactData.GetActiveRecordsFromDB().Except(oldContactsList).Count() == 0) { CreateContactForTestIfNecessary(true); } contact = ContactData.GetActiveRecordsFromDB().Except(oldContactsList).First(); } // Test section app.Contacts.AddContactToGroup(contact, group); List <ContactData> newContactsList = group.GetContacts(); oldContactsList.Add(contact); oldContactsList.Sort(); newContactsList.Sort(); Assert.AreEqual(oldContactsList, newContactsList); }