Skip to content

Commit

Permalink
Merge branch 'main' into AddEncodedByToTag
Browse files Browse the repository at this point in the history
  • Loading branch information
decriptor authored Aug 31, 2024
2 parents dea93e5 + 228d5cb commit 9f898eb
Show file tree
Hide file tree
Showing 21 changed files with 711 additions and 34 deletions.
4 changes: 2 additions & 2 deletions src/TaglibSharp.Tests/FileFormats/M4aFormatTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ public void bgo_676934 ()
[Test]
public void bgo_701689 ()
{
// This file contains a musicbrainz track id "883821fc-9bbc-4e04-be79-b4b12c4c4a4e"
// This file contains a musicbrainz recording id "883821fc-9bbc-4e04-be79-b4b12c4c4a4e"
// This case also handles bgo #701690 as a proper value for the tag must be returned
var file = TagLib.File.Create (TestPath.Samples + "bgo_701689.m4a");
Assert.AreEqual ("883821fc-9bbc-4e04-be79-b4b12c4c4a4e", file.Tag.MusicBrainzTrackId, "#1");
Assert.AreEqual ("883821fc-9bbc-4e04-be79-b4b12c4c4a4e", file.Tag.MusicBrainzRecordingId, "#1");
}

[Test]
Expand Down
52 changes: 51 additions & 1 deletion src/TaglibSharp.Tests/TaggingFormats/ApeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,56 @@ public void TestMusicBrainzTrackID ()
});
}

[Test]
public void TestMusicBrainzRecordingID ()
{
Tag tag = new Tag ();

TagTestWithSave (ref tag, delegate (Tag t, string m) {
Assert.IsTrue (t.IsEmpty, "Initial (IsEmpty): " + m);
Assert.IsNull (t.MusicBrainzRecordingId, "Initial (Null): " + m);
});

tag.MusicBrainzRecordingId = val_sing;

TagTestWithSave (ref tag, delegate (Tag t, string m) {
Assert.IsFalse (t.IsEmpty, "Value Set (!IsEmpty): " + m);
Assert.AreEqual (val_sing, t.MusicBrainzRecordingId, "Value Set (!Null): " + m);
});

tag.MusicBrainzRecordingId = string.Empty;

TagTestWithSave (ref tag, delegate (Tag t, string m) {
Assert.IsTrue (t.IsEmpty, "Value Cleared (IsEmpty): " + m);
Assert.IsNull (t.MusicBrainzRecordingId, "Value Cleared (Null): " + m);
});
}

[Test]
public void TestMusicBrainzWorkID ()
{
Tag tag = new Tag ();

TagTestWithSave (ref tag, delegate (Tag t, string m) {
Assert.IsTrue (t.IsEmpty, "Initial (IsEmpty): " + m);
Assert.IsNull (t.MusicBrainzWorkId, "Initial (Null): " + m);
});

tag.MusicBrainzWorkId = val_sing;

TagTestWithSave (ref tag, delegate (Tag t, string m) {
Assert.IsFalse (t.IsEmpty, "Value Set (!IsEmpty): " + m);
Assert.AreEqual (val_sing, t.MusicBrainzWorkId, "Value Set (!Null): " + m);
});

tag.MusicBrainzWorkId = string.Empty;

TagTestWithSave (ref tag, delegate (Tag t, string m) {
Assert.IsTrue (t.IsEmpty, "Value Cleared (IsEmpty): " + m);
Assert.IsNull (t.MusicBrainzWorkId, "Value Cleared (Null): " + m);
});
}

[Test]
public void TestMusicBrainzDiscID ()
{
Expand Down Expand Up @@ -842,4 +892,4 @@ void TagTestWithSave (ref Tag tag, TagTestFunc testFunc)
testFunc (tag, "After Save");
}
}
}
}
50 changes: 50 additions & 0 deletions src/TaglibSharp.Tests/TaggingFormats/AsfTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,56 @@ public void TestMusicBrainzTrackID ()
});
}

[Test]
public void TestMusicBrainzRecordingID ()
{
var file = CreateFile (out var abst);

TagTestWithSave (ref file, abst, delegate (Tag t, string m) {
Assert.IsTrue (t.IsEmpty, "Initial (IsEmpty): " + m);
Assert.IsNull (t.MusicBrainzRecordingId, "Initial (Null): " + m);
});

file.Tag.MusicBrainzRecordingId = val_sing;

TagTestWithSave (ref file, abst, delegate (Tag t, string m) {
Assert.IsFalse (t.IsEmpty, "Value Set (!IsEmpty): " + m);
Assert.AreEqual (val_sing, t.MusicBrainzRecordingId, "Value Set (!Null): " + m);
});

file.Tag.MusicBrainzRecordingId = string.Empty;

TagTestWithSave (ref file, abst, delegate (Tag t, string m) {
Assert.IsTrue (t.IsEmpty, "Value Cleared (IsEmpty): " + m);
Assert.IsNull (t.MusicBrainzRecordingId, "Value Cleared (Null): " + m);
});
}

