Skip to content

Commit 65b54af

Browse files
CodeWithMadecriptor
authored andcommitted
Add TaggingFormats Tests.
1 parent 95d6343 commit 65b54af

File tree

5 files changed

+257
-1
lines changed

5 files changed

+257
-1
lines changed

src/TaglibSharp.Tests/TaggingFormats/ApeTest.cs

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,56 @@ public void TestMusicBrainzTrackID ()
634634
});
635635
}
636636

637+
[Test]
638+
public void TestMusicBrainzRecordingID ()
639+
{
640+
Tag tag = new Tag ();
641+
642+
TagTestWithSave (ref tag, delegate (Tag t, string m) {
643+
Assert.IsTrue (t.IsEmpty, "Initial (IsEmpty): " + m);
644+
Assert.IsNull (t.MusicBrainzRecordingId, "Initial (Null): " + m);
645+
});
646+
647+
tag.MusicBrainzRecordingId = val_sing;
648+
649+
TagTestWithSave (ref tag, delegate (Tag t, string m) {
650+
Assert.IsFalse (t.IsEmpty, "Value Set (!IsEmpty): " + m);
651+
Assert.AreEqual (val_sing, t.MusicBrainzRecordingId, "Value Set (!Null): " + m);
652+
});
653+
654+
tag.MusicBrainzRecordingId = string.Empty;
655+
656+
TagTestWithSave (ref tag, delegate (Tag t, string m) {
657+
Assert.IsTrue (t.IsEmpty, "Value Cleared (IsEmpty): " + m);
658+
Assert.IsNull (t.MusicBrainzRecordingId, "Value Cleared (Null): " + m);
659+
});
660+
}
661+
662+
[Test]
663+
public void TestMusicBrainzWorkID ()
664+
{
665+
Tag tag = new Tag ();
666+
667+
TagTestWithSave (ref tag, delegate (Tag t, string m) {
668+
Assert.IsTrue (t.IsEmpty, "Initial (IsEmpty): " + m);
669+
Assert.IsNull (t.MusicBrainzWorkId, "Initial (Null): " + m);
670+
});
671+
672+
tag.MusicBrainzWorkId = val_sing;
673+
674+
TagTestWithSave (ref tag, delegate (Tag t, string m) {
675+
Assert.IsFalse (t.IsEmpty, "Value Set (!IsEmpty): " + m);
676+
Assert.AreEqual (val_sing, t.MusicBrainzWorkId, "Value Set (!Null): " + m);
677+
});
678+
679+
tag.MusicBrainzWorkId = string.Empty;
680+
681+
TagTestWithSave (ref tag, delegate (Tag t, string m) {
682+
Assert.IsTrue (t.IsEmpty, "Value Cleared (IsEmpty): " + m);
683+
Assert.IsNull (t.MusicBrainzWorkId, "Value Cleared (Null): " + m);
684+
});
685+
}
686+
637687
[Test]
638688
public void TestMusicBrainzDiscID ()
639689
{
@@ -842,4 +892,4 @@ void TagTestWithSave (ref Tag tag, TagTestFunc testFunc)
842892
testFunc (tag, "After Save");
843893
}
844894
}
845-
}
895+
}

src/TaglibSharp.Tests/TaggingFormats/AsfTest.cs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,56 @@ public void TestMusicBrainzTrackID ()
633633
});
634634
}
635635

636+
[Test]
637+
public void TestMusicBrainzRecordingID ()
638+
{
639+
var file = CreateFile (out var abst);
640+
641+
TagTestWithSave (ref file, abst, delegate (Tag t, string m) {
642+
Assert.IsTrue (t.IsEmpty, "Initial (IsEmpty): " + m);
643+
Assert.IsNull (t.MusicBrainzRecordingId, "Initial (Null): " + m);
644+
});
645+
646+
file.Tag.MusicBrainzRecordingId = val_sing;
647+
648+
TagTestWithSave (ref file, abst, delegate (Tag t, string m) {
649+
Assert.IsFalse (t.IsEmpty, "Value Set (!IsEmpty): " + m);
650+
Assert.AreEqual (val_sing, t.MusicBrainzRecordingId, "Value Set (!Null): " + m);
651+
});
652+
653+
file.Tag.MusicBrainzRecordingId = string.Empty;
654+
655+
TagTestWithSave (ref file, abst, delegate (Tag t, string m) {
656+
Assert.IsTrue (t.IsEmpty, "Value Cleared (IsEmpty): " + m);
657+
Assert.IsNull (t.MusicBrainzRecordingId, "Value Cleared (Null): " + m);
658+
});
659+
}
660+
661+
[Test]
662+
public void TestMusicBrainzWorkID ()
663+
{
664+
var file = CreateFile (out var abst);
665+
666+
TagTestWithSave (ref file, abst, delegate (Tag t, string m) {
667+
Assert.IsTrue (t.IsEmpty, "Initial (IsEmpty): " + m);
668+
Assert.IsNull (t.MusicBrainzWorkId, "Initial (Null): " + m);
669+
});
670+
671+
file.Tag.MusicBrainzWorkId = val_sing;
672+
673+
TagTestWithSave (ref file, abst, delegate (Tag t, string m) {
674+
Assert.IsFalse (t.IsEmpty, "Value Set (!IsEmpty): " + m);
675+
Assert.AreEqual (val_sing, t.MusicBrainzWorkId, "Value Set (!Null): " + m);
676+
});
677+
678+
file.Tag.MusicBrainzWorkId = string.Empty;
679+
680+
TagTestWithSave (ref file, abst, delegate (Tag t, string m) {
681+
Assert.IsTrue (t.IsEmpty, "Value Cleared (IsEmpty): " + m);
682+
Assert.IsNull (t.MusicBrainzWorkId, "Value Cleared (Null): " + m);
683+
});
684+
}
685+
636686
[Test]
637687
public void TestMusicBrainzDiscID ()
638688
{

src/TaglibSharp.Tests/TaggingFormats/Id3V2Test.cs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,62 @@ public void TestMusicBrainzTrackID ()
744744
}
745745
}
746746

