private static AuthorizationClient GetClientThatReturns(string message) { var webClient = new WebClientFake() { DownloadStringReturns = message, }; var path = new ApplicationBasePath("", "", ""); return(new AuthorizationClient(webClient, path)); }
public static Uri GetResponseUri(this Uri This, int retryCount = 0, IEnumerable <KeyValuePair <HttpRequestHeader, string> > headers = null, IDictionary <string, string> postValues = null) { Contract.Requires(This != null); Trace.WriteLine(This.AbsoluteUri); if (This.IsFile) { return(This); } using (var webClient = new WebClientFake()) { _SetWebClientHeaders(webClient, headers); var nameValCollection = new NameValueCollection(); if (postValues != null) { foreach (var kvp in postValues) { nameValCollection.Add(kvp.Key, kvp.Value); } } Exception ex = null; byte[] dummy; while (retryCount-- >= 0) { try { if (postValues == null) { dummy = webClient.DownloadData(This); return(webClient.ResponseUri); } dummy = webClient.UploadValues(This, nameValCollection); return(webClient.ResponseUri); } catch (Exception e) { ex = e; } } throw (ex); } }