Init
This commit is contained in:
35
Prefab/Test/Detector.cs
Normal file
35
Prefab/Test/Detector.cs
Normal 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; }
|
||||
}
|
||||
Reference in New Issue
Block a user