747+
[Test]
748+
public void TestMusicBrainzRecordingID ()
749+
{
750+
var tag = new Tag ();
751+
for (byte version = 2; version <= 4; version++) {
752+
tag.Version = version;
753+
754+
TagTestWithSave (ref tag, delegate (Tag t, string m) {
755+
Assert.IsTrue (t.IsEmpty, "Initial (IsEmpty): " + m);
756+
Assert.IsNull (t.MusicBrainzRecordingId, "Initial (Null): " + m);
757+
});
758+
759+
tag.MusicBrainzRecordingId = val_sing;
760+
761+
TagTestWithSave (ref tag, delegate (Tag t, string m) {
762+
Assert.IsFalse (t.IsEmpty, "Value Set (!IsEmpty): " + m);
763+
Assert.AreEqual (val_sing, t.MusicBrainzRecordingId, "Value Set (!Null): " + m);
764+
});
765+
766+
tag.MusicBrainzRecordingId = string.Empty;
767+
768+
TagTestWithSave (ref tag, delegate (Tag t, string m) {
769+
Assert.IsTrue (t.IsEmpty, "Value Cleared (IsEmpty): " + m);
770+
Assert.IsNull (t.MusicBrainzRecordingId, "Value Cleared (Null): " + m);
771+
});
772+
}
773+
}
774+
775+
[Test]
776+
public void TestMusicBrainzWorkID ()
777+
{
778+
var tag = new Tag ();
779+
for (byte version = 2; version <= 4; version++) {
780+
tag.Version = version;
781+
782+
TagTestWithSave (ref tag, delegate (Tag t, string m) {
783+
Assert.IsTrue (t.IsEmpty, "Initial (IsEmpty): " + m);
784+
Assert.IsNull (t.MusicBrainzWorkId, "Initial (Null): " + m);
785+
});
786+
787+
tag.MusicBrainzWorkId = val_sing;
788+
789+
TagTestWithSave (ref tag, delegate (Tag t, string m) {
790+
Assert.IsFalse (t.IsEmpty, "Value Set (!IsEmpty): " + m);
791+
Assert.AreEqual (val_sing, t.MusicBrainzWorkId, "Value Set (!Null): " + m);
792+
});
793+
794+
tag.MusicBrainzWorkId = string.Empty;
795+
796+
TagTestWithSave (ref tag, delegate (Tag t, string m) {
797+
Assert.IsTrue (t.IsEmpty, "Value Cleared (IsEmpty): " + m);
798+
Assert.IsNull (t.MusicBrainzWorkId, "Value Cleared (Null): " + m);
799+
});
800+
}
801+
}
802+
747803
[Test]
748804
public void TestMusicBrainzDiscID ()
749805
{

src/TaglibSharp.Tests/TaggingFormats/Mpeg4Test.cs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,56 @@ public void TestMusicBrainzTrackID ()
634634
});
635635
}
636636

