Class DefaultModeDetector
- Namespace
- Splat
- Assembly
- Splat.dll
Provides a default implementation for detecting whether the current process is running within a unit test environment.
public class DefaultModeDetector : IModeDetector, IEnableLogger
- Inheritance
-
DefaultModeDetector
- Implements
-
IEnableLogger
- Extension Methods
Remarks
This class uses a combination of environment variable checks, process name heuristics, and assembly scanning to determine if the application is executing under a known test runner. It is intended for use in scenarios where behavior should change when running under test conditions, such as enabling test-specific features or diagnostics. The detection logic prioritizes explicit signals and is designed to minimize performance impact by avoiding unnecessary allocations and expensive operations where possible.
Constructors
DefaultModeDetector()
public DefaultModeDetector()
Methods
InUnitTestRunner()
Determines whether the current process is running within a recognized unit test runner environment.
public bool? InUnitTestRunner()
Returns
- bool?
true if the process is running under a supported unit test runner; false if it is not; or null if the detection could not be performed.
Remarks
This method can be used to alter behavior when running under test conditions, such as skipping certain operations or enabling test-specific logic. The result may be null if the environment cannot be reliably detected, so callers should account for this possibility.