public override FrameCodec Clone() { FrameCodec2_4 result = new FrameCodec2_4(); result.SizeContent = SizeContent; result.Flags = Flags; return(result); }
private static void TestFrameCodec2_4() { byte[] data = new byte[] { // Frame ID (byte)'M', (byte)'C', (byte)'D', (byte)'I', // Size 0, 0, 0, 0, // Flags 0x70, 0x4F }; FrameCodec2_4 codec = new FrameCodec2_4(); codec.IgnoreUnsupportedFlags = true; Frame frame = new Frame(TagDescriptionMap.Instance[Version.v2_4]); 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); UnitTest.Test(codec.IsUnsynchronisation); UnitTest.Test(codec.IsDataLengthIndicator); using (Writer writer = new Writer()) { codec.Write(writer, frame); UnitTest.Test(ArrayUtils.IsEqual(writer.OutData, data)); } }
private static void TestFrameCodec2_4Desynchronized() { byte[] data = new byte[] { // Frame ID (byte)'M', (byte)'C', (byte)'D', (byte)'I', // Size 0, 0, 0, 8, // Flags 0x70, 0x4F, // Payload 0xFF, 0, 0xFF, 0x1, 0x2, 0xFF, 0, 0xFF }; byte[] dstPlayload = new byte[] { 0xFF, 0xFF, 0x1, 0x2, 0xFF, 0xFF }; FrameCodec2_4 codec = new FrameCodec2_4(); codec.IgnoreUnsupportedFlags = true; Frame frame = new Frame(TagDescriptionMap.Instance[Version.v2_4]); frame.Codec = codec; using (Reader reader = new Reader(data)) { codec.ReadHeader(reader, frame); codec.ReadContent(reader, frame); } UnitTest.Test(ArrayUtils.IsEqual( (frame.Content as FrameContentBinary).Content, dstPlayload)); using (Writer writer = new Writer()) { codec.Write(writer, frame); UnitTest.Test(ArrayUtils.IsEqual(writer.OutData, data)); } }