637+
[Test]
638+
public void TestMusicBrainzRecordingID ()
639+
{
640+
var file = CreateFile (out var abst);
641+
642+
TagTestWithSave (ref file, abst, delegate (Tag t, string m) {
643+
Assert.IsTrue (t.IsEmpty, "Initial (IsEmpty): " + m);
644+
Assert.IsNull (t.MusicBrainzRecordingId, "Initial (Null): " + m);
645+
});
646+
647+
file.Tag.MusicBrainzRecordingId = val_sing;
648+
649+
TagTestWithSave (ref file, abst, delegate (Tag t, string m) {
650+
Assert.IsFalse (t.IsEmpty, "Value Set (!IsEmpty): " + m);
651+
Assert.AreEqual (val_sing, t.MusicBrainzRecordingId, "Value Set (!Null): " + m);
652+
});
653+
654+
file.Tag.MusicBrainzRecordingId = string.Empty;
655+
656+
TagTestWithSave (ref file, abst, delegate (Tag t, string m) {
657+
Assert.IsTrue (t.IsEmpty, "Value Cleared (IsEmpty): " + m);
658+
Assert.IsNull (t.MusicBrainzRecordingId, "Value Cleared (Null): " + m);
659+
});
660+
}
661+
662+
[Test]
663+
public void TestMusicBrainzWorkID ()
664+
{
665+
var file = CreateFile (out var abst);
666+
667+
TagTestWithSave (ref file, abst, delegate (Tag t, string m) {
668+
Assert.IsTrue (t.IsEmpty, "Initial (IsEmpty): " + m);
669+
Assert.IsNull (t.MusicBrainzWorkId, "Initial (Null): " + m);
670+
});
671+
672+
file.Tag.MusicBrainzWorkId = val_sing;
673+
674+
TagTestWithSave (ref file, abst, delegate (Tag t, string m) {
675+
Assert.IsFalse (t.IsEmpty, "Value Set (!IsEmpty): " + m);
676+
Assert.AreEqual (val_sing, t.MusicBrainzWorkId, "Value Set (!Null): " + m);
677+
});
678+
679+
file.Tag.MusicBrainzWorkId = string.Empty;
680+
681+
TagTestWithSave (ref file, abst, delegate (Tag t, string m) {
682+
Assert.IsTrue (t.IsEmpty, "Value Cleared (IsEmpty): " + m);
683+
Assert.IsNull (t.MusicBrainzWorkId, "Value Cleared (Null): " + m);
684+
});
685+
}
686+
637687
[Test]
638688
public void TestMusicBrainzDiscID ()
639689
{

src/TaglibSharp.Tests/TaggingFormats/XiphTest.cs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,56 @@ public void TestMusicBrainzTrackID ()
659659
});
660660
}
661661

662+
[Test]
663+
public void TestMusicBrainzRecordingID ()
664+
{
665+
var tag = new XiphComment ();
666+
667+
TagTestWithSave (ref tag, delegate (XiphComment t, string m) {
668+
Assert.IsTrue (t.IsEmpty, "Initial (IsEmpty): " + m);
669+
Assert.IsNull (t.MusicBrainzRecordingId, "Initial (Null): " + m);
670+
});
671+
672+
tag.MusicBrainzRecordingId = val_sing;
673+
674+
TagTestWithSave (ref tag, delegate (XiphComment t, string m) {
675+
Assert.IsFalse (t.IsEmpty, "Value Set (!IsEmpty): " + m);
676+
Assert.AreEqual (val_sing, t.MusicBrainzRecordingId, "Value Set (!Null): " + m);
677+
});
678+
679+
tag.MusicBrainzRecordingId = string.Empty;
680+
681+
TagTestWithSave (ref tag, delegate (XiphComment t, string m) {
682+
Assert.IsTrue (t.IsEmpty, "Value Cleared (IsEmpty): " + m);
683+
Assert.IsNull (t.MusicBrainzRecordingId, "Value Cleared (Null): " + m);
684+
});
685+
}
686+
687+
[Test]
688+
public void TestMusicBrainzWorkID ()
689+
{
690+
var tag = new XiphComment ();
691+
692+
TagTestWithSave (ref tag, delegate (XiphComment t, string m) {
693+
Assert.IsTrue (t.IsEmpty, "Initial (IsEmpty): " + m);
694+
Assert.IsNull (t.MusicBrainzWorkId, "Initial (Null): " + m);
695+
});
696+
697+
tag.MusicBrainzWorkId = val_sing;
698+
699+
TagTestWithSave (ref tag, delegate (XiphComment t, string m) {
700+
Assert.IsFalse (t.IsEmpty, "Value Set (!IsEmpty): " + m);
701+
Assert.AreEqual (val_sing, t.MusicBrainzWorkId, "Value Set (!Null): " + m);
702+
});
703+
704+
tag.MusicBrainzWorkId = string.Empty;
705+
706+
TagTestWithSave (ref tag, delegate (XiphComment t, string m) {
707+
Assert.IsTrue (t.IsEmpty, "Value Cleared (IsEmpty): " + m);
708+
Assert.IsNull (t.MusicBrainzWorkId, "Value Cleared (Null): " + m);
709+
});
710+
}
711+
662712
[Test]
663713
public void TestMusicBrainzDiscID ()
664714
{

0 commit comments

Comments
 (0)