Example #1
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
        }
Example #2
0
        public async Task ReadAndConvertImage()
        {
            //arrange
            var ss = new StorageService();
            var imageBytes = await ss.GetAssetFileAsync("Assets/Tests/" + TestFile);
            var stream = new MemoryStream(imageBytes);

            var ps = new PlatformCodeService();

            //act
            //do not resize
            var bytesOrigin = await ps.ResizeImageAsync(stream, 10000, 10000);
            //resize
            var byteSmall = await ps.ResizeImageAsync(stream, 200, 200);

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

            //expected
            //Assert.IsTrue(image.Length > byteSmall.Length); //--FAILS--
            //real
            Assert.IsNull(byteSmall); //because of the exception occured in FlushAsync
        }