This commit is contained in:
2025-10-27 17:39:18 -04:00
commit 31f723bea4
1579 changed files with 642409 additions and 0 deletions

35
Prefab/Test/Detector.cs Normal file
View File

@@ -0,0 +1,35 @@
namespace Prefab.Test;
/// <summary>
/// Used for determining whether the system is under test or not.
/// </summary>
public static class Detector
{
/// <summary>
/// Static constructor for the Detector class.
/// </summary>
/// <returns>
/// None.
/// </returns>
static Detector()
{
var testAssemblyNames = new[]
{
"Microsoft.TestPlatform",
"xunit.core",
"xunit.assert",
"xunit.extensibility.core",
"xunit.extensibility.execution",
"nunit.framework"
};
SystemIsUnderTest = AppDomain.CurrentDomain.GetAssemblies()
.Any(a => testAssemblyNames.Any(t => a.FullName != null && a.FullName.StartsWith(t)));
}
/// <summary>
/// Gets a value indicating whether the code is currently running in a test.
/// </summary>
/// <returns>true if the code is running in a test; otherwise, false.</returns>
public static bool SystemIsUnderTest { get; }
}