public async Task SocialFollowingUserTest() { // create a client SocialPlusClient client = new SocialPlusClient(TestConstants.ServerApiBaseUrl); // create user1 and user2 var postUserResponse1 = await TestUtilities.PostGenericUser(client); var postUserResponse2 = await TestUtilities.PostGenericUser(client); string auth1 = AuthHelper.CreateSocialPlusAuth(postUserResponse1.SessionToken); string auth2 = AuthHelper.CreateSocialPlusAuth(postUserResponse2.SessionToken); // user2 gets the feed of users that he is following FeedResponseUserCompactView following1 = await client.MyFollowing.GetFollowingUsersAsync(auth2, null, 10); // user2 follows user1 PostFollowingUserRequest postFollowingRequest = new PostFollowingUserRequest(postUserResponse1.UserHandle); await client.MyFollowing.PostFollowingUserAsync(postFollowingRequest, auth2); // user2 gets the feed of users that he is following var following2 = await client.UserFollowing.GetFollowingAsync(postUserResponse2.UserHandle, auth2, null, 10); // user1 gets the profile of user2 // user2 gets the profile of user1 var userProfile1 = await client.Users.GetUserAsync(postUserResponse2.UserHandle, auth1); var userProfile2 = await client.Users.GetUserAsync(postUserResponse1.UserHandle, auth2); // clean up: delete both users await TestUtilities.DeleteUser(client, auth1); await TestUtilities.DeleteUser(client, auth2); // validate: check that following1 is empty, following2 contains user1, and both user profiles have the correct state Assert.AreEqual(0, following1.Data.Count); Assert.AreEqual(1, following2.Data.Count); Assert.AreEqual(postUserResponse1.UserHandle, following2.Data[0].UserHandle); Assert.AreEqual(FollowerStatus.Follow, following2.Data[0].FollowerStatus); Assert.AreEqual(FollowerStatus.None, userProfile1.FollowerStatus); Assert.AreEqual(FollowingStatus.Follow, userProfile1.FollowingStatus); Assert.AreEqual(0, userProfile1.TotalFollowers); Assert.AreEqual(1, userProfile1.TotalFollowing); Assert.AreEqual(FollowerStatus.Follow, userProfile2.FollowerStatus); Assert.AreEqual(FollowingStatus.None, userProfile2.FollowingStatus); Assert.AreEqual(1, userProfile2.TotalFollowers); Assert.AreEqual(0, userProfile2.TotalFollowing); }
public async Task SocialFollowPrivateUserRejectTest() { // create a client SocialPlusClient client = new SocialPlusClient(TestConstants.ServerApiBaseUrl); // create user1 and user2 var postUserResponse1 = await TestUtilities.PostGenericUser(client); var postUserResponse2 = await TestUtilities.PostGenericUser(client); string auth1 = AuthHelper.CreateSocialPlusAuth(postUserResponse1.SessionToken); string auth2 = AuthHelper.CreateSocialPlusAuth(postUserResponse2.SessionToken); // user1 gets the profile of user2 // user2 gets the profile of user1 var userProfile1 = await client.Users.GetUserAsync(postUserResponse2.UserHandle, auth1); var userProfile2 = await client.Users.GetUserAsync(postUserResponse1.UserHandle, auth2); // make user2 a private user PutUserVisibilityRequest putUserVisibilityRequest = new PutUserVisibilityRequest(Visibility.Private); await client.Users.PutUserVisibilityAsync(putUserVisibilityRequest, auth2); // user1 requests to follow user2 PostFollowingUserRequest postFollowingRequest = new PostFollowingUserRequest(postUserResponse2.UserHandle); await client.MyFollowing.PostFollowingUserAsync(postFollowingRequest, auth1); CountResponse getPendingUserCount1 = null; FeedResponseUserCompactView getPendingUsers1 = null; // user2 gets the count of his pending users // user2 gets his feed of pending users getPendingUserCount1 = await client.MyPendingUsers.GetPendingUsersCountAsync(auth2); getPendingUsers1 = await client.MyPendingUsers.GetPendingUsersAsync(auth2, null, 10); // user1 gets the profile of user2 // user2 gets the profile of user1 var userProfile3 = await client.Users.GetUserAsync(postUserResponse2.UserHandle, auth1); var userProfile4 = await client.Users.GetUserAsync(postUserResponse1.UserHandle, auth2); // user2 rejects user1's follow request await client.MyPendingUsers.DeletePendingUserAsync(postUserResponse1.UserHandle, auth2); // user2 gets the count of his pending users // user2 gets his feed of pending users CountResponse getPendingUserCount2 = await client.MyPendingUsers.GetPendingUsersCountAsync(auth2); var getPendingUsers2 = await client.MyPendingUsers.GetPendingUsersAsync(auth2, null, 10); // user1 gets the profile of user2 // user2 gets the profile of user1 var userProfile5 = await client.Users.GetUserAsync(postUserResponse2.UserHandle, auth1); var userProfile6 = await client.Users.GetUserAsync(postUserResponse1.UserHandle, auth2); // clean up: delete both users await TestUtilities.DeleteUser(client, auth1); await TestUtilities.DeleteUser(client, auth2); // validate: // check that user2's list of pending users includes user1 // check that user2's list of pending users is empty after the reject // check the user profiles to see that follower status and following status are updated correctly Assert.AreEqual(1, getPendingUserCount1.Count); Assert.AreEqual(0, getPendingUserCount2.Count); Assert.AreEqual(postUserResponse1.UserHandle, getPendingUsers1.Data[0].UserHandle); Assert.AreEqual(FollowerStatus.None, getPendingUsers1.Data[0].FollowerStatus); Assert.AreEqual(Visibility.Public, getPendingUsers1.Data[0].Visibility); // Validate User Profiles Assert.AreEqual(FollowerStatus.None, userProfile1.FollowerStatus); Assert.AreEqual(FollowingStatus.None, userProfile1.FollowingStatus); Assert.AreEqual(Visibility.Public, userProfile1.Visibility); Assert.AreEqual(FollowerStatus.None, userProfile2.FollowerStatus); Assert.AreEqual(FollowingStatus.None, userProfile2.FollowingStatus); Assert.AreEqual(Visibility.Public, userProfile2.Visibility); Assert.AreEqual(FollowerStatus.Pending, userProfile3.FollowerStatus); Assert.AreEqual(FollowingStatus.None, userProfile3.FollowingStatus); Assert.AreEqual(Visibility.Private, userProfile3.Visibility); Assert.AreEqual(FollowerStatus.None, userProfile4.FollowerStatus); Assert.AreEqual(FollowingStatus.Pending, userProfile4.FollowingStatus); Assert.AreEqual(Visibility.Public, userProfile4.Visibility); Assert.AreEqual(FollowerStatus.None, userProfile5.FollowerStatus); Assert.AreEqual(FollowingStatus.None, userProfile5.FollowingStatus); Assert.AreEqual(Visibility.Private, userProfile5.Visibility); Assert.AreEqual(FollowerStatus.None, userProfile6.FollowerStatus); Assert.AreEqual(FollowingStatus.None, userProfile6.FollowingStatus); Assert.AreEqual(Visibility.Public, userProfile6.Visibility); }