Ejemplo n.º 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));
        }
Ejemplo n.º 2
0
        public static void CreateDemoTags(string path, int count, Action <TagEditor> action)
        {
            for (int i = 0; i < count; ++i)
            {
                Tag tag = TestTags.CreateDemoTag(ID3.Version.v2_3);

                TagEditor editor = new TagEditor(tag);
                editor.Title       = "Song No. " + (i + 1);
                editor.TrackNumber = (i + 1).ToString();
                editor.ReleaseYear = "1993";

                action(editor);

                TagUtils.WriteTag(tag, new FileInfo(Path.Combine(path, "Test" + i + ".mp3")));
            }
        }
Ejemplo n.º 3
0
        private static void TestTagUtilsBuildByCodeAndSerializeInVirtualStore()
        {
            foreach (ID3.Version version in ID3.Version.Versions)
            {
                string filename = VirtualDrive.VirtualFileName(
                    "TestID3TagBuildByCodeAndSerializeInVirtualStore\\" + version.ToString() + ".tag");

                Tag tag0 = TestTags.CreateDemoTag(version);

                TagUtils.WriteTag(tag0, new FileInfo(filename));

                Tag tag1 = TagUtils.ReadTag(new FileInfo(filename));

                TagEditor editor0 = new TagEditor(tag0);
                TagEditor editor1 = new TagEditor(tag1);

                UnitTest.Test(editor1.Equals(editor0));
            }
        }
Ejemplo n.º 4
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));
        }