using System.Collections.Generic;

namespace QC.QsprTestObjects.Tests.Base;

public static class FolderTestExtensions
{
	public static bool ContainsTest(this FolderTest folder, BaseTest test)
	{
		foreach (BaseTest test2 in folder.TestList)
		{
			if (test == test2)
			{
				return true;
			}
			if (test2 is FolderTest && (test2 as FolderTest).ContainsTest(test))
			{
				return true;
			}
		}
		return false;
	}

	public static bool ContainsTest(this FolderTest folder, List<BaseTest> tests)
	{
		foreach (BaseTest test in tests)
		{
			if (folder.ContainsTest(test))
			{
				return true;
			}
		}
		return false;
	}

	public static bool IsInSetupFolder(this BaseTest test)
	{
		if (test is FolderTest && ((FolderTest)test).FolderProperties.IsSetupFolder)
		{
			return true;
		}
		if (test.Parent != null && test.Parent.IsInSetupFolder())
		{
			return true;
		}
		return false;
	}

	public static bool IsInCleanupFolder(this BaseTest test)
	{
		if (test is FolderTest && ((FolderTest)test).FolderProperties.IsCleanupFolder)
		{
			return true;
		}
		if (test.Parent != null && test.Parent.IsInCleanupFolder())
		{
			return true;
		}
		return false;
	}
}
