Beispiel #1
0
        public virtual void testDecodeOID()
        {
            IDecoder decoder = newDecoder();

            Assert.IsNotNull(decoder);

            System.IO.MemoryStream stream = new System.IO.MemoryStream(coderTestUtils.createTestOID1Bytes());
            ObjectIdentifier       oid1   = decoder.decode <ObjectIdentifier>(stream);

            System.Console.Out.WriteLine("Decoded by " + decoder.ToString() + " (OID " + oid1.Value + ") : " + ByteTools.byteArrayToHexString(stream.ToArray()));
            Assert.AreEqual(oid1.Value, coderTestUtils.createTestOID1().Value.Value);

            stream = new System.IO.MemoryStream(coderTestUtils.createTestOID1Bytes());
            TestOID oid1_boxed = decoder.decode <TestOID>(stream);

            Assert.AreEqual(oid1_boxed.Value.Value, coderTestUtils.createTestOID1().Value.Value);

            stream = new System.IO.MemoryStream(coderTestUtils.createTestOID2Bytes());
            ObjectIdentifier oid2 = decoder.decode <ObjectIdentifier>(stream);

            System.Console.Out.WriteLine("Decoded by " + decoder.ToString() + " (OID " + oid2.Value + ") : " + ByteTools.byteArrayToHexString(stream.ToArray()));
            Assert.AreEqual(oid2.Value, coderTestUtils.createTestOID2().Value.Value);

            stream = new System.IO.MemoryStream(coderTestUtils.createTestOID3Bytes());
            ObjectIdentifier oid3 = decoder.decode <ObjectIdentifier>(stream);

            System.Console.Out.WriteLine("Decoded by " + decoder.ToString() + " (OID " + oid3.Value + ") : " + ByteTools.byteArrayToHexString(stream.ToArray()));
            Assert.AreEqual(oid3.Value, coderTestUtils.createTestOID3().Value.Value);

            stream = new System.IO.MemoryStream(coderTestUtils.createTestOID4Bytes());
            ObjectIdentifier oid4 = decoder.decode <ObjectIdentifier>(stream);

            System.Console.Out.WriteLine("Decoded by " + decoder.ToString() + " (OID " + oid4.Value + ") : " + ByteTools.byteArrayToHexString(stream.ToArray()));
            Assert.AreEqual(oid4.Value, coderTestUtils.createTestOID4().Value.Value);
        }
Beispiel #2
0
        public virtual void testEncodeOID()
        {
            IEncoder encoder = newEncoder();

            Assert.IsNotNull(encoder);
            //
            TestOID testOID = coderTestUtils.createTestOID1();

            printEncoded("OID " + testOID.Value.Value, encoder, testOID);
            checkEncoded(encoder, coderTestUtils.createTestOID1(), coderTestUtils.createTestOID1Bytes());
            //
            testOID = coderTestUtils.createTestOID2();
            printEncoded("OID " + testOID.Value.Value, encoder, testOID);
            checkEncoded(encoder, coderTestUtils.createTestOID2(), coderTestUtils.createTestOID2Bytes());
            //
            testOID = coderTestUtils.createTestOID3();
            printEncoded("OID " + testOID.Value.Value, encoder, testOID);
            checkEncoded(encoder, coderTestUtils.createTestOID3(), coderTestUtils.createTestOID3Bytes());
            //
            testOID = coderTestUtils.createTestOID4();
            printEncoded("OID " + testOID.Value.Value, encoder, testOID);
            checkEncoded(encoder, coderTestUtils.createTestOID4(), coderTestUtils.createTestOID4Bytes());
        }