Exemple #1
0
        public async Task TestNullUrlConfig()
        {
            var config = new RssDataConfig
            {
                Url = null
            };

            var dataProvider = new RssDataProvider();

            ConfigParameterNullException exception = await ExceptionsAssert.ThrowsAsync<ConfigParameterNullException>(async () => await dataProvider.LoadDataAsync(config));
            Assert.IsTrue(exception.Message.Contains("Url"));
        }
Exemple #2
0
        public async Task TestMaxRecords_Min()
        {
            var config = new RssDataConfig()
            {
                Url = new Uri("http://blogs.msdn.com/b/windows_app_studio_news/rss.aspx")
            };
            var maxRecords = 1;
            var dataProvider = new RssDataProvider();
            IEnumerable<RssSchema> rssItems = await dataProvider.LoadDataAsync(config, maxRecords);

            Assert.AreEqual(maxRecords, rssItems.Count());
        }
Exemple #3
0
        public async Task LoadRss()
        {
            var config = new RssDataConfig()
            {
                Url = new Uri("http://blogs.msdn.com/b/windows_app_studio_news/rss.aspx")
            };

            var dataProvider = new RssDataProvider();
            IEnumerable<RssSchema> rssItems = await dataProvider.LoadDataAsync(config);

            Assert.IsNotNull(rssItems);
            Assert.AreNotEqual(rssItems.Count(), 0);
        }
Exemple #4
0
        public async Task LoadPaginationRss()
        {

            var config = new RssDataConfig()
            {
                Url = new Uri("http://blogs.msdn.com/b/windows_app_studio_news/rss.aspx")
            };

            var dataProvider = new RssDataProvider();
            await dataProvider.LoadDataAsync(config, 2);

            Assert.IsTrue(dataProvider.HasMoreItems);

            IEnumerable<RssSchema> result = await dataProvider.LoadMoreDataAsync();

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Any());
        }
Exemple #5
0
        public async void GetItems()
        {
            string rssQuery = "http://www.blogger.com/feeds/6781693/posts/default";
            int maxRecordsParam = 20;
            string orderBy = "PublishDate";
            SortDirection sortDirection = SortDirection.Descending;

            _rssDataProvider = new RssDataProvider();
            this.Items = new ObservableCollection<object>();

            var config = new RssDataConfig
            {
                Url = new Uri(rssQuery, UriKind.Absolute),
                OrderBy = orderBy,
                SortDirection = sortDirection
            };

            var items = await _rssDataProvider.LoadDataAsync(config, maxRecordsParam);
            foreach (var item in items)
            {
                Items.Add(item);
            }
        }
