Ejemplo n.º 1
0
        public void Test12_transform()
        {
            string xml = @"
        <collection>
           <validator location='海淀分馆' >
               <patron>
                   <CMIS />
                   <range value='P000001-P999999' />
               </patron>
               <entity>
                   <range value='0000001-9999999' transform='barcode+&quot;tail1&quot;'></range>
               </entity>
               <transform>
                    barcode+'tail2'
               </transform>
           </validator>
        </collection>";

            BarcodeValidator validator = new BarcodeValidator(xml);

            {
                var result = validator.Transform("海淀分馆", "0000001");
                Assert.AreEqual(true, result.OK);
                Assert.AreEqual("entity", result.Type);
                Assert.AreEqual("0000001tail1", result.TransformedBarcode);
                Assert.AreEqual(true, result.Transformed);
            }
        }
Ejemplo n.º 2
0
        public void Test14_transform()
        {
            string xml = @"
        <collection>
           <validator location='海淀分馆' >
               <patron>
                   <CMIS />
                   <range value='P000001-P999999' />
               </patron>
               <entity>
                   <range value='0000001-9999999'></range>
               </entity>
           </validator>
        </collection>";

            BarcodeValidator validator = new BarcodeValidator(xml);

            {
                var result = validator.Transform("海淀分馆", "T0000001");
                Assert.AreEqual(true, result.OK);
                Assert.AreEqual("notMatch", result.ErrorCode);

                Assert.AreEqual(null, result.Type);
                Assert.AreEqual(null, result.TransformedBarcode);
                Assert.AreEqual(false, result.Transformed);
            }
        }
Ejemplo n.º 3
0
        public void Test18_transform()
        {
            string xml = @"
<barcodeValidation>
    <validator location='第三中学'>
        <patron>
            <CMIS />
            <range value='T000001-T999999' />
            <range value='000001-999999' transform='result=&quot;T&quot;+barcode ;' />
        </patron>
        <entity>
            <range value='SZ001-SZ999' />
            <range value='Z001-Z999' transform='result= &quot;S&quot; + barcode ;' />
        </entity>
        <transform>
	        if (barcode.length == 4)
	            result = 'Z' + barcode;
            else if (barcode.length == 5)
                result = barcode;
            else
	            message = '待变换的输入条码号 \''+barcode+'\' 长度不对';
        </transform>
    </validator>
</barcodeValidation>";

            BarcodeValidator validator = new BarcodeValidator(xml);

            {
                var result = validator.Transform("第三中学", "A0001");
                Assert.AreEqual(true, result.OK);
                Assert.AreEqual(null, result.ErrorCode);

                Assert.AreEqual(null, result.Type);
                Assert.AreEqual("A0001", result.TransformedBarcode);
                Assert.AreEqual(true, result.Transformed);
            }
        }
Ejemplo n.º 4
0
        public void Test04()
        {
            string xml = @"
<barcodeValidation>
    <validator location=''>
        <patron>
            <CMIS />
            <range value='000001-009999' />
            <range value='P000001-P999999' />
        </patron>
        <entity>
            <range value='00000001-00999999' />
            <range value='20000001-20999999' />
            <range value='Z00001-Z99999' />
        </entity>
    </validator>
    <validator location='北院*'>
        <patron>
            <CMIS />
            <range value='N0000-N9999' />
            <range value='DZ0000-DZ9999' />
        </patron>
        <entity>
            <range value='BY200000000-BY999999999' />
            <range value='200000000-999999999' transform='result= &quot;BY&quot; + barcode ;' />
        </entity>
    </validator>
    <validator location='中院*'>
        <patron>
            <CMIS />
            <range value='N0000-N9999' />
            <range value='DZ0000-DZ9999' />
        </patron>
        <entity>
            <range value='ZY200000000-ZY999999999' />
            <range value='200000000-999999999' transform='result= &quot;ZY&quot; + barcode ;' />
        </entity>
    </validator>
    <validator location='南院*'>
        <patron>
            <CMIS />
            <range value='N0000-N9999' />
            <range value='DZ0000-DZ9999' />
        </patron>
        <entity>
            <range value='NY200000000-NY999999999' />
            <range value='200000000-999999999' transform='result= &quot;NY&quot; + barcode ;' />
        </entity>
    </validator>
</barcodeValidation>";

            BarcodeValidator validator = new BarcodeValidator(xml);

            {
                var result = validator.Transform("北院", "N9999");
                Assert.AreEqual(true, result.OK);
                Assert.AreEqual("patron", result.Type);
                Assert.AreEqual(false, result.Transformed);
                Assert.AreEqual(null, result.TransformedBarcode);
            }

            /*
             * // 直接匹配
             * {
             *  var result = validator.Validate("北院书库1", "0000001");
             *  Assert.AreEqual(true, result.OK);
             *  Assert.AreEqual("entity", result.Type);
             * }
             *
             * // 这个应该匹配不上
             * {
             *  var result = validator.Validate("南院书库", "0000001");
             *  Assert.AreEqual(false, result.OK);
             *  Assert.AreEqual(null, result.Type);
             * }
             *
             * // 前方一致匹配
             * {
             *  var result = validator.Validate("北院其他库", "0000001");
             *  Assert.AreEqual(true, result.OK);
             *  Assert.AreEqual("entity", result.Type);
             * }
             *
             * // 前方一致匹配
             * {
             *  var result = validator.Validate("北院阅览室", "0000001");
             *  Assert.AreEqual(true, result.OK);
             *  Assert.AreEqual("entity", result.Type);
             * }
             */
        }