namespace Prefab.Test;
///
/// Used for determining whether the system is under test or not.
///
public static class Detector
{
///
/// Static constructor for the Detector class.
///
///
/// None.
///
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)));
}
///
/// Gets a value indicating whether the code is currently running in a test.
///
/// true if the code is running in a test; otherwise, false.
public static bool SystemIsUnderTest { get; }
}