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; } }
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); } }
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 override async Task <IEnumerable <TwitterSchema> > GetDataAsync(SchemaBase connectedItem = null) { var config = new TwitterDataConfig { QueryType = TwitterQueryType.Search, Query = @"#rodin" }; return(await _dataProvider.LoadDataAsync(config, MaxRecords)); }
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 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 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 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"); }
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 TestNullParser() { TwitterDataProvider dataProvider = new TwitterDataProvider(new TwitterOAuthTokens()); await ExceptionsAssert.ThrowsAsync<ParserNullException>(async () => await dataProvider.LoadDataAsync<TwitterSchema>(new TwitterDataConfig(), 20, null)); }
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 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 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 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 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 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 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 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 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 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 TestNullOAuth() { var config = new TwitterDataConfig { QueryType = TwitterQueryType.User, Query = "lumia" }; var dataProvider = new TwitterDataProvider(null); await ExceptionsAssert.ThrowsAsync<ConfigParameterNullException>(async () => await dataProvider.LoadDataAsync(config)); }