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 GetImageMetadata_ValidParams_ReturnsDictionaryOfEEFluxImageMetadata() { // ARRANGE var parameters = Arranger.GetCafEEFluxParametersValid(); var expected = Arranger.GetEEFluxImageMetadataActual(); var actual = new Dictionary <int, EEFluxImageMetadata>(); EEFluxClientWebApi sut = arrangeEEFluxClientWebApi( "landsat", getEEFluxResponseLandsatValid()); // ACT actual = await sut.GetImageMetadataAsync(parameters); // ASSERT Assert.Equal(actual, expected); }