public bool IsValid_FluentValidation() { _fluentValidationValidator.CascadeMode = CascadeMode.Stop; var models = _dataSets[DataSet]; var t = true; for (var i = 0; i < models.Count; ++i) { t = _fluentValidationValidator.Validate(models[i]).IsValid; } return(t); }
public object Reporting_FluentValidation() { var models = _dataSets[DataSet]; var t = new object(); for (var i = 0; i < models.Count; ++i) { var result = _fluentValidationValidator.Validate(models[i]); if (!result.IsValid) { t = result.ToString(); } } return(t); }
public void GlobalSetup() { var fluentValidationValidator = new ComparisonDataSet.FullModelValidator(); var validotValidator = Validator.Factory.Create(ComparisonDataSet.FullModelSpecification); _validotResults = new Dictionary <string, IReadOnlyList <IValidationResult> >() { ["ManyErrors"] = GetValidotResults(ComparisonDataSet.ManyErrorsDataSet), ["HalfErrors"] = GetValidotResults(ComparisonDataSet.HalfErrorsDataSet), ["NoErrors"] = GetValidotResults(ComparisonDataSet.NoErrorsDataSet), }; _fluentValidationResults = new Dictionary <string, IReadOnlyList <ValidationResult> >() { ["ManyErrors"] = GetFluentValidationResults(ComparisonDataSet.ManyErrorsDataSet), ["HalfErrors"] = GetFluentValidationResults(ComparisonDataSet.HalfErrorsDataSet), ["NoErrors"] = GetFluentValidationResults(ComparisonDataSet.NoErrorsDataSet), }; IReadOnlyList <IValidationResult> GetValidotResults(IReadOnlyList <ComparisonDataSet.FullModel> models) => models.Select(m => validotValidator.Validate(m)).ToList(); IReadOnlyList <ValidationResult> GetFluentValidationResults(IReadOnlyList <ComparisonDataSet.FullModel> models) => models.Select(m => fluentValidationValidator.Validate(m)).ToList(); }