private IEnumerable <string> GenerateUrlsForAction(Web.Models.Action action) { var urls = new List <string>(); var tokens = ParseTokens(action.Template); GenerateUrls(urls, tokens, action.Parameters, action.Template); return(urls); }
private async Task TestSingleUrlAsync(string authScheme, HttpStatusCode expectedStatusCode, Web.Models.Action action, string url) { foreach (var actionMethod in action.Methods) { // Note: authentication is not used at the moment //switch (authScheme) //{ // case "Basic": // Client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(authScheme, CreateBasicAuth()); // break; // case "Bearer": // Client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(authScheme, CreateAccessToken()); // break; //} using (var msg = new HttpRequestMessage(ActionMethodToHttpMethod(actionMethod), $"http://localhost/{url}")) { using (var response = await Client.SendAsync(msg).ConfigureAwait(false)) { Console.WriteLine(expectedStatusCode != response.StatusCode ? $"{actionMethod} {url} {expectedStatusCode} {response.StatusCode} NOK" : $"{actionMethod} {url} {expectedStatusCode} {response.StatusCode} OK"); Assert.Equal(expectedStatusCode, response.StatusCode); if (!response.IsSuccessStatusCode) { continue; } ValidateHeaders(response.Headers); } } } }
protected async Task TestSingleActionAsync(string authScheme, HttpStatusCode expectedStatusCode, Web.Models.Action action) { var urls = GenerateUrlsForAction(action); foreach (var url in urls) { await TestSingleUrlAsync(authScheme, expectedStatusCode, action, url).ConfigureAwait(false); } }