예제 #1
0
        public override async Task <IEnumerable <BingSchema> > GetDataAsync(SchemaBase connectedItem = null)
        {
            var config = new BingDataConfig
            {
                Country = BingCountry.France,
                Query   = @"college rodin"
            };

            return(await _dataProvider.LoadDataAsync(config, MaxRecords));
        }
예제 #2
0
        private async void Request()
        {
            try
            {
                IsBusy              = true;
                HasErrors           = false;
                NoItems             = false;
                DataProviderRawData = string.Empty;
                Items.Clear();
                var bingDataProvider = new BingDataProvider();
                var config           = new BingDataConfig()
                {
                    Query = BingQueryParam, Country = BingCountrySelectedItem
                };

                var rawParser = new RawParser();
                var rawData   = await bingDataProvider.LoadDataAsync(config, MaxRecordsParam, rawParser);

                DataProviderRawData = rawData.FirstOrDefault()?.Raw;

                var items = await bingDataProvider.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;
            }
        }
예제 #3
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"));
        }
예제 #4
0
        public async Task TestMaxRecords()
        {
            int maxRecords = 50;
            var config     = new BingDataConfig
            {
                Query   = "Microsoft",
                Country = BingCountry.UnitedStates
            };

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

            Assert.IsTrue(data.Count() > 20);
        }
예제 #5
0
        public async Task TestMaxRecords_Min()
        {
            int maxRecords = 1;
            var config     = new BingDataConfig
            {
                Query   = "Windows App Studio",
                Country = BingCountry.UnitedStates
            };

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

            Assert.AreEqual(maxRecords, data.Count());
        }
예제 #6
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);
        }
예제 #7
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);           
        }
예제 #8
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);
            }
        }
예제 #9
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());
        }
예제 #10
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());
        }
예제 #11
0
        public async void GetItems()
        {
            string      bingQueryParam          = "Windows App Studio";
            BingCountry bingCountrySelectedItem = BingCountry.UnitedStates;
            int         maxRecordsParam         = 20;

            Items.Clear();
            var bingDataProvider = new BingDataProvider();
            var config           = new BingDataConfig()
            {
                Query = bingQueryParam, Country = bingCountrySelectedItem
            };

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

            foreach (var item in items)
            {
                Items.Add(item);
            }
        }
예제 #12
0
        public async Task TestNullParser()
        {
            var dataProvider = new BingDataProvider();

            await ExceptionsAssert.ThrowsAsync <ParserNullException>(async() => await dataProvider.LoadDataAsync <BingSchema>(new BingDataConfig(), 20, null));
        }
예제 #13
0
        public async Task TestNullConfig()
        {
            var dataProvider = new BingDataProvider();

            await ExceptionsAssert.ThrowsAsync <ConfigNullException>(async() => await dataProvider.LoadDataAsync(null));
        }
예제 #14
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"));
        }
예제 #15
0
        public async Task TestNullParser()
        {
            var dataProvider = new BingDataProvider();

            await ExceptionsAssert.ThrowsAsync<ParserNullException>(async () => await dataProvider.LoadDataAsync<BingSchema>(new BingDataConfig(), 20, null));
        }      
예제 #16
0
        public async Task TestNullConfig()
        {
            var dataProvider = new BingDataProvider();

            await ExceptionsAssert.ThrowsAsync<ConfigNullException>(async () => await dataProvider.LoadDataAsync(null));
        }