Class Mode
- Namespace
- Splat.ModeDetection
- Assembly
- Splat.dll
Represents an application mode that indicates whether the code is running under a unit test runner or in normal execution.
public sealed class Mode : IModeDetector
- Inheritance
-
Mode
- Implements
- Extension Methods
Remarks
Use the predefined Run and Test instances to distinguish between standard execution and test environments. This type is typically used to alter behavior based on the current execution context, such as enabling test-specific logic or bypassing certain runtime checks during automated testing.
Fields
Run
The default implementation of the run mode.
public static readonly Mode Run
Field Value
Test
The default implementation of the test mode.
public static readonly Mode Test
Field Value
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.