| SmartTestErrorCaseTParam, T Method (ExpressionFuncTParam, EnumTypeHelperPlaceHolderT, T) |
Creates an instance of
Case class for a specific parameter path to manage errors.
Namespace:
SmartTests
Assembly:
SmartTests (in SmartTests.dll) Version: 1.12.0
Syntax public static Case ErrorCase<TParam, T>(
Expression<Func<TParam, EnumTypeHelperPlaceHolder<T>>> path,
out T value
)
where T : struct, new(), IComparable
Public Shared Function ErrorCase(Of TParam, T As {Structure, New, IComparable}) (
path As Expression(Of Func(Of TParam, EnumTypeHelperPlaceHolder(Of T))),
<OutAttribute> ByRef value As T
) As Case
public:
generic<typename TParam, typename T>
where T : value class, gcnew(), IComparable
static Case^ ErrorCase(
Expression<Func<TParam, EnumTypeHelperPlaceHolder<T>^>^>^ path,
[OutAttribute] T% value
)
static member ErrorCase :
path : Expression<Func<'TParam, EnumTypeHelperPlaceHolder<'T>>> *
value : 'T byref -> 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.
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( ErrorCase( (DateTime date) => date.DayOfWeek.Values( DayOfWeek.Saturday, DayOfWeek.Sunday ), out var value ),
() => DateTimeHelper.IsWeekEnd( GenerateDateOnWeekDay( value ) ) );
Assert.IsTrue( result );
}
See Also