Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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();
        }