public void ExecuteNoHandle() { var profile = new UserPublicProfile() { TwitterHandle = StringHelper.NullEmptyWhiteSpace(), }; var profiles = new List <UserPublicProfile>(); profiles.Add(profile); var tweets = new Status[] { new Status(), new Status() }.AsQueryable(); var container = new Mock <ITextContainer <CodeStormSocial> >(MockBehavior.Strict); var userCore = new Mock <IUserCore>(MockBehavior.Strict); var twitter = new Mock <ITwitterSource>(MockBehavior.Strict); userCore.Setup(r => r.PublicProfilesFull(It.IsAny <Application>(), true)).Returns(profiles); container.Setup(r => r.Save(It.IsAny <string>(), It.IsAny <CodeStormSocial>())); twitter.Setup(t => t.ByUser(profile.TwitterHandle, 5)).Returns(tweets); var item = new TwitterHarvestor(userCore.Object, container.Object, twitter.Object); item.Execute(); userCore.Verify(r => r.PublicProfilesFull(It.IsAny <Application>(), true), Times.Once()); container.Verify(r => r.Save(It.IsAny <string>(), It.IsAny <CodeStormSocial>()), Times.Once()); twitter.Verify(t => t.ByUser(profile.TwitterHandle, 5), Times.Never()); }
public void ExecuteByUserThrows() { var profile = new UserPublicProfile() { TwitterHandle = "DudeYa", }; var profiles = new List <UserPublicProfile>(); profiles.Add(profile); var container = new Mock <ITextContainer <CodeStormSocial> >(MockBehavior.Strict); var userCore = new Mock <IUserCore>(MockBehavior.Strict); var twitter = new Mock <ITwitterSource>(MockBehavior.Strict); userCore.Setup(r => r.PublicProfilesFull(It.IsAny <Application>(), true)).Returns(profiles); container.Setup(r => r.Save(It.IsAny <string>(), It.IsAny <CodeStormSocial>())); twitter.Setup(t => t.ByUser(profile.TwitterHandle, 5)).Throws <Exception>(); var item = new TwitterHarvestor(userCore.Object, container.Object, twitter.Object); item.Execute(); userCore.Verify(r => r.PublicProfilesFull(It.IsAny <Application>(), true), Times.Once()); container.Verify(r => r.Save(It.IsAny <string>(), It.IsAny <CodeStormSocial>()), Times.Once()); twitter.Verify(t => t.ByUser(profile.TwitterHandle, 5), Times.Once()); }