35 lines
1011 B
C#
35 lines
1011 B
C#
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; }
|
|
} |