| 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>
Public Shared Function Case(Of TParam, T As {Object, IComparable(Of T)}) (
path As Expression(Of Func(Of TParam, INumericType(Of T))),
<OutAttribute> ByRef value As T,
ParamArray avoidedValues As T()
) As Case
public:
generic<typename TParam, typename T>
where T : Object, IComparable<T>
static Case^ Case(
Expression<Func<TParam, INumericType<T>^>^>^ path,
[OutAttribute] T% value,
... array<T>^ avoidedValues
)
static member Case :
path : Expression<Func<'TParam, INumericType<'T>>> *
value : 'T byref *
avoidedValues : 'T[] -> Case when 'T : Object and 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:
CaseThe newly created
Case.
Remarks Warning: Not all lambda can be used.
It has to have 2 constraints:
- Valid Parameter Name -
- Valid Parameter Type -
- 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