cloutier--bird.makeup/src/Tests/BirdsiteLive.Twitter.Tests/TweetTests.cs

51 lines
2.4 KiB
C#
Raw Normal View History

using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.Extensions.Logging;
using System.Threading.Tasks;
using BirdsiteLive.Twitter;
using BirdsiteLive.Twitter.Tools;
using BirdsiteLive.Statistics.Domain;
using Moq;
namespace BirdsiteLive.ActivityPub.Tests
{
[TestClass]
public class TweetTests
{
private ITwitterTweetsService _tweetService;
[TestInitialize]
public async Task TestInit()
{
var logger1 = new Mock<ILogger<TwitterAuthenticationInitializer>>(MockBehavior.Strict);
var logger2 = new Mock<ILogger<TwitterUserService>>(MockBehavior.Strict);
var logger3 = new Mock<ILogger<TwitterTweetsService>>(MockBehavior.Strict);
var stats = new Mock<ITwitterStatisticsHandler>();
ITwitterAuthenticationInitializer auth = new TwitterAuthenticationInitializer(logger1.Object);
ITwitterUserService user = new TwitterUserService(auth, stats.Object, logger2.Object);
_tweetService = new TwitterTweetsService(auth, stats.Object, user, logger3.Object);
}
[TestMethod]
public async Task SimpleTextTweet()
{
var tweet = await _tweetService.GetTweetAsync(1600905296892891149);
Assert.AreEqual(tweet.MessageContent, "Were strengthening American manufacturing by creating 750,000 manufacturing jobs since I became president.");
}
[TestMethod]
public async Task SimpleTextAndSinglePictureTweet()
{
var tweet = await _tweetService.GetTweetAsync(1593344577385160704);
Assert.AreEqual(tweet.MessageContent, "Speaker Nancy Pelosi will go down as one of most accomplished legislators in American history—breaking barriers, opening doors for others, and working every day to serve the American people. I couldnt be more grateful for her friendship and leadership.");
2022-12-16 10:23:48 -05:00
// TODO validate media type and length
// TODO test alt-text of images
}
2022-12-16 10:23:48 -05:00
[TestMethod]
public async Task SimpleTextAndSingleLinkTweet()
{
var tweet = await _tweetService.GetTweetAsync(1602618920996945922);
Assert.AreEqual(tweet.MessageContent, "#Linux 6.2 Expands Support For More #Qualcomm #Snapdragon SoCs, #Apple M1 Pro/Ultra/Max\n\nhttps://www.phoronix.com/news/Linux-6.2-Arm-SoC-Updates");
}
}
}