public void ArrayInArrayTest()
        {
            var val = new GTXValue();

            val.Choice = GTXValueChoice.Array;
            val.Array  = new System.Collections.Generic.List <GTXValue>();

            var innerVal = new GTXValue();

            innerVal.Choice = GTXValueChoice.Array;
            innerVal.Array  = new System.Collections.Generic.List <GTXValue>();

            var innerInnerVal = new GTXValue();

            innerInnerVal.Choice  = GTXValueChoice.Integer;
            innerInnerVal.Integer = Int64.MinValue;
            innerVal.Array.Add(innerInnerVal);

            val.Array.Add(innerVal);

            if (PRINT_CONTENT)
            {
                var str = PostchainUtil.ByteArrayToString(val.Encode());
                System.Console.WriteLine("ArrayInArrayTest: " + str.ToUpper());
            }

            var decoded = GTXValue.Decode(new AsnReader(val.Encode()));

            Assert.Equal(val.Choice, decoded.Choice);
            Assert.Equal(val.Array, decoded.Array);
            Assert.Equal(val, decoded);
        }
        public static DictPair Decode(ASN1.AsnReader sequence)
        {
            var dict         = new DictPair();
            var dictSequence = sequence.ReadSequence();

            dict.Name  = dictSequence.ReadUTF8String();
            dict.Value = GTXValue.Decode(dictSequence);

            return(dict);
        }
        public void FullArrayTest()
        {
            var val = new GTXValue();

            val.Choice = GTXValueChoice.Array;
            val.Array  = new System.Collections.Generic.List <GTXValue>();

            var innerVal1 = new GTXValue();

            innerVal1.Choice = GTXValueChoice.String;
            innerVal1.String = "test";
            val.Array.Add(innerVal1);

            var innerVal2 = new GTXValue();

            innerVal2.Choice = GTXValueChoice.Null;
            val.Array.Add(innerVal2);

            var innerVal3 = new GTXValue();

            innerVal3.Choice  = GTXValueChoice.Integer;
            innerVal3.Integer = Int64.MaxValue;
            val.Array.Add(innerVal3);

            var innerVal4 = new GTXValue();

            innerVal4.Choice    = GTXValueChoice.ByteArray;
            innerVal4.ByteArray = new byte[] { 0xde, 0xad, 0xbe, 0xef };
            val.Array.Add(innerVal4);

            var innerVal5 = new GTXValue();

            innerVal5.Choice = GTXValueChoice.Array;
            innerVal5.Array  = new System.Collections.Generic.List <GTXValue>();
            val.Array.Add(innerVal5);

            if (PRINT_CONTENT)
            {
                var str = PostchainUtil.ByteArrayToString(val.Encode());
                System.Console.WriteLine("FullArrayTest: " + str.ToUpper());
            }

            var decoded = GTXValue.Decode(new AsnReader(val.Encode()));

            Assert.Equal(val.Choice, decoded.Choice);
            Assert.Equal(val.Array, decoded.Array);
            Assert.Equal(val, decoded);
        }
Esempio n. 4
0
        public void SimpleNullTest()
        {
            var val = new GTXValue();

            val.Choice = GTXValueChoice.Null;

            if (PRINT_CONTENT)
            {
                var str = PostchainUtil.ByteArrayToString(val.Encode());
                System.Console.WriteLine("SimpleNullTest: " + str.ToUpper());
            }

            var decoded = GTXValue.Decode(new AsnReader(val.Encode()));

            Assert.Equal(val.Choice, decoded.Choice);
            Assert.Equal(val, decoded);
        }
Esempio n. 5
0
        public void MinIntegerTest()
        {
            var val = new GTXValue();

            val.Choice  = GTXValueChoice.Integer;
            val.Integer = Int64.MinValue;

            if (PRINT_CONTENT)
            {
                var str = PostchainUtil.ByteArrayToString(val.Encode());
                System.Console.WriteLine("MinIntegerTest: " + str.ToUpper());
            }

            var decoded = GTXValue.Decode(new AsnReader(val.Encode()));

            Assert.Equal(val.Choice, decoded.Choice);
            Assert.Equal(val.Integer, decoded.Integer);
            Assert.Equal(val, decoded);
        }
Esempio n. 6
0
        public void LongStringTest()
        {
            var val = new GTXValue();

            val.Choice = GTXValueChoice.String;
            val.String = new string('x', 2048);

            if (PRINT_CONTENT)
            {
                var str = PostchainUtil.ByteArrayToString(val.Encode());
                System.Console.WriteLine("LongStringTest: " + str.ToUpper());
            }

            var decoded = GTXValue.Decode(new AsnReader(val.Encode()));

            Assert.Equal(val.Choice, decoded.Choice);
            Assert.Equal(val.String, decoded.String);
            Assert.Equal(val, decoded);
        }