using System;
using System.Runtime.InteropServices;
using QC.QSPRAutomation.Internal;
using QC.QTMInterface;

namespace QC.QSPRAutomationInterface;

[ProgId("QSPR3.TestNode")]
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
public class TestNode : ITestNode
{
	private string lastCallInfo = "";

	private string lastError = "No Error";

	[ComVisible(false)]
	private QSPRInstance qsprInstance;

	[ComVisible(false)]
	private XTTDocument xttDoc;

	[ComVisible(false)]
	private string testIndex;

	internal XTTDocument XttDocument
	{
		get
		{
			return xttDoc;
		}
		set
		{
			xttDoc = value;
		}
	}

	internal string TestIndex
	{
		get
		{
			return testIndex;
		}
		set
		{
			testIndex = value;
		}
	}

	public int Checked
	{
		get
		{
			try
			{
				lastCallInfo = "Checked";
				if (testIndex == null)
				{
					lastCallInfo = "Checked called for invalid TestNode object.";
					lastError = "Checked failed, the testNode object is not valid";
					qsprInstance.SetErrorsExist(1);
					return 0;
				}
				return qsprInstance.GetTestChecked(testIndex);
			}
			catch (Exception ex)
			{
				lastError = string.Concat("Checked failed: ", ex.InnerException, " ", ex);
				qsprInstance.SetErrorsExist(1);
				return 0;
			}
		}
		set
		{
			lastCallInfo = "Checked = " + value;
			if (testIndex == null)
			{
				lastCallInfo = "Checked called for invalid TestNode object.";
				lastError = "Checked failed, the testNode object is not valid";
				qsprInstance.SetErrorsExist(1);
			}
			else
			{
				qsprInstance.SetTestChecked(testIndex, value);
			}
		}
	}

	internal void SetAutomationObject(QSPRInstance qsprinstance)
	{
		qsprInstance = qsprinstance;
	}

	public TestNode AddTest(string realName, string newTestName)
	{
		if (testIndex == null)
		{
			lastCallInfo = "TestNode object is not valid. The index of the node is null.";
			lastError = "TestNode object is not valid. The index of the node is null.";
			qsprInstance.SetErrorsExist(1);
			return null;
		}
		if (string.IsNullOrEmpty(realName))
		{
			lastCallInfo = "AddTest called with invalid first argument. RealName can't be null or empty";
			lastError = "AddTest called with invalid first argument. RealName can't be null or empty";
			qsprInstance.SetErrorsExist(1);
			return null;
		}
		if (newTestName == null)
		{
			lastCallInfo = "AddTest called with invalid third argument. NewTestName can't be null";
			lastError = "AddTest called with invalid third argument. NewTestName can't be null";
			qsprInstance.SetErrorsExist(1);
			return null;
		}
		lastCallInfo = "AddTest(" + realName + ", " + newTestName + ")";
		string text = qsprInstance.AddTest(realName, newTestName, testIndex, 3);
		if (text != null)
		{
			TestNode testNode = new TestNode();
			testNode.XttDocument = xttDoc;
			testNode.TestIndex = text;
			testNode.SetAutomationObject(qsprInstance);
			return testNode;
		}
		lastError = "AddTest failed";
		qsprInstance.SetErrorsExist(1);
		return null;
	}

	public TestNode AddTestAtPosition(string realName, string newTestName, int position)
	{
		if (testIndex == null)
		{
			lastCallInfo = "TestNode object is not valid. The index of the node is null.";
			lastError = "TestNode object is not valid. The index of the node is null.";
			qsprInstance.SetErrorsExist(1);
			return null;
		}
		if (string.IsNullOrEmpty(realName))
		{
			lastCallInfo = "AddTestAtPosition called with invalid first argument. RealName can't be null or empty";
			lastError = "AddTestAtPosition called with invalid first argument. RealName can't be null or empty";
			qsprInstance.SetErrorsExist(1);
			return null;
		}
		if (newTestName == null)
		{
			lastCallInfo = "AddTestAtPosition called with invalid second argument. NewTestName can't be null";
			lastError = "AddTestAtPosition called with invalid second argument. NewTestName can't be null";
			qsprInstance.SetErrorsExist(1);
			return null;
		}
		if (position < 0 || position > 3)
		{
			lastCallInfo = "AddTestAtPosition called with invalid third argument. Position must be an integer value in the range 0-3";
			lastError = "AddTestAtPosition called with invalid third argument. Position must be an integer value in the range 0-3";
			qsprInstance.SetErrorsExist(1);
			return null;
		}
		lastCallInfo = "AddTestAtPosition(" + realName + ", " + newTestName + ", " + position + ")";
		string text = qsprInstance.AddTest(realName, newTestName, testIndex, position);
		if (text != null)
		{
			TestNode testNode = new TestNode();
			testNode.XttDocument = xttDoc;
			testNode.TestIndex = text;
			testNode.SetAutomationObject(qsprInstance);
			return testNode;
		}
		lastError = "AddTestAtPosition failed";
		qsprInstance.SetErrorsExist(1);
		return null;
	}

	public TestNode CopyTest(string DestinationFolder, string newTestName, int position)
	{
		if (testIndex == null)
		{
			lastCallInfo = "TestNode object is not valid. The index of the node is null.";
			lastError = "TestNode object is not valid. The index of the node is null.";
			qsprInstance.SetErrorsExist(1);
			return null;
		}
		if (DestinationFolder == null)
		{
			lastCallInfo = "CopyTest called with invalid first argument. DestinationFolder can't be null";
			lastError = "CopyTest called with invalid first argument. DestinationFolder can't be null";
			qsprInstance.SetErrorsExist(1);
			return null;
		}
		if (newTestName == null)
		{
			lastCallInfo = "CopyTest called with invalid second argument. NewTestName can't be null";
			lastError = "CopyTest called with invalid second argument. NewTestName can't be null";
			qsprInstance.SetErrorsExist(1);
			return null;
		}
		if (position < 1 || position > 2)
		{
			lastCallInfo = "CopyTest called with invalid third argument. Position must be an integer value in the range 1-2";
			lastError = "CopyTest called with invalid third argument. Position must be an integer value in the range 1-2";
			qsprInstance.SetErrorsExist(1);
			return null;
		}
		lastCallInfo = "CopyTest(" + DestinationFolder + ", " + newTestName + ", " + position + ")";
		string text = qsprInstance.CopyTest(DestinationFolder, newTestName, testIndex, position);
		if (text != null)
		{
			TestNode testNode = new TestNode();
			testNode.XttDocument = xttDoc;
			testNode.TestIndex = text;
			testNode.SetAutomationObject(qsprInstance);
			return testNode;
		}
		lastError = "CopyTest failed";
		qsprInstance.SetErrorsExist(1);
		return null;
	}

