internal TOut GetDirPackagesDataForRow <TOut>(bool returnArray) { string tblData = returnArray ? "2286180604, 6045180604, 3421180604, 0083180604, 6045180605, 3424180606, 0663180606, 2286180606, 6045180606, 3424180607, 0663180607, 2286180607, 6045180607, 1716180607, 6045180608, 2286180608, 6621180609, 1716180607" : "DIRNumber"; BaseUtils utils = new BaseUtils(); if (returnArray) { string[] arrayArg = new string[] { }; arrayArg = Regex.Split(tblData, ", "); return(utils.ConvertToType <TOut>(arrayArg)); } else { return(utils.ConvertToType <TOut>(tblData)); } }
private IRestResponse GetTestRunTask <T>(TestRunType testRunType, T taskParams) { int testBuildId = -1; string content = string.Empty; string statusCode = string.Empty; Type paramType = taskParams.GetType(); BaseUtils baseUtils = new BaseUtils(); try { if (paramType == typeof(int)) { testBuildId = baseUtils.ConvertToType <int>(taskParams); } else if (paramType == typeof(object[])) { testBuildId = (int)baseUtils.ConvertToType <object[]>(taskParams)[0]; } var testRunTaskParms = new object[] { testRunType, testBuildId, }; var testRunTask = CallExecuteRequest(Method.GET, ResourceType.TestRuns, null, testRunTaskParms); Task.WaitAll(testRunTask); var response = testRunTask.Result; statusCode = response.StatusCode.ToString(); content = response.Content; return(response); } catch (Exception e) { log.Debug($"Get TestRun Task StatusCode: {statusCode}\n{e.Message}"); log.Debug(content); throw; } }
public void EnumParseTest() { Enum tblTabEnum = TableBtns.Report_View; BaseUtils baseUtils = new BaseUtils(); Type enumType = tblTabEnum.GetType(); object kendoTabStripEnum = Enum.Parse(enumType, "KendoTabStripId"); Enum tabStripEnum = baseUtils.ConvertToType <Enum>(kendoTabStripEnum); string expected = "KENDOUItabStripID"; string actual = tabStripEnum.GetString(); Console.WriteLine($"EXPECTED VALUE: {expected}\nACTUAL VALUE: {actual}"); Assert.AreEqual(expected, actual); bool nostringEnumVal = TableBtns.NoStringValueEnum.Equals("NoStringValueEnum"); Console.WriteLine($"nostringEnumVal : {nostringEnumVal}"); Console.WriteLine(TableBtns.Report_View.ToString()); }
private Task <IRestResponse> ExecuteRequest(Method requestMethod, ResourceType resource, RootObject json = null, params object[] requestParams) { int buildId; int testRunId; int testResultId; int testSnapshotId; string endPoint = string.Empty; string content = string.Empty; string statusCode = string.Empty; BaseUtils baseUtils = new BaseUtils(); try { switch (resource) { case ResourceType.TestRuns: if (requestMethod == Method.GET) { TestRunType testRunType = (TestRunType)requestParams[0]; testRunId = baseUtils.ConvertToType <int>(requestParams[1]); if (testRunType == TestRunType.GetTest) { testSnapshotId = baseUtils.ConvertToType <int>(requestParams[3]); bool allTests = baseUtils.ConvertToType <bool>(requestParams[2]); endPoint = allTests ? $"/test_runs/{testRunId}/test_snapshots" : $"/test_runs/{testRunId}"; } else if (testRunType == TestRunType.Sync) { endPoint = $"/test_runs/{testRunId}?show_synchronization_information=true"; } } else { endPoint = "/test_runs"; } break; case ResourceType.TestResults: if (requestMethod == Method.POST) { testRunId = baseUtils.ConvertToType <int>(requestParams[0]); buildId = baseUtils.ConvertToType <int>(requestParams[1]); endPoint = $"/test_runs/{testRunId}/builds/{buildId}/test_results"; } else if (requestMethod == Method.PATCH) { testRunId = baseUtils.ConvertToType <int>(requestParams[0]); testSnapshotId = baseUtils.ConvertToType <int>(requestParams[1]); testResultId = baseUtils.ConvertToType <int>(requestParams[2]); endPoint = $"/test_runs/{testRunId}/test_snapshots/{testSnapshotId}/test_results/{testResultId}"; } else { testRunId = baseUtils.ConvertToType <int>(requestParams[0]); testSnapshotId = baseUtils.ConvertToType <int>(requestParams[1]); endPoint = $"/test_runs/{testRunId}/test_snapshots/{testSnapshotId}?include=last-result"; } break; case ResourceType.TestSnapshots: testRunId = baseUtils.ConvertToType <int>(requestParams[0]); endPoint = $"/test_runs/{testRunId}/test_snapshots?include=scenario"; break; } IRestRequest request = CreateRequest(requestMethod, endPoint); if (json != null) { request.AddJsonBody(json); } log.Info($"API Endpoint: {endPoint}"); IRestClient client = new RestClient(ApiBase); var responseTask = Task.Factory.StartNew(() => client.Execute(request)); Task.WaitAny(responseTask); var response = responseTask.Result; statusCode = response.StatusCode.ToString(); content = response.Content; return(responseTask); } catch (Exception e) { log.Debug($"ExecuteRequest StatusCode: {statusCode}\n{e.Message}"); log.Debug(content); throw; } }