예제 #1
0
        public void XmlApplysucessandfailRuleTest()
        {
            //Order order = ExampleUsage.GetOrder();
            string xml = "<root><Country><Id>1</Id><CountryCode>USAmerica</CountryCode>" +
                         "<State><StateCode>NY</StateCode></State></Country><Status></Status></root>";
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(xml);
            Rule rule = Rule.MethodOnChild("Country.CountryCode", "EndsWith", "India") &
                        Rule.Create("Country.State.StateCode", mreOperator.Equal, "TN");

            MRE engine       = new MRE();
            var compiledRule = engine.CompileXmlRule <XmlDocument>(rule);
            var succesrule   = Rule.Create("Status", mreOperator.Equal, "Success");
            var failurerule  = Rule.Create("Status", mreOperator.Equal, "Failed");


            bool passes = compiledRule(doc, "");

            if (passes)
            {
                Helpers.ChangePropertyValue <XmlDocument>(doc, succesrule);
            }
            else
            {
                Helpers.ChangePropertyValue <XmlDocument>(doc, failurerule);
            }

            Assert.IsFalse(passes);
        }
예제 #2
0
        public void JsonrEqualvalueFailTest()
        {
            //Order order = ExampleUsage.GetOrder();
            string json = "{  \"AnnotationId\": \"f573e938-7602-5f07-7d64-f92c162199ff\",\"RecordId\": \"788\",\"PageNumber\": \"90\",  \"ParentId\": \"fdc732ee-4e8d-c930-2d85-14933013998a\"}";

            dynamic data = Json.Decode(json);
            Rule    rule = Rule.Create("PageNumber", mreOperator.Equal, "91") &
                           Rule.Create("RecordId", mreOperator.Equal, "788");

            MRE  engine       = new MRE();
            var  compiledRule = engine.CompileXmlRule <dynamic>(rule);
            bool passes       = compiledRule(data, "");

            Assert.IsFalse(passes);
        }
예제 #3
0
        public void XmlGreaterThanFailTest()
        {
            //Order order = ExampleUsage.GetOrder();
            string xml = "<root><Country><Id>0</Id><CountryCode>USAmerica</CountryCode>" +
                         "<State><StateCode>NY</StateCode></State></Country></root>";
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(xml);
            Rule rule = Rule.Create("Country.Id", mreOperator.GreaterThanOrEqual, 1) &
                        Rule.Create("Country.State.StateCode", mreOperator.Equal, "NY");

            MRE  engine       = new MRE();
            var  compiledRule = engine.CompileXmlRule <XmlDocument>(rule);
            bool passes       = compiledRule(doc, "");

            Assert.IsFalse(passes);
        }
예제 #4
0
        public void XmlEndswithTest()
        {
            //Order order = ExampleUsage.GetOrder();
            string xml = "<root><Country><Id>1</Id><CountryCode>USAmerica</CountryCode>" +
                         "<State><StateCode>NY</StateCode></State></Country></root>";
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(xml);
            Rule rule = Rule.MethodOnChild("Country.CountryCode", "EndsWith", "America") &
                        Rule.Create("Country.State.StateCode", mreOperator.Equal, "NY");

            MRE  engine       = new MRE();
            var  compiledRule = engine.CompileXmlRule <XmlDocument>(rule);
            bool passes       = compiledRule(doc, "");

            Assert.IsTrue(passes);
        }
        public void JsonregexPassFail()
        {
            //Order order = ExampleUsage.GetOrder();
            string json = "{  \"AnnotationId\": \"f573e938-7602-5f07-7d64-f92c162199ff\",\"RecordId\": \"788\",\"PageNumber\": \"90-1\",  \"ParentId\": \"fdc732ee-4e8d-c930-2d85-14933013998a\"}";

            dynamic data = Json.Decode(json);
            Rule    rule = new Rule()
            {
                MemberName = "PageNumber", Operator = "IsMatch", TargetValue = "(?<=\\s|^)\\d+(?=\\s|$)"
            }&
            Rule.Create("RecordId", mreOperator.Equal, "788");

            MRE  engine       = new MRE();
            var  compiledRule = engine.CompileXmlRule <dynamic>(rule);
            bool passes       = compiledRule(data, "");

            Assert.IsFalse(passes);
        }
        public void XmlRegexfailProperties2()
        {
            //Order order = ExampleUsage.GetOrder();
            string xml = "<root><Country><CountryCode>USA</CountryCode>" +
                         "<State><StateCode>NY</StateCode></State><SSN>123-123-3345</SSN></Country></root>";
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(xml);
            Rule rule = new Rule()
            {
                MemberName = "SSN", Operator = "IsMatch", TargetValue = "(^\\d{3}-?\\d{2}-?\\d{4}$|^XXX-XX-XXXX$)"
            }&
            Rule.Create("Country.State.StateCode", mreOperator.Equal, "NY");

            MRE  engine       = new MRE();
            var  compiledRule = engine.CompileXmlRule <XmlDocument>(rule);
            bool passes       = compiledRule(doc, "");

            Assert.IsFalse(passes);
        }