Click or drag to resize

SmartTestCaseTParam, T Method (ExpressionFuncTParam, INumericTypeT, T, 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 Case<TParam, T>(
	Expression<Func<TParam, INumericType<T>>> path,
	out T value,
	params T[] avoidedValues
)
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.
avoidedValues
Type: T
A value to avoid in the range. For example, when testing a property setter with a different value, you do not want the value to be the current value, even if it is within the tested range.

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()
{
    var result = RunTest( Case( (int n) => n.Below( 0 ).Above( 0 ), out var value ),
                          () => IntHelper.Inverse( value ) );

    Assert.AreEqual( 1 / value, result );
}
See Also

Reference