SmartTestCaseT Method (ExpressionFuncT, Object, Criteria) |
Namespace: SmartTests
Warning: Not all lambda can be used.
It has to have 2 constraints:
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() { // 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 ); }