示例#1
0
        public void DownloadPhotoRequest_ArgumentsQueryWithAWhitespace_ProducesAnExpectedURI()
        {
            var  baseUrl = new Uri("http://a.b.c");
            uint width   = 200;
            uint height  = 100;
            var  crop    = Crop.EDGES;
            var  format  = Format.GIF;
            uint quality = 100;
            var  fit     = Fit.CLAMP;
            uint dpi     = 150;

            var request = new DownloadPhotoRequest(baseUrl,
                                                   width,
                                                   height,
                                                   crop,
                                                   format,
                                                   quality,
                                                   fit,
                                                   dpi);

            Assert.Matches($"http://a.b.c/" +
                           $"&w={width}" +
                           $"&h={height}" +
                           $"&crop={crop.Describe()}" +
                           $"&fm={format.Describe()}" +
                           $"&q={quality}" +
                           $"&fit={fit.Describe()}" +
                           $"&dpi={dpi}",
                           request.Uri.AbsoluteUri);
        }
示例#2
0
        public async Task <long> DownloadPhotoAsync(Uri url, string id, string destination)
        {
            var uri   = new DownloadPhotoRequest(url).Uri;
            var bytes = await netClient.GetByteArrayAsync(uri).ConfigureAwait(false);

            long fileSize = StoreFile(destination, bytes);

            await RecordPhotoDownloadAsync(id).ConfigureAwait(false);

            return(fileSize);
        }
示例#3
0
        public async Task <long> DownloadPhotoAsync(DownloadPhotoRequest request,
                                                    string id,
                                                    string destination)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }
            var bytes = await netClient.GetByteArrayAsync(request.Uri).ConfigureAwait(false);

            long fileSize = StoreFile(destination, bytes);

            await RecordPhotoDownloadAsync(id).ConfigureAwait(false);

            return(fileSize);
        }