Exemple #6
0
        private async void Request()
        {
            try
            {
                IsBusy = true;
                HasErrors = false;
                NoItems = false;
                DataProviderRawData = string.Empty;
                Items.Clear();

                var config = new RssDataConfig
                {
                    Url = new Uri(RssQuery, UriKind.Absolute),
                    OrderBy = OrderBy != RssSampleOrderBy.None ? OrderBy.ToString() : string.Empty,
                    OrderDirection = SortDirection
                };

                var items = await rssDataProvider.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 #7
0
        public async Task LoadMoreDataInvalidOperationRss()
        {
            var config = new RssDataConfig()
            {
                Url = new Uri("http://blogs.msdn.com/b/windows_app_studio_news/rss.aspx")
            };

            var dataProvider = new RssDataProvider();
            InvalidOperationException exception = await ExceptionsAssert.ThrowsAsync<InvalidOperationException>(async () => await dataProvider.LoadMoreDataAsync());
        }
Exemple #8
0
        public async Task LoadRss_OrderByPublishDate()
        {
            var config = new RssDataConfig()
            {
                Url = new Uri("http://blogs.msdn.com/b/windows_app_studio_news/rss.aspx"),
                OrderBy = nameof(RssSchema.PublishDate),
                OrderDirection = SortDirection.Ascending
            };

            var dataProvider = new RssDataProvider();
            IEnumerable<RssSchema> rssItems = await dataProvider.LoadDataAsync(config, 5);

            Assert.AreEqual(rssItems.OrderBy(x => x.PublishDate).Select(x => x.PublishDate).FirstOrDefault(), rssItems.ToList()[0].PublishDate, "LoadDataAsync: Rss sorting (ascending) is not working");
            Assert.AreEqual(rssItems.OrderBy(x => x.PublishDate).Select(x => x.PublishDate).LastOrDefault(), rssItems.ToList()[rssItems.Count() - 1].PublishDate, "LoadDataAsync: Rss sorting (ascending) is not working");

            rssItems = await dataProvider.LoadMoreDataAsync();

            Assert.AreEqual(rssItems.OrderBy(x => x.PublishDate).Select(x => x.PublishDate).FirstOrDefault(), rssItems.ToList()[0].PublishDate, "LoadMoreDataAsync: Rss sorting (ascending) is not working");
            Assert.AreEqual(rssItems.OrderBy(x => x.PublishDate).Select(x => x.PublishDate).LastOrDefault(), rssItems.ToList()[rssItems.Count() - 1].PublishDate, "LoadMoreDataAsync: Rss sorting (ascending) is not working");

            config = new RssDataConfig()
            {
                Url = new Uri("http://blogs.msdn.com/b/windows_app_studio_news/rss.aspx"),
                OrderBy = nameof(RssSchema.PublishDate),
                OrderDirection = SortDirection.Descending
            };

            dataProvider = new RssDataProvider();
            rssItems = await dataProvider.LoadDataAsync(config, 5);

            Assert.AreEqual(rssItems.OrderByDescending(x => x.PublishDate).Select(x => x.PublishDate).FirstOrDefault(), rssItems.ToList()[0].PublishDate, "LoadDataAsync: Rss sorting (ascending) is not working");
            Assert.AreEqual(rssItems.OrderByDescending(x => x.PublishDate).Select(x => x.PublishDate).LastOrDefault(), rssItems.ToList()[rssItems.Count() - 1].PublishDate, "LoadDataAsync: Rss sorting (ascending) is not working");

            rssItems = await dataProvider.LoadMoreDataAsync();

            Assert.AreEqual(rssItems.OrderByDescending(x => x.PublishDate).Select(x => x.PublishDate).FirstOrDefault(), rssItems.ToList()[0].PublishDate, "LoadMoreDataAsync: Rss sorting (descending) is not working");
            Assert.AreEqual(rssItems.OrderByDescending(x => x.PublishDate).Select(x => x.PublishDate).LastOrDefault(), rssItems.ToList()[rssItems.Count() - 1].PublishDate, "LoadMoreDataAsync: Rss sorting (descending) is not working");
        }
Exemple #9
0
        public async Task LoadRss_Encoding_ISO88591()
        {
            var config = new RssDataConfig()
            {
                Url = new Uri("http://feeds.folha.uol.com.br/colunas/jaimespitzcovsky/rss091.xml")
            };

            var dataProvider = new RssDataProvider();
            IEnumerable<RssSchema> rssItems = await dataProvider.LoadDataAsync(config);

            Assert.IsNotNull(rssItems);
            Assert.AreNotEqual(rssItems.Count(), 0);
        }
Exemple #10
0
        public async Task LoadRss_CatalanSpecialCharacters()
        {
            var config = new RssDataConfig()
            {
                Url = new Uri("http://www.hacesfalta.org/oportunidades/presencial/buscador/rss.aspx?c=oportunidadesPresenciales_hf&&idPais=60&enfamilia=0&engrupo=0")
            };

            var dataProvider = new RssDataProvider();
            IEnumerable<RssSchema> rssItems = await dataProvider.LoadDataAsync(config);

            Assert.IsNotNull(rssItems);
            Assert.AreNotEqual(rssItems.Count(), 0);
            Assert.IsFalse(rssItems.Any(x => x.Content.Contains("Ã")));
        }
Exemple #11
0
        public async Task LoadRss_GreekSpecialCharacters()
        {
            var config = new RssDataConfig()
            {
                Url = new Uri("https://www.tuc.gr/754.html?&tx_mmforum_pi1%5Bfid%5D=27")
            };

            var dataProvider = new RssDataProvider();
            IEnumerable<RssSchema> rssItems = await dataProvider.LoadDataAsync(config);

            Assert.IsNotNull(rssItems);
            Assert.AreNotEqual(rssItems.Count(), 0);
            Assert.IsFalse(rssItems.Any(x => x.Title.Contains("Î")));
        }
Exemple #12
0
        public async Task LoadRss_GermanSpecialCharacters()
        {
            var config = new RssDataConfig()
            {
                Url = new Uri("http://www.inforadio.de/nachrichten/index.xml/feed=rss.xml")
            };

            var dataProvider = new RssDataProvider();
            IEnumerable<RssSchema> rssItems = await dataProvider.LoadDataAsync(config);

            Assert.IsNotNull(rssItems);
            Assert.AreNotEqual(rssItems.Count(), 0);
            Assert.IsFalse(rssItems.Any(x => x.Content.Contains("Ã")));
        }
Exemple #13
0
        public async Task LoadRss_RequestFailedException_Apache403()
        {
            var dataProvider = new RssDataProvider();
            IEnumerable<RssSchema> rssItems = null;
            var config = new RssDataConfig()
            {
                Url = new Uri("http://www.brunswickcps.org/apps/news/news_rss.jsp?id=0")
            };
            rssItems = await dataProvider.LoadDataAsync(config);
            Assert.IsNotNull(rssItems);
            Assert.AreNotEqual(rssItems.Count(), 0);

            config = new RssDataConfig()
            {
                Url = new Uri("http://www.vicoteka.mk/tvitoteka/feed/")
            };
            rssItems = await dataProvider.LoadDataAsync(config);
            Assert.IsNotNull(rssItems);
            Assert.AreNotEqual(rssItems.Count(), 0);

            config = new RssDataConfig()
            {
                Url = new Uri("http://www.vicoteka.mk/vicovi/vic-na-denot/feed")
            };
            rssItems = await dataProvider.LoadDataAsync(config);
            Assert.IsNotNull(rssItems);
            Assert.AreNotEqual(rssItems.Count(), 0);
        }