public void DownloadAsync()
        {
            AsyncDownloader downloader = new AsyncDownloader();
            string          url        = "http://localhost:51234/";
            string          expected   = "That's a nice string you have there";

            HttpListener listener = new HttpListener();

            listener.Prefixes.Add(url);
            listener.Start();

            listener.BeginGetContext(result =>
            {
                HttpListenerContext context = listener.EndGetContext(result);
                using (StreamWriter writer = new StreamWriter(context.Response.OutputStream))
                {
                    writer.Write(expected);
                    writer.Flush();
                }
            }, null);

            string actual = downloader.DownloadAsync(url).Result;

            listener.Stop();
            listener.Close();

            Assert.AreEqual(expected, actual);
        }
        public void DownloadAsyncTimeout()
        {
            AsyncDownloader downloader = new AsyncDownloader();
            string          url        = "http://localhost:51234/";
            int             timeout    = 250;

            HttpListener listener = new HttpListener();

            listener.Prefixes.Add(url);
            listener.Start();

            Assert.That(async() => await downloader.DownloadAsync(url, timeout), Throws.InstanceOf <TaskCanceledException>());

            listener.Stop();
            listener.Close();
        }