Exemple #1
0
        public async void GetItems()
        {
            string             wordPressQuery = "en.blog.wordpress.com";
            WordPressQueryType queryType      = WordPressQueryType.Posts;
            string             queryFilterBy  = string.Empty;
            int maxRecordsParam            = 20;
            WordPressOrderBy orderBy       = WordPressOrderBy.None;
            SortDirection    sortDirection = SortDirection.Ascending;

            _wordPressDataProvider = new WordPressDataProvider();
            this.Items             = new ObservableCollection <object>();

            var config = new WordPressDataConfig()
            {
                Query         = wordPressQuery,
                QueryType     = queryType,
                FilterBy      = queryFilterBy,
                OrderBy       = orderBy,
                SortDirection = sortDirection
            };

            var items = await _wordPressDataProvider.LoadDataAsync(config, maxRecordsParam);

            foreach (var item in items)
            {
                Items.Add(item);
            }
        }
Exemple #2
0
        public override async Task <IEnumerable <WordPressSchema> > GetDataAsync(SchemaBase connectedItem = null)
        {
            var config = new WordPressDataConfig
            {
                QueryType = WordPressQueryType.Posts,
                Query     = @"jamianadwiyyacollageevents.wordpress.com",
                FilterBy  = @"",
            };

            return(await _dataProvider.LoadDataAsync(config, MaxRecords));
        }
        public async Task LoadMoreDataBeforeLoadDataWordPressPost()
        {
            var config = new WordPressDataConfig
            {
                Query     = "en.blog.wordpress.com",
                QueryType = WordPressQueryType.Posts
            };

            var dataProvider = new WordPressDataProvider();
            InvalidOperationException exception = await ExceptionsAssert.ThrowsAsync <InvalidOperationException>(async() => await dataProvider.LoadMoreDataAsync());
        }
        public async Task LoadMoreCommentsPagination_InvalidOperationWordPress()
        {
            var config = new WordPressDataConfig
            {
                Query     = "en.blog.wordpress.com",
                QueryType = WordPressQueryType.Category,
                FilterBy  = "themes"
            };

            var dataProvider = new WordPressDataProvider();
            InvalidOperationException exception = await ExceptionsAssert.ThrowsAsync <InvalidOperationException>(async() => await dataProvider.GetMoreComments());
        }
        public async Task LoadMoreDataInvalidOperationWordPressTag()
        {
            var config = new WordPressDataConfig
            {
                Query     = "en.blog.wordpress.com",
                QueryType = WordPressQueryType.Tag,
                FilterBy  = "apps"
            };

            var dataProvider = new WordPressDataProvider();
            InvalidOperationException exception = await ExceptionsAssert.ThrowsAsync <InvalidOperationException>(async() => await dataProvider.LoadMoreDataAsync());
        }
Exemple #6
0
        public async Task TestNullQueryConfig()
        {
            var config = new WordPressDataConfig
            {
                Query     = null,
                QueryType = WordPressQueryType.Posts
            };

            var dataProvider = new WordPressDataProvider();

            ConfigParameterNullException exception = await ExceptionsAssert.ThrowsAsync <ConfigParameterNullException>(async() => await dataProvider.LoadDataAsync(config));

            Assert.IsTrue(exception.Message.Contains("Query"));
        }
