Click or drag to resize

SmartTestErrorCaseTParam, T Method (ExpressionFuncTParam, INumericTypeT, T)

Creates an instance of Case class for a specific parameter path.

Namespace:  SmartTests
Assembly:  SmartTests (in SmartTests.dll) Version: 1.12.0
Syntax
public static Case ErrorCase<TParam, T>(
	Expression<Func<TParam, INumericType<T>>> path,
	out T value
)
where T : Object, IComparable<T>

Parameters

path
Type: System.Linq.ExpressionsExpressionFuncTParam, INumericTypeT
An Expression of the path and the criteria for the parameter of the method to test.
value
Type: T
One random value from the provided values in the equivalence class.

Type Parameters

TParam
The type of the parameter of the method to test.
T
The type of the parameter

Return Value

Type: Case
The newly created Case.
Remarks

Warning: Not all lambda can be used.

It has to have 2 constraints:

  1. Valid Parameter Name -
  2. Valid Parameter Type -
  3. Valid Path -
Examples
static class IntHelper
{
    public static double Inverse(int n) => 1 / n;
}

...

[Test]
public void IntTest()
{
    Assert.Throws<DivideByZeroException>, () => RunTest( ErrorCase( (int n) => n.Value( 0 ), out var value ),
                                                                    () => IntHelper.Inverse( value ) ));
}
See Also

Reference