[Test]
public void TestMusicBrainzWorkID ()
{
var file = CreateFile (out var abst);

TagTestWithSave (ref file, abst, delegate (Tag t, string m) {
Assert.IsTrue (t.IsEmpty, "Initial (IsEmpty): " + m);
Assert.IsNull (t.MusicBrainzWorkId, "Initial (Null): " + m);
});

file.Tag.MusicBrainzWorkId = val_sing;

TagTestWithSave (ref file, abst, delegate (Tag t, string m) {
Assert.IsFalse (t.IsEmpty, "Value Set (!IsEmpty): " + m);
Assert.AreEqual (val_sing, t.MusicBrainzWorkId, "Value Set (!Null): " + m);
});

file.Tag.MusicBrainzWorkId = string.Empty;

TagTestWithSave (ref file, abst, delegate (Tag t, string m) {
Assert.IsTrue (t.IsEmpty, "Value Cleared (IsEmpty): " + m);
Assert.IsNull (t.MusicBrainzWorkId, "Value Cleared (Null): " + m);
});
}

[Test]
public void TestMusicBrainzDiscID ()
{
Expand Down
104 changes: 104 additions & 0 deletions src/TaglibSharp.Tests/TaggingFormats/Id3V2Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,62 @@ public void TestMusicBrainzTrackID ()
}
}

[Test]
public void TestMusicBrainzRecordingID ()
{
var tag = new Tag ();
for (byte version = 2; version <= 4; version++) {
tag.Version = version;

TagTestWithSave (ref tag, delegate (Tag t, string m) {
Assert.IsTrue (t.IsEmpty, "Initial (IsEmpty): " + m);
Assert.IsNull (t.MusicBrainzRecordingId, "Initial (Null): " + m);
});

tag.MusicBrainzRecordingId = val_sing;

TagTestWithSave (ref tag, delegate (Tag t, string m) {
Assert.IsFalse (t.IsEmpty, "Value Set (!IsEmpty): " + m);
Assert.AreEqual (val_sing, t.MusicBrainzRecordingId, "Value Set (!Null): " + m);
});

tag.MusicBrainzRecordingId = string.Empty;

TagTestWithSave (ref tag, delegate (Tag t, string m) {
Assert.IsTrue (t.IsEmpty, "Value Cleared (IsEmpty): " + m);
Assert.IsNull (t.MusicBrainzRecordingId, "Value Cleared (Null): " + m);
});
}
}

[Test]
public void TestMusicBrainzWorkID ()
{
var tag = new Tag ();
for (byte version = 2; version <= 4; version++) {
tag.Version = version;

TagTestWithSave (ref tag, delegate (Tag t, string m) {
Assert.IsTrue (t.IsEmpty, "Initial (IsEmpty): " + m);
Assert.IsNull (t.MusicBrainzWorkId, "Initial (Null): " + m);
});

tag.MusicBrainzWorkId = val_sing;

TagTestWithSave (ref tag, delegate (Tag t, string m) {
Assert.IsFalse (t.IsEmpty, "Value Set (!IsEmpty): " + m);
Assert.AreEqual (val_sing, t.MusicBrainzWorkId, "Value Set (!Null): " + m);
});

tag.MusicBrainzWorkId = string.Empty;

TagTestWithSave (ref tag, delegate (Tag t, string m) {
Assert.IsTrue (t.IsEmpty, "Value Cleared (IsEmpty): " + m);
Assert.IsNull (t.MusicBrainzWorkId, "Value Cleared (Null): " + m);
});
}
}

[Test]
public void TestMusicBrainzDiscID ()
{
Expand Down Expand Up @@ -1528,6 +1584,54 @@ public void TestUserTextInformationFrame ()
});
}

[Test]
public void TestMovementNameFrame ()
{
ByteVector id = "MVNM";
var frame = new TextInformationFrame (id) {
Text = val_mult
};

FrameTest (frame, 2,
delegate (Frame f, StringType e) {
(f as TextInformationFrame).TextEncoding = e;
},
(d, v) => new TextInformationFrame (d, v),

delegate (Frame f, string m) {
var g = (f as TextInformationFrame);
Assert.AreEqual (id, g.FrameId, m);
Assert.AreEqual (val_mult.Length, g.Text.Length, m);
for (int i = 0; i < val_mult.Length; i++) {
Assert.AreEqual (val_mult[i], g.Text[i], m);
}
});
}

[Test]
public void TestMovementNumberFrame ()
{
ByteVector id = "MVIN";
var frame = new TextInformationFrame (id) {
Text = val_mult
};

FrameTest (frame, 2,
delegate (Frame f, StringType e) {
(f as TextInformationFrame).TextEncoding = e;
},
(d, v) => new TextInformationFrame (d, v),

delegate (Frame f, string m) {
var g = (f as TextInformationFrame);
Assert.AreEqual (id, g.FrameId, m);
Assert.AreEqual (val_mult.Length, g.Text.Length, m);
for (int i = 0; i < val_mult.Length; i++) {
Assert.AreEqual (val_mult[i], g.Text[i], m);
}
});
}

