Example #1
0
        private static void TestFrameCodec2_3()
        {
            byte[] data = new byte[]
            {
                // Frame ID
                (byte)'M', (byte)'C', (byte)'D', (byte)'I',

                // Size
                0, 0, 0, 0,

                // Flags
                0xE0, 0xE0
            };

            FrameCodec2_3 codec = new FrameCodec2_3();

            codec.IgnoreUnsupportedFlags = true;

            Frame frame = new Frame(TagDescriptionMap.Instance[Version.v2_3]);

            frame.Codec = codec;

            using (Reader reader = new Reader(data))
            {
                codec.ReadHeader(reader, frame);
                codec.ReadContent(reader, frame);
            }

            UnitTest.Test(frame.FrameId == "MCDI");
            UnitTest.Test(codec.SizeContent == 0);

            UnitTest.Test(codec.IsTagAlterPreservation);
            UnitTest.Test(codec.IsFileAlterPreservation);
            UnitTest.Test(codec.IsReadOnly);
            UnitTest.Test(codec.IsGroupingIdentity);
            UnitTest.Test(codec.IsCompression);
            UnitTest.Test(codec.IsEncryption);

            using (Writer writer = new Writer())
            {
                codec.Write(writer, frame);
                UnitTest.Test(ArrayUtils.IsEqual(writer.OutData, data));
            }
        }
Example #2
0
        private static void TestFrameCodec2_3Desynchronized()
        {
            byte[] data = new byte[]
            {
                // Frame ID
                (byte)'M', (byte)'C', (byte)'D', (byte)'I',

                // Size
                0, 0, 0, 6,

                // Flags
                0xE0, 0xE0,

                // Payload
                0xFF, 0, 0xFF, 0x1, 0x2, 0xFF, 0, 0xFF
            };

            byte[] dstPlayload = new byte[] { 0xFF, 0xFF, 0x1, 0x2, 0xFF, 0xFF };

            FrameCodec2_3 codec = new FrameCodec2_3();

            codec.IgnoreUnsupportedFlags = true;

            Frame frame = new Frame(TagDescriptionMap.Instance[Version.v2_3]);

            frame.Codec = codec;

            using (Reader reader = new Reader(data))
            {
                reader.Unsynchronization = true;
                codec.ReadHeader(reader, frame);
                codec.ReadContent(reader, frame);
            }

            UnitTest.Test(ArrayUtils.IsEqual((frame.Content as FrameContentBinary).Content, dstPlayload));

            using (Writer writer = new Writer())
            {
                writer.Unsynchronization = true;
                codec.Write(writer, frame);
                UnitTest.Test(ArrayUtils.IsEqual(writer.OutData, data));
            }
        }