Exemple #7
0
        public async Task LoadWordPressPost()
        {
            var config = new WordPressDataConfig
            {
                Query     = "en.blog.wordpress.com",
                QueryType = WordPressQueryType.Posts
            };

            var dataProvider = new WordPressDataProvider();
            IEnumerable <WordPressSchema> data = await dataProvider.LoadDataAsync(config);

            Assert.IsNotNull(data);
            Assert.AreNotEqual(data.Count(), 0);
        }
        public async Task TestMaxRecordsWordPressPost()
        {
            int maxRecords = 25;
            var config     = new WordPressDataConfig
            {
                Query     = "en.blog.wordpress.com",
                QueryType = WordPressQueryType.Posts
            };

            var dataProvider = new WordPressDataProvider();
            IEnumerable <WordPressSchema> data = await dataProvider.LoadDataAsync(config, maxRecords);

            Assert.IsTrue(data.Count() > 20);
        }
        public async Task TestMaxRecordsWordPressCategory_Min()
        {
            int maxRecords = 1;
            var config     = new WordPressDataConfig
            {
                Query     = "en.blog.wordpress.com",
                QueryType = WordPressQueryType.Category,
                FilterBy  = "themes"
            };

            var dataProvider = new WordPressDataProvider();
            IEnumerable <WordPressSchema> data = await dataProvider.LoadDataAsync(config, maxRecords);

            Assert.AreEqual(maxRecords, data.Count());
        }
        public async Task LoadWordPressCategory_Sorting()
        {
            var config = new WordPressDataConfig
            {
                Query     = "en.blog.wordpress.com",
                QueryType = WordPressQueryType.Category,
                FilterBy  = "themes"
            };

            var dataProviderNoSorting          = new WordPressDataProvider();
            IEnumerable <WordPressSchema> data = await dataProviderNoSorting.LoadDataAsync(config);

            IEnumerable <WordPressSchema> moreData = await dataProviderNoSorting.LoadMoreDataAsync();

            config = new WordPressDataConfig
            {
                Query          = "en.blog.wordpress.com",
                QueryType      = WordPressQueryType.Category,
                FilterBy       = "themes",
                OrderBy        = WordPressOrderBy.Id,
                OrderDirection = SortDirection.Ascending
            };

            var dataProvider = new WordPressDataProvider();
            IEnumerable <WordPressSchema> sortedData = await dataProvider.LoadDataAsync(config);

            IEnumerable <WordPressSchema> moreSortedData = await dataProvider.LoadMoreDataAsync();

            config = new WordPressDataConfig
            {
                Query          = "en.blog.wordpress.com",
                QueryType      = WordPressQueryType.Category,
                FilterBy       = "themes",
                OrderBy        = WordPressOrderBy.Id,
                OrderDirection = SortDirection.Descending
            };

            var dataProviderDesc = new WordPressDataProvider();
            IEnumerable <WordPressSchema> sortedDescData = await dataProviderDesc.LoadDataAsync(config);

            IEnumerable <WordPressSchema> moreSortedDescData = await dataProviderDesc.LoadMoreDataAsync();


            Assert.AreNotEqual(data.FirstOrDefault().Title, sortedData.FirstOrDefault().Title, "LoadDataAsync: WordPress sorting (ascending) is not working");
            Assert.AreNotEqual(moreData.FirstOrDefault().Title, moreSortedData.FirstOrDefault().Title, "LoadMoreDataAsync: WordPress sorting (ascending) is not working");
            Assert.AreNotEqual(sortedData.FirstOrDefault().Title, sortedDescData.FirstOrDefault().Title, "LoadDataAsync: WordPress sorting (descending) is not working");
            Assert.AreNotEqual(moreSortedData.FirstOrDefault().Title, moreSortedDescData.FirstOrDefault().Title, "LoadMoreDataAsync: WordPress sorting (descending) is not working");
        }
        public async Task LoadPaginationWordPressPost()
        {
            var config = new WordPressDataConfig
            {
                Query     = "en.blog.wordpress.com",
                QueryType = WordPressQueryType.Posts
            };

            var dataProvider = new WordPressDataProvider();
            await dataProvider.LoadDataAsync(config, 5);

            Assert.IsTrue(dataProvider.HasMoreItems);

            IEnumerable <WordPressSchema> data = await dataProvider.LoadMoreDataAsync();

            Assert.IsNotNull(data);
            Assert.IsTrue(data.Any());
        }
        private async void Request()
        {
            try
            {
                IsBusy              = true;
                HasErrors           = false;
                NoItems             = false;
                DataProviderRawData = string.Empty;
                Items.Clear();
                var config = new WordPressDataConfig()
                {
                    Query          = WordPressQuery,
                    QueryType      = WordPressQueryTypeSelectedItem,
                    FilterBy       = WordPressQueryFilterBy,
                    OrderBy        = OrderBy,
                    OrderDirection = SortDirection
                };
                var items = await wordPressDataProvider.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;
            }
        }
Exemple #13
0
        public async void GetItems()
        {
            string             wordPressQuery = "en.blog.wordpress.com";
            WordPressQueryType queryType      = WordPressQueryType.Posts;
            string             queryFilterBy  = string.Empty;
            int maxRecordsParam = 20;

            Items.Clear();
            var wordPressDataProvider = new WordPressDataProvider();
            var config = new WordPressDataConfig()
            {
                Query     = wordPressQuery,
                QueryType = queryType,
                FilterBy  = queryFilterBy
            };

            var items = await wordPressDataProvider.LoadDataAsync(config, maxRecordsParam);

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