public void Add_Contact_To_Organization_Contact_List()
        {
            ContactCreator.CreateSimpleOrphanContact();
            OrganizationCreator.CreateSimpleOrganization();
            OrganizationViewPage.AddContactsToContactList().WithFirstName(ContactCreator.FirstContact.FirstName).AndLastName(ContactCreator.FirstContact.LastName).Add();

            OrganizationsPage.FindOrganization().WithOrganizationName(OrganizationCreator.FirstOrganization.OrganizationName).Open();

            AssertThat.IsTrue(
                OrganizationViewPage.FindContactFromOrganizationContactList()
                .WithFirstName(ContactCreator.FirstContact.FirstName)
                .AndLastName(ContactCreator.FirstContact.LastName)
                .Find(),
                $"Contact {ContactCreator.FirstContact.FullName} does not exist within organization {OrganizationCreator.FirstOrganization.OrganizationName} contacts, although it was added previously");

            OrganizationViewPage.FindContactFromOrganizationContactList().BySequence(1).Remove();

            AssertThat.IsFalse(
                OrganizationViewPage.FindContactFromOrganizationContactList()
                .WithFirstName(ContactCreator.FirstContact.FirstName)
                .AndLastName(ContactCreator.FirstContact.LastName)
                .Find(),
                $"Contact {ContactCreator.FirstContact.FullName} exists within organization {OrganizationCreator.FirstOrganization.OrganizationName} contacts, although it was removed previously");

            ContactsPage.FindContact().WithFirstName(ContactCreator.FirstContact.FirstName).AndLastName(ContactCreator.FirstContact.LastName).Open();

            AssertThat.AreEqual(ContactViewPage.OrganizationName, "", $"Contact {ContactCreator.FirstContact.FullName} is not orphan though it should because it was removed from organization '{OrganizationCreator.FirstOrganization.OrganizationName}' contacts");
        }
        public void Add_Existing_No_Orphan_Contact_To_An_Organization()
        {
            ContactCreator.CreateSimpleContact();
            OrganizationCreator.CreateSimpleOrganization();

            OrganizationViewPage.AddContactsToContactList()
            .UncheckingOrphanCheckbox()
            .WithFirstName(ContactCreator.FirstContact.FirstName)
            .AndLastName(ContactCreator.FirstContact.LastName)
            .Add();

            AssertThat.IsTrue(
                OrganizationViewPage.FindContactFromOrganizationContactList()
                .WithFirstName(ContactCreator.FirstContact.FirstName)
                .AndLastName(ContactCreator.FirstContact.LastName)
                .Find(),
                $"Contact with name {ContactCreator.FirstContact.FullName} should be linked to organization {OrganizationViewPage.OrganizationName} but it is not."
                );

            OrganizationsPage.FindOrganization().WithOrganizationName(ContactCreator.FirstContact.OrganizationName).Open();
            AssertThat.IsFalse(
                OrganizationViewPage.FindContactFromOrganizationContactList()
                .WithFirstName(ContactCreator.FirstContact.FirstName)
                .AndLastName(ContactCreator.FirstContact.LastName)
                .Find(),
                $"Contact with name {ContactCreator.FirstContact.FullName} should not belong to organization {OrganizationViewPage.OrganizationName} but it is still linked with it."
                );
        }
        public void Make_A_Contact_Primary_From_Within_Organization()
        {
            OrganizationCreator.CreateSimpleOrganization();
            OrganizationViewPage.AddContactsToContactList().Randomly(2).Add();

            AssertThat.AreEqual(OrganizationViewPage.ContactListCount, 2, "Previously added contacts did not show up in organization contact list");
            OrganizationViewPage.FindContactFromOrganizationContactList().BySequence(1).MakePrimaryContact();
            AssertThat.AreEqual(OrganizationViewPage.PrimaryContact, OrganizationViewPage.GetContactFullNameBySequence(1), $"Contact '{OrganizationViewPage.GetContactFullNameBySequence(1)}' was not made primary though it should");

            OrganizationViewPage.FindContactFromOrganizationContactList().BySequence(2).MakePrimaryContact();
            AssertThat.AreEqual(OrganizationViewPage.PrimaryContact, OrganizationViewPage.GetContactFullNameBySequence(2), $"Contact '{OrganizationViewPage.GetContactFullNameBySequence(2)}' was not made primary though it should");
        }
        public void Delete_Organization_Along_With_Its_Linked_Contacts()
        {
            ContactCreator.CreateSimpleOrphanContact();
            ContactCreator.CreateSimpleOrphanContact();
            ContactCreator.CreateSimpleOrphanContact();

            OrganizationCreator.CreateSimpleOrganization();

            OrganizationViewPage.AddContactsToContactList()
            .WithFirstName(ContactCreator.FirstContact.FirstName)
            .AndLastName(ContactCreator.FirstContact.LastName)
            .Add();
            OrganizationViewPage.AddContactsToContactList()
            .WithFirstName(ContactCreator.SecondContact.FirstName)
            .AndLastName(ContactCreator.SecondContact.LastName)
            .Add();
            OrganizationViewPage.AddContactsToContactList()
            .WithFirstName(ContactCreator.ThirdContact.FirstName)
            .AndLastName(ContactCreator.ThirdContact.LastName)
            .Add();

            OrganizationViewPage.DeleteOrganization().WithContacts();

            VerifyThat.IsFalse(
                OrganizationsPage.FindOrganization().WithOrganizationName(OrganizationCreator.FirstOrganization.OrganizationName).Find(),
                $"Organization with name {OrganizationCreator.FirstOrganization.OrganizationName} should be deleted but, it still exists"
                );

            VerifyThat.IsFalse(
                ContactsPage.FindContact().ContainingKeyword(ContactCreator.FirstContact.FullName).Find(),
                $"Contact with name {ContactCreator.FirstContact.FullName} should be deleted along with its organization but, it still exists"
                );
            VerifyThat.IsFalse(
                ContactsPage.FindContact().ContainingKeyword(ContactCreator.SecondContact.FullName).Find(),
                $"Contact with name {ContactCreator.FirstContact.FullName} should be deleted along with its organization but, it still exists"
                );
            VerifyThat.IsFalse(
                ContactsPage.FindContact().ContainingKeyword(ContactCreator.ThirdContact.FullName).Find(),
                $"Contact with name {ContactCreator.FirstContact.FullName} should be deleted along with its organization but, it still exists"
                );
        }