示例#1
0
        public async Task TestNullQueryConfig()
        {
            var config = new BingDataConfig
            {
                Query = null,
                Country = BingCountry.UnitedStates
            };

            var dataProvider = new BingDataProvider();

            ConfigParameterNullException exception = await ExceptionsAssert.ThrowsAsync<ConfigParameterNullException>(async () => await dataProvider.LoadDataAsync(config));
            Assert.IsTrue(exception.Message.Contains("Query"));
        }
示例#2
0
        public async Task LoadBing()
        {
            var config = new BingDataConfig
            {
                Query = "Windows App Studio",
                Country = BingCountry.UnitedStates
            };

            var dataProvider = new BingDataProvider();
            IEnumerable<BingSchema> data = await dataProvider.LoadDataAsync(config);

            Assert.IsNotNull(data);
            Assert.AreNotEqual(data.Count(), 0);           
        }
示例#3
0
        public async void GetItems()
        {           
            string bingQueryParam = "Windows App Studio";
            BingCountry bingCountrySelectedItem = BingCountry.UnitedStates;
            int maxRecordsParam = 20;          
           
            _bingDataProvider = new BingDataProvider();
            this.Items = new ObservableCollection<object>();

            var config = new BingDataConfig() { Query = bingQueryParam, Country = bingCountrySelectedItem };

            var items = await _bingDataProvider.LoadDataAsync(config, maxRecordsParam);  
            foreach (var item in items)
            {
                Items.Add(item);
            }
        }
示例#4
0
        public async Task LoadPaginationBing()
        {
            var config = new BingDataConfig
            {
                Query = "Windows App Studio",
                Country = BingCountry.UnitedStates
            };

            var dataProvider = new BingDataProvider();
            await dataProvider.LoadDataAsync(config, 20);

            Assert.IsTrue(dataProvider.HasMoreItems);

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

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Any());
        }
示例#5
0
        private async void Request()
        {
            try
            {
                IsBusy = true;
                HasErrors = false;
                NoItems = false;
                DataProviderRawData = string.Empty;
                Items.Clear();
                
                var config = new BingDataConfig() { Query = BingQueryParam, Country = BingCountrySelectedItem };
               
                var items = await bingDataProvider.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;
            }
        }
示例#6
0
        public async Task LoadMoreDataInvalidOperationBing()
        {
            var config = new BingDataConfig
            {
                Query = "Windows App Studio",
                Country = BingCountry.UnitedStates
            };

            var dataProvider = new BingDataProvider();          
            InvalidOperationException exception = await ExceptionsAssert.ThrowsAsync<InvalidOperationException>(async () => await dataProvider.LoadMoreDataAsync());

        }