public string FindTwitterProfiles(string searchText) { try { //Process authorization if (!ProcessAuthorization(HttpContext.Current)) { AccessDenied(HttpContext.Current); return(null); } TwitterDataProvider provider = new TwitterDataProvider(TwitterApiHelper.GetTwitterApiInfoForCurrentUser()); List <TwitterUserInfo> users = provider.FindUsers(searchText); /*List<TwitterUserInfo> users = new List<TwitterUserInfo>(); * users.Add(new TwitterUserInfo { Description = "I'm a cool user", SmallImageUrl = "http://localhost/TeamLab/products/crm/data/0/photos/00/00/10/contact_10_50_50.jpg", UserName = "******", ScreenName = "user", UserID = 1 }); * users.Add(new TwitterUserInfo { Description = "I'm a cool user", SmallImageUrl = "http://localhost/TeamLab/products/crm/data/0/photos/00/00/10/contact_10_50_50.jpg", UserName = "******", ScreenName = "user", UserID = 1 }); * users.Add(new TwitterUserInfo { Description = "I'm a cool user", SmallImageUrl = "http://localhost/TeamLab/products/crm/data/0/photos/00/00/10/contact_10_50_50.jpg", UserName = "******", ScreenName = "user", UserID = 1 });*/ string result = JsonConvert.SerializeObject(users); return(result); } catch (Exception ex) { throw ProcessError(ex, "FindTwitterProfiles"); } }
private List <Message> GetUserActivity() { if (SelectedSocialNetworks == null) { return(null); } List <Message> messages = new List <Message>(); if (SelectedSocialNetworks.Contains(SocialNetworks.Twitter)) { TwitterDataProvider twitterProvider = new TwitterDataProvider(TwitterInformation.ApiInfo); foreach (UserAccountInfo accountInfo in TwitterInformation.UserAccounts) { try { messages.AddRange(twitterProvider.GetUserTweets(accountInfo.UserID, accountInfo.ScreenName, MessageCount)); } catch (ResourceNotFoundException) { _ctrlErrorDescription.InnerText += String.Format("{0}: {1}", SocialMediaResource.ErrorUnknownTwitterAccount, accountInfo.ScreenName); _ctrlErrorDescriptionContainer.Style.Add(System.Web.UI.HtmlTextWriterStyle.Display, "block"); this.InvalidTwitterAccountExist = true; } } } return(messages.OrderByDescending(m => m.PostedOn).Take(MessageCount).ToList()); }
public void MultiThreadTest() { var ai = new TwitterApiInfo { ConsumerKey = "hYd5c8gYxhy3T2Nvj8wLA", ConsumerSecret = "KZGPvAN6kgioWlf0zrGYOzKevLatexuuuJlIhJQg" }; var provider = new TwitterDataProvider(ai); var messages = provider.GetUserTweets(40648902, null, 10); //List<Message> messages = provider.GetUserHomeTimeLine(10); Action dlgFirstThread = StartFirstThread; Action dlgSecondThread = StartSecondThread; var arFirstThread = dlgFirstThread.BeginInvoke(null, null); var arSecondThread = dlgSecondThread.BeginInvoke(null, null); var waitHandles = new WaitHandle[] { arFirstThread.AsyncWaitHandle, arSecondThread.AsyncWaitHandle }; //WaitHandle[] waitHandles = new WaitHandle[] { arFirstThread.AsyncWaitHandle }; WaitHandle.WaitAll(waitHandles); Console.WriteLine("Operation complete. Press any key to close window..."); Console.ReadLine(); }
private List <SocialMediaImageDescription> GetTwitterImageDescriptionList(List <String> twitterAccounts, Tenant tenant) { var images = new List <SocialMediaImageDescription>(); if (twitterAccounts.Count == 0) { return(images); } try { CoreContext.TenantManager.SetCurrentTenant(tenant); var provider = new TwitterDataProvider(TwitterApiHelper.GetTwitterApiInfoForCurrentUser()); twitterAccounts = twitterAccounts.Distinct().ToList(); images.AddRange(from twitterAccount in twitterAccounts let imageUrl = provider.GetUrlOfUserImage(twitterAccount, TwitterDataProvider.ImageSize.Small) where imageUrl != null select new SocialMediaImageDescription { Identity = twitterAccount, ImageUrl = imageUrl, SocialNetwork = SocialNetworks.Twitter }); } catch (Exception ex) { _logger.Error(ex); } return(images); }
public async void GetItems() { string consumerKey = "YourConsumerKey"; string consumerSecret = "YourConsumerSecret"; string accessToken = "YourAccessToken"; string accessTokenSecret = "YourAccessTokenSecret"; string twitterQueryParam = "WindowsAppStudio"; TwitterQueryType queryType = TwitterQueryType.Search; int maxRecordsParam = 20; Items.Clear(); _twitterDataProvider = new TwitterDataProvider(new TwitterOAuthTokens { AccessToken = accessToken, AccessTokenSecret = accessTokenSecret, ConsumerKey = consumerKey, ConsumerSecret = consumerSecret }); var config = new TwitterDataConfig { Query = twitterQueryParam, QueryType = queryType }; var items = await _twitterDataProvider.LoadDataAsync(config, maxRecordsParam); foreach (var item in items) { Items.Add(item); } }
public async void GetItems() { string consumerKey = "YourConsumerKey"; string consumerSecret = "YourConsumerSecret"; string accessToken = "YourAccessToken"; string accessTokenSecret = "YourAccessTokenSecret"; string twitterQueryParam = "WindowsAppStudio"; TwitterQueryType queryType = TwitterQueryType.Search; int maxRecordsParam = 20; Items.Clear(); var twitterDataProvider = new TwitterDataProvider(new TwitterOAuthTokens { AccessToken = accessToken, AccessTokenSecret = accessTokenSecret, ConsumerKey = consumerKey, ConsumerSecret = consumerSecret }); var config = new TwitterDataConfig { Query = twitterQueryParam, QueryType = queryType }; var items = await twitterDataProvider.LoadDataAsync(config, maxRecordsParam); foreach (var item in items) { Items.Add(item); } }
private List <SocialMediaImageDescription> GetTwitterImageDescriptionList(Contact contact, Tenant tenant) { CoreContext.TenantManager.SetCurrentTenant(tenant); var images = new List <SocialMediaImageDescription>(); var twitterAccounts = Global.DaoFactory.GetContactInfoDao().GetListData(contact.ID, ContactInfoType.Twitter); if (twitterAccounts.Count == 0) { return(images); } var provider = new TwitterDataProvider(TwitterApiHelper.GetTwitterApiInfoForCurrentUser()); images.AddRange(from twitterAccount in twitterAccounts let imageUrl = provider.GetUrlOfUserImage(twitterAccount, TwitterDataProvider.ImageSize.Small) where imageUrl != null select new SocialMediaImageDescription { Identity = twitterAccount, ImageUrl = imageUrl, SocialNetwork = SocialNetworks.Twitter }); return(images); }
public async void GetItems() { string consumerKey = "5zcs3Bp2kTlrsDUsMDv5BYfND"; string consumerSecret = "oZDbzyY6xmPJVskIUx0pyA4VlB6XdMQHPb4sjHDxUshgCStxzf"; string accessToken = " 248216142-jMUS9hvL97gu8fwCpkD7XqkyDBfJypvvogNybchv"; string accessTokenSecret = "coDm0ePUoWIXlIH5v46jDJFUYANVG4SvGADrUL5Kf8aSQ"; string twitterQueryParam = "WindowsAppStudio"; TwitterQueryType queryType = TwitterQueryType.Search; int maxRecordsParam = 12; Items.Clear(); _twitterDataProvider = new TwitterDataProvider(new TwitterOAuthTokens { AccessToken = accessToken, AccessTokenSecret = accessTokenSecret, ConsumerKey = consumerKey, ConsumerSecret = consumerSecret }); var config = new TwitterDataConfig { Query = twitterQueryParam, QueryType = queryType }; var items = await _twitterDataProvider.LoadDataAsync(config, maxRecordsParam); foreach (var item in items) { Items.Add(item); } }
public async Task LoadMoreDataInvalidOperationTwitterHomeTimeLine() { var config = new TwitterDataConfig { QueryType = TwitterQueryType.Home }; var dataProvider = new TwitterDataProvider(OAuthKeys.TwitterValidKeys); InvalidOperationException exception = await ExceptionsAssert.ThrowsAsync <InvalidOperationException>(async() => await dataProvider.LoadMoreDataAsync()); }
public TwitterSection() { _dataProvider = new TwitterDataProvider(new TwitterOAuthTokens { ConsumerKey = "xxxx", //use your own key go to https://apps.twitter.com/ beginners learn more here https://appstudio.windows.com/fr-fr/home/howto#twitter // ConsumerSecret = "xxxx", //use your own key go to https://apps.twitter.com/ beginners learn more here https://appstudio.windows.com/fr-fr/home/howto#twitter // AccessToken = "xxxx", //use your own key go to https://apps.twitter.com/ beginners learn more here https://appstudio.windows.com/fr-fr/home/howto#twitter // AccessTokenSecret = "xxxx" //use your own key go to https://apps.twitter.com/ beginners learn more here https://appstudio.windows.com/fr-fr/home/howto#twitter // }); }
public TwitterSection() { _dataProvider = new TwitterDataProvider(new TwitterOAuthTokens { ConsumerKey = "AY0htcsmuiSNUzXZVahoX2s5a", ConsumerSecret = "tqIXQ94yIPSYrFovyF8HZASqNNVbg7NxoqX0KFinHSN5bxn5hJ", AccessToken = "2456546750-ephWGDu1WI5Ig8TPn6q5HAdNnCkkqv0oCBsdWd6", AccessTokenSecret = "p8OF0ldLIX7ZZXMhx1ZaBXyVT9sUkQ2BQ6Qol56GufWu2" }); }
public async Task TestNullOAuth() { var config = new TwitterDataConfig { QueryType = TwitterQueryType.User, Query = "lumia" }; var dataProvider = new TwitterDataProvider(null); await ExceptionsAssert.ThrowsAsync <ConfigParameterNullException>(async() => await dataProvider.LoadDataAsync(config)); }
public async Task TestHomeTimeLine() { var config = new TwitterDataConfig { QueryType = TwitterQueryType.Home }; var dataProvider = new TwitterDataProvider(OAuthKeys.TwitterValidKeys); IEnumerable<TwitterSchema> result = await dataProvider.LoadDataAsync(config); Assert.IsNotNull(result); Assert.IsTrue(result.Any()); }
public async Task TestHomeTimeLine() { var config = new TwitterDataConfig { QueryType = TwitterQueryType.Home }; var dataProvider = new TwitterDataProvider(OAuthKeys.TwitterValidKeys); IEnumerable <TwitterSchema> result = await dataProvider.LoadDataAsync(config); Assert.IsNotNull(result); Assert.IsTrue(result.Any()); }
public async Task TestMaxRecordsHomeTimeLine() { int maxRecords = 70; var config = new TwitterDataConfig { QueryType = TwitterQueryType.Home }; var dataProvider = new TwitterDataProvider(OAuthKeys.TwitterValidKeys); IEnumerable <TwitterSchema> result = await dataProvider.LoadDataAsync(config, maxRecords); Assert.IsTrue(result.Count() > 15, $"There are {result.Count()} elements"); }
public async Task TestRevokedOAuth() { var config = new TwitterDataConfig { QueryType = TwitterQueryType.User, Query = "lumia" }; var dataProvider = new TwitterDataProvider(OAuthKeys.TwitterRevokedKeys); await ExceptionsAssert.ThrowsAsync <OAuthKeysRevokedException>(async() => await dataProvider.LoadDataAsync(config)); }
public async Task TestRevokedOAuth() { var config = new TwitterDataConfig { QueryType = TwitterQueryType.User, Query = "lumia" }; var dataProvider = new TwitterDataProvider(OAuthKeys.TwitterRevokedKeys); await ExceptionsAssert.ThrowsAsync<OAuthKeysRevokedException>(async () => await dataProvider.LoadDataAsync(config)); }
public async Task TestNullQuery() { var config = new TwitterDataConfig { QueryType = TwitterQueryType.User }; var dataProvider = new TwitterDataProvider(new TwitterOAuthTokens()); ConfigParameterNullException exception = await ExceptionsAssert.ThrowsAsync <ConfigParameterNullException>(async() => await dataProvider.LoadDataAsync(config)); Assert.IsTrue(exception.Message.Contains("Query")); }
public async Task TestMaxRecordsSearch_Min() { int maxRecords = 1; var config = new TwitterDataConfig { QueryType = TwitterQueryType.Search, Query = "microsoft" }; var dataProvider = new TwitterDataProvider(OAuthKeys.TwitterValidKeys); IEnumerable <TwitterSchema> result = await dataProvider.LoadDataAsync(config, maxRecords); Assert.IsTrue(result.Count() <= maxRecords); }
public async Task TestEmptyOAuth() { var config = new TwitterDataConfig { QueryType = TwitterQueryType.User, Query = "lumia" }; var dataProvider = new TwitterDataProvider(new TwitterOAuthTokens()); OAuthKeysNotPresentException exception = await ExceptionsAssert.ThrowsAsync <OAuthKeysNotPresentException>(async() => await dataProvider.LoadDataAsync(config)); Assert.IsTrue(exception.Message.Contains("ConsumerKey")); }
private async void Request() { try { IsBusy = true; HasErrors = false; NoItems = false; DataProviderRawData = string.Empty; Items.Clear(); var twitterDataProvider = new TwitterDataProvider(new TwitterOAuthTokens { AccessToken = AccessToken, AccessTokenSecret = AccessTokenSecret, ConsumerKey = ConsumerKey, ConsumerSecret = ConsumerSecret }); var config = new TwitterDataConfig { Query = TwitterQueryParam, QueryType = TwitterQueryTypeSelectedItem }; var rawParser = new RawParser(); var rawData = await twitterDataProvider.LoadDataAsync(config, MaxRecordsParam, rawParser); DataProviderRawData = rawData.FirstOrDefault()?.Raw; var items = await twitterDataProvider.LoadDataAsync(config, MaxRecordsParam); NoItems = !items.Any(); foreach (var item in items) { Items.Add(item); } } catch (Exception ex) { DataProviderRawData += ex.Message; DataProviderRawData += ex.StackTrace; HasErrors = true; } finally { IsBusy = false; } }
private List <Message> GetUserWallTwitter() { List <Message> messageList = new List <Message>(); try { TwitterDataProvider twitterProvider = new TwitterDataProvider(TwitterInformation.ApiInfo); messageList.AddRange(twitterProvider.GetUserHomeTimeLine(MessageCount)); } catch (Exception ex) { ThrownExceptions.Add(ex); } return(messageList); }
public async Task TestMaxRecordsUserTimeLine() { int maxRecords = 70; var config = new TwitterDataConfig { QueryType = TwitterQueryType.User, Query = "lumia" }; var dataProvider = new TwitterDataProvider(OAuthKeys.TwitterValidKeys); IEnumerable <TwitterSchema> result = await dataProvider.LoadDataAsync(config, maxRecords); Assert.AreEqual(maxRecords, result.Count()); Assert.IsTrue(result.Count() > 25); }
public async Task LoadPaginationTwitterHomeTimeLine() { var config = new TwitterDataConfig { QueryType = TwitterQueryType.Home }; var dataProvider = new TwitterDataProvider(OAuthKeys.TwitterValidKeys); await dataProvider.LoadDataAsync(config, 2); Assert.IsTrue(dataProvider.HasMoreItems); IEnumerable <TwitterSchema> result = await dataProvider.LoadMoreDataAsync(); Assert.IsNotNull(result); Assert.IsTrue(result.Any()); }
public async Task LoadPaginationTwitterSearch() { var config = new TwitterDataConfig { QueryType = TwitterQueryType.Search, Query = "microsoft" }; var dataProvider = new TwitterDataProvider(OAuthKeys.TwitterValidKeys); await dataProvider.LoadDataAsync(config, 2); Assert.IsTrue(dataProvider.HasMoreItems, "HasMoreItems is false"); IEnumerable <TwitterSchema> result = await dataProvider.LoadMoreDataAsync(); Assert.IsNotNull(result); Assert.IsTrue(result.Any(), "There aren't any elements"); }
private void InitializeDataProvider() { twitterDataProvider = new TwitterDataProvider(new TwitterOAuthTokens { AccessToken = AccessToken, AccessTokenSecret = AccessTokenSecret, ConsumerKey = ConsumerKey, ConsumerSecret = ConsumerSecret }); rawDataProvider = new TwitterDataProvider(new TwitterOAuthTokens { AccessToken = AccessToken, AccessTokenSecret = AccessTokenSecret, ConsumerKey = ConsumerKey, ConsumerSecret = ConsumerSecret }); }
public string ShowTwitterUserRelationWindow(string userID) { try { //Process authorization if (!ProcessAuthorization(HttpContext.Current)) { AccessDenied(HttpContext.Current); return(null); } TwitterDataProvider provider = new TwitterDataProvider(TwitterApiHelper.GetTwitterApiInfoForCurrentUser()); TwitterUserInfo user = provider.LoadUserInfo(Convert.ToDecimal(userID)); return(GetTwitterUserInfoPage(user)); } catch (Exception ex) { throw ProcessError(ex, "ShowTwitterUserRelationWindow"); } }
public async Task TestInvalidOAuth() { var config = new TwitterDataConfig { QueryType = TwitterQueryType.User, Query = "lumia" }; var tokens = new TwitterOAuthTokens { ConsumerKey = "INVALID", ConsumerSecret = "INVALID", AccessToken = "INVALID", AccessTokenSecret = "INVALID" }; var dataProvider = new TwitterDataProvider(tokens); await ExceptionsAssert.ThrowsAsync <OAuthKeysRevokedException>(async() => await dataProvider.LoadDataAsync(config)); }
private void StartFirstThread() { var apiInfo = new TwitterApiInfo { AccessToken = "313315355-DT9HzoZKyLC4WbfKblVh5KAMyE0IGvtx5XFDtUx5", AccessTokenSecret = "7BhEPtC9RaQK0VIHmrugaimXXoOYjxxVhZGpcxw1w", ConsumerKey = "hYd5c8gYxhy3T2Nvj8wLA", ConsumerSecret = "KZGPvAN6kgioWlf0zrGYOzKevLatexuuuJlIhJQg" }; var provider = new TwitterDataProvider(apiInfo); try { var result = provider.GetUrlOfUserImage("kamorin_roman", TwitterDataProvider.ImageSize.Small); var messages = provider.GetUserHomeTimeLine(10); } catch (Exception) { } Console.WriteLine("First thread complete"); }
public string FindUsers(string searchText, string socialNetwork) { try { //Process authorization if (!ProcessAuthorization(HttpContext.Current)) { AccessDenied(HttpContext.Current); return(null); } if (socialNetwork.ToLower() == "twitter") { TwitterDataProvider provider = new TwitterDataProvider(TwitterApiHelper.GetTwitterApiInfoForCurrentUser()); List <TwitterUserInfo> users = provider.FindUsers(searchText); return(GetTwitterUserListPage(users)); } if (socialNetwork.ToLower() == "facebook") { FacebookApiInfo apiInfo = FacebookApiHelper.GetFacebookApiInfoForCurrentUser(); if (apiInfo == null) { throw new SocialMediaAccountNotFound(SocialMediaResource.SocialMediaAccountNotFoundFacebook); } FacebookDataProvider facebookProvider = new FacebookDataProvider(apiInfo); List <FacebookUserInfo> users = facebookProvider.FindUsers(searchText); return(GetFacebookUserListPage(users)); } return(null); } catch (Exception ex) { throw ProcessError(ex, "FindUsers"); } }
static private void StartSecondThread() { var errorsCount = 0; var apiInfo = new TwitterApiInfo { AccessToken = "333874355-YBK9kp8Qc0mtRuYp9org5XegCX3DZKwycJdZZd8l", AccessTokenSecret = "q0qjlrXlehPag6mNqamvMhoLtb6z2bPUPDRh27HKN7Y", ConsumerKey = "hYd5c8gYxhy3T2Nvj8wLA", ConsumerSecret = "KZGPvAN6kgioWlf0zrGYOzKevLatexuuuJlIhJQg" }; var provider = new TwitterDataProvider(apiInfo); for (var i = 0; i < MaxIterations; i++) { Thread.Sleep(100); try { provider.GetUserHomeTimeLine(1); Console.WriteLine("Second thread: Success. Iteration {0} ", i + 1); } catch (Exception) { Console.WriteLine("Second thread: Exception. Iteration {0} ", i + 1); errorsCount++; if (errorsCount == MaxErrorsCount) { Console.WriteLine("Second thread: Exception Max count reached. Breaking. Iteration {0} ", i + 1); break; } } } Console.WriteLine("Second thread complete"); }
public string SaveUserAvatarFromSocialNetwork(int contactID, SocialNetworks socialNetwork, string userIdentity) { try { //Process authorization if (!ProcessAuthorization(HttpContext.Current)) { AccessDenied(HttpContext.Current); return(null); } if (socialNetwork == SocialNetworks.Twitter) { TwitterDataProvider provider = new TwitterDataProvider(TwitterApiHelper.GetTwitterApiInfoForCurrentUser()); string imageUrl = provider.GetUrlOfUserImage(userIdentity, TwitterDataProvider.ImageSize.Original); return(SaveAvatar(contactID, imageUrl)); } if (socialNetwork == SocialNetworks.Facebook) { FacebookDataProvider provider = new FacebookDataProvider(FacebookApiHelper.GetFacebookApiInfoForCurrentUser()); string imageUrl = provider.GetUrlOfUserImage(userIdentity, FacebookDataProvider.ImageSize.Original); return(SaveAvatar(contactID, imageUrl)); } if (socialNetwork == SocialNetworks.LinkedIn) { LinkedInDataProvider provider = LinkedInApiHelper.GetLinkedInDataProviderForCurrentUser(); string imageUrl = provider.GetUrlOfUserImage(userIdentity); return(SaveAvatar(contactID, imageUrl)); } return(null); } catch (Exception ex) { throw ProcessError(ex, "SaveUserAvatarFromSocialNetwork"); } }
public async Task TestEmptyOAuth() { var config = new TwitterDataConfig { QueryType = TwitterQueryType.User, Query = "lumia" }; var dataProvider = new TwitterDataProvider(new TwitterOAuthTokens()); OAuthKeysNotPresentException exception = await ExceptionsAssert.ThrowsAsync<OAuthKeysNotPresentException>(async () => await dataProvider.LoadDataAsync(config)); Assert.IsTrue(exception.Message.Contains("ConsumerKey")); }
public async Task TestNullQuery() { var config = new TwitterDataConfig { QueryType = TwitterQueryType.User }; var dataProvider = new TwitterDataProvider(new TwitterOAuthTokens()); ConfigParameterNullException exception = await ExceptionsAssert.ThrowsAsync<ConfigParameterNullException>(async () => await dataProvider.LoadDataAsync(config)); Assert.IsTrue(exception.Message.Contains("Query")); }
public async Task TestNullConfig() { TwitterDataProvider dataProvider = new TwitterDataProvider(new TwitterOAuthTokens()); await ExceptionsAssert.ThrowsAsync<ConfigNullException>(async () => await dataProvider.LoadDataAsync(null)); }
public async Task TestNullOAuth() { var config = new TwitterDataConfig { QueryType = TwitterQueryType.User, Query = "lumia" }; var dataProvider = new TwitterDataProvider(null); await ExceptionsAssert.ThrowsAsync<ConfigParameterNullException>(async () => await dataProvider.LoadDataAsync(config)); }
public async Task TestMaxRecordsUserTimeLine_Min() { int maxRecords = 1; var config = new TwitterDataConfig { QueryType = TwitterQueryType.User, Query = "lumia" }; var dataProvider = new TwitterDataProvider(OAuthKeys.TwitterValidKeys); IEnumerable<TwitterSchema> result = await dataProvider.LoadDataAsync(config, maxRecords); Assert.IsTrue(result.Count() <= maxRecords); }
public async Task TestNullParser() { TwitterDataProvider dataProvider = new TwitterDataProvider(new TwitterOAuthTokens()); await ExceptionsAssert.ThrowsAsync<ParserNullException>(async () => await dataProvider.LoadDataAsync<TwitterSchema>(new TwitterDataConfig(), 20, null)); }
public async Task TestMaxRecordsSearch() { int maxRecords = 70; var config = new TwitterDataConfig { QueryType = TwitterQueryType.Search, Query = "microsoft" }; var dataProvider = new TwitterDataProvider(OAuthKeys.TwitterValidKeys); IEnumerable<TwitterSchema> result = await dataProvider.LoadDataAsync(config, maxRecords); Assert.IsTrue(result.Count() > 15, $"There are {result.Count()} elements"); }
public async Task TestMaxRecordsUserTimeLine() { int maxRecords = 70; var config = new TwitterDataConfig { QueryType = TwitterQueryType.User, Query = "lumia" }; var dataProvider = new TwitterDataProvider(OAuthKeys.TwitterValidKeys); IEnumerable<TwitterSchema> result = await dataProvider.LoadDataAsync(config, maxRecords); Assert.AreEqual(maxRecords, result.Count()); Assert.IsTrue(result.Count() > 15, $"There are {result.Count()} elements"); }
public async Task LoadPaginationTwitterUserTimeLine() { var config = new TwitterDataConfig { QueryType = TwitterQueryType.User, Query = "lumia" }; var dataProvider = new TwitterDataProvider(OAuthKeys.TwitterValidKeys); await dataProvider.LoadDataAsync(config, 5); Assert.IsTrue(dataProvider.HasMoreItems); IEnumerable<TwitterSchema> result = await dataProvider.LoadMoreDataAsync(); Assert.IsNotNull(result); Assert.IsTrue(result.Any()); }
public async Task LoadMoreDataInvalidOperationTwitterSearch() { var config = new TwitterDataConfig { QueryType = TwitterQueryType.Search, Query = "lumia" }; var dataProvider = new TwitterDataProvider(OAuthKeys.TwitterValidKeys); InvalidOperationException exception = await ExceptionsAssert.ThrowsAsync<InvalidOperationException>(async () => await dataProvider.LoadMoreDataAsync()); }
public async Task TestInvalidOAuth() { var config = new TwitterDataConfig { QueryType = TwitterQueryType.User, Query = "lumia" }; var tokens = new TwitterOAuthTokens { ConsumerKey = "INVALID", ConsumerSecret = "INVALID", AccessToken = "INVALID", AccessTokenSecret = "INVALID" }; var dataProvider = new TwitterDataProvider(tokens); await ExceptionsAssert.ThrowsAsync<OAuthKeysRevokedException>(async () => await dataProvider.LoadDataAsync(config)); }
public async Task TestNullParser() { TwitterDataProvider dataProvider = new TwitterDataProvider(new TwitterOAuthTokens()); await ExceptionsAssert.ThrowsAsync <ParserNullException>(async() => await dataProvider.LoadDataAsync <TwitterSchema>(new TwitterDataConfig(), 20, null)); }