banshee r3604 - in trunk/musicbrainz-sharp: src/MusicBrainz src/MusicBrainz/MusicBrainz tests tests/MusicBrainz.Tests
- From: scottp svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r3604 - in trunk/musicbrainz-sharp: src/MusicBrainz src/MusicBrainz/MusicBrainz tests tests/MusicBrainz.Tests
- Date: Sun, 30 Mar 2008 21:58:02 +0100 (BST)
Author: scottp
Date: Sun Mar 30 21:58:01 2008
New Revision: 3604
URL: http://svn.gnome.org/viewvc/banshee?rev=3604&view=rev
Log:
* src/MusicBrainz/MusicBrainz/Release.cs: Instantiate tracks with the
artist of the release.
* src/MusicBrainz/MusicBrainz/Track.cs: Use new constructor.
* src/MusicBrainz/MusicBrainz/MusicBrainzItem.cs: Added the ability for
a MusicBrainzItem to be instantiated with an Artist. This artist
will only be used if no artist was found in the XML.
* tests/MusicBrainz.Tests/ReleaseTests.cs: Two new tests to make sure
we only do one query to get the artists of all tracks in a release,
for both single and multi-artist releases.
Modified:
trunk/musicbrainz-sharp/src/MusicBrainz/ChangeLog
trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/MusicBrainzItem.cs
trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Release.cs
trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Track.cs
trunk/musicbrainz-sharp/tests/ChangeLog
trunk/musicbrainz-sharp/tests/MusicBrainz.Tests/ReleaseTests.cs
Modified: trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/MusicBrainzItem.cs
==============================================================================
--- trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/MusicBrainzItem.cs (original)
+++ trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/MusicBrainzItem.cs Sun Mar 30 21:58:01 2008
@@ -90,8 +90,9 @@
{
}
- internal MusicBrainzItem (XmlReader reader, bool all_rels_loaded) : base (reader, all_rels_loaded)
+ internal MusicBrainzItem (XmlReader reader, Artist artist, bool all_rels_loaded) : base (reader, all_rels_loaded)
{
+ if (this.artist == null) this.artist = artist;
}
protected override void HandleCreateInc (StringBuilder builder)
Modified: trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Release.cs
==============================================================================
--- trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Release.cs (original)
+++ trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Release.cs Sun Mar 30 21:58:01 2008
@@ -137,16 +137,18 @@
{
}
- internal Release (XmlReader reader) : base(reader, false)
+ internal Release (XmlReader reader) : base (reader, null, false)
{
}
+ static readonly string [] track_params = new string [] { "tracks", "track-level-rels", "artist" };
+
protected override void HandleCreateInc (StringBuilder builder)
{
AppendIncParameters (builder, "release-events", "labels");
if (discs == null) AppendIncParameters (builder, "discs");
if (tracks == null) {
- AppendIncParameters (builder, "tracks", "track-level-rels");
+ AppendIncParameters (builder, track_params);
AllRelsLoaded = false;
}
base.HandleCreateInc (builder);
@@ -222,7 +224,7 @@
track_number = int.Parse (offset) + 1;
if (reader.ReadToDescendant ("track")) {
List<Track> tracks = new List<Track> ();
- do tracks.Add (new Track (reader.ReadSubtree (), AllDataLoaded));
+ do tracks.Add (new Track (reader.ReadSubtree (), Artist, AllDataLoaded));
while (reader.ReadToNextSibling ("track"));
this.tracks = tracks.AsReadOnly ();
}
Modified: trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Track.cs
==============================================================================
--- trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Track.cs (original)
+++ trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Track.cs Sun Mar 30 21:58:01 2008
@@ -90,11 +90,11 @@
{
}
- internal Track (XmlReader reader) : base (reader, false)
+ internal Track (XmlReader reader) : base (reader, null, false)
{
}
- internal Track (XmlReader reader, bool all_rels_loaded) : base (reader, all_rels_loaded)
+ internal Track (XmlReader reader, Artist artist, bool all_rels_loaded) : base (reader, artist, all_rels_loaded)
{
}
Modified: trunk/musicbrainz-sharp/tests/MusicBrainz.Tests/ReleaseTests.cs
==============================================================================
--- trunk/musicbrainz-sharp/tests/MusicBrainz.Tests/ReleaseTests.cs (original)
+++ trunk/musicbrainz-sharp/tests/MusicBrainz.Tests/ReleaseTests.cs Sun Mar 30 21:58:01 2008
@@ -212,5 +212,25 @@
Assert.AreEqual(release.Status, ReleaseStatus.Official);
Assert.AreEqual(release.Type, ReleaseType.Album);
}
+
+ [Test]
+ public void GetAndCheckSingleArtistParsing()
+ {
+ xml_request_count = 0;
+ Release release = Release.Get(fiji_baby_mbid);
+ foreach(Track track in release.Tracks)
+ Assert.IsNotNull(track.Artist.Name);
+ Assert.AreEqual(xml_request_count, 1);
+ }
+
+ [Test]
+ public void GetAndCheckMultiArtistParsing()
+ {
+ xml_request_count = 0;
+ Release release = Release.Get("29e85760-d699-47d6-b71b-27b8933e7380");
+ foreach(Track track in release.Tracks)
+ Assert.IsNotNull(track.Artist.Name);
+ Assert.AreEqual(xml_request_count, 1);
+ }
}
}
\ No newline at end of file
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]