| SmartTestCaseTParam, T Method (ExpressionFuncTParam, EnumTypeHelperPlaceHolderT, 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, EnumTypeHelperPlaceHolder<T>>> path,
out T value,
params T[] avoidedValues
)
where T : struct, new(), IComparable
Public Shared Function Case(Of TParam, T As {Structure, New, IComparable}) (
path As Expression(Of Func(Of TParam, EnumTypeHelperPlaceHolder(Of T))),
<OutAttribute> ByRef value As T,
ParamArray avoidedValues As T()
) As Case
public:
generic<typename TParam, typename T>
where T : value class, gcnew(), IComparable
static Case^ Case(
Expression<Func<TParam, EnumTypeHelperPlaceHolder<T>^>^>^ path,
[OutAttribute] T% value,
... array<T>^ avoidedValues
)
static member Case :
path : Expression<Func<'TParam, EnumTypeHelperPlaceHolder<'T>>> *
value : 'T byref *
avoidedValues : 'T[] -> Case when 'T : struct, new() and IComparable
Parameters
- path
- Type: System.Linq.ExpressionsExpressionFuncTParam, EnumTypeHelperPlaceHolderT
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 DateTimeHelper
{
public static bool IsWeekEnd(DateTime date)
{
return date.DayOfWeek == DayOfWeek.Saturday ||
date.DayOfWeek == DayOfWeek.Sunday;
}
}
...
private static DateTime GenerateDateOnWeekDay( DayOfWeek day )
{
var result = DateTime.Now;
return result.AddDays( day - result.DayOfWeek );
}
[Test]
public void WeekEndTest()
{
var result = RunTest( Case( (DateTime date) => date.DayOfWeek.Values( DayOfWeek.Saturday, DayOfWeek.Sunday ), out var value ),
() => DateTimeHelper.IsWeekEnd( GenerateDateOnWeekDay( value ) ) );
Assert.IsTrue( result );
}
See Also Reference
SmartTestCaseTParam, T(ExpressionFuncTParam, EnumTypeHelperPlaceHolderT, T, T)