	public int CreatePreConditionOnTestParam(string conditionName, string testName, string paramName, int conditionSign, int valueType, object value)
	{
		if (string.IsNullOrEmpty(testIndex))
		{
			lastCallInfo = "TestNode object is invalid. The test index cannot be null or empty.";
			lastError = "TestNode object is invalid. The test index cannot be null or empty.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		if (string.IsNullOrEmpty(conditionName))
		{
			lastCallInfo = "CreatePreConditionOnTestParam called with invalid conditionName. This argument cannot be null or empty.";
			lastError = "CreatePreConditionOnTestParam called with invalid conditionName. This argument cannot be null or empty.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		if (string.IsNullOrEmpty(testName))
		{
			lastCallInfo = "CreatePreConditionOnTestParam called with invalid testName. This argument cannot be null or empty.";
			lastError = "CreatePreConditionOnTestParam called with invalid testName. This argument cannot be null or empty.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		if (string.IsNullOrEmpty(paramName))
		{
			lastCallInfo = "CreatePreConditionOnTestParam called with invalid paramName. This argument cannot be null or empty.";
			lastError = "CreatePreConditionOnTestParam called with invalid paramName. This argument cannot be null or empty.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		if (conditionSign < 0 || conditionSign > 5)
		{
			lastCallInfo = "CreatePreConditionOnTestParam called with invalid conditionSign. This argument must be an integer value in the range 0-5.";
			lastError = "CreatePreConditionOnTestParam called with invalid conditionSign. This argument must be an integer value in the range 0-5.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		switch (valueType)
		{
		default:
			lastCallInfo = "CreatePreConditionOnTestParam called with invalid valueType. This argument must be an integer value in the range 0-3.";
			lastError = "CreatePreConditionOnTestParam called with invalid valueType. This argument must be an integer value in the range 0-3.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		case 0:
			if (value == null)
			{
				lastCallInfo = "CreatePreConditionOnTestParam called with invalid value. This argument must be an integer value in the range 0-2.";
				lastError = "CreatePreConditionOnTestParam called with invalid value. This argument must be an integer value in the range 0-2.";
				qsprInstance.SetErrorsExist(1);
				return 0;
			}
			break;
		case 1:
			if (string.IsNullOrEmpty(value.ToString()))
			{
				lastCallInfo = "CreatePreConditionOnTestParam called with invalid value. This argument cannot be null or empty.";
				lastError = "CreatePreConditionOnTestParam called with invalid value. This argument cannot be null or empty.";
				qsprInstance.SetErrorsExist(1);
				return 0;
			}
			break;
		case 2:
		case 3:
			break;
		}
		lastCallInfo = string.Concat("CreatePreConditionOnTestParam(", conditionName, ", ", testName, ", ", paramName, ", ", conditionSign, ", ", valueType, ", ", value, ")");
		if (qsprInstance.CreateConditionOnTestParam(conditionName, 0, testName, testIndex, paramName, conditionSign, valueType, value))
		{
			return 1;
		}
		lastError = "CreatePreConditionOnTestParam failed";
		qsprInstance.SetErrorsExist(1);
		return 0;
	}

	public int CreatePostConditionOnTestParam(string conditionName, string paramName, int conditionSign, int valueType, object value)
	{
		if (string.IsNullOrEmpty(testIndex))
		{
			lastCallInfo = "TestNode object is invalid. The test index cannot be null or empty.";
			lastError = "TestNode object is invalid. The test index cannot be null or empty.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		if (string.IsNullOrEmpty(conditionName))
		{
			lastCallInfo = "CreatePostConditionOnTestParam called with invalid conditionName. This argument cannot be null or empty.";
			lastError = "CreatePostConditionOnTestParam called with invalid conditionName. This argument cannot be null or empty.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		if (string.IsNullOrEmpty(paramName))
		{
			lastCallInfo = "CreatePostConditionOnTestParam called with invalid paramName. This argument cannot be null or empty.";
			lastError = "CreatePostConditionOnTestParam called with invalid paramName. This argument cannot be null or empty.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		if (conditionSign < 0 || conditionSign > 5)
		{
			lastCallInfo = "CreatePostConditionOnTestParam called with invalid conditionSign. This argument must be an integer value in the range 0-5.";
			lastError = "CreatePostConditionOnTestParam called with invalid conditionSign. This argument must be an integer value in the range 0-5.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		switch (valueType)
		{
		default:
			lastCallInfo = "CreatePostConditionOnTestParam called with invalid valueType. This argument must be an integer value in the range 0-3.";
			lastError = "CreatePostConditionOnTestParam called with invalid valueType. This argument must be an integer value in the range 0-3.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		case 0:
			if (value == null)
			{
				lastCallInfo = "CreatePostConditionOnTestParam called with invalid value. This argument must be an integer value in the range 0-2.";
				lastError = "CreatePostConditionOnTestParam called with invalid value. This argument must be an integer value in the range 0-2.";
				qsprInstance.SetErrorsExist(1);
				return 0;
			}
			break;
		case 1:
			if (string.IsNullOrEmpty(value.ToString()))
			{
				lastCallInfo = "CreatePostConditionOnTestParam called with invalid value. This argument cannot be null or empty.";
				lastError = "CreatePostConditionOnTestParam called with invalid value. This argument cannot be null or empty.";
				qsprInstance.SetErrorsExist(1);
				return 0;
			}
			break;
		case 2:
		case 3:
			break;
		}
		lastCallInfo = string.Concat("CreatePostConditionOnTestParam(", conditionName, ", ", paramName, ", ", conditionSign, ", ", valueType, ", ", value, ")");
		if (qsprInstance.CreateConditionOnTestParam(conditionName, 1, null, testIndex, paramName, conditionSign, valueType, value))
		{
			return 1;
		}
		lastError = "CreatePostConditionOnTestParam failed";
		qsprInstance.SetErrorsExist(1);
		return 0;
	}

	public int CreatePreConditionOnTestResult(string conditionName, string testName, int testResult)
	{
		if (string.IsNullOrEmpty(testIndex))
		{
			lastCallInfo = "TestNode object is invalid. The test index cannot be null or empty.";
			lastError = "TestNode object is invalid. The test index cannot be null or empty.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		if (string.IsNullOrEmpty(conditionName))
		{
			lastCallInfo = "CreatePreConditionOnTestResult called with invalid conditionName. This argument cannot be null or empty.";
			lastError = "CreatePreConditionOnTestResult called with invalid conditionName. This argument cannot be null or empty.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		if (string.IsNullOrEmpty(testName))
		{
			lastCallInfo = "CreatePreConditionOnTestResult called with invalid testName. This argument cannot be null or empty.";
			lastError = "CreatePreConditionOnTestResult called with invalid testName. This argument cannot be null or empty.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		if (testResult != 0 && testResult != 1)
		{
			lastCallInfo = "CreatePreConditionOnTestResult called with invalid testResult. This argument must be an integer value of 0 or 1.";
			lastError = "CreatePreConditionOnTestResult called with invalid testResult. This argument must be an integer value of 0 or 1.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		lastCallInfo = "CreatePreConditionOnTestResult(" + conditionName + ", " + testName + ", " + testResult + ")";
		if (qsprInstance.CreateConditionOnTestResult(conditionName, 0, testName, testIndex, testResult))
		{
			return 1;
		}
		lastError = "CreatePreConditionOnTestResult failed";
		qsprInstance.SetErrorsExist(1);
		return 0;
	}

	public int CreatePostConditionOnTestResult(string conditionName, int testResult)
	{
		if (string.IsNullOrEmpty(testIndex))
		{
			lastCallInfo = "TestNode object is invalid. The test index cannot be null or empty.";
			lastError = "TestNode object is invalid. The test index cannot be null or empty.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		if (string.IsNullOrEmpty(conditionName))
		{
			lastCallInfo = "CreatePostConditionOnTestResult called with invalid conditionName. This argument cannot be null or empty.";
			lastError = "CreatePostConditionOnTestResult called with invalid conditionName. This argument cannot be null or empty.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		if (testResult != 0 && testResult != 1)
		{
			lastCallInfo = "CreatePostConditionOnTestResult called with invalid testResult. This argument must be an integer value of 0 or 1.";
			lastError = "CreatePostConditionOnTestResult called with invalid testResult. This argument must be an integer value of 0 or 1.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		lastCallInfo = "CreatePostConditionOnTestResult(" + conditionName + ", " + testResult + ")";
		if (qsprInstance.CreateConditionOnTestResult(conditionName, 1, null, testIndex, testResult))
		{
			return 1;
		}
		lastError = "CreatePostConditionOnTestResult failed";
		qsprInstance.SetErrorsExist(1);
		return 0;
	}

	public int CreatePreConditionOnGlobal(string conditionName, string globalName, int conditionSign, int valueType, object value)
	{
		if (string.IsNullOrEmpty(testIndex))
		{
			lastCallInfo = "TestNode object is invalid. The test index cannot be null or empty.";
			lastError = "TestNode object is invalid. The test index cannot be null or empty.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		if (string.IsNullOrEmpty(conditionName))
		{
			lastCallInfo = "CreatePreConditionOnGlobal called with invalid conditionName. This argument cannot be null or empty.";
			lastError = "CreatePreConditionOnGlobal called with invalid conditionName. This argument cannot be null or empty.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		if (string.IsNullOrEmpty(globalName))
		{
			lastCallInfo = "CreatePreConditionOnGlobal called with invalid globalName. This argument cannot be null or empty.";
			lastError = "CreatePreConditionOnGlobal called with invalid globalName. This argument cannot be null or empty.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		if (conditionSign < 0 || conditionSign > 5)
		{
			lastCallInfo = "CreatePreConditionOnGlobal called with invalid conditionSign. This argument must be an integer value in the range 0-5.";
			lastError = "CreatePreConditionOnGlobal called with invalid conditionSign. This argument must be an integer value in the range 0-5.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		if (valueType != 0 && valueType != 1)
		{
			lastCallInfo = "CreateCondition called with invalid valueType. This argument must be an integer value of 0 or 1.";
			lastError = "CreateCondition called with invalid valueType. This argument must be an integer value of 0 or 1.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		switch (valueType)
		{
		case 0:
			if (value == null)
			{
				lastCallInfo = "CreatePreConditionOnGlobal called with invalid value. This argument cannot be null or empty.";
				lastError = "CreatePreConditionOnGlobal called with invalid value. This argument cannot be null or empty.";
				qsprInstance.SetErrorsExist(1);
				return 0;
			}
			break;
		case 1:
			if (string.IsNullOrEmpty(value.ToString()))
			{
				lastCallInfo = "CreatePreConditionOnGlobal called with invalid value. This argument cannot be null or empty.";
				lastError = "CreatePreConditionOnGlobal called with invalid value. This argument cannot be null or empty.";
				qsprInstance.SetErrorsExist(1);
				return 0;
			}
			break;
		}
		lastCallInfo = string.Concat("CreatePreConditionOnGlobal(", conditionName, ", ", globalName, ", ", conditionSign, ", ", valueType, ", ", value, ")");
		if (qsprInstance.CreateConditionOnGlobal(conditionName, 0, testIndex, globalName, conditionSign, valueType, value))
		{
			return 1;
		}
		lastError = "CreatePreConditionOnGlobal failed";
		qsprInstance.SetErrorsExist(1);
		return 0;
	}

	public int CreatePostConditionOnGlobal(string conditionName, string globalName, int conditionSign, int valueType, object value)
	{
		if (string.IsNullOrEmpty(testIndex))
		{
			lastCallInfo = "TestNode object is invalid. The test index cannot be null or empty.";
			lastError = "TestNode object is invalid. The test index cannot be null or empty.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		if (string.IsNullOrEmpty(conditionName))
		{
			lastCallInfo = "CreatePostConditionOnGlobal called with invalid conditionName. This argument cannot be null or empty.";
			lastError = "CreatePostConditionOnGlobal called with invalid conditionName. This argument cannot be null or empty.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		if (string.IsNullOrEmpty(globalName))
		{
			lastCallInfo = "CreatePostConditionOnGlobal called with invalid globalName. This argument cannot be null or empty.";
			lastError = "CreatePostConditionOnGlobal called with invalid globalName. This argument cannot be null or empty.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		if (conditionSign < 0 || conditionSign > 5)
		{
			lastCallInfo = "CreatePostConditionOnGlobal called with invalid conditionSign. This argument must be an integer value in the range 0-5.";
			lastError = "CreatePostConditionOnGlobal called with invalid conditionSign. This argument must be an integer value in the range 0-5.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		if (valueType != 0 && valueType != 1)
		{
			lastCallInfo = "CreatePostConditionOnGlobal called with invalid valueType. This argument must be an integer value of 0 or 1.";
			lastError = "CreatePostConditionOnGlobal called with invalid valueType. This argument must be an integer value of 0 or 1.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		switch (valueType)
		{
		case 0:
			if (value == null)
			{
				lastCallInfo = "CreatePostConditionOnGlobal called with invalid value. This argument cannot be null or empty.";
				lastError = "CreatePostConditionOnGlobal called with invalid value. This argument cannot be null or empty.";
				qsprInstance.SetErrorsExist(1);
				return 0;
			}
			break;
		case 1:
			if (string.IsNullOrEmpty(value.ToString()))
			{
				lastCallInfo = "CreatePostConditionOnGlobal called with invalid value. This argument cannot be null or empty.";
				lastError = "CreatePostConditionOnGlobal called with invalid value. This argument cannot be null or empty.";
				qsprInstance.SetErrorsExist(1);
				return 0;
			}
			break;
		}
		lastCallInfo = string.Concat("CreatePostConditionOnGlobal(", conditionName, ", ", globalName, ", ", conditionSign, ", ", valueType, ", ", value, ")");
		if (qsprInstance.CreateConditionOnGlobal(conditionName, 1, testIndex, globalName, conditionSign, valueType, value))
		{
			return 1;
		}
		lastError = "CreatePostConditionOnGlobal failed";
		qsprInstance.SetErrorsExist(1);
		return 0;
	}

	public int AssignPreCondition(string formula, int runWhenConditionMet)
	{
		if (string.IsNullOrEmpty(testIndex))
		{
			lastCallInfo = "TestNode object is invalid. The test index cannot be null or empty.";
			lastError = "TestNode object is invalid. The test index cannot be null or empty.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		if (string.IsNullOrEmpty(formula))
		{
			lastCallInfo = "AssignPreCondition called with invalid Formula. This argument cannot be null or empty.";
			lastError = "AssignPreCondition called with invalid Formula. This argument cannot be null or empty.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		if (runWhenConditionMet != 0 && runWhenConditionMet != 1)
		{
			lastCallInfo = "AssignPreCondition called with invalid RunWhenConditionMet. This argument must be an integer value of 0 or 1.";
			lastError = "AssignPreCondition called with invalid RunWhenConditionMet. This argument must be an integer value of 0 or 1.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		lastCallInfo = "AssignPreCondition(" + formula + ", " + runWhenConditionMet + ")";
		if (qsprInstance.SetCondition(testIndex, 0, formula, runWhenConditionMet, 0, ""))
		{
			return 1;
		}
		lastError = "AssignPreCondition failed";
		qsprInstance.SetErrorsExist(1);
		return 0;
	}

	public int AssignPostCondition(string formula, int runWhenConditionMet, int action, string branchToTestName)
	{
		if (string.IsNullOrEmpty(testIndex))
		{
			lastCallInfo = "TestNode object is invalid. The test index cannot be null or empty.";
			lastError = "TestNode object is invalid. The test index cannot be null or empty.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		if (string.IsNullOrEmpty(formula))
		{
			lastCallInfo = "AssignPostCondition called with invalid Formula. This argument cannot be null or empty.";
			lastError = "AssignPostCondition called with invalid Formula. This argument cannot be null or empty.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		if (runWhenConditionMet != 0 && runWhenConditionMet != 1)
		{
			lastCallInfo = "AssignPostCondition called with invalid RunWhenConditionMet. This argument must be an integer value of 0 or 1.";
			lastError = "AssignPostCondition called with invalid RunWhenConditionMet. This argument must be an integer value of 0 or 1.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		switch (action)
		{
		default:
			lastCallInfo = "AssignPostCondition called with invalid Action. This argument must be an integer value in the range 0-11.";
			lastError = "AssignPostCondition called with invalid Action. This argument must be an integer value in the range 0-11.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		case 11:
			if (string.IsNullOrEmpty(branchToTestName))
			{
				lastCallInfo = "AssignPostCondition called with invalid branchToTestName. This argument cannot be null or empty if Branch is the selected action.";
				lastError = "AssignPostCondition called with invalid branchToTestName. This argument cannot be null or empty if Branch is the selected action.";
				qsprInstance.SetErrorsExist(1);
				return 0;
			}
			break;
		case 0:
		case 1:
		case 2:
		case 3:
		case 4:
		case 5:
		case 6:
		case 7:
		case 8:
		case 9:
		case 10:
			break;
		}
		if (branchToTestName == null)
		{
			branchToTestName = "";
		}
		lastCallInfo = "AssignPostCondition(" + formula + ", " + runWhenConditionMet + ", " + action + ", " + branchToTestName + ")";
		if (qsprInstance.SetCondition(testIndex, 1, formula, runWhenConditionMet, action, branchToTestName))
		{
			return 1;
		}
		lastError = "AssignPostCondition failed";
		qsprInstance.SetErrorsExist(1);
		return 0;
	}

	public int EnablePreCondition(int enableCondition)
	{
		if (string.IsNullOrEmpty(testIndex))
		{
			lastCallInfo = "TestNode object is invalid. The test index cannot be null or empty.";
			lastError = "TestNode object is invalid. The test index cannot be null or empty.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		if (enableCondition != 0 && enableCondition != 1)
		{
			lastCallInfo = "EnablePreCondition called with invalid conditionActive. This argument must be an integer value of 0 or 1.";
			lastError = "EnablePreCondition called with invalid conditionActive. This argument must be an integer value of 0 or 1.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		lastCallInfo = "EnablePreCondition(" + enableCondition + ")";
		if (qsprInstance.SetConditionActive(testIndex, 0, enableCondition))
		{
			return 1;
		}
		lastError = "EnablePreCondition failed";
		qsprInstance.SetErrorsExist(1);
		return 0;
	}

	public int EnablePostCondition(int enableCondition)
	{
		if (string.IsNullOrEmpty(testIndex))
		{
			lastCallInfo = "TestNode object is invalid. The test index cannot be null or empty.";
			lastError = "TestNode object is invalid. The test index cannot be null or empty.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		if (enableCondition != 0 && enableCondition != 1)
		{
			lastCallInfo = "EnablePostCondition called with invalid conditionActive. This argument must be an integer value of 0 or 1.";
			lastError = "EnablePostCondition called with invalid conditionActive. This argument must be an integer value of 0 or 1.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		lastCallInfo = "EnablePostCondition(" + enableCondition + ")";
		if (qsprInstance.SetConditionActive(testIndex, 1, enableCondition))
		{
			return 1;
		}
		lastError = "EnablePostCondition failed";
		qsprInstance.SetErrorsExist(1);
		return 0;
	}

	public int SetTestProperty(string propertyName, object value)
	{
		try
		{
			if (string.IsNullOrEmpty(testIndex))
			{
				lastCallInfo = "TestNode object is invalid. The test index cannot be null or empty.";
				lastError = "TestNode object is invalid. The test index cannot be null or empty.";
				qsprInstance.SetErrorsExist(1);
				return 0;
			}
			if (string.IsNullOrEmpty(propertyName))
			{
				lastCallInfo = "SetTestProperty called with invalid propertyName. This argument cannot be null or empty.";
				lastError = "SetTestProperty called with invalid propertyName. This argument cannot be null or empty.";
				qsprInstance.SetErrorsExist(1);
				return 0;
			}
			if (value == null)
			{
				lastCallInfo = "SetTestProperty called with invalid value. This argument cannot be null.";
				lastError = "SetTestProperty called with invalid value. This argument cannot be null.";
				qsprInstance.SetErrorsExist(1);
				return 0;
			}
			lastCallInfo = "SetTestProperty(" + propertyName + ", " + value.ToString() + ")";
			if (qsprInstance.SetTestProperty(testIndex, propertyName, value))
			{
				return 1;
			}
			lastError = "SetTestProperty failed";
			qsprInstance.SetErrorsExist(1);
		}
		catch (Exception ex)
		{
			lastError = "SetTestProperty failed: " + ex.Message + ex.InnerException;
			qsprInstance.SetErrorsExist(1);
		}
		return 0;
	}

	public int IsValid()
	{
		int result = 1;
		lastCallInfo = "IsValid()";
		if (xttDoc == null || qsprInstance == null)
		{
			return 0;
		}
		return result;
	}

	public int ExportToTextFile(string filePath, int includeProperties, int includeParameters, int includeGlobalVals, int includeNotes, int includeLoop)
	{
		try
		{
			if (string.IsNullOrEmpty(testIndex))
			{
				lastCallInfo = "TestNode object is invalid. The test index cannot be null or empty.";
				lastError = "TestNode object is invalid. The test index cannot be null or empty.";
				qsprInstance.SetErrorsExist(1);
				return 0;
			}
			if (string.IsNullOrEmpty(filePath))
			{
				lastCallInfo = "ExportToTextFile called with invalid filePath. This argument cannot be null or empty.";
				lastError = "ExportToTextFile called with invalid filePath. This argument cannot be null or empty.";
				qsprInstance.SetErrorsExist(1);
				return 0;
			}
			if (includeProperties != 0 && includeProperties != 1)
			{
				lastCallInfo = "ExportToTextFile called with invalid includeProperties. This argument must be an integer value of 0 or 1.";
				lastError = "ExportToTextFile called with invalid includeProperties. This argument must be an integer value of 0 or 1.";
				qsprInstance.SetErrorsExist(1);
				return 0;
			}
			if (includeParameters != 0 && includeParameters != 1)
			{
				lastCallInfo = "ExportToTextFile called with invalid includeParameters. This argument must be an integer value of 0 or 1.";
				lastError = "ExportToTextFile called with invalid includeParameters. This argument must be an integer value of 0 or 1.";
				qsprInstance.SetErrorsExist(1);
				return 0;
			}
			if (includeGlobalVals != 0 && includeGlobalVals != 1)
			{
				lastCallInfo = "ExportToTextFile called with invalid includeGlobalVals. This argument must be an integer value of 0 or 1.";
				lastError = "ExportToTextFile called with invalid includeGlobalVals. This argument must be an integer value of 0 or 1.";
				qsprInstance.SetErrorsExist(1);
				return 0;
			}
			if (includeNotes != 0 && includeNotes != 1)
			{
				lastCallInfo = "ExportToTextFile called with invalid includeNotes. This argument must be an integer value of 0 or 1.";
				lastError = "ExportToTextFile called with invalid includeNotes. This argument must be an integer value of 0 or 1.";
				qsprInstance.SetErrorsExist(1);
				return 0;
			}
			if (includeLoop != 0 && includeLoop != 1)
			{
				lastCallInfo = "ExportToTextFile called with invalid includeLoop. This argument must be an integer value of 0 or 1.";
				lastError = "ExportToTextFile called with invalid includeLoop. This argument must be an integer value of 0 or 1.";
				qsprInstance.SetErrorsExist(1);
				return 0;
			}
			lastCallInfo = "ExportToTextFile(" + filePath + ", " + includeProperties + ", " + includeParameters + ", " + includeGlobalVals + ", " + includeNotes + ", " + includeLoop + ")";
			if (qsprInstance.ExportToTextFile(testIndex, filePath, includeProperties, includeParameters, includeGlobalVals, includeNotes, includeLoop))
			{
				return 1;
			}
			lastError = "ExportToTextFile failed";
			qsprInstance.SetErrorsExist(1);
		}
		catch (Exception ex)
		{
			lastError = "ExportToTextFile failed: " + ex.Message + ex.InnerException;
			qsprInstance.SetErrorsExist(1);
		}
		return 0;
	}

	public int SetTestParameter(string ParamName, object newVal, string lowerLimit, string upperLimit)
	{
		if (ParamName == null || newVal == null)
		{
			lastCallInfo = "SetTestParameter called with one or more null arguments";
			lastError = "SetTestParameter failed, one or more arguments were null";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		if (lowerLimit == null)
		{
			lowerLimit = "";
		}
		if (upperLimit == null)
		{
			upperLimit = "";
		}
		lastCallInfo = "SetTestParameter(" + ParamName + ", " + newVal.ToString() + ", " + lowerLimit + ", " + upperLimit + ")";
		string text = newVal.GetType().Name.ToString();
		string text2 = "";
		if (text.CompareTo("String") == 0)
		{
			text2 = (string)newVal;
		}
		else if (text.CompareTo("Int32") == 0)
		{
			text2 = ((int)newVal).ToString();
		}
		else if (text.CompareTo("Int16") == 0)
		{
			text2 = ((short)newVal).ToString();
		}
		else if (text.CompareTo("Float") == 0)
		{
			text2 = ((float)newVal).ToString();
		}
		else
		{
			if (text.CompareTo("Double") != 0)
			{
				lastError = "SetTestParameter failed, invalid value";
				qsprInstance.SetErrorsExist(1);
				return 0;
			}
			text2 = ((double)newVal).ToString();
		}
		if (!qsprInstance.SetTestParameter(testIndex, ParamName, text2, lowerLimit, upperLimit, isTestIndex: true))
		{
			lastError = "SetTestParameter failed";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		return 1;
	}

	public TestNode CreateFolder(string subFolderName)
	{
		if (string.IsNullOrEmpty(subFolderName))
		{
			lastCallInfo = "CreateFolder was called with a null foldername";
			lastError = "CreateFolder failed, foldername was null";
			qsprInstance.SetErrorsExist(1);
			return null;
		}
		lastCallInfo = "CreateFolder(" + subFolderName + ")";
		string text = qsprInstance.CreateFolder(subFolderName, testIndex, isTestIndex: true);
		if (text != null)
		{
			TestNode testNode = new TestNode();
			testNode.XttDocument = XttDocument;
			testNode.TestIndex = text;
			testNode.SetAutomationObject(qsprInstance);
			return testNode;
		}
		lastError = "Failed to create folder.";
		qsprInstance.SetErrorsExist(1);
		return null;
	}

	public int SetLoopType(int countdownValue, string parameterName, string loopValue, int loopType)
	{
		if (parameterName == null || loopValue == null)
		{
			lastCallInfo = "SetLoopType was called with one or more null arguments";
		}
		else
		{
			lastCallInfo = "SetLoopType(" + countdownValue + ", " + parameterName + ", " + loopValue + ", " + loopType + ")";
		}
		if (loopType < 0 || loopType > 4)
		{
			lastError = "Failed to set loop type, an invalid loop type was specified. This argument must be an integer value in the range 0-4.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		if (!qsprInstance.SetLoopType(testIndex, countdownValue, parameterName, loopValue, loopType, isTestIndex: true, "", ""))
		{
			lastError = "SetLoopType failed";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		return 1;
	}

	public object GetTestParameterValue(string paramName, int convertToString)
	{
		if (paramName == null)
		{
			lastCallInfo = "GetTestParameterValue was called with a null paramName";
			lastError = "GetTestParameterValue failed, the paramName was null";
			qsprInstance.SetErrorsExist(1);
			return null;
		}
		lastCallInfo = "GetTestParameterValue(" + paramName + ", " + convertToString + ")";
		object testParameterValue = qsprInstance.GetTestParameterValue(paramName, testIndex, convertToString);
		if (testParameterValue == null)
		{
			lastError = "GetTestParameterValue failed";
			qsprInstance.SetErrorsExist(1);
		}
		return testParameterValue;
	}

	public int SetTestParamLimit(string ParamName, string LimitValue, int LimitType)
	{
		if (ParamName == null || LimitValue == null)
		{
			lastCallInfo = "SetTestParamLimit was called with one or more null arguments";
			lastError = "SetTestParamLimit failed, one or more arguments were null";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		lastCallInfo = "SetTestParamLimit(" + ParamName + ", " + LimitValue + ", " + LimitType + ")";
		if (!qsprInstance.SetTestParamLimit(testIndex, ParamName, LimitValue, LimitType))
		{
			lastError = "SetTestParamLimit failed";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		return 1;
	}

	public string GetTestParamLimit(string ParamName, int LimitType)
	{
		if (ParamName == null)
		{
			lastCallInfo = "GetTestParamLimit called with null param name";
			lastError = "GetTestParamLimit failed, the ParamName is null";
			qsprInstance.SetErrorsExist(1);
			return "";
		}
		lastCallInfo = "GetTestParamLimit(" + ParamName + " ," + LimitType + ")";
		return qsprInstance.GetTestParamLimit(testIndex, ParamName, LimitType);
	}

	public string GetTestParamUnits(string ParamName)
	{
		if (ParamName == null)
		{
			lastCallInfo = "GetTestParamUnits called with null param name";
			lastError = "GetTestParamUnits failed, the ParamName is null";
			qsprInstance.SetErrorsExist(1);
			return "";
		}
		lastCallInfo = "GetTestParamUnits(" + ParamName + ")";
		return qsprInstance.GetTestParamUnits(testIndex, ParamName);
	}

	public int SetTestParamUnits(string ParamName, string Units)
	{
		if (ParamName == null || Units == null)
		{
			lastCallInfo = "SetTestParamUnits called with one or more null argument";
			lastError = "SetTestParamUnits failed, one or more arguments were null";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		lastCallInfo = "SetTestParamUnits(" + ParamName + "," + Units + ")";
		if (!qsprInstance.SetTestParamUnits(testIndex, ParamName, Units))
		{
			lastError = "SetTestParamUnits failed";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		return 1;
	}

	public object GetTestPropertyValue(string propertyName, int convertToString)
	{
		if (propertyName == null)
		{
			lastCallInfo = "GetTestPropertyValue called with one or more null argument";
			lastError = "GetTestPropertyValue failed, one or more arguments were null";
			qsprInstance.SetErrorsExist(1);
			return null;
		}
		lastCallInfo = "GetTestPropertyValue(" + propertyName + " ," + convertToString + ")";
		object testPropertyValue = qsprInstance.GetTestPropertyValue(propertyName, testIndex, convertToString);
		if (testPropertyValue == null)
		{
			lastError = "GetTestPropertyValue failed";
			qsprInstance.SetErrorsExist(1);
		}
		return testPropertyValue;
	}

	public TestNode GetNextNode()
	{
		if (testIndex == null)
		{
			lastCallInfo = "GetNextNode called for invalid TestNode object.";
			lastError = "GetNextNode failed, the TestNode object is not valid";
			qsprInstance.SetErrorsExist(1);
			return null;
		}
		lastCallInfo = "GetNextNode()";
		string node = qsprInstance.GetNode(testIndex, NextNodePosition.NextNode);
		if (node != null)
		{
			TestNode testNode = new TestNode();
			testNode.XttDocument = xttDoc;
			testNode.TestIndex = node;
			testNode.SetAutomationObject(qsprInstance);
			return testNode;
		}
		return null;
	}

	public TestNode GetFirstChild()
	{
		if (testIndex == null)
		{
			lastCallInfo = "GetFirstChild called for invalid TestNode object.";
			lastError = "GetFirstChild failed, the TestNode object is not valid";
			qsprInstance.SetErrorsExist(1);
			return null;
		}
		lastCallInfo = "GetFirstChild()";
		string node = qsprInstance.GetNode(testIndex, NextNodePosition.FirstChild);
		if (node != null)
		{
			TestNode testNode = new TestNode();
			testNode.XttDocument = xttDoc;
			testNode.TestIndex = node;
			testNode.SetAutomationObject(qsprInstance);
			return testNode;
		}
		return null;
	}

	public TestNode GetLastChild()
	{
		if (testIndex == null)
		{
			lastCallInfo = "GetLastChild called for invalid TestNode object.";
			lastError = "GetLastChild failed, the testNode object is not valid";
			qsprInstance.SetErrorsExist(1);
			return null;
		}
		lastCallInfo = "GetLastChild()";
		string node = qsprInstance.GetNode(testIndex, NextNodePosition.LastChild);
		if (node != null)
		{
			TestNode testNode = new TestNode();
			testNode.XttDocument = xttDoc;
			testNode.TestIndex = node;
			testNode.SetAutomationObject(qsprInstance);
			return testNode;
		}
		return null;
	}

	public TestNode GetPreviousSibling()
	{
		if (testIndex == null)
		{
			lastCallInfo = "GetPreviousSibling called for invalid TestNode object.";
			lastError = "GetPreviousSibling failed, the testNode object is not valid";
			qsprInstance.SetErrorsExist(1);
			return null;
		}
		lastCallInfo = "GetPreviousSibling()";
		string node = qsprInstance.GetNode(testIndex, NextNodePosition.PreviousSibling);
		if (node != null)
		{
			TestNode testNode = new TestNode();
			testNode.XttDocument = xttDoc;
			testNode.TestIndex = node;
			testNode.SetAutomationObject(qsprInstance);
			return testNode;
		}
		return null;
	}

	public TestNode GetNextSibling()
	{
		lastCallInfo = "GetNextSibling()";
		if (testIndex == null)
		{
			lastCallInfo = "GetNextSibling called for invalid TestNode object.";
			lastError = "GetNextSibling failed, the testNode object is not valid";
			qsprInstance.SetErrorsExist(1);
			return null;
		}
		string node = qsprInstance.GetNode(testIndex, NextNodePosition.NextSibling);
		if (node != null)
		{
			TestNode testNode = new TestNode();
			testNode.XttDocument = xttDoc;
			testNode.TestIndex = node;
			testNode.SetAutomationObject(qsprInstance);
			return testNode;
		}
		return null;
	}

	public int IsFolder()
	{
		lastCallInfo = "IsFolder()";
		if (testIndex == null)
		{
			lastCallInfo = "IsFolder called for invalid TestNode object.";
			lastError = "IsFolder failed, the testNode object is not valid";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		return qsprInstance.IsFolder(testIndex);
	}

	public TestNode GetParentFolder()
	{
		if (testIndex == null)
		{
			lastCallInfo = "GetParentFolder called for invalid TestNode object.";
			lastError = "GetParentFolder failed, the testNode object is not valid";
			qsprInstance.SetErrorsExist(1);
			return null;
		}
		lastCallInfo = "GetParentFolder()";
		string parentNode = qsprInstance.GetParentNode(testIndex);
		if (parentNode != null)
		{
			TestNode testNode = new TestNode();
			testNode.XttDocument = xttDoc;
			testNode.TestIndex = parentNode;
			testNode.SetAutomationObject(qsprInstance);
			return testNode;
		}
		return null;
	}

	public string GetLoopNames()
	{
		if (testIndex == null)
		{
			lastCallInfo = "GetLoopNames called for invalid TestNode object.";
			lastError = "GetLoopNames failed, the testNode object is not valid";
			qsprInstance.SetErrorsExist(1);
			return null;
		}
		lastCallInfo = "GetLoopNames()";
		return qsprInstance.GetLoopNames(testIndex);
	}

	public int EnableLoopRow(int rowID, int enableRow)
	{
		lastCallInfo = "EnableLoopRow(" + rowID + ", " + enableRow + ")";
		if (rowID <= 0)
		{
			lastError = "EnableLoopRow failed, the rowID is not valid. Valid values are greater than or equal to 1";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		if (enableRow < 0 || enableRow > 1)
		{
			lastError = "EnableLoopRow failed, enableRow is not valid. Valid values are 0 or 1";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		if (!qsprInstance.EnableLoopRow(testIndex, rowID, enableRow == 1, isTestIndex: true))
		{
			lastError = "EnableLoopRow failed";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		return 1;
	}

	public int SetParamLoop(string paramName, string paramValue, string testToUpdate, string loopName)
	{
		if (paramName == null || paramValue == null || testToUpdate == null || loopName == null)
		{
			lastCallInfo = "SetParamLoop was called with one or more null arguments";
		}
		else
		{
			lastCallInfo = "SetParamLoop(" + paramName + ", " + paramValue + ", " + testToUpdate + ", " + loopName + ")";
		}
		if (testToUpdate == null)
		{
			testToUpdate = "";
		}
		if (loopName == null)
		{
			loopName = "";
		}
		if (!qsprInstance.SetLoopType(testIndex, 0, paramName, paramValue, 3, isTestIndex: true, testToUpdate, loopName))
		{
			lastError = "SetParamLoop failed";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		return 1;
	}

	public string GetLoopRowsEnabled()
	{
		if (testIndex == null)
		{
			lastCallInfo = "GetLoopRowsEnabled called for invalid TestNode object.";
			lastError = "GetLoopRowsEnabled failed, the testNode object is not valid";
			qsprInstance.SetErrorsExist(1);
			return null;
		}
		lastCallInfo = "GetLoopRowsEnabled()";
		return qsprInstance.GetLoopRowsEnabled(testIndex);
	}

	public string GetParamLoopedTestName(string loopName)
	{
		if (testIndex == null)
		{
			lastCallInfo = "GetParamLoopedTestName called for invalid TestNode object.";
			lastError = "GetParamLoopedTestName failed, the testNode object is not valid";
			qsprInstance.SetErrorsExist(1);
			return null;
		}
		if (string.IsNullOrEmpty(loopName))
		{
			lastCallInfo = "GetParamLoopedTestName called for invalid loopName.";
			lastError = "GetParamLoopedTestName failed, the loopName was null or empty.";
			qsprInstance.SetErrorsExist(1);
			return null;
		}
		lastCallInfo = "GetParamLoopedTestName()";
		return qsprInstance.GetParamLoopedTestName(testIndex, loopName);
	}

	public string GetLoopParamName(string loopName)
	{
		if (testIndex == null)
		{
			lastCallInfo = "GetLoopParamName called for invalid TestNode object.";
			lastError = "GetLoopParamName failed, the testNode object is not valid";
			qsprInstance.SetErrorsExist(1);
			return null;
		}
		if (string.IsNullOrEmpty(loopName))
		{
			lastCallInfo = "GetLoopParamName called for invalid loopName.";
			lastError = "GetLoopParamName failed, the loopName was null or empty.";
			qsprInstance.SetErrorsExist(1);
			return null;
		}
		lastCallInfo = "GetLoopParamName()";
		return qsprInstance.GetLoopParamName(testIndex, loopName);
	}

	private int SetTestParamGV(string command, string ParamName, string GvName)
	{
		if (testIndex == null)
		{
			lastCallInfo = command + " called for invalid TestNode object.";
			lastError = command + " failed, the testNode object is not valid";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		if (string.IsNullOrEmpty(ParamName))
		{
			lastCallInfo = command + " called for invalid ParamName.";
			lastError = command + " failed, the ParamName was null or empty.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		if (GvName == null)
		{
			lastCallInfo = command + " called for invalid GvName.";
			lastError = command + " failed, the GvName was null.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		lastCallInfo = command + "()";
		bool flag = false;
		switch (command)
		{
		case "SetTestParamGvGet":
			flag = qsprInstance.SetTestParamGv("Set Test Param GV Get", testIndex, ParamName, GvName);
			break;
		case "SetTestParamGvSet":
			flag = qsprInstance.SetTestParamGv("Set Test Param GV Set", testIndex, ParamName, GvName);
			break;
		case "SetTestParamGvGetLL":
			flag = qsprInstance.SetTestParamGv("Set Test Param GV Get LL", testIndex, ParamName, GvName);
			break;
		case "SetTestParamGvGetUL":
			flag = qsprInstance.SetTestParamGv("Set Test Param GV Get UL", testIndex, ParamName, GvName);
			break;
		}
		if (flag)
		{
			return 1;
		}
		return 0;
	}

	public int SetTestParamGvGet(string ParamName, string GvName)
	{
		return SetTestParamGV("SetTestParamGvGet", ParamName, GvName);
	}

	public int SetTestParamGvSet(string ParamName, string GvName)
	{
		return SetTestParamGV("SetTestParamGvSet", ParamName, GvName);
	}

	public int SetTestParamGvGetLL(string ParamName, string GvName)
	{
		return SetTestParamGV("SetTestParamGvGetLL", ParamName, GvName);
	}

	public int SetTestParamGvGetUL(string ParamName, string GvName)
	{
		return SetTestParamGV("SetTestParamGvGetUL", ParamName, GvName);
	}

	public int EnableLoopValues(string LoopName, string Values, int Enable)
	{
		if (string.IsNullOrEmpty(LoopName))
		{
			lastCallInfo = "EnableLoopValues called with invalid param: LoopName";
			lastError = "EnableLoopValues called with invalid param: LoopName";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		if (string.IsNullOrEmpty(Values))
		{
			lastCallInfo = "EnableLoopValues called with invalid param: Values";
			lastError = "EnableLoopValues called with invalid param: Values";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		if (Enable < 0 || Enable > 1)
		{
			lastCallInfo = "EnableLoopValues called with invalid param: Enable. Value should be 0 or 1.";
			lastError = "EnableLoopValues called with invalid param: Enable. Value should be 0 or 1.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		lastCallInfo = "EnableLoopValues(" + LoopName + "," + Values + "," + Enable + ")";
		if (!qsprInstance.EnableLoopValues(testIndex, LoopName, Values, Enable == 1, isTestIndex: true))
		{
			lastError = "Failed to enable loop values";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		return 1;
	}

	public string GetLoopValues(string LoopName)
	{
		if (string.IsNullOrEmpty(LoopName))
		{
			lastCallInfo = "GetLoopValues called with one or more null arguments: LoopName";
			lastError = "GetLoopValues failed, one or more arguments were null: LoopName";
			qsprInstance.SetErrorsExist(1);
			return "";
		}
		lastCallInfo = "GetLoopValues(" + LoopName + ")";
		return qsprInstance.GetLoopValues(testIndex, LoopName, isTestIndex: true);
	}

	public int EnableDataLogging(int Enable, string ParamName)
	{
		if (ParamName == null)
		{
			lastCallInfo = "EnableDataLogging called with invalid param: ParamName";
			lastError = "EnableDataLogging called with invalid param: ParamName";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		if (Enable < 0 || Enable > 1)
		{
			lastCallInfo = "EnableDataLogging called with invalid param: Enable. Value should be 0 or 1.";
			lastError = "EnableDataLogging called with invalid param: Enable. Value should be 0 or 1.";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		lastCallInfo = "EnableDataLogging(" + Enable + "," + ParamName + ")";
		if (!qsprInstance.EnableDataLogging(testIndex, ParamName, Enable == 1, isTestIndex: true))
		{
			lastError = "Failed to enable data logging";
			qsprInstance.SetErrorsExist(1);
			return 0;
		}
		return 1;
	}

	public string GetLastError()
	{
		return lastError;
	}

	public string LastCallInfo()
	{
		return lastCallInfo;
	}
}
