Click or drag to resize

SmartTestCaseT Method (ExpressionFuncT, Object, Criteria)

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

Namespace:  SmartTests
Assembly:  SmartTests (in SmartTests.dll) Version: 1.12.0
public static Case Case<T>(
	Expression<Func<T, Object>> path,
	Criteria criteria


Type: System.Linq.ExpressionsExpressionFuncT, Object
An Expression of the path for the created Case.
Type: SmartTestsCriteria
The Criteria for the created Case.

Type Parameters

The type of the parameter

Return Value

Type: Case
The newly created Case.

Warning: Not all lambda can be used.

It has to have 2 constraints:

  1. Valid Parameter Name -
  2. Valid Parameter Type -
  3. Valid Path -
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 );

public void WeekEndTest()
    // You will have a warning because you do not test other days of the week
    var result = RunTest( Case( (DateTime date) => date.DayOfWeek,
                                SmartTest.Enum.Values( out value, DayOfWeek.Saturday, DayOfWeek.Sunday ) ),
                          () => DateTimeHelper.IsWeekEnd( GenerateDateOnWeekDay( value ) ) );

    Assert.IsTrue( result );
See Also