public async Task DestroyFriendshipAsync_WithValidScreenName_Succeeds()
        {
            const string ScreenName   = "JoeMayo";
            string       expectedName = "Joe Mayo";

            InitializeTwitterContext <User>(SingleUserResponse);

            User actual = await ctx.DestroyFriendshipAsync(ScreenName);

            Assert.AreEqual(expectedName, actual.Name);
        }
예제 #2
0
        static async Task DestroyFriendshipAsync(TwitterContext twitterCtx)
        {
            var user = await twitterCtx.DestroyFriendshipAsync("Linq2Twitr");

            if (user != null && user.Status != null)
            {
                Console.WriteLine(
                    "User Name: {0}, Status: {1}",
                    user.Name,
                    user.Status.Text);
            }
        }
예제 #3
0
        public void ClearFollowings()
        {
            if (DateTime.Now.DayOfWeek == DayOfWeek.Sunday)
            {
                try
                {
                    var followers  = GetFriendship(FriendshipType.FollowerIDs);
                    var followings = GetFriendship(FriendshipType.FriendIDs);
                    var count      = 0;

                    foreach (var id in followings)
                    {
                        if (!followers.Contains(id))
                        {
//                            Limiter(DestroyFriendshipLimitName);
                            var user = _twitterCtx.DestroyFriendshipAsync(id).Result;
                            if (user?.Status != null)
                            {
                                _logs.WriteBlackList(id);
                                count++;
#if DEBUG
                                Console.WriteLine(count);
#endif
                            }
                            else
                            {
                                _logs.WriteLog($"An error during unfollowing. Returned user is null.");
                            }
                        }
                    }

                    _logs.WriteLog($"Unfollowed {count} users");
                }
                catch (Exception e)
                {
                    _logs.WriteLog($"ClearFollowings Failed. Exception was thrown.");
                    _logs.WriteErrorLog(e);
                }
            }
        }