Esempio n. 1
0
        public void TestCompositeTagSettingAndGettingValue()
        {
            CompositeTestTag tag = new CompositeTestTag(0x1, false, false,
                                                        new ITlvTag[]
            {
                new CompositeTestTag(0x5, true, false,
                                     new ITlvTag[] { new RawTag(0x1, true, false, new byte[] { 0x1, 0x2 }), new RawTag(0x2, true, false, new byte[] { 0x3, 0x4 }) })
            });

            CollectionAssert.AreEqual(new ITlvTag[] { new RawTag(0x1, true, false, new byte[] { 0x1, 0x2 }), new RawTag(0x2, true, false, new byte[] { 0x3, 0x4 }) },
                                      tag.CompositeTestTagValue, "1. Tag child value should be decoded correctly");
            CollectionAssert.AreEqual(new byte[] { 0x45, 0x8, 0x41, 0x2, 0x1, 0x2, 0x42, 0x2, 0x3, 0x4 }, tag.EncodeValue(), "2. Tag value should be encoded correctly");
        }
Esempio n. 2
0
        public void TestEncodeValue()
        {
            CompositeTestTag tag = new CompositeTestTag(new RawTag(0x1, true, false, new byte[] { 0x41, 0x2, 0x1, 0x2, 0x42, 0x2, 0x3, 0x4 }));

            CollectionAssert.AreEqual(new byte[] { 0x41, 0x2, 0x1, 0x2, 0x42, 0x2, 0x3, 0x4 }, tag.EncodeValue(), "Tag should encode value correctly");
        }
Esempio n. 3
0
        public void TestToString()
        {
            CompositeTestTag tag = new CompositeTestTag(0x1, true, true,
                                                        new ITlvTag[]
            {
                new RawTag(0x1, true, false, new byte[] { 0x1, 0x2 }),
                new RawTag(0x2, true, false, new byte[] { 0x3, 0x4 }),
                new CompositeTestTag(0x5, true, false, new ITlvTag[] { new RawTag(0x1, true, false, new byte[] { 8, 9 }) })
            });

            string expected = "TLV[0x1,N,F]:" + Environment.NewLine + "  TLV[0x1,N]:0x0102" + Environment.NewLine + "  TLV[0x2,N]:0x0304" + Environment.NewLine + "  TLV[0x5,N]:" +
                              Environment.NewLine +
                              "    TLV[0x1,N]:0x0809";

            Assert.AreEqual(expected, tag.ToString(), "1. Tag string representation should be correct");

            tag = new CompositeTestTag(new RawTag(tag.Type, tag.NonCritical, tag.Forward, tag.EncodeValue()));

            Assert.AreEqual(expected, tag.ToString(), "2. Tag string representation should be correct");
        }