public async Task Integration_Valid_ReturnsExpected() { // ARRANGE string b = Container.GetBaseAddress(); HttpClient c = Container.ResolveHttpClient(); var m = Container.ResolveImageTypeToUriMap(); IEEFluxClient <HttpResponseMessage> sut = new EEFluxClientWebApi(c, b, m); CafEEFluxParameters p = getCafEEFluxParametersValid(); // ACT Dictionary <int, EEFluxImageMetadata> imageMetas = await sut.GetImageMetadataAsync(p); Dictionary <EEFluxImageTypes, EEFluxImage> image = await sut.GetImageUriAsync( p, imageMetas[0].ImageId, EEFluxImageTypes.Ndvi); Uri imageUrl = new Uri(image[EEFluxImageTypes.Ndvi].Url); string fullPath = Path.GetFullPath(p.OutputDirectoryPath); if (!Directory.Exists(fullPath)) { Directory.CreateDirectory(fullPath); } // await sut.DownloadImageAsync(fullPath, imageUrl); Task <HttpResponseMessage> download = sut.DownloadImageAsync(imageUrl); var response = await download; string filePath = $"{p.OutputDirectoryPath}\\{response.Content.Headers.ContentDisposition.FileName}"; using (Stream readStream = await response.Content.ReadAsStreamAsync()) { using (Stream writeStream = File.Open( filePath, FileMode.Create)) { await readStream.CopyToAsync(writeStream); } } // ASSERT Assert.True( File.Exists("Output/LE70440272015152EDC00_NDVI.zip")); double expectedLength = new FileInfo("Assets/LE70440272015152EDC00_NDVI.zip").Length; double actualLength = new FileInfo("Output/LE70440272015152EDC00_NDVI.zip").Length; Assert.Equal( expectedLength, actualLength); }
public async Task GetImageUri_Etof_ReturnsDictionaryOfEEFluxImages() { // ARRANGE string imageId = "LE70420282015170EDC00"; var parameters = Arranger.GetCafEEFluxParametersValid(); var expected = Arranger.GetEEFluxResponseDownloadEtofValid(); EEFluxClientWebApi sut = arrangeEEFluxClientWebApi( "download_etof", "{\"etof\": {\"url\": \"https://earthengine.googleapis.com/api/download?docid=6277fdbbcb5e4e0bc2f2d5562f4d1c4a&token=da96164b598072a0163f34ceaac8f5b6\"}}"); // ACT var actual = await sut.GetImageUriAsync( parameters, imageId, EEFluxImageTypes.Etof); // ASSERT Assert.Equal(actual, expected); }