Example #1
0
File: TestUHF.cs Project: zgren/dp2
        public void Test_splitSegment_1()
        {
            var segments = UhfUtility.SplitSegment("123456789");

            Assert.AreEqual(1, segments.Count);
            Assert.AreEqual("digit", segments[0].Type);
            Assert.AreEqual("123456789", segments[0].Text);
        }
Example #2
0
File: TestUHF.cs Project: zgren/dp2
        public void Test_splitSegment_7()
        {
            var segments = UhfUtility.SplitSegment("78.");

            Assert.AreEqual(1, segments.Count);
            Assert.AreEqual("table", segments[0].Type);
            Assert.AreEqual("78.", segments[0].Text);
        }
Example #3
0
File: TestUHF.cs Project: zgren/dp2
        static void TestEncodeUII(string uii, string hex)
        {
            var bytes = UhfUtility.EncodeUII(uii);

            byte[] correct = Element.FromHexString(hex);

            //
            Assert.AreEqual(0, ByteArray.Compare(correct, bytes));
        }
Example #4
0
File: TestUHF.cs Project: zgren/dp2
        static void TestDecodeUii(string hex, string text)
        {
            byte[] source = Element.FromHexString(hex);

            var result = UhfUtility.DecodeUII(source, 0, source.Length);

            //
            Assert.AreEqual(text, result);
        }
Example #5
0
File: TestUHF.cs Project: zgren/dp2
        public void Test_encode_uii_3()
        {
            var bytes = UhfUtility.EncodeUII("B.A12312345678");

            byte[] correct = Element.FromHexString(
                @"10 E2 FB 21 02 DD DF 7C 4E");

            //
            Assert.AreEqual(0, ByteArray.Compare(correct, bytes));
        }
Example #6
0
File: TestUHF.cs Project: zgren/dp2
        public void Test_encode_uii_2()
        {
            var bytes = UhfUtility.EncodeUII("CH-000134-1.12345678.31");

            byte[] correct = Element.FromHexString(
                @"141c c04f c70b adb5 c6e2 da1d ed4d d319");

            //
            Assert.AreEqual(0, ByteArray.Compare(correct, bytes));
        }
Example #7
0
File: TestUHF.cs Project: zgren/dp2
        public void Test_decode_longNumericString()
        {
            byte[] source = Element.FromHexString(
                @"FB 21 02 DD DF 7C 4E");
            string result = UhfUtility.DecodeLongNumericString(source, 0, out int used);

            //
            Assert.AreEqual("12312345678", result);
            Assert.AreEqual(source.Length, used);
        }
Example #8
0
File: TestUHF.cs Project: zgren/dp2
        public void Test_decode_uii_2()
        {
            byte[] source = Element.FromHexString(
                @"141c c04f c70b adb5 c6e2 da1d ed4d d319");

            var result = UhfUtility.DecodeUII(source, 0, source.Length);

            //
            Assert.AreEqual("CH-000134-1.12345678.31", result);
        }
Example #9
0
File: TestUHF.cs Project: zgren/dp2
        public void Test_encode_longNumericString()
        {
            // 以 long numeric string 方式编码一个数字字符串
            var bytes = UhfUtility.EncodeLongNumericString("12312345678");

            byte[] correct = Element.FromHexString(
                @"FB 21 02 DD DF 7C 4E");

            //
            Assert.AreEqual(0, ByteArray.Compare(correct, bytes));
        }
Example #10
0
File: TestUHF.cs Project: zgren/dp2
        public void Test_splitSegment_4()
        {
            var segments = UhfUtility.SplitSegment("123456789AB.");

            Assert.AreEqual(2, segments.Count);

            Assert.AreEqual("digit", segments[0].Type);
            Assert.AreEqual("123456789", segments[0].Text);

            Assert.AreEqual("table", segments[1].Type);
            Assert.AreEqual("AB.", segments[1].Text);
        }
Example #11
0
File: TestUHF.cs Project: zgren/dp2
        public void Test_splitSegment_6()
        {
            var segments = UhfUtility.SplitSegment("1234中国56789");

            Assert.AreEqual(3, segments.Count);

            Assert.AreEqual("table", segments[0].Type);
            Assert.AreEqual("1234", segments[0].Text);

            Assert.AreEqual("utf8-triple-byte", segments[1].Type);
            Assert.AreEqual("中国", segments[1].Text);

            Assert.AreEqual("table", segments[2].Type);
            Assert.AreEqual("56789", segments[2].Text);
        }