public void CanDelete() { // setup string tweet1 = "Tweet 1"; Status theTweet1 = new Status { Id = tweet1, CreatedAt = DateTime.Today }; string tweet2 = "Tweet 2"; Status theTweet2 = new Status { Id = tweet2, CreatedAt = DateTime.Today.AddDays(-5) }; string tweet3 = "Tweet 3"; Status theTweet3 = new Status { Id = tweet3, CreatedAt = DateTime.Today.AddDays(-10) }; _tweetsManager.All.Add(theTweet1); _tweetsManager.All.Add(theTweet2); _tweetsManager.All.Add(theTweet3); // record Expect.Call(_twitterApiClient.DestroyStatus(tweet2)).Return(new Status { Id = tweet2 }); // playback _mocks.ReplayAll(); _tweetsManager.Delete(theTweet2); // assert Assert.AreEqual(2, _tweetsManager.All.Count); Assert.AreEqual(tweet1, _tweetsManager.All[0].Id); Assert.AreEqual(tweet3, _tweetsManager.All[1].Id); _mocks.VerifyAll(); }
public void CanDeleteAbortOnTwitterApiError() { // setup string tweet1 = "Tweet 1"; Status theTweet1 = new Status { Id = tweet1, CreatedAt = DateTime.Today }; string tweet2 = "Tweet 2"; Status theTweet2 = new Status { Id = tweet2, CreatedAt = DateTime.Today.AddDays(-5) }; string tweet3 = "Tweet 3"; Status theTweet3 = new Status { Id = tweet3, CreatedAt = DateTime.Today.AddDays(-10) }; _tweetsManager.All.Add(theTweet1); _tweetsManager.All.Add(theTweet2); _tweetsManager.All.Add(theTweet3); // record Expect.Call(_twitterApiClient.DestroyStatus(null)).IgnoreArguments().Throw(new Exception()); // playback _mocks.ReplayAll(); _tweetsManager.Delete(theTweet2); // assert Assert.AreEqual(3, _tweetsManager.All.Count); Assert.AreEqual(tweet1, _tweetsManager.All[0].Id); Assert.AreEqual(tweet2, _tweetsManager.All[1].Id); Assert.AreEqual(tweet3, _tweetsManager.All[2].Id); _mocks.VerifyAll(); }
public override void Delete(Status tweet) { throw new NotSupportedException("Cannot delete replies. Replies are from other users. Please use Tweets Manager to delete your own tweets"); }
public void CanThrowExceptionOnDelete() { Status deleteMe = new Status { Id = "111" }; _repliesManager.Delete(deleteMe); }
public static string GetTweetColor(Status tweet) { return GetUserColor(tweet.User); }
public void CanReplyAbortOnTwitterApiError() { // setup string tweet1 = "Tweet 1"; Status theTweet1 = new Status { Id = tweet1, CreatedAt = DateTime.Today }; string tweet2 = "Tweet 2"; Status theTweet2 = new Status { Id = tweet2, CreatedAt = DateTime.Today.AddDays(-5) }; string tweet3 = "Tweet 3"; Status theTweet3 = new Status { Id = tweet3, CreatedAt = DateTime.Today.AddDays(-10) }; _tweetsManager.All.Add(theTweet1); _tweetsManager.All.Add(theTweet2); _tweetsManager.All.Add(theTweet3); // record string reply = "Reply Me"; Expect.Call(_twitterApiClient.UpdateWithSource(reply, theTweet1.Id, TweetsManager.APP_NAME)).Throw(new Exception()); // playback _mocks.ReplayAll(); _tweetsManager.Reply(reply, theTweet1); // assert Assert.AreEqual(3, _tweetsManager.All.Count); Assert.AreEqual(tweet1, _tweetsManager.All[0].Id); Assert.AreEqual(tweet2, _tweetsManager.All[1].Id); Assert.AreEqual(tweet3, _tweetsManager.All[2].Id); _mocks.VerifyAll(); }
public void CanReply() { // setup string tweet1 = "Tweet 1"; Status theTweet1 = new Status { Id = tweet1, CreatedAt = DateTime.Today }; string tweet2 = "Tweet 2"; Status theTweet2 = new Status { Id = tweet2, CreatedAt = DateTime.Today.AddDays(-5) }; string tweet3 = "Tweet 3"; Status theTweet3 = new Status { Id = tweet3, CreatedAt = DateTime.Today.AddDays(-10) }; _tweetsManager.All.Add(theTweet1); _tweetsManager.All.Add(theTweet2); _tweetsManager.All.Add(theTweet3); // record string reply = "Reply 1"; Status replyTweet = new Status { Id = reply, CreatedAt = DateTime.Today.AddDays(1) }; Expect.Call(_twitterApiClient.UpdateWithSource(reply, theTweet3.Id, TweetsManager.APP_NAME)).Return(replyTweet); // playback _mocks.ReplayAll(); _tweetsManager.Reply(reply, theTweet3); // assert Assert.AreEqual(4, _tweetsManager.All.Count); Assert.AreEqual(reply, _tweetsManager.All[0].Id); Assert.AreEqual(tweet1, _tweetsManager.All[1].Id); Assert.AreEqual(tweet2, _tweetsManager.All[2].Id); Assert.AreEqual(tweet3, _tweetsManager.All[3].Id); _mocks.VerifyAll(); }