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); }
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 }