Ejemplo n.º 1
0
        public void testConvertingFromANumber()
        {
            SECSItemFormatCode formatCode;

            /*
             * Test the codes that are supposed to be there.
             */
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)0x00);
            Assert.IsTrue(formatCode == SECSItemFormatCode.L);

            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)0x08);
            Assert.IsTrue(formatCode == SECSItemFormatCode.B);

            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)0x09);
            Assert.IsTrue(formatCode == SECSItemFormatCode.BO);

            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)0x10);
            Assert.IsTrue(formatCode == SECSItemFormatCode.A);

            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)0x11);
            Assert.IsTrue(formatCode == SECSItemFormatCode.J8);

            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)0x12);
            Assert.IsTrue(formatCode == SECSItemFormatCode.C2);

            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)0x18);
            Assert.IsTrue(formatCode == SECSItemFormatCode.I8);

            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)0x19);
            Assert.IsTrue(formatCode == SECSItemFormatCode.I1);

            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)0x1A);
            Assert.IsTrue(formatCode == SECSItemFormatCode.I2);

            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)0x1C);
            Assert.IsTrue(formatCode == SECSItemFormatCode.I4);

            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)0x20);
            Assert.IsTrue(formatCode == SECSItemFormatCode.F8);

            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)0x24);
            Assert.IsTrue(formatCode == SECSItemFormatCode.F4);

            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)0x28);
            Assert.IsTrue(formatCode == SECSItemFormatCode.U8);

            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)0x29);
            Assert.IsTrue(formatCode == SECSItemFormatCode.U1);

            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)0x2A);
            Assert.IsTrue(formatCode == SECSItemFormatCode.U2);

            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)0x2C);
            Assert.IsTrue(formatCode == SECSItemFormatCode.U4);

            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)0x3E);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);

            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)0x3F);
            Assert.IsTrue(formatCode == SECSItemFormatCode.HeaderOnly);

            /*
             * Now we need to verify that we do not get a legitimate code from empty
             * elements in the table.
             *
             * Yes, yes, it will blow up if a number is specified that is out of
             * bounds, but, deal with it.
             */
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)1);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)2);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)3);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)4);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)5);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)6);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)7);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)10);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)11);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)12);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)13);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)14);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)15);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)19);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)20);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)21);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)22);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)23);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)27);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)29);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)30);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)31);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)33);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)34);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)35);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)37);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)38);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)39);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)43);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)45);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)46);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)47);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)48);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)49);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)50);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)51);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)52);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)53);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)54);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)55);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)56);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)57);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)58);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)59);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)60);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)61);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
            formatCode = SECSItemFormatCodeFunctions.GetSECSItemFormatCodeFromNumber((byte)62);
            Assert.IsTrue(formatCode == SECSItemFormatCode.UNDEFINED);
        }