PexChoose
Static class which supplies auxiliary input values to a test, which can be used to implement
Parameterized Mocks.
The
PexChoose class does not help in determining whether a test passes for particular input values, or fails.
PexChoose simply provides input values, which we also call
choices. It is still up to the user to restrict the input values, and to write assertions to define when a test passes or fails.)
Modes of operation
The
PexChoose class can operate in two modes:
- While Pex is performing a symbolic analysis of the test and the tested code during Input Generation, the chooser returns arbitrary values, and Pex tracks how the value is used in the test and the tested code. Pex will generate relevant values to trigger different execution paths in the test and the tested code.
- The generated code for particular test cases sets up the choice provider in a specific way, so that the reexecution of such a test case will make particular choices to trigger a particular execution path.
Usage
- Simple call PexChoose.Value<T> to a new value from Pex.
public int Foo() {
return PexChoose.Value<int>("foo");
}
See Also
Parameterized Mocks