public DocFile(string basePath, string relativePath, DocSet parent) : this() { this.BasePath = basePath; this.FullPath = Path.Combine(basePath, relativePath.Substring(1)); this.DisplayName = relativePath; this.Parent = parent; }
public DocFile(string basePath, string relativePath, DocSet parent) : this() { this.BasePath = basePath; this.FullPath = Path.Combine(basePath, relativePath.Substring(1)); this.DisplayName = relativePath; this.Parent = parent; this.DocumentHeaders = new List <Config.DocumentHeader>(); }
/// <summary> /// Take a scenario definition and convert the prototype request into a fully formed request. This includes appending /// the base URL to the request URL, executing any test-setup requests, and replacing the placeholders in the prototype /// request with proper values. /// </summary> /// <param name="scenario"></param> /// <param name="documents"></param> /// <param name="account"></param> /// <returns></returns> public async Task <ValidationResult <HttpRequest> > GenerateMethodRequestAsync(ScenarioDefinition scenario, DocSet documents, IServiceAccount account) { var parser = new HttpParser(); var request = parser.ParseHttpRequest(this.Request); AddAccessTokenToRequest(account.CreateCredentials(), request); AddTestHeaderToRequest(scenario, request); AddAdditionalHeadersToRequest(account, request); List <ValidationError> errors = new List <ValidationError>(); if (null != scenario) { var storedValuesForScenario = new Dictionary <string, string>(); if (null != scenario.TestSetupRequests) { foreach (var setupRequest in scenario.TestSetupRequests) { try { var result = await setupRequest.MakeSetupRequestAsync(storedValuesForScenario, documents, scenario, account); errors.AddRange(result.Messages); if (result.IsWarningOrError) { // If we can an error or warning back from a setup method, we fail the whole request. return(new ValidationResult <HttpRequest>(null, errors)); } } catch (Exception ex) { return(new ValidationResult <HttpRequest>(null, new ValidationError(ValidationErrorCode.ConsolidatedError, null, "An exception occured while processing setup-requests: {0}", ex.Message))); } } } try { var placeholderValues = scenario.RequestParameters.ToPlaceholderValuesArray(storedValuesForScenario); request.RewriteRequestWithParameters(placeholderValues); } catch (Exception ex) { // Error when applying parameters to the request errors.Add( new ValidationError( ValidationErrorCode.RewriteRequestFailure, "GenerateMethodRequestAsync", ex.Message)); return(new ValidationResult <HttpRequest>(null, errors)); } if (scenario.StatusCodesToRetry != null) { request.RetryOnStatusCode = (from status in scenario.StatusCodesToRetry select(System.Net.HttpStatusCode) status).ToList(); } } if (string.IsNullOrEmpty(request.Accept)) { if (!string.IsNullOrEmpty(ValidationConfig.ODataMetadataLevel)) { request.Accept = MimeTypeJson + "; " + ValidationConfig.ODataMetadataLevel; } else { request.Accept = MimeTypeJson; } } this.ModifyRequestForAccount(request, account); return(new ValidationResult <HttpRequest>(request, errors)); }