public async Task <Uri> GetDownloadUrl(Guid fileId) { var file = await _metadataRepository.GetFileMetadata(fileId); if (file == null) { return(null); } return(await _blobRepository.GetDownloadUrl(file)); }
public async Task GetDownloadLink_ExistingFile_Ok() { var fileId = Guid.NewGuid(); var fakeBlobUrl = new Uri("http://image.url"); var client = await _factory.CreateAuthenticatedClient(); _fileMetadataRepository.GetFileMetadata(fileId) .Returns(new FileMetadata { Id = fileId }); _fileBlobRepository.GetDownloadUrl(Arg.Is <FileMetadata>(metadata => metadata.Id == fileId)) .Returns(fakeBlobUrl); var response = await client.GetAsync($"/api/v2/file/{fileId}/download-link"); var downloadLink = await response.EnsureSuccessStatusCode() .Content.ReadAsAsync <DownloadLinkResponse>(); Assert.Equal(fakeBlobUrl, downloadLink.FileUri); }