コード例 #1
0
ファイル: RuleAdmin.cs プロジェクト: srahaeasyclinic/VPC-CODE
        bool IRuleAdmin.Create(Guid tenantId, RuleInfo ruleInfo, ref string strMsg)
        {
            var lstSource = ruleInfo.SourceList;

            ruleInfo.Source = Newtonsoft.Json.JsonConvert.SerializeObject(lstSource);
            var lstTarget = ruleInfo.TargetList;

            ruleInfo.Target = Newtonsoft.Json.JsonConvert.SerializeObject(lstTarget);
            ruleInfo.Id     = Guid.NewGuid();
            return(dataRule.Create(tenantId, ruleInfo, ref strMsg));
        }
コード例 #2
0
        public void NotADataRow()
        {
            Order order = ExampleUsage.GetOrder();
            Rule  rule  = DataRule.Create <int>("Customer", mreOperator.Equal, "123");

            MRE  engine = new MRE();
            var  c1_123 = engine.CompileRule <Order>(rule);
            bool passes = c1_123(order);

            Assert.IsTrue(false);       // should not get here.
        }
コード例 #3
0
ファイル: DataRowTest.cs プロジェクト: mddos/MicroRuleEngine
        public void DataRowTest()
        {
            var dr = GetDataRow();

            Rule rule = DataRule.Create <int>("Column2", mreOperator.Equal, "123") & DataRule.Create <string>("Column1", mreOperator.Equal, "Test");

            MRE  engine = new MRE();
            var  c1_123 = engine.CompileRule <DataRow>(rule);
            bool passes = c1_123(dr);

            Assert.IsTrue(passes);

            dr["Column2"] = 456;
            dr["Column1"] = "Hello";
            passes        = c1_123(dr);
            Assert.IsFalse(passes);
        }
コード例 #4
0
        public void DataRowTest_RuntimeType()
        {
            var dt = CreateEmptyDataTable();

            Rule rule = DataRule.Create("Column2", MreOperator.Equal, 123, dt.Columns["Column2"].DataType);

            Mre engine = new Mre();
            var c1123  = engine.CompileRule <DataRow>(rule);

            var  dr     = GetDataRow(dt);
            bool passes = c1123(dr);

            Assert.IsTrue(passes);

            dr["Column2"] = 456;
            dr["Column1"] = "Hello";
            passes        = c1123(dr);
            Assert.IsFalse(passes);
        }
コード例 #5
0
        public void DataRowTest_DBNull()
        {
            Rule rule = DataRule.Create <int?>("Column2", MreOperator.Equal, (int?)null) &
                        DataRule.Create <string>("Column1", MreOperator.Equal, null);

            Mre engine = new Mre();
            var c1123  = engine.CompileRule <DataRow>(rule);

            var dt = CreateEmptyDataTable();
            var dr = GetDataRowDbNull(dt);

            bool passes = c1123(dr);

            Assert.IsTrue(passes);

            dr["Column2"] = 456;
            dr["Column1"] = "Hello";
            passes        = c1123(dr);
            Assert.IsFalse(passes);
        }