Example #1
0
        public virtual void testEncodeChoice()
        {
            IEncoder encoder = newEncoder();

            Assert.IsNotNull(encoder);
            Data choice = new Data();

            choice.selectBinary(new TestOCT(new byte[] { (byte)(0xFF) }));
            printEncoded("Choice boxed octet", encoder, choice);
            checkEncoded(encoder, choice, coderTestUtils.createDataChoiceTestOCTBytes());

            choice.selectSimpleType("aaaaaaa");
            printEncoded("Choice string", encoder, choice);
            checkEncoded(encoder, choice, coderTestUtils.createDataChoiceSimpleTypeBytes());

            choice.selectBooleanType(true);
            printEncoded("Choice boolean", encoder, choice);
            checkEncoded(encoder, choice, coderTestUtils.createDataChoiceBooleanBytes());

            choice.selectIntBndType(7);
            printEncoded("Choice boxed int", encoder, choice);
            checkEncoded(encoder, choice, coderTestUtils.createDataChoiceIntBndBytes());

            choice.selectPlain(new TestPRN("bbbbbb"));
            printEncoded("Choice plain", encoder, choice);
            checkEncoded(encoder, choice, coderTestUtils.createDataChoicePlainBytes());

            choice.selectSimpleOctType(new byte[10]);
            printEncoded("Choice simple octet", encoder, choice);
            choice.selectIntType(7);
            printEncoded("Choice simple int", encoder, choice);
        }
Example #2
0
        public virtual void testDecodeChoice()
        {
            IDecoder decoder = newDecoder();

            System.IO.MemoryStream stream = new System.IO.MemoryStream((coderTestUtils.createDataChoicePlainBytes()));
            Data choice = new Data();
            Data val    = decoder.decode <Data>(stream);

            Assert.IsNotNull(val);
            choice.selectPlain(new TestPRN("bbbbbb"));
            checkData(val, choice);

            stream = new System.IO.MemoryStream((coderTestUtils.createDataChoiceSimpleTypeBytes()));
            val    = decoder.decode <Data>(stream);
            Assert.IsNotNull(val);
            choice.selectSimpleType("aaaaaaa");
            checkData(val, choice);

            stream = new System.IO.MemoryStream((coderTestUtils.createDataChoiceTestOCTBytes()));
            val    = decoder.decode <Data>(stream);
            Assert.IsNotNull(val);
            choice.selectBinary(new TestOCT(new byte[] { 0xFF }));
            checkData(val, choice);

            stream = new System.IO.MemoryStream((coderTestUtils.createDataChoiceBooleanBytes()));
            val    = decoder.decode <Data>(stream);
            Assert.IsNotNull(val);
            choice.selectBooleanType(true);
            checkData(val, choice);

            stream = new System.IO.MemoryStream((coderTestUtils.createDataChoiceIntBndBytes()));
            val    = decoder.decode <Data>(stream);
            Assert.IsNotNull(val);
            choice.selectIntBndType(7);
            checkData(val, choice);
        }