Example #1
0
        private static void TestTagUtilsTestCloneUsingRaw()
        {
            ID3.Tag tag = TestTags.CreateDemoTag(Version.v2_3);

            byte[] b0 = TagUtils.TagToRaw(tag);
            byte[] b1 = TagUtils.TagToRaw(tag.Clone());

            UnitTest.Test(ArrayUtils.IsEqual(b0, b1));
        }
Example #2
0
        private static void TestTagUtilsWriteTagSmallerExact()
        {
            Tag   tag = TagUtils.RawToTag(TestTags.demoTag2_3);
            Frame f   = new Frame(tag.DescriptionMap, "MCDI");

            (f.Content as FrameContentBinary).Content = new byte[1024];
            tag.Add(f);

            string fileName = VirtualDrive.VirtualFileName("TestTagUtilsWriteTagSmallerExact\\t1.mp3");

            TestTags.WriteDemoMp3(fileName, TagUtils.TagToRaw(tag));

            tag.Remove(f);
            FileInfo fileInfo = new FileInfo(fileName);

            TagUtils.WriteTagV2(tag, fileInfo, Rewriter.Strategy.Exact);
            UnitTest.Test(VirtualDrive.FileLength(fileName) == TagUtils.TagToRaw(tag).Length + TestTags.mpegDummy.Length);
            TagUtils.StripTagV2(fileInfo, 0);
            UnitTest.Test(ArrayUtils.IsEqual(VirtualDrive.Load(fileName), TestTags.mpegDummy));
        }
Example #3
0
        private static void TestTagUtilsRewriteMP3()
        {
            byte[] tag20 = TagUtils.TagToRaw(TestTags.CreateDemoTag(Version.v2_3));
            byte[] tag10 = TestTags.demoTag1_0;

            string fileName = VirtualDrive.VirtualFileName("TestID3TagUtilsRewrite\\t1.mp3");

            using (Stream s = VirtualDrive.OpenOutStream(fileName))
            {
                s.Write(tag20, 0, tag20.Length);
                s.WriteByte(0);
                s.WriteByte(0);
                s.Write(TestTags.mpegDummy, 0, TestTags.mpegDummy.Length);
                s.Write(tag10, 0, tag10.Length);
            }

            long offset = TagUtils.OffsetTagToMpegHeader(new FileInfo(fileName));

            UnitTest.Test(offset == 2);

            TagUtils.StripTags(new FileInfo(fileName), 0, 0);

            UnitTest.Test(ArrayUtils.IsEqual(VirtualDrive.Load(fileName), TestTags.mpegDummy));
        }