public void VerifySetupValidationResults() { var expectedErrors = ValidatorSetups .Where(x => !x.Result.IsValid) .SelectMany(x => x.Result.Errors) .ToArray(); ValidationAssert.Errors(expectedErrors); // TODO: Check if this logic is correct for collection expectations. var validViewModelPropertyCombinations = ActualInvocations .Where(x => x.TargetVM != null) .GroupBy(x => new { VM = x.TargetVM, Prop = x.TargetProperty }) .Where(g => !ValidatorSetups .Select(x => new { VM = x.Invocation.TargetVM, Prop = x.Invocation.TargetProperty }) .Contains(g.Key) ); foreach (var item in validViewModelPropertyCombinations) { var target = item.Key.VM; var targetProperty = item.Key.Prop; if (targetProperty != null) { ValidationAssert.IsValid(target, targetProperty); } else { ValidationAssert.ValidViewModelValidationResultIsValid(target); } } var validSetup = ValidatorSetups.Where(x => x.Result.IsValid); foreach (var setup in validSetup) { var target = setup.Invocation.TargetVM; var targetProperty = setup.Invocation.TargetProperty; if (targetProperty != null) { ValidationAssert.IsValid(target, targetProperty); } else { ValidationAssert.ValidViewModelValidationResultIsValid(target); } } }