Example #1
0
        /// <seealso cref="Encoder.encode(T,OutputStream)">
        /// </seealso>
        public virtual void  testEncodeChoice()
        {
            //UPGRADE_NOTE: There is an untranslated Statement.  Please refer to original code. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1153'"
            IEncoder encoder = newEncoder();

            Assert.NotNull(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.NotNull(val);
            choice.selectPlain(new TestPRN("bbbbbb"));
            checkData(val, choice);

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

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

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

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