public void TestMusicBrainzReleaseCountry() { MemoryFileAbstraction abst; Mpeg4.File file = CreateFile(out abst); TagTestWithSave(ref file, abst, delegate(Tag t, string m) { Assert.IsTrue(t.IsEmpty, "Initial (IsEmpty): " + m); Assert.IsNull(t.MusicBrainzReleaseCountry, "Initial (Null): " + m); }); file.Tag.MusicBrainzReleaseCountry = val_sing; TagTestWithSave(ref file, abst, delegate(Tag t, string m) { Assert.IsFalse(t.IsEmpty, "Value Set (!IsEmpty): " + m); Assert.AreEqual(val_sing, t.MusicBrainzReleaseCountry, "Value Set (!Null): " + m); }); file.Tag.MusicBrainzReleaseCountry = string.Empty; TagTestWithSave(ref file, abst, delegate(Tag t, string m) { Assert.IsTrue(t.IsEmpty, "Value Cleared (IsEmpty): " + m); Assert.IsNull(t.MusicBrainzReleaseCountry, "Value Cleared (Null): " + m); }); }
public void TestAlbumArtists() { MemoryFileAbstraction abst; Mpeg4.File file = CreateFile(out abst); TagTestWithSave(ref file, abst, delegate(Tag t, string m) { Assert.IsTrue(t.IsEmpty, "Initial (IsEmpty): " + m); Assert.AreEqual(0, t.AlbumArtists.Length, "Initial (Zero): " + m); }); file.Tag.AlbumArtists = val_mult; TagTestWithSave(ref file, abst, delegate(Tag t, string m) { Assert.IsFalse(t.IsEmpty, "Value Set (!IsEmpty): " + m); Assert.AreEqual(val_mult.Length, t.AlbumArtists.Length, "Value Set: " + m); for (int i = 0; i < val_mult.Length; i++) { Assert.AreEqual(val_mult [i], t.AlbumArtists [i], "Value Set: " + m); } }); file.Tag.AlbumArtists = new string [0]; TagTestWithSave(ref file, abst, delegate(Tag t, string m) { Assert.IsTrue(t.IsEmpty, "Value Cleared (IsEmpty): " + m); Assert.AreEqual(0, t.AlbumArtists.Length, "Value Cleared (Zero): " + m); }); }
public void TestBeatsPerMinute() { MemoryFileAbstraction abst; Mpeg4.File file = CreateFile(out abst); TagTestWithSave(ref file, abst, delegate(Tag t, string m) { Assert.IsTrue(t.IsEmpty, "Initial (IsEmpty): " + m); Assert.AreEqual(0, t.BeatsPerMinute, "Initial (Zero): " + m); }); file.Tag.BeatsPerMinute = 199; TagTestWithSave(ref file, abst, delegate(Tag t, string m) { Assert.IsFalse(t.IsEmpty, "Value Set (!IsEmpty): " + m); Assert.AreEqual(199, t.BeatsPerMinute, "Value Set: " + m); }); file.Tag.BeatsPerMinute = 0; TagTestWithSave(ref file, abst, delegate(Tag t, string m) { Assert.IsTrue(t.IsEmpty, "Value Cleared (IsEmpty): " + m); Assert.AreEqual(0, t.BeatsPerMinute, "Value Cleared (Zero): " + m); }); }
private void TagTestWithSave(ref Mpeg4.File file, MemoryFileAbstraction abst, TagTestFunc testFunc) { testFunc(file.GetTag(TagTypes.Apple), "Before Save"); file.Save(); // Console.WriteLine (); // Extras.DumpHex ((abst.ReadStream as System.IO.MemoryStream).ToArray ()); file = new Mpeg4.File(abst, ReadStyle.None); testFunc(file.GetTag(TagTypes.Apple), "After Save"); }
public void TestPictures() { MemoryFileAbstraction abst; Mpeg4.File file = CreateFile(out abst); Picture [] pictures = new Picture [] { new Picture(TestPath.Covers + "sample_a.png"), new Picture(TestPath.Covers + "sample_a.jpg"), new Picture(TestPath.Covers + "sample_b.png"), new Picture(TestPath.Covers + "sample_b.jpg"), new Picture(TestPath.Covers + "sample_c.png"), new Picture(TestPath.Covers + "sample_c.jpg") }; for (int i = 0; i < 6; i++) { pictures [i].Type = (PictureType)(i * 2); } pictures [3].Description = val_sing; TagTestWithSave(ref file, abst, delegate(Tag t, string m) { Assert.IsTrue(t.IsEmpty, "Initial (IsEmpty): " + m); Assert.AreEqual(0, t.Pictures.Length, "Initial (Zero): " + m); }); file.Tag.Pictures = pictures; TagTestWithSave(ref file, abst, delegate(Tag t, string m) { Assert.IsFalse(t.IsEmpty, "Value Set (!IsEmpty): " + m); Assert.AreEqual(pictures.Length, t.Pictures.Length, "Value Set: " + m); for (int i = 0; i < pictures.Length; i++) { string msg = "Value " + i + "Set: " + m; Assert.AreEqual(pictures [i].Data, t.Pictures [i].Data, msg); Assert.AreEqual(PictureType.FrontCover, t.Pictures [i].Type, msg); Assert.AreEqual(i % 2 == 0 ? "cover.png" : "cover.jpg", t.Pictures [i].Description, msg); Assert.AreEqual(pictures [i].MimeType, t.Pictures [i].MimeType, msg); } }); file.Tag.Pictures = new Picture [0]; TagTestWithSave(ref file, abst, delegate(Tag t, string m) { Assert.IsTrue(t.IsEmpty, "Value Cleared (IsEmpty): " + m); Assert.AreEqual(0, t.Pictures.Length, "Value Cleared (Zero): " + m); }); }
public void TestClear() { MemoryFileAbstraction abst; Mpeg4.File file = CreateFile(out abst); file.Tag.Title = "A"; file.Tag.Performers = new string [] { "B" }; file.Tag.AlbumArtists = new string [] { "C" }; file.Tag.Composers = new string [] { "D" }; file.Tag.Album = "E"; file.Tag.Comment = "F"; file.Tag.Genres = new string [] { "Blues" }; file.Tag.Year = 123; file.Tag.Track = 234; file.Tag.TrackCount = 234; file.Tag.Disc = 234; file.Tag.DiscCount = 234; file.Tag.Lyrics = "G"; file.Tag.Grouping = "H"; file.Tag.BeatsPerMinute = 234; file.Tag.Conductor = "I"; file.Tag.Copyright = "J"; file.Tag.Pictures = new Picture [] { new Picture(TestPath.Covers + "sample_a.png") }; Assert.IsFalse(file.Tag.IsEmpty, "Should be full."); file.Tag.Clear(); Assert.IsNull(file.Tag.Title, "Title"); Assert.AreEqual(0, file.Tag.Performers.Length, "Performers"); Assert.AreEqual(0, file.Tag.AlbumArtists.Length, "AlbumArtists"); Assert.AreEqual(0, file.Tag.Composers.Length, "Composers"); Assert.IsNull(file.Tag.Album, "Album"); Assert.IsNull(file.Tag.Comment, "Comment"); Assert.AreEqual(0, file.Tag.Genres.Length, "Genres"); Assert.AreEqual(0, file.Tag.Year, "Year"); Assert.AreEqual(0, file.Tag.Track, "Track"); Assert.AreEqual(0, file.Tag.TrackCount, "TrackCount"); Assert.AreEqual(0, file.Tag.Disc, "Disc"); Assert.AreEqual(0, file.Tag.DiscCount, "DiscCount"); Assert.IsNull(file.Tag.Lyrics, "Lyrics"); Assert.IsNull(file.Tag.Comment, "Comment"); Assert.AreEqual(0, file.Tag.BeatsPerMinute, "BeatsPerMinute"); Assert.IsNull(file.Tag.Conductor, "Conductor"); Assert.IsNull(file.Tag.Copyright, "Copyright"); Assert.AreEqual(0, file.Tag.Pictures.Length, "Pictures"); Assert.IsTrue(file.Tag.IsEmpty, "Should be empty."); }
private void TagTestWithSave (ref Mpeg4.File file, MemoryFileAbstraction abst, TagTestFunc testFunc) { testFunc (file.GetTag (TagTypes.Apple), "Before Save"); file.Save (); // Console.WriteLine (); // Extras.DumpHex ((abst.ReadStream as System.IO.MemoryStream).ToArray ()); file = new Mpeg4.File (abst, ReadStyle.None); testFunc (file.GetTag (TagTypes.Apple), "After Save"); }