I created a program to call thousands of urls, what I want to do is make sure if the url times out I can trace the timeout error back to the url. What I have in place is:
string url = "http://www.google.com";
HttpWebRequest request = (HttpWebRequest)
WebRequest.Create(url);
request.Timeout = 5000;
request.ReadWriteTimeout = 5000;
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20100101 Firefox/14.0.1";
//From Fiddler
DateTime giveUp = DateTime.UtcNow.AddSeconds(5);
if (DateTime.UtcNow > giveUp)
throw new TimeoutException("The following url could not be reached: " + url);
I want to make a unit to test that the timeout Exception works correctly. Let me know if you need more details but this should suffice.