예제 #1
0
        public void DeleteComment()
        {
            try
            {
                // Get the recent media of the auth user
                var AuthUserMedia = UserManager.GetRecentMedia();
                Assert.IsNotNull(AuthUserMedia);

                // Post a comment to the most recent media
                IMedia recentMedia = AuthUserMedia.First();

                // Comments from this media
                List <IComment> prevComments = CommentsManager.GetCommentsFromMedia(recentMedia.Id);

                Assert.IsNotNull(prevComments);

                // Delete the comment made in the previous test
                CommentsManager.DeleteComment(recentMedia.Id, prevComments.Single(c => c.Text.Contains("Making some tests.")).Id);

                // Get the comements again
                List <IComment> currentComments = CommentsManager.GetCommentsFromMedia(recentMedia.Id);

                // Check that 1 comment has been deleted
                Assert.AreEqual(prevComments.Count() - 1, currentComments.Count());

                // Check if new comment doesn't exist now
                Assert.IsFalse(currentComments.Any(c => c.Text.Contains("Making some tests.")));
            }
            catch (Exceptions.CommentFormatException e)
            {
                Assert.Fail("Incorrect comment error." + e.ToString());
            }
            catch (Exceptions.InstagramAPICallException e)
            {
                Assert.Fail("Instagram API call error." + e.ToString());
            }
        }