Added detector that checks if code is being run via unit test
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace QuestPDF.Previewer;
|
||||
|
||||
internal static class UnitTestDetector
|
||||
{
|
||||
public static bool RunningInUnitTest { get; }
|
||||
|
||||
private static string[] UnitTestAssemblies = { "xunit", "nunit", "mstest" };
|
||||
|
||||
static UnitTestDetector()
|
||||
{
|
||||
RunningInUnitTest = AppDomain
|
||||
.CurrentDomain
|
||||
.GetAssemblies()
|
||||
.Select(x => x.FullName.ToLowerInvariant())
|
||||
.Any(x => UnitTestAssemblies.Any(x.Contains));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user