/// <summary> /// Update the test details to say it has finished /// </summary> /// <param name="TestId"></param> private static void UpdateTestDetailsEnd(int TestId) { SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder hostServerConnectionString = new SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder(); hostServerConnectionString.Host = "localhost"; hostServerConnectionString.Port = 5555; hostServerConnectionString.IsPrimaryLogin = true; hostServerConnectionString.Integrated = true; SourceCode.SmartObjects.Client.SmartObjectClientServer serverName = new SourceCode.SmartObjects.Client.SmartObjectClientServer(); serverName.CreateConnection(); serverName.Connection.Open(hostServerConnectionString.ToString()); try { SourceCode.SmartObjects.Client.SmartObject smartObject = serverName.GetSmartObject("K2C_TST_SMO_TestRun"); smartObject.MethodToExecute = "Execute_NaN_NaN_1"; smartObject.GetMethod("Execute_NaN_NaN_1").Parameters["pTestId"].Value = TestId.ToString(); serverName.ExecuteScalar(smartObject); } catch (Exception ex) { string x = ex.Message; } finally { serverName.Connection.Close(); } }
/// <summary> /// Records the test result /// </summary> /// <param name="TestRunId"></param> /// <param name="Actual"></param> /// <param name="Expected"></param> /// <param name="Sign"></param> private static void RecordResult(int TestRunId, object Actual, string Expected, string Sign) { SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder hostServerConnectionString = new SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder(); hostServerConnectionString.Host = "localhost"; hostServerConnectionString.Port = 5555; hostServerConnectionString.IsPrimaryLogin = true; hostServerConnectionString.Integrated = true; SourceCode.SmartObjects.Client.SmartObjectClientServer serverName = new SourceCode.SmartObjects.Client.SmartObjectClientServer(); serverName.CreateConnection(); serverName.Connection.Open(hostServerConnectionString.ToString()); try { SourceCode.SmartObjects.Client.SmartObject smartObject = serverName.GetSmartObject("K2C_TST_SMO_TestRun"); smartObject.MethodToExecute = "Execute_NaN"; smartObject.GetMethod("Execute_NaN").Parameters["pTestRunId"].Value = TestRunId.ToString(); smartObject.GetMethod("Execute_NaN").Parameters["pResult"].Value = Actual.ToString(); smartObject.GetMethod("Execute_NaN").Parameters["pExpectedResult"].Value = Expected; smartObject.GetMethod("Execute_NaN").Parameters["pPass"].Value = Result(Actual, Expected, Sign).ToString(); serverName.ExecuteScalar(smartObject); } catch (Exception ex) { string x = ex.Message; } finally { serverName.Connection.Close(); } }
/// <summary> /// Updates the test details to say it has started /// </summary> /// <param name="TestDetailsid"></param> /// <param name="ProcessInstanceId"></param> /// <param name="Folio"></param> /// <param name="Originator"></param> /// <param name="StartedDate"></param> /// <param name="Started"></param> private static void UpdateTestDetails(int TestDetailsid, int ProcessInstanceId, string Folio, string Originator, DateTime StartedDate, bool Started) { SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder hostServerConnectionString = new SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder(); hostServerConnectionString.Host = "localhost"; hostServerConnectionString.Port = 5555; hostServerConnectionString.IsPrimaryLogin = true; hostServerConnectionString.Integrated = true; SourceCode.SmartObjects.Client.SmartObjectClientServer serverName = new SourceCode.SmartObjects.Client.SmartObjectClientServer(); serverName.CreateConnection(); serverName.Connection.Open(hostServerConnectionString.ToString()); try { SourceCode.SmartObjects.Client.SmartObject smartObject = serverName.GetSmartObject("K2C_TST_SMO_TestRun"); smartObject.MethodToExecute = "Execute_NaN_1"; smartObject.GetMethod("Execute_NaN_1").Parameters["pTestDetailsid"].Value = TestDetailsid.ToString(); smartObject.GetMethod("Execute_NaN_1").Parameters["pProcessInstanceId"].Value = ProcessInstanceId.ToString(); smartObject.GetMethod("Execute_NaN_1").Parameters["pFolio"].Value = Folio.ToString(); smartObject.GetMethod("Execute_NaN_1").Parameters["pOriginator"].Value = Originator.ToString(); smartObject.GetMethod("Execute_NaN_1").Parameters["pStartedDate"].Value = StartedDate.ToString(); smartObject.GetMethod("Execute_NaN_1").Parameters["pStarted"].Value = Started.ToString(); serverName.ExecuteScalar(smartObject); } catch (Exception ex) { string x = ex.Message; } finally { serverName.Connection.Close(); } }
/// <summary> /// Gets the test details /// </summary> /// <param name="TestId"></param> /// <returns></returns> public static List <TestPlanDetails> GetTestDetails(int TestId) { List <TestPlanDetails> list = new List <TestPlanDetails>(); SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder hostServerConnectionString = new SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder(); hostServerConnectionString.Host = "localhost"; hostServerConnectionString.Port = 5555; hostServerConnectionString.IsPrimaryLogin = true; hostServerConnectionString.Integrated = true; SourceCode.SmartObjects.Client.SmartObjectClientServer serverName = new SourceCode.SmartObjects.Client.SmartObjectClientServer(); serverName.CreateConnection(); serverName.Connection.Open(hostServerConnectionString.ToString()); try { SourceCode.SmartObjects.Client.SmartObject smartObject = serverName.GetSmartObject("K2C_TST_SMO_TestRun"); SourceCode.SmartObjects.Client.SmartObject returnSmartObject; smartObject.MethodToExecute = "List_NaN_NaN"; smartObject.GetMethod("List_NaN_NaN").Parameters["pTestId"].Value = TestId.ToString(); returnSmartObject = serverName.ExecuteScalar(smartObject); int ProcessTypeId = 0; int ProcessInstanceId = 0; int parameters = 0; DateTime StartedDate = DateTime.Today; DateTime FinishedDate = DateTime.Today; int.TryParse(returnSmartObject.Properties["ProcessTypeId"].Value, out ProcessTypeId); int.TryParse(returnSmartObject.Properties["ProcessInstanceId"].Value, out ProcessInstanceId); DateTime.TryParse(returnSmartObject.Properties["StartedDate"].Value, out StartedDate); DateTime.TryParse(returnSmartObject.Properties["FinishedDate"].Value, out FinishedDate); list.Add(new TestPlanDetails { TestName = returnSmartObject.Properties["TestName"].Value, WorkflowName = returnSmartObject.Properties["WorkflowName"].Value, ProcessTypeId = ProcessTypeId, ProcessInstanceId = ProcessInstanceId, Folio = returnSmartObject.Properties["Folio"].Value, Originator = returnSmartObject.Properties["Originator"].Value, Started = returnSmartObject.Properties["Started"].Value, StartedDate = StartedDate, Finished = returnSmartObject.Properties["Finished"].Value, FinishedDate = FinishedDate, Status = returnSmartObject.Properties["Status"].Value, Route = returnSmartObject.Properties["Route"].Value }); } catch (Exception ex) { list.Add(new TestPlanDetails { TestName = ex.Message }); } finally { serverName.Connection.Close(); } return(list); }