public void QueryFBTests() { ConnectorTask taskInfo = new ConnectorTask() { StartTime = DateTime.Parse("2018-01-01"), EndTime = DateTime.Parse("2018-09-17"), DirtyEntities = new List <string> { "123", "456" }, }; SourceInfoFB sourceInfo = new SourceInfoFB() { PageId = "123" }; string expectedFeedUrl = "https://graph.facebook.com:443/v3.0/123/feed?fields=id,created_time,from{name,id,picture},to,message,story,likes.summary(true),reactions.summary(true),comments{from{name,id,picture},id,created_time,message,parent{id},comment_count,like_count,attachment,message_tags,comments{from{name,id,picture},id,created_time,message,parent{id},comment_count,like_count,attachment,message_tags}},attachments,source,message_tags,type,status_type&since=2018-01-01T00:00:00&until=2018-09-17T00:00:00"; string actualFeedUrl = QueryFB.GetFeedUrl(taskInfo, sourceInfo); Assert.AreEqual(expectedFeedUrl, actualFeedUrl); string expectedUpdatePostsUrl = "https://graph.facebook.com:443/v3.0/?ids=123,456&fields=id,created_time,from{name,id,picture},to,message,story,likes.summary(true),reactions.summary(true),comments{from{name,id,picture},id,created_time,message,parent{id},comment_count,like_count,attachment,message_tags,comments{from{name,id,picture},id,created_time,message,parent{id},comment_count,like_count,attachment,message_tags}},attachments,source,message_tags,type,status_type"; string actualUpdatePostsUrl = QueryFB.GetUpdatedPostsUrl(taskInfo); Assert.AreEqual(expectedUpdatePostsUrl, actualUpdatePostsUrl); string expectedVideoSourceUrl = "https://graph.facebook.com:443/v3.0/123?fields=source"; string actualVideoSourceUrl = QueryFB.GetVideoUrl("123"); Assert.AreEqual(expectedVideoSourceUrl, actualVideoSourceUrl); }
public async Task GetResourceInfoTest() { var response = new PageFB() { Id = "id", Name = "name", AccessToken = "accessToken" }; var restApiRepositoryMock = new Mock <IRestApiRepository>(); restApiRepositoryMock.Setup(x => x.GetRequestAsync <PageFB>(It.IsAny <string>(), null, It.IsAny <Dictionary <string, string> >(), It.IsAny <CancellationToken>())) .ReturnsAsync(response); var facebookProvider = new FacebookProvider(new AzureTableProvider(Settings.StorageAccountConnectionString)) { Client = restApiRepositoryMock.Object }; var sourceInfo = await facebookProvider.GetResourceInfo(string.Empty, string.Empty); SourceInfoFB info = JsonConvert.DeserializeObject <SourceInfoFB>(sourceInfo); Assert.AreEqual(info.PageId, "id"); Assert.AreEqual(info.PageName, "name"); Assert.AreEqual(info.AccessToken, "accessToken"); }