private void btnCreateTestInstance_Click(object sender, EventArgs e) { int testInstance = pcRestProxy.CreateTestInstance(int.Parse(txtTestID.Text), int.Parse(txtTestSetID.Text)); if (testInstance != 0) { btnCreateTestInstance.Text = "TestInstance " + testInstance + " created"; btnCreateTestInstance.BackColor = Color.Green; } else { btnCreateTestInstance.Text = "TestInstance Not create"; btnCreateTestInstance.BackColor = Color.Red; } }
private int GetCorrectTestInstanceID(int testID) { PCErrorResponse pcErrorResponse = new PCErrorResponse("", 0); if (!TestExist(testID, ref pcErrorResponse)) { _fileLog.Write(LogMessageType.Info, string.Format("Error: {0}", pcErrorResponse.ExceptionMessage)); return(0); } if (_pcModel.AutoTestInstance) { try { _fileLog.Write(LogMessageType.Info, "Searching for available Test Instance"); PCTestInstances pcTestInstances = _pcRestProxy.GetTestInstancesByTestId(testID, ref pcErrorResponse); int testInstanceID = 0; if (pcTestInstances != null && pcTestInstances.TestInstancesList != null && pcTestInstances.TestInstancesList.Count > 0) { PCTestInstance pcTestInstance = pcTestInstances.TestInstancesList[pcTestInstances.TestInstancesList.Count - 1]; testInstanceID = pcTestInstance.TestInstanceID; _fileLog.Write(LogMessageType.Info, "Found test instance ID: " + testInstanceID + "\n"); } else { _fileLog.Write(LogMessageType.Info, "Could not find available TestInstanceID, Creating Test Instance."); _fileLog.Write(LogMessageType.Info, "Searching for available TestSet"); // Get a random TestSet PCTestSets pcTestSets = _pcRestProxy.GetAllTestSets(ref pcErrorResponse); if (pcTestSets != null && pcTestSets.PCTestSetsList != null) { PCTestSet pcTestSet = pcTestSets.PCTestSetsList[pcTestSets.PCTestSetsList.Count - 1]; int testSetID = pcTestSet.TestSetID; _fileLog.Write(LogMessageType.Info, string.Format("Creating Test Instance with testID: {0} and TestSetID: {1}", testID, testSetID)); testInstanceID = _pcRestProxy.CreateTestInstance(testID, testSetID, ref pcErrorResponse); if (testInstanceID == 0) { _fileLog.Write(LogMessageType.Info, string.Format("Test Instance could not be created for Test ID '", testID + "'")); } else { _fileLog.Write(LogMessageType.Info, string.Format("Test Instance with ID : {0} has been created successfully.", testInstanceID)); } } else { string msg = "No TestSetID available in project, please create a testset from LoadRunner Enterprise UI"; _fileLog.Write(LogMessageType.Info, msg); } } return(testInstanceID); } catch (Exception ex) { _fileLog.Write(LogMessageType.Error, string.Format("getCorrectTestInstanceID failed, reason: {0}", ex)); if (pcErrorResponse.ErrorCode > 0) { _fileLog.Write(LogMessageType.Error, string.Format("getCorrectTestInstanceID failed, ExceptionMessage: {0}, ErrorCode: {1}", pcErrorResponse.ExceptionMessage, pcErrorResponse.ErrorCode)); } return(int.Parse(null)); } } return(int.Parse(_pcModel.TestInstanceId)); }