using System;
using System.Collections;
using System.Xml.Serialization;

namespace QC.QSPRTreeSchemaLibrary;

[Serializable]
public class FolderTest : BaseTest
{
	public const string FOLDER = "Folder";

	private ArrayList arrayTests = new ArrayList();

	private FolderTestProperties folderProperties = new FolderTestProperties();

	[XmlAttribute("NodeType")]
	public override string NodeType
	{
		get
		{
			return "Folder";
		}
		set
		{
			base.NodeType = value;
		}
	}

	public override TestProperties Properties
	{
		get
		{
			return folderProperties;
		}
		set
		{
			folderProperties = (FolderTestProperties)value;
		}
	}

	public FolderTestProperties FolderProperties
	{
		get
		{
			return folderProperties;
		}
		set
		{
			folderProperties = value;
		}
	}

	[XmlElement(Type = typeof(LabVIEWTest))]
	[XmlElement(Type = typeof(FolderTest))]
	[XmlElement(Type = typeof(ScriptTest))]
	[XmlElement(Type = typeof(BaseTest))]
	[XmlElement(Type = typeof(DotNetTest))]
	[XmlElement(Type = typeof(CTSTest))]
	[XmlElement(Type = typeof(HiveTest))]
	public ArrayList TestList
	{
		get
		{
			return arrayTests;
		}
		set
		{
			arrayTests = value;
		}
	}

	public FolderTest()
	{
	}

	public FolderTest(string name)
		: base(name)
	{
		folderProperties = new FolderTestProperties();
		folderProperties.RealName = "Folder";
		folderProperties.TestName = name;
		folderProperties.StopOnError = StopOnErrorTypes.None;
	}

	internal void GetFolderByNameFromIndex(int startIndex, string folderName, string nodeType, out BaseTest newBaseFolder, out int newbaseFolderIndex)
	{
		newBaseFolder = null;
		newbaseFolderIndex = -1;
		for (newbaseFolderIndex = startIndex; newbaseFolderIndex < TestList.Count; newbaseFolderIndex++)
		{
			BaseTest baseTest = (BaseTest)TestList[newbaseFolderIndex];
			if (baseTest.Properties.TestName == folderName && baseTest.NodeType == nodeType)
			{
				newBaseFolder = baseTest;
				return;
			}
		}
		newBaseFolder = null;
		newbaseFolderIndex = -1;
	}
}
