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); }
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); }
static void TestEncodeUII(string uii, string hex) { var bytes = UhfUtility.EncodeUII(uii); byte[] correct = Element.FromHexString(hex); // Assert.AreEqual(0, ByteArray.Compare(correct, bytes)); }
static void TestDecodeUii(string hex, string text) { byte[] source = Element.FromHexString(hex); var result = UhfUtility.DecodeUII(source, 0, source.Length); // Assert.AreEqual(text, result); }
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)); }
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)); }
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); }
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); }
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)); }
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); }
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); }