コード例 #1
0
        /// <summary>
        /// Validations the test multi function paralell.
        /// </summary>
        public void ValidationTest_MultiFunctionParalell()
        {
            string[] testValues = { "abc-1234 10/16/2017" }; //, "def-4567 10/16/2017" };
            string   methods    = " !IsAlpha(0,3) ; IsChar(3, 1, -) ; IsNumeric(5,3) ;";

            methods += "IsInteger(5,3) ; IsMultiByteString() ; GreaterThanEqualInteger(5,1,6);";
            methods += "GreaterThanEqualDate(9,10, 11/1/2017) ; VerifyDateFormat(9,10,MM/dd/yyyy);";
            methods += @"LookInList(0,3, .\lookup.csv);IsBlank();";

            ValidatorRepository validator = new ValidatorRepository();

            validator.LoadLists(methods);

            //   Parallel.ForEach(testValues, testvalue =>
            ///    {
            foreach (var testValue in testValues)
            {
                List <bool> results = new List <bool>();
                foreach (var method in ValidatorRepository.ParseFunctions(methods))
                {
                    var items = ValidatorRepository.ParseParameters(method);
                    results.Add(validator[items.First()](testValue, method));
                }
                Assert.AreEqual(true, results.Take(4).All(a => a == true));
                Assert.AreEqual(true, results.Skip(4).Take(3).All(a => a == false));
                Assert.AreEqual(true, results.Skip(7).Take(1).All(a => a == true));
                Assert.AreEqual(true, results.Skip(8).Take(1).All(a => a == true));
                Assert.AreEqual(true, results.Skip(9).Take(1).All(a => a == false));
            }
            //    });
        }
コード例 #2
0
        //public frmMacroSetup(CompareModel model, DataSourceModel data) : this()
        //{
        //    this.model = model;
        //    this.dataSource = data;
        //    this.listBoxControl2.DataSource = ValidatorRepository.GetFunctionList();
        //}

        /// <summary>
        /// Initializes a new instance of the <see cref="frmMacroSetup"/> class.
        /// </summary>
        /// <param name="model">The model.</param>
        public frmMacroSetup(FieldSchemaModel model) : this()
        {
            this.model = model;
            this.Text  = model.TableName + "\\" + model.Name;
            this.listBoxControl2.DataSource = ValidatorRepository.GetFunctionList();
            this.memoEdit1.Text             = model.GetMacros(); //.ValidationMacros;
        }
コード例 #3
0
 /// <summary>
 /// Refreshes the summary.
 /// </summary>
 public void RefreshSummary()
 {
     gridControl2.DataSource = ValidatorRepository.GetFunctionSummary(dataSource.SelectedSchema().Fields, eventItems);
     gridControl3.DataSource = eventItems.ToList();
     gridControl2.RefreshDataSource();
     gridControl3.RefreshDataSource();
 }
コード例 #4
0
ファイル: Setup.cs プロジェクト: decojs/QvcFluentValidation
        public static void SetupRepositories(
            ValidatorRepository validatorRepository, 
            MapperRepository mapperRepository, 
            IReadOnlyCollection<Type> types)
        {
            Reflection.GetAllValidators(types).ToList()
                .ForEach(p => validatorRepository.AddValidator(p.Key, p.Value));

            Reflection.GetAllValidationConstraintMappers(types).ToList()
                .ForEach(p => mapperRepository.AddMapper(p.Key, p.Value));
        }
コード例 #5
0
        public void ValidationTest_Datatable()
        {
            string path      = @"C:\Users\mcarlucci\Desktop\Tim\";
            string modelFile = "Validation Test Model.xml";
            string xlsFile   = "SmartSolve Extract.xlsx";
            var    temp      = Serializer.DeSerialize <CompareModel>(path + modelFile);

            ExcelDbConnectionStringBuilder builder = new ExcelDbConnectionStringBuilder(path + xlsFile);
            OleDbDataSource dql = new OleDbDataSource(builder.ConnectionString);
            var             ds  = dql.ExecuteQuery(string.Format("select * from [{0}]", temp.Source.SelectedTable));

            ValidatorRepository repo = new ValidatorRepository();

            repo.Execute(ds.Table(), temp.Source.SelectedSchema().Fields);
        }
コード例 #6
0
        /// <summary>
        /// Handles the ItemClick event of the btnExecute control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="DevExpress.XtraBars.ItemClickEventArgs"/> instance containing the event data.</param>
        private void btnExecute_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            try
            {
                Cursor = Cursors.WaitCursor;
                xtraTabControl1.SelectedTabPage = xtraTabPage2;
                //barEditItem2.Visibility = DevExpress.XtraBars.BarItemVisibility.Always;

                ValidatorRepository repo = new ValidatorRepository();
                repo.Validate += Repo_Validate;
                CancellationTokenSource cancelToken = new CancellationTokenSource();

                eventItems = new ConcurrentBag <ValidationEventArgs>();
                gridControl3.DataSource = eventItems;

                QueryBuilder query = this.model.Source.DataSource.GetQueryBuilder();
                query.IncludeVersion = model.Source.IncludeVersions;
                var      select1    = query.BuildSql(model.Source, dataSource.SelectedSchema().Fields.Select(s => s.Name).ToArray(), model.GetSourceIds(), model.GetSourceFilter());
                DateTime qStartTime = DateTime.Now;

                if (dataSource.SelectedSchema().IsCustom)
                {
                    select1 = dataSource.SelectedSchema().Query;
                }

                executionStartTime = DateTime.Now;

                var data1 = model.Source.DataSource.ExecuteQuery(select1, cancelToken.Token);
                this.gridSourceData.DataSource = data1.Table();

                lblQueryElapsed.Caption = "Query: " + new TimeSpan(DateTime.Now.Ticks - qStartTime.Ticks).Duration().ToString();

                repo.Execute(data1.Table(), dataSource.SelectedSchema().Fields);
                RefreshSummary();
                CreateReportSummary();
                lblElapsed.Caption = "Validation: " + new TimeSpan(DateTime.Now.Ticks - executionStartTime.Ticks).Duration().ToString();
                MessageBox.Show("Validation Complete", "Validation Service", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.GetType().Name, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                Cursor = Cursors.Default;
                barEditItem2.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
            }
        }
コード例 #7
0
 public ExpressionValidationResult Validate(IExpression expression)
 {
     return(ValidatorRepository.Validate(expression, this));
 }
コード例 #8
0
 public void Setup()
 {
     _validatorRepo = new ValidatorRepository();
     _validatorRepo.AddValidator(typeof(CommandA), typeof(TestValidator<CommandA>));
     _validatorRepo.AddValidator(typeof(QueryA), typeof(TestValidator<CommandB>));
 }