public void GetFileNameFromUrl()
        {
            var image = new PWImage();
            var imageName = image.GetImageFileName(expectedImageUrl);

            Assert.AreEqual("big_584778739bace9b64fb91975340190ed2f64a51d.jpg", imageName);
        }
        public async Task DownloadImage(PWImage image, string path, Action<PWImage, string> SetupProgress, Action endTask, TaskScheduler scheduler)
        {
            await Task.Factory.StartNew(() =>
            {
                SetupProgress(image, path);
            }, CancellationToken.None, TaskCreationOptions.None, scheduler);

            using (WebClient wc = new WebClient())
            {

                await wc.DownloadFileTaskAsync(image.imageUrl, path, image.progress);

            }
            endTask();
        }
        private void SetupProgress(PWImage image, string dir)
        {
            progressTable.SuspendLayout();
            var label = new Label();
            label.AutoSize = true;
            label.Text = dir;

            var progressBar = new ProgressBar();

            image.progress = new Progress<DownloadProgressChangedEventArgs>();
            image.progress.ProgressChanged += (s, e) =>
            {
                progressBar.Value = e.ProgressPercentage;
            };


            var panel = new FlowLayoutPanel();
            panel.AutoSize = true;
            panel.Controls.Add(progressBar);
            panel.Controls.Add(label);


            progressTable.Controls.Add(panel);
            progressTable.ResumeLayout();
    
        }
 public void FileNameShouldCallGetImageFileName()
 {
     var image = new PWImage();
     image.imageUrl = expectedImageUrl;
     Assert.AreEqual("big_584778739bace9b64fb91975340190ed2f64a51d.jpg", image.imageName);
 }