public async Task UpdatesNowPlaying() { var trackPlayed = DateTime.UtcNow.AddMinutes(-1); var testScrobble = new Scrobble(ARTIST_NAME, ALBUM_NAME, TRACK_NAME, trackPlayed) { Duration = new TimeSpan(0, 0, 3, 49, 200), AlbumArtist = ARTIST_NAME }; var response = await Lastfm.Track.UpdateNowPlayingAsync(testScrobble); Assert.IsTrue(response.Success); var tracks = await Lastfm.User.GetRecentScrobbles(Lastfm.Auth.UserSession.Username, null, 1, 1); var expectedTrack = new LastTrack { Name = TRACK_NAME, ArtistName = ARTIST_NAME, AlbumName = ALBUM_NAME, Mbid = "1b9ee1d8-c5a7-44d9-813e-85beb0d59f1b", ArtistMbid = "b1570544-93ab-4b2b-8398-131735394202", Url = new Uri("http://www.last.fm/music/Crystal+Castles/_/Not+in+Love"), Images = new LastImageSet("http://userserve-ak.last.fm/serve/34s/61473043.png", "http://userserve-ak.last.fm/serve/64s/61473043.png", "http://userserve-ak.last.fm/serve/126/61473043.png", "http://userserve-ak.last.fm/serve/300x300/61473043.png"), IsNowPlaying = true }; var expectedJson = expectedTrack.TestSerialise(); var actualJson = tracks.Content.FirstOrDefault().TestSerialise(); Assert.AreEqual(expectedJson, actualJson, expectedJson.DifferencesTo(actualJson)); }
public async Task ScrobblesSingle() { var trackPlayed = DateTimeOffset.UtcNow.AddMinutes(-1).RoundToNearestSecond(); var testScrobble = new Scrobble("Hot Chip", "The Warning", "Over and Over", trackPlayed) { AlbumArtist = ARTIST_NAME, ChosenByUser = false }; var response = await Lastfm.Scrobbler.ScrobbleAsync(testScrobble); Assert.IsTrue(response.Success); var testGuid = Guid.Empty; var expectedTrack = new LastTrack { Name = TRACK_NAME, ArtistName = ARTIST_NAME, AlbumName = ALBUM_NAME, Mbid = testGuid.ToString("D"), ArtistMbid = testGuid.ToString("D"), Url = new Uri("http://www.last.fm/music/Hot+Chip/_/Over+and+Over"), Images = new LastImageSet("http://userserve-ak.last.fm/serve/34s/50921593.png", "http://userserve-ak.last.fm/serve/64s/50921593.png", "http://userserve-ak.last.fm/serve/126/50921593.png", "http://userserve-ak.last.fm/serve/300x300/50921593.png") }; var expectedJson = expectedTrack.TestSerialise(); var tracks = await Lastfm.User.GetRecentScrobbles(Lastfm.Auth.UserSession.Username, null, 0, 1); Assert.IsTrue(tracks.Any()); var actual = tracks.Content.First(); TestHelper.AssertSerialiseEqual(trackPlayed, actual.TimePlayed); actual.TimePlayed = null; // MBIDs returned by last.fm change from time to time, so let's just test that they're there. Assert.IsTrue(Guid.Parse(actual.Mbid) != Guid.Empty); Assert.IsTrue(Guid.Parse(actual.ArtistMbid) != Guid.Empty); actual.Mbid = testGuid.ToString("D"); actual.ArtistMbid = testGuid.ToString("D"); var actualJson = actual.TestSerialise(); Assert.AreEqual(expectedJson, actualJson, expectedJson.DifferencesTo(actualJson)); }
public async Task ScrobblesSingle() { var trackPlayed = DateTimeOffset.UtcNow.AddMinutes(-1).RoundToNearestSecond(); var testScrobble = new Scrobble("Hot Chip", "The Warning", "Over and Over", trackPlayed) { AlbumArtist = ARTIST_NAME, ChosenByUser = false }; var response = await Lastfm.Scrobbler.ScrobbleAsync(testScrobble); Assert.IsTrue(response.Success); var expectedTrack = new LastTrack { Name = TRACK_NAME, ArtistName = ARTIST_NAME, AlbumName = ALBUM_NAME }; var expectedJson = expectedTrack.TestSerialise(); var tracks = await Lastfm.User.GetRecentScrobbles(Lastfm.Auth.UserSession.Username, null, 1, 1); Assert.IsTrue(tracks.Any()); var actual = tracks.Content.First(); TestHelper.AssertSerialiseEqual(trackPlayed, actual.TimePlayed); actual.TimePlayed = null; // Some properties change from time to time; parsing is covered in unit tests actual.Mbid = null; actual.ArtistMbid = null; actual.Images = null; actual.Url = null; var actualJson = actual.TestSerialise(); Assert.AreEqual(expectedJson, actualJson, expectedJson.DifferencesTo(actualJson)); }