public void TestRemoveContacts() { var member1 = _memberAccountsCommand.CreateTestMember(1); Assert.IsTrue(_memberContactsQuery.GetFirstDegreeContacts(member1.Id).Count == 0); var member2 = _memberAccountsCommand.CreateTestMember(2); _networkingCommand.CreateFirstDegreeLink(member1.Id, member2.Id); AssertFirstDegreeContacts(member1.Id, member2.Id); _networkingCommand.DeleteFirstDegreeLink(member1.Id, member2.Id); Assert.IsTrue(_memberContactsQuery.GetFirstDegreeContacts(member1.Id).Count == 0); Assert.IsTrue(_memberContactsQuery.GetFirstDegreeContacts(member2.Id).Count == 0); Assert.IsFalse(_memberContactsQuery.AreFirstDegreeContacts(member1.Id, member2.Id)); Assert.IsFalse(_memberContactsQuery.AreFirstDegreeContacts(member2.Id, member1.Id)); }
private void AssertFriends(Guid memberId, ICollection <Member> expected, IEnumerable <Member> notExpected) { var firstDegreeContacts = _memberContactsQuery.GetFirstDegreeContacts(memberId); Assert.AreEqual(expected.Count, firstDegreeContacts.Count); foreach (var expectedFriend in expected) { Assert.IsTrue(firstDegreeContacts.Contains(expectedFriend.Id)); } foreach (var expectedMember in expected) { Assert.IsTrue(_memberContactsQuery.AreFirstDegreeContacts(memberId, expectedMember.Id)); } foreach (var notExpectedMember in notExpected) { Assert.IsFalse(_memberContactsQuery.AreFirstDegreeContacts(memberId, notExpectedMember.Id)); } }
private static IList <string> SendFriendInvitations(Guid inviterId, IEnumerable <string> inviteeEmailAddresses, string text, Guid?donationRequestId) { var firstDegreeContacts = new List <string>(); foreach (var emailAddress in inviteeEmailAddresses.Distinct()) { if (emailAddress != null && emailAddress.Trim().Length != 0) { // Check whether they are an existing member. var invitee = _membersQuery.GetMember(emailAddress); if (invitee != null) { // A member cannot invite themselves. if (invitee.Id != inviterId) { // Do not invite if they are already linked. if (_memberContactsQuery.AreFirstDegreeContacts(invitee.Id, inviterId)) { firstDegreeContacts.Add(emailAddress); } else { // Invitation for an already existing member (no donation request for existing members). _memberFriendsCommand.SendInvitation(new FriendInvitation { InviteeId = invitee.Id, InviterId = inviterId, Text = text }); } } } else { // Not a member so send them a new invitation. _memberFriendsCommand.SendInvitation(new FriendInvitation { DonationRequestId = donationRequestId, InviteeEmailAddress = emailAddress, InviterId = inviterId, Text = text }); } } } return(firstDegreeContacts.ToList()); }
public void TestByEmail() { var member = _memberAccountsCommand.CreateTestMember(0); var activated = _memberAccountsCommand.CreateTestMember(EmailAddress1, FirstName, LastName1); Assert.IsFalse(_memberContactsQuery.AreFirstDegreeContacts(member.Id, activated.Id)); activated.VisibilitySettings.Personal.Set(PersonalContactDegree.Public, PersonalVisibility.Name); _memberAccountsCommand.UpdateMember(activated); Assert.AreEqual(activated.Id, _memberContactsQuery.GetContact(member.Id, activated.GetBestEmailAddress().Address)); activated.VisibilitySettings.Personal.Set(PersonalContactDegree.Public, PersonalVisibility.EmailAddress); activated.VisibilitySettings.Personal.Set(PersonalContactDegree.Public, PersonalVisibility.Name); _memberAccountsCommand.UpdateMember(activated); Assert.AreEqual(activated.Id, _memberContactsQuery.GetContact(member.Id, activated.GetBestEmailAddress().Address)); // Remove access to name flag for public so member shouldn't be found. activated.VisibilitySettings.Personal.Set(PersonalContactDegree.SecondDegree, PersonalVisibility.Name); _memberAccountsCommand.UpdateMember(activated); Assert.IsNull(_memberContactsQuery.GetContact(member.Id, activated.GetBestEmailAddress().Address)); }