public static string SetEmitionType(this IDSFDataObject dataObject, WebRequestTO webRequest, string serviceName, NameValueCollection headers) { int extensionStartLocation; var originalServiceName = serviceName; if (!string.IsNullOrEmpty(serviceName) && (extensionStartLocation = serviceName.LastIndexOf(".", StringComparison.Ordinal)) > 0) { dataObject.ReturnType = EmitionTypes.XML; if (extensionStartLocation > 0) { var extension = serviceName.Substring(extensionStartLocation + 1); serviceName = SetReturnTypeForExtension(dataObject, extensionStartLocation, originalServiceName, extension); } } else { if (serviceName == "*" && webRequest.WebServerUrl.EndsWith("/.tests", StringComparison.InvariantCultureIgnoreCase)) { dataObject.ReturnType = EmitionTypes.TEST; } if (serviceName == "*" && webRequest.WebServerUrl.EndsWith("/.tests.trx", StringComparison.InvariantCultureIgnoreCase)) { dataObject.ReturnType = EmitionTypes.TRX; } dataObject.SetContentType(headers); } return(serviceName); }
public static void SetupForTestExecution(this IDSFDataObject dataObject, string serviceName, NameValueCollection headers) { if (IsRunAllTestsRequest(dataObject.ReturnType, serviceName)) { dataObject.IsServiceTestExecution = true; dataObject.TestName = "*"; } else { dataObject.SetContentType(headers); } }
public static string SetEmitionType(this IDSFDataObject dataObject, string serviceName, NameValueCollection headers) { int loc; if (!string.IsNullOrEmpty(serviceName) && (loc = serviceName.LastIndexOf(".", StringComparison.Ordinal)) > 0) { // default it to xml dataObject.ReturnType = EmitionTypes.XML; if (loc > 0) { var typeOf = serviceName.Substring(loc + 1).ToUpper(); EmitionTypes myType; if (Enum.TryParse(typeOf, out myType)) { dataObject.ReturnType = myType; } if (typeOf.StartsWith("tests", StringComparison.InvariantCultureIgnoreCase)) { dataObject.IsServiceTestExecution = true; var idx = serviceName.LastIndexOf("/", StringComparison.InvariantCultureIgnoreCase); if (idx > loc) { var testName = serviceName.Substring(idx + 1).ToUpper(); dataObject.TestName = string.IsNullOrEmpty(testName) ? "*" : testName; } else { dataObject.TestName = "*"; } dataObject.ReturnType = EmitionTypes.TEST; } if (typeOf.Equals("api", StringComparison.OrdinalIgnoreCase)) { dataObject.ReturnType = EmitionTypes.SWAGGER; } serviceName = serviceName.Substring(0, loc); dataObject.ServiceName = serviceName; } } else { dataObject.SetContentType(headers); } return(serviceName); }
public static string SetEmissionType(this IDSFDataObject dataObject, Uri uri, string serviceName, NameValueCollection headers) { var startLocation = serviceName.LastIndexOf(".", StringComparison.Ordinal); if (!string.IsNullOrEmpty(serviceName) && startLocation > 0) { dataObject.ReturnType = EmitionTypes.XML; var extension = serviceName.Substring(startLocation + 1); return(SetReturnTypeForExtension(dataObject, startLocation, extension)); } if (serviceName == "*" || serviceName == ".coverage") { var path = uri.AbsolutePath; if (path.EndsWith("/.tests", StringComparison.InvariantCultureIgnoreCase)) { dataObject.ReturnType = EmitionTypes.TEST; } if (path.EndsWith("/.coverage", StringComparison.InvariantCultureIgnoreCase)) { dataObject.ReturnType = EmitionTypes.Cover; } if (path.EndsWith("/.coverage.json", StringComparison.InvariantCultureIgnoreCase)) { dataObject.ReturnType = EmitionTypes.CoverJson; } if (path.EndsWith("/.tests.trx", StringComparison.InvariantCultureIgnoreCase)) { dataObject.ReturnType = EmitionTypes.TRX; } } dataObject.SetContentType(headers); return(serviceName); }