Class EnvironmentFixture
- Namespace
- FEFF.TestFixtures
- Assembly
- FEFF.TestFixtures.dll
Snapshots the process environment before a test and reverts changes after the test.
public sealed class EnvironmentFixture : IDisposable
- Inheritance
-
EnvironmentFixture
- Implements
- Inherited Members
Remarks
These tests should not be run in parallel; otherwise, an exception will be thrown. xUnit: Consider using the [Collection] attribute on all test classes that will be part of a collection. Tests within the same collection run sequentially.
Constructors
EnvironmentFixture()
Initializes a new instance of EnvironmentFixture and captures the current environment variables.
public EnvironmentFixture()
Remarks
Throws if another instance is already active in the process.
Properties
InitialSnapshot
Gets a snapshot of the environment variables as they were when this fixture was constructed.
public FrozenDictionary<string, string> InitialSnapshot { get; }
Property Value
Methods
Dispose()
Restores all process environment variables to their original state captured during construction.
public void Dispose()
SetEnvironmentVariable(string, string?)
Same as SetEnvironmentVariable(string, string).
This method is used not to forget to instantiate EnvironmentFixture.
public void SetEnvironmentVariable(string variable, string? value)
Parameters
variablestringThe name of the environment variable.
valuestringThe value to set for the environment variable.
Remarks
Underlying SetEnvironmentVariable(string, string) can also be used instead of this.