[Test]
public void TestUniqueFileIdentifierFrame ()
{
Expand Down
50 changes: 50 additions & 0 deletions src/TaglibSharp.Tests/TaggingFormats/Mpeg4Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,56 @@ public void TestMusicBrainzTrackID ()
});
}

[Test]
public void TestMusicBrainzRecordingID ()
{
var file = CreateFile (out var abst);

TagTestWithSave (ref file, abst, delegate (Tag t, string m) {
Assert.IsTrue (t.IsEmpty, "Initial (IsEmpty): " + m);
Assert.IsNull (t.MusicBrainzRecordingId, "Initial (Null): " + m);
});

file.Tag.MusicBrainzRecordingId = val_sing;

TagTestWithSave (ref file, abst, delegate (Tag t, string m) {
Assert.IsFalse (t.IsEmpty, "Value Set (!IsEmpty): " + m);
Assert.AreEqual (val_sing, t.MusicBrainzRecordingId, "Value Set (!Null): " + m);
});

file.Tag.MusicBrainzRecordingId = string.Empty;

TagTestWithSave (ref file, abst, delegate (Tag t, string m) {
Assert.IsTrue (t.IsEmpty, "Value Cleared (IsEmpty): " + m);
Assert.IsNull (t.MusicBrainzRecordingId, "Value Cleared (Null): " + m);
});
}

[Test]
public void TestMusicBrainzWorkID ()
{
var file = CreateFile (out var abst);

TagTestWithSave (ref file, abst, delegate (Tag t, string m) {
Assert.IsTrue (t.IsEmpty, "Initial (IsEmpty): " + m);
Assert.IsNull (t.MusicBrainzWorkId, "Initial (Null): " + m);
});

file.Tag.MusicBrainzWorkId = val_sing;

TagTestWithSave (ref file, abst, delegate (Tag t, string m) {
Assert.IsFalse (t.IsEmpty, "Value Set (!IsEmpty): " + m);
Assert.AreEqual (val_sing, t.MusicBrainzWorkId, "Value Set (!Null): " + m);
});

file.Tag.MusicBrainzWorkId = string.Empty;

TagTestWithSave (ref file, abst, delegate (Tag t, string m) {
Assert.IsTrue (t.IsEmpty, "Value Cleared (IsEmpty): " + m);
Assert.IsNull (t.MusicBrainzWorkId, "Value Cleared (Null): " + m);
});
}

[Test]
public void TestMusicBrainzDiscID ()
{
Expand Down
50 changes: 50 additions & 0 deletions src/TaglibSharp.Tests/TaggingFormats/XiphTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,56 @@ public void TestMusicBrainzTrackID ()
});
}

[Test]
public void TestMusicBrainzRecordingID ()
{
var tag = new XiphComment ();

TagTestWithSave (ref tag, delegate (XiphComment t, string m) {
Assert.IsTrue (t.IsEmpty, "Initial (IsEmpty): " + m);
Assert.IsNull (t.MusicBrainzRecordingId, "Initial (Null): " + m);
});

tag.MusicBrainzRecordingId = val_sing;

TagTestWithSave (ref tag, delegate (XiphComment t, string m) {
Assert.IsFalse (t.IsEmpty, "Value Set (!IsEmpty): " + m);
Assert.AreEqual (val_sing, t.MusicBrainzRecordingId, "Value Set (!Null): " + m);
});

tag.MusicBrainzRecordingId = string.Empty;

TagTestWithSave (ref tag, delegate (XiphComment t, string m) {
Assert.IsTrue (t.IsEmpty, "Value Cleared (IsEmpty): " + m);
Assert.IsNull (t.MusicBrainzRecordingId, "Value Cleared (Null): " + m);
});
}

[Test]
public void TestMusicBrainzWorkID ()
{
var tag = new XiphComment ();

TagTestWithSave (ref tag, delegate (XiphComment t, string m) {
Assert.IsTrue (t.IsEmpty, "Initial (IsEmpty): " + m);
Assert.IsNull (t.MusicBrainzWorkId, "Initial (Null): " + m);
});

tag.MusicBrainzWorkId = val_sing;

TagTestWithSave (ref tag, delegate (XiphComment t, string m) {
Assert.IsFalse (t.IsEmpty, "Value Set (!IsEmpty): " + m);
Assert.AreEqual (val_sing, t.MusicBrainzWorkId, "Value Set (!Null): " + m);
});

tag.MusicBrainzWorkId = string.Empty;

TagTestWithSave (ref tag, delegate (XiphComment t, string m) {
Assert.IsTrue (t.IsEmpty, "Value Cleared (IsEmpty): " + m);
Assert.IsNull (t.MusicBrainzWorkId, "Value Cleared (Null): " + m);
});
}

[Test]
public void TestMusicBrainzDiscID ()
{
Expand Down
Loading

0 comments on commit 9f898eb

Please sign in to comment.