コード例 #1
0
ファイル: TagUtils.cs プロジェクト: MRoc/puremp3
        private static void TestTagUtilsWriteRawSmallerNeverShrink()
        {
            string fileName = VirtualDrive.VirtualFileName("TestTagUtilsWriteRawSmallerNeverShrink\\t1.mp3");

            TestTags.WriteDemoMp3(fileName, TestTags.demoTag2_4);

            FileInfo fileInfo = new FileInfo(fileName);

            TagUtils.WriteTagV2(TestTags.demoTag2_3, fileInfo, Rewriter.Strategy.NeverShrink);
            UnitTest.Test(TagUtils.TagSizeV2(fileInfo) == TestTags.demoTag2_4.Length);
            TagUtils.StripTagV2(fileInfo, 0);
            UnitTest.Test(ArrayUtils.IsEqual(VirtualDrive.Load(fileName), TestTags.mpegDummy));
        }
コード例 #2
0
ファイル: TagUtils.cs プロジェクト: MRoc/puremp3
        private static void TestTagUtilsWriteRawSmallerQuantizeAbove()
        {
            string fileName = VirtualDrive.VirtualFileName("TestTagUtilsWriteRawSmallerQuantizeAbove\\t1.mp3");

            TestTags.WriteDemoMp3(fileName, TestTags.demoTag2_4);

            FileInfo fileInfo = new FileInfo(fileName);

            TagUtils.WriteTagV2(TestTags.demoTag2_3, fileInfo, Rewriter.Strategy.Quantize);
            UnitTest.Test(TagUtils.TagSizeV2(new FileInfo(fileName)) % Rewriter.BlockSize == 0);
            TagUtils.StripTagV2(new FileInfo(fileName), 0);
            UnitTest.Test(ArrayUtils.IsEqual(VirtualDrive.Load(fileName), TestTags.mpegDummy));
        }
コード例 #3
0
ファイル: TagUtils.cs プロジェクト: MRoc/puremp3
        private static void TestTagUtilsWriteRawBiggerExact()
        {
            string fileName = VirtualDrive.VirtualFileName("TestTagUtilsWriteRawBiggerExact\\t1.mp3");

            TestTags.WriteDemoMp3(fileName, TestTags.demoTag2_3);

            FileInfo fileInfo = new FileInfo(fileName);

            TagUtils.WriteTagV2(TestTags.demoTag2_4, fileInfo, Rewriter.Strategy.Exact);
            UnitTest.Test(VirtualDrive.FileLength(fileName) == TestTags.demoTag2_4.Length + TestTags.mpegDummy.Length);
            TagUtils.StripTagV2(fileInfo, 0);
            UnitTest.Test(ArrayUtils.IsEqual(VirtualDrive.Load(fileName), TestTags.mpegDummy));
        }
コード例 #4
0
ファイル: TagUtils.cs プロジェクト: MRoc/puremp3
        private static void TestTagUtilsWriteTagBiggerQuantize()
        {
            string fileName = VirtualDrive.VirtualFileName("TestTagUtilsWriteTagBiggerQuantize\\t1.mp3");

            TestTags.WriteDemoMp3(fileName, TestTags.demoTag2_3);
            FileInfo fileInfo = new FileInfo(fileName);
            Tag      tag      = TagUtils.ReadTag(fileInfo);
            Frame    f        = new Frame(tag.DescriptionMap, "MCDI");

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

            TagUtils.WriteTagV2(tag, fileInfo, Rewriter.Strategy.Quantize);
            UnitTest.Test(VirtualDrive.FileLength(fileName) == 2048 + TestTags.mpegDummy.Length);
            TagUtils.StripTagV2(fileInfo, 0);
            UnitTest.Test(ArrayUtils.IsEqual(VirtualDrive.Load(fileName), TestTags.mpegDummy));
        }
コード例 #5
0
ファイル: TagUtils.cs プロジェクト: MRoc/puremp3
        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));
        }