private static IEnumerable <ValidationCase> CreateCorrectCases <TValue>( IEnumerable <TValue> correctValues, IEnumerable <TValue> inccorrectValues, CheckFunctions <TValue> checkFunction) { var emptyStringArray = new string[0]; foreach (var value in correctValues) { var name = checkFunction.functionName + " of " + value; yield return(new ValidationCase(() => checkFunction.StateCheck(value), false, null, null, name + _index++)); yield return(new ValidationCase(() => checkFunction.StateCheckFormat(value, "123 {0}", new object[] { "1" }), false, null, null, name + _index++)); yield return(new ValidationCase(() => checkFunction.ArgumentCheck(value, "arg1"), false, null, null, name + _index++)); yield return(new ValidationCase(() => checkFunction.ArgumentCheckFormat(value, "arg1", "123 {0}", new object[] { "1" }), false, null, null, name + _index++)); } var nonFormatRequirements = checkFunction.RequiredSubstrings; var formatterRequirements = nonFormatRequirements.Concat(new[] { "longMessage formatParameter" }).ToArray(); foreach (var value in inccorrectValues) { var name = checkFunction.functionName + " of " + value; yield return(new ValidationCase(() => checkFunction.StateCheck(value), true, nonFormatRequirements, typeof(InvalidOperationException), name + _index++)); yield return(new ValidationCase(() => checkFunction.StateCheckFormat(value, "longMessage {0}", new object[] { "formatParameter" }), true, formatterRequirements, typeof(InvalidOperationException), name + _index++)); yield return(new ValidationCase(() => checkFunction.ArgumentCheck(value, "arg1"), true, nonFormatRequirements, typeof(ArgumentException), name + _index++)); yield return(new ValidationCase(() => checkFunction.ArgumentCheckFormat(value, "arg1", "longMessage {0}", new object[] { "formatParameter" }), true, formatterRequirements, typeof(ArgumentException), name + _index++)); // invalid input parameters yield return(new ValidationCase(() => checkFunction.StateCheckFormat(value, "longMessage {0}", new object[] { "formatParameter", "formatParameter2" }), true, emptyStringArray, typeof(InvalidOperationException), name + _index++)); yield return(new ValidationCase(() => checkFunction.ArgumentCheck(value, null), true, emptyStringArray, typeof(ArgumentException), name + _index++)); yield return(new ValidationCase(() => checkFunction.ArgumentCheck(value, string.Empty), true, emptyStringArray, typeof(ArgumentException), name + _index++)); yield return(new ValidationCase(() => checkFunction.ArgumentCheckFormat(value, null, "longMessage {0}", new object[] { "formatParameter" }), true, emptyStringArray, typeof(ArgumentException), name + _index++)); yield return(new ValidationCase(() => checkFunction.ArgumentCheckFormat(value, string.Empty, "longMessage {0}", new object[] { "formatParameter" }), true, emptyStringArray, typeof(ArgumentException), name + _index++)); } }