internal static void VerifyResults(Tuple<string, string>[] expectedResults, IEnumerable<DbValidationError> actualResults) { Assert.Equal(expectedResults.Count(), actualResults.Count()); foreach (var validationError in actualResults) { Assert.True( expectedResults.SingleOrDefault( r => r.Item1 == validationError.PropertyName && r.Item2 == validationError.ErrorMessage) != null, String.Format( "Unexpected error message '{0}' for property '{1}' not found", validationError.ErrorMessage, validationError.PropertyName)); } }
public string ValidateParms(INakedObjectAdapter nakedObjectAdapter, Tuple<string, INakedObjectAdapter>[] parms) { foreach (NakedObjectValidationMethod validator in ValidateMethods) { Tuple<string, INakedObjectAdapter>[] matches = validator.ParameterNames.Select(name => parms.SingleOrDefault(p => p.Item1.ToLower() == name)).Where(p => p != null).ToArray(); if (matches.Count() == validator.ParameterNames.Count()) { INakedObjectAdapter[] parameters = matches.Select(p => p.Item2).ToArray(); string result = validator.Execute(nakedObjectAdapter, parameters); if (result != null) return result; } else { string actual = parms.Select(s => s.Item1).Aggregate((s, t) => s + " " + t); LogNoMatch(validator, actual); } } return null; }