Ejemplo n.º 1
0
        public async Task TestRevokedOAuth()
        {
            var config = new FacebookDataConfig
            {
                UserId = "8195378771",
            };

            var dataProvider = new FacebookDataProvider(OAuthKeys.FacebookRevokedKeys);

            await ExceptionsAssert.ThrowsAsync<OAuthKeysRevokedException>(async () => await dataProvider.LoadDataAsync(config));
        }
Ejemplo n.º 2
0
        public async Task TestNullUserId()
        {
            var config = new FacebookDataConfig
            {
                UserId = null,
            };

            var dataProvider = new FacebookDataProvider(OAuthKeys.FacebookValidKeys);

            ConfigParameterNullException exception = await ExceptionsAssert.ThrowsAsync<ConfigParameterNullException>(async () => await dataProvider.LoadDataAsync(config));
            Assert.IsTrue(exception.Message.Contains("UserId"));
        }
Ejemplo n.º 3
0
        public async Task TestEmptyOAuth()
        {
            var config = new FacebookDataConfig
            {
                UserId = "8195378771",
            };

            var dataProvider = new FacebookDataProvider(new FacebookOAuthTokens());

            OAuthKeysNotPresentException exception = await ExceptionsAssert.ThrowsAsync<OAuthKeysNotPresentException>(async () => await dataProvider.LoadDataAsync(config));
            Assert.IsTrue(exception.Message.Contains("AppId"));
        }
Ejemplo n.º 4
0
        public async Task LoadFacebook()
        {
            var config = new FacebookDataConfig
            {
                UserId = "8195378771",
            };
            var dataProvider = new FacebookDataProvider(OAuthKeys.FacebookValidKeys);
            IEnumerable<FacebookSchema> result = await dataProvider.LoadDataAsync(config);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Any());
        }
Ejemplo n.º 5
0
        public async Task TestInvalidOAuth()
        {
            var config = new FacebookDataConfig
            {
                UserId = "8195378771",
            };

            var tokens = new FacebookOAuthTokens
            {
                AppId = "INVALID",
                AppSecret = "INVALID"
            };

            var dataProvider = new FacebookDataProvider(tokens);

            await ExceptionsAssert.ThrowsAsync<OAuthKeysRevokedException>(async () => await dataProvider.LoadDataAsync(config));
        }
Ejemplo n.º 6
0
        public async void GetItems()
        {
            string appId = "YourAppId";   
            string appSecret = "YourAppSecret";
            string FacebookQueryParam = "8195378771";
            int MaxRecordsParam = 20;

            Items.Clear();

            _facebookDataProvider = new FacebookDataProvider(new FacebookOAuthTokens { AppId = appId, AppSecret = appSecret });
            var config = new FacebookDataConfig
            {
                UserId = FacebookQueryParam
            };          

            var items = await _facebookDataProvider.LoadDataAsync(config, MaxRecordsParam);         

            foreach (var item in items)
            {
                Items.Add(item);
            }
        }
Ejemplo n.º 7
0
        public async Task TestNullOAuth()
        {
            var config = new FacebookDataConfig
            {
                UserId = "8195378771",
            };

            var dataProvider = new FacebookDataProvider(null);

            await ExceptionsAssert.ThrowsAsync<ConfigParameterNullException>(async () => await dataProvider.LoadDataAsync(config));
        }
Ejemplo n.º 8
0
 public async Task LoadMoreDataInvalidOperationFacebook()
 {
     var config = new FacebookDataConfig
     {
         UserId = "8195378771",
     };
     var dataProvider = new FacebookDataProvider(OAuthKeys.FacebookValidKeys);
     InvalidOperationException exception = await ExceptionsAssert.ThrowsAsync<InvalidOperationException>(async () => await dataProvider.LoadMoreDataAsync());
 }
Ejemplo n.º 9
0
        public async Task TestMaxRecords()
        {
            int maxRecords = 70;
            var config = new FacebookDataConfig
            {
                UserId = "150135720497",
            };
            var dataProvider = new FacebookDataProvider(OAuthKeys.FacebookValidKeys);
            IEnumerable<FacebookSchema> result = await dataProvider.LoadDataAsync(config, maxRecords);

            Assert.IsTrue(result.Count() > 25);
        }
Ejemplo n.º 10
0
        public async Task TestMaxRecords_Min()
        {
            int maxRecords = 1;
            var config = new FacebookDataConfig
            {
                UserId = "8195378771",
            };
            var dataProvider = new FacebookDataProvider(OAuthKeys.FacebookValidKeys);
            IEnumerable<FacebookSchema> result = await dataProvider.LoadDataAsync(config, maxRecords);

            Assert.AreEqual(maxRecords, result.Count());
        }
Ejemplo n.º 11
0
        private async void Request()
        {
            try
            {
                IsBusy = true;
                HasErrors = false;
                NoItems = false;
                DataProviderRawData = string.Empty;
                Items.Clear();
               
                var config = new FacebookDataConfig
                {
                    UserId = FacebookQueryParam
                };

                var items = await facebookDataProvider.LoadDataAsync(config, MaxRecordsParam);

                NoItems = !items.Any();

                foreach (var item in items)
                {
                    Items.Add(item);
                }

                var rawParser = new RawParser();
                var rawData = await rawDataProvider.LoadDataAsync(config, MaxRecordsParam, rawParser);
                DataProviderRawData = rawData.FirstOrDefault()?.Raw;
            }
            catch (Exception ex)
            {
                DataProviderRawData += ex.Message;
                DataProviderRawData += ex.StackTrace;
                HasErrors = true;
            }
            finally
            {
                IsBusy = false;
            }
        }