Merge branch 'master' into scrobbler

Conflicts:
	src/IF.Lastfm.Core.Tests.Integration/packages.config
	src/IF.Lastfm.Core.Tests/TestHelper.cs
This commit is contained in:
Rikki Tooley 2015-04-05 23:26:34 +01:00
commit f299b1f8e9
36 changed files with 213 additions and 177 deletions

View File

@ -1,4 +1,4 @@
# Api Progress ![Progress](http://progressed.io/bar/26)
# Api Progress ![Progress](http://progressed.io/bar/27)
These are all the Last.fm API methods currently available.
@ -6,7 +6,7 @@ These are all the Last.fm API methods currently available.
- Methods ~~marked with strikethrough~~ aren't currently implemented. Pull requests are welcome!
- Methods _marked with an asterisk *_ aren't listed on [the Last.fm documentation](http://www.last.fm/api), so they might not work!
This list is generated by the [ProgressReport](https://github.com/inflatablefriends/lastfm/tree/master/src/IF.Lastfm.ProgressReport) tool in the solution. Last updated on 04 January 2015 03:55
This list is generated by the [ProgressReport](src/IF.Lastfm.ProgressReport) tool in the solution. Last updated on 05 April 2015 00:02
## Album
- [album.getInfo](http://www.last.fm/api/show/album.getInfo)
@ -90,6 +90,8 @@ This list is generated by the [ProgressReport](https://github.com/inflatablefrie
## Library
- [library.getTracks](http://www.last.fm/api/show/library.getTracks)
- [library.removeScrobble](http://www.last.fm/api/show/library.removeScrobble)
- [library.removeTrack](http://www.last.fm/api/show/library.removeTrack)
- ~~[library.addAlbum](http://www.last.fm/api/show/library.addAlbum)~~
- ~~[library.addArtist](http://www.last.fm/api/show/library.addArtist)~~
- ~~[library.addTrack](http://www.last.fm/api/show/library.addTrack)~~
@ -97,8 +99,6 @@ This list is generated by the [ProgressReport](https://github.com/inflatablefrie
- ~~[library.getArtists](http://www.last.fm/api/show/library.getArtists)~~
- ~~[library.removeAlbum](http://www.last.fm/api/show/library.removeAlbum)~~
- ~~[library.removeArtist](http://www.last.fm/api/show/library.removeArtist)~~
- ~~[library.removeScrobble](http://www.last.fm/api/show/library.removeScrobble)~~
- ~~[library.removeTrack](http://www.last.fm/api/show/library.removeTrack)~~
## Playlist

View File

@ -1,6 +1,6 @@
using IF.Lastfm.Core.Api;
using IF.Lastfm.Core.Tests.Api.Commands;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;
namespace IF.Lastfm.Core.Tests.Integration.Commands
{
@ -11,7 +11,7 @@ public class CommandIntegrationTestsBase : CommandTestsBase
protected LastAuth Auth { get; private set; }
[TestInitialize]
[SetUp]
public void Initialise()
{
Auth = new LastAuth(LastFm.TEST_APIKEY, LastFm.TEST_APISECRET);

View File

@ -1,20 +1,20 @@
using IF.Lastfm.Core.Api;
using IF.Lastfm.Core.Objects;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;
using System;
using System.Linq;
using System.Threading.Tasks;
namespace IF.Lastfm.Core.Tests.Integration.Commands
{
[TestClass]
public class TrackScrobbleCommandTests : CommandIntegrationTestsBase
{
private const string ARTIST_NAME = "Hot Chip";
private const string ALBUM_NAME = "The Warning";
private const string TRACK_NAME = "Over and Over";
[TestMethod]
[Test]
public async Task ScrobblesSingle()
{
var trackPlayed = DateTimeOffset.UtcNow.AddMinutes(-1).RoundToNearestSecond();

View File

@ -1,20 +1,20 @@
using IF.Lastfm.Core.Api;
using IF.Lastfm.Core.Objects;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;
using System;
using System.Linq;
using System.Threading.Tasks;
namespace IF.Lastfm.Core.Tests.Integration.Commands
{
[TestClass]
public class TrackUpdateNowPlayingCommandTests : CommandIntegrationTestsBase
{
private const string ARTIST_NAME = "Crystal Castles";
private const string ALBUM_NAME = "Crystal Castles ( II )";
private const string TRACK_NAME = "Not in Love";
[TestMethod]
[Test]
public async Task UpdatesNowPlaying()
{
var trackPlayed = DateTime.UtcNow.AddMinutes(-1);

View File

@ -45,6 +45,8 @@
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
<Reference Include="nunit.framework">
<HintPath>..\..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Net.Http" />
@ -62,11 +64,7 @@
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
</ItemGroup>
</Otherwise>
<Otherwise />
</Choose>
<ItemGroup>
<Compile Include="Commands\CommandIntegrationTestsBase.cs" />

View File

@ -4,5 +4,6 @@
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="net45" />
<package id="Microsoft.Net.Http" version="2.2.28" targetFramework="net45" />
<package id="Moq" version="4.2.1502.0911" targetFramework="net45" />
<package id="NUnit" version="2.6.4" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
</packages>

View File

@ -4,15 +4,14 @@
using IF.Lastfm.Core.Api.Enums;
using IF.Lastfm.Core.Objects;
using IF.Lastfm.Core.Tests.Resources;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Text;
using System.Threading.Tasks;
using IF.Lastfm.Core.Api.Commands.Album;
using Newtonsoft.Json;
using NUnit.Framework;
namespace IF.Lastfm.Core.Tests.Api.Commands.AlbumApi
{
[TestClass]
public class GetAlbumInfoCommandTests : CommandTestsBase
{
private GetInfoCommand _command;
@ -27,9 +26,9 @@ public GetAlbumInfoCommandTests()
_command.SetParameters();
}
[TestMethod]
[Test]
public async Task HandleSuccessResponse()
{
var expectedAlbum = new LastAlbum
@ -73,7 +72,7 @@ public async Task HandleSuccessResponse()
Assert.AreEqual(expectedJson, actualJson, expectedJson.DifferencesTo(actualJson));
}
[TestMethod]
[Test]
public async Task HandleErrorResponse()
{
var response = CreateResponseMessage(Encoding.UTF8.GetString(AlbumApiResponses.AlbumGetInfoMissing));

View File

@ -6,12 +6,11 @@
using IF.Lastfm.Core.Api.Enums;
using IF.Lastfm.Core.Objects;
using IF.Lastfm.Core.Tests.Resources;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;
using NUnit.Framework;
namespace IF.Lastfm.Core.Tests.Api.Commands.AlbumApi
{
[TestClass]
public class GetAlbumShoutsCommandTests : CommandTestsBase
{
private GetShoutsCommand _command;
@ -21,7 +20,7 @@ public GetAlbumShoutsCommandTests()
_command = new GetShoutsCommand(MAuth.Object, "Visions", "Grimes");
}
[TestMethod]
[Test]
public async Task HandleSuccessResponse()
{
var response = CreateResponseMessage(Encoding.UTF8.GetString(AlbumApiResponses.AlbumGetShoutsMultiple));
@ -45,7 +44,7 @@ public async Task HandleSuccessResponse()
Assert.AreEqual(expectedJson, actualJson, expectedJson.DifferencesTo(actualJson));
}
[TestMethod]
[Test]
public async Task HandleResponseSingle()
{
var response = CreateResponseMessage(Encoding.UTF8.GetString(AlbumApiResponses.AlbumGetShoutsSingle));
@ -57,7 +56,7 @@ public async Task HandleResponseSingle()
Assert.IsTrue(parsed.Content.Count() == 1);
}
[TestMethod]
[Test]
public async Task HandleEmptyResponse()
{
var response = CreateResponseMessage(Encoding.UTF8.GetString(AlbumApiResponses.AlbumGetShoutsEmpty));
@ -69,7 +68,7 @@ public async Task HandleEmptyResponse()
Assert.IsTrue(!parsed.Content.Any());
}
[TestMethod]
[Test]
public async Task HandleErrorResponse()
{
var response = CreateResponseMessage(Encoding.UTF8.GetString(AlbumApiResponses.AlbumGetShoutsAlbumMissing));

View File

@ -1,14 +1,13 @@
using IF.Lastfm.Core.Api.Enums;
using IF.Lastfm.Core.Tests.Resources;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using IF.Lastfm.Core.Api.Commands.Album;
using NUnit.Framework;
namespace IF.Lastfm.Core.Tests.Api.Commands.AlbumApi
{
[TestClass]
public class GetAlbumTopTagsCommandTest : CommandTestsBase
{
private GetTopTagsCommand _command;
@ -24,7 +23,7 @@ public GetAlbumTopTagsCommandTest()
_command.SetParameters();
}
[TestMethod]
[Test]
public void Constructor()
{
Assert.AreEqual(_command.Method, "album.getTopTags");
@ -32,7 +31,7 @@ public void Constructor()
Assert.AreEqual(_command.Parameters["artist"], "Cher");
}
[TestMethod]
[Test]
public async Task HandleSuccessResponse()
{
var response = CreateResponseMessage(Encoding.UTF8.GetString(AlbumApiResponses.AlbumGetTopTags));
@ -43,7 +42,7 @@ public async Task HandleSuccessResponse()
Assert.IsNotNull(parsed.Content);
}
[TestMethod]
[Test]
public async Task HandleEmptyResponse()
{
var response = CreateResponseMessage(Encoding.UTF8.GetString(AlbumApiResponses.AlbumGetTopTagsEmpty));
@ -55,7 +54,7 @@ public async Task HandleEmptyResponse()
Assert.IsTrue(!parsed.Content.Any());
}
[TestMethod]
[Test]
public async Task HandleErrorResponse()
{
var response = CreateResponseMessage(Encoding.UTF8.GetString(AlbumApiResponses.AlbumGetTopTagsError));

View File

@ -1,14 +1,13 @@
using IF.Lastfm.Core.Api.Enums;
using IF.Lastfm.Core.Tests.Resources;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using IF.Lastfm.Core.Api.Commands.Album;
using NUnit.Framework;
namespace IF.Lastfm.Core.Tests.Api.Commands.AlbumApi
{
[TestClass]
public class SearchAlbumsCommandTests : CommandTestsBase
{
private SearchCommand _command;
@ -24,7 +23,7 @@ public SearchAlbumsCommandTests()
_command.SetParameters();
}
[TestMethod]
[Test]
public void Constructor()
{
Assert.AreEqual(_command.Method, "album.search");
@ -34,7 +33,7 @@ public void Constructor()
Assert.AreEqual(_command.Parameters["limit"], "3");
}
[TestMethod]
[Test]
public async Task HandleSuccessResponse()
{
var response = CreateResponseMessage(Encoding.UTF8.GetString(AlbumApiResponses.AlbumSearch));
@ -47,7 +46,7 @@ public async Task HandleSuccessResponse()
Assert.IsTrue(parsed.Content.Count() == 3);
}
[TestMethod]
[Test]
public async Task HandleResponseSingle()
{
var response = CreateResponseMessage(Encoding.UTF8.GetString(AlbumApiResponses.AlbumSearchSingle));
@ -59,7 +58,7 @@ public async Task HandleResponseSingle()
Assert.IsTrue(parsed.Content.Count() == 1);
}
[TestMethod]
[Test]
public async Task HandleEmptyResponse()
{
var response = CreateResponseMessage(Encoding.UTF8.GetString(AlbumApiResponses.AlbumSearchEmpty));
@ -71,7 +70,7 @@ public async Task HandleEmptyResponse()
Assert.IsTrue(!parsed.Content.Any());
}
[TestMethod]
[Test]
public async Task HandleErrorResponse()
{
var response = CreateResponseMessage(Encoding.UTF8.GetString(AlbumApiResponses.AlbumSearchError));

View File

@ -1,7 +1,7 @@
using IF.Lastfm.Core.Api.Enums;
using IF.Lastfm.Core.Objects;
using IF.Lastfm.Core.Tests.Resources;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -10,18 +10,17 @@
namespace IF.Lastfm.Core.Tests.Api.Commands
{
[TestClass]
public class AlbumGetTagsByUserCommandTests : CommandTestsBase
{
private GetTagsByUserCommand _command;
[TestInitialize]
[SetUp]
public void Initialise()
{
_command = new GetTagsByUserCommand(MAuth.Object, "", "", "");
}
[TestMethod]
[Test]
public async Task HandleResponseSingle()
{
var expectedTags = new List<LastTag>
@ -39,7 +38,7 @@ public async Task HandleResponseSingle()
Assert.AreEqual(expectedJson, actualJson, expectedJson.DifferencesTo(actualJson));
}
[TestMethod]
[Test]
public async Task HandleResponseMultiple()
{
var expectedTags = new List<LastTag>
@ -58,7 +57,7 @@ public async Task HandleResponseMultiple()
Assert.AreEqual(expectedJson, actualJson, expectedJson.DifferencesTo(actualJson));
}
[TestMethod]
[Test]
public async Task HandleResponseEmpty()
{
var response = CreateResponseMessage(Encoding.UTF8.GetString(AlbumApiResponses.AlbumGetTagsEmpty));
@ -68,7 +67,7 @@ public async Task HandleResponseEmpty()
Assert.IsTrue(!parsed.Content.Any());
}
[TestMethod]
[Test]
public async Task HandleResponseError()
{
var response = CreateResponseMessage(Encoding.UTF8.GetString(AlbumApiResponses.AlbumGetTagsError));

View File

@ -1,7 +1,7 @@
using IF.Lastfm.Core.Api.Enums;
using IF.Lastfm.Core.Objects;
using IF.Lastfm.Core.Tests.Resources;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Text;
@ -10,12 +10,12 @@
namespace IF.Lastfm.Core.Tests.Api.Commands
{
[TestClass]
public class ArtistGetInfoCommandTests : CommandTestsBase
{
private GetInfoCommand _command;
[TestInitialize]
[SetUp]
public void Initialise()
{
_command = new GetInfoCommand(MAuth.Object)
@ -24,7 +24,7 @@ public void Initialise()
};
}
[TestMethod]
[Test]
public async Task HandleSuccessResponse()
{
var expectedArtist = new LastArtist()
@ -120,7 +120,7 @@ public async Task HandleSuccessResponse()
Assert.AreEqual(expectedJson, actualJson, expectedJson.DifferencesTo(actualJson));
}
[TestMethod]
[Test]
public async Task HandleErrorResponse()
{
var response = CreateResponseMessage(Encoding.UTF8.GetString(ArtistApiResponses.ArtistGetInfoMissing));

View File

@ -1,7 +1,7 @@
using IF.Lastfm.Core.Api.Enums;
using IF.Lastfm.Core.Objects;
using IF.Lastfm.Core.Tests.Resources;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -10,18 +10,18 @@
namespace IF.Lastfm.Core.Tests.Api.Commands
{
[TestClass]
public class ArtistGetTagsByUserCommandTests : CommandTestsBase
{
private GetTagsByUserCommand _command;
[TestInitialize]
[SetUp]
public void Initialise()
{
_command = new GetTagsByUserCommand(MAuth.Object, "", "");
}
[TestMethod]
[Test]
public async Task HandleResponseSingle()
{
var expectedTags = new List<LastTag>
@ -39,7 +39,7 @@ public async Task HandleResponseSingle()
Assert.AreEqual(expectedJson, actualJson, expectedJson.DifferencesTo(actualJson));
}
[TestMethod]
[Test]
public async Task HandleResponseMultiple()
{
var expectedTags = new List<LastTag>
@ -58,7 +58,7 @@ public async Task HandleResponseMultiple()
Assert.AreEqual(expectedJson, actualJson, expectedJson.DifferencesTo(actualJson));
}
[TestMethod]
[Test]
public async Task HandleResponseEmpty()
{
var response = CreateResponseMessage(Encoding.UTF8.GetString(ArtistApiResponses.ArtistGetTagsEmpty));
@ -68,7 +68,7 @@ public async Task HandleResponseEmpty()
Assert.IsTrue(!parsed.Content.Any());
}
[TestMethod]
[Test]
public async Task HandleResponseError()
{
var response = CreateResponseMessage(Encoding.UTF8.GetString(ArtistApiResponses.ArtistGetTagsError));

View File

@ -1,7 +1,7 @@
using IF.Lastfm.Core.Api.Enums;
using IF.Lastfm.Core.Objects;
using IF.Lastfm.Core.Tests.Resources;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -10,18 +10,18 @@
namespace IF.Lastfm.Core.Tests.Api.Commands
{
[TestClass]
public class ArtistGetTopTagsCommandTests : CommandTestsBase
{
private GetTopTagsCommand _command;
[TestInitialize]
[SetUp]
public void Initialise()
{
_command = new GetTopTagsCommand(MAuth.Object, "");
}
[TestMethod]
[Test]
public async Task HandleResponseSingle()
{
var expectedTags = new List<LastTag>
@ -39,7 +39,7 @@ public async Task HandleResponseSingle()
Assert.AreEqual(expectedJson, actualJson, expectedJson.DifferencesTo(actualJson));
}
[TestMethod]
[Test]
public async Task HandleResponseMultiple()
{
var expectedTags = new List<LastTag>
@ -61,7 +61,7 @@ public async Task HandleResponseMultiple()
Assert.AreEqual(expectedJson, actualJson, expectedJson.DifferencesTo(actualJson));
}
[TestMethod]
[Test]
public async Task HandleResponseEmpty()
{
var response = CreateResponseMessage(Encoding.UTF8.GetString(ArtistApiResponses.ArtistGetTopTagsEmpty));
@ -71,7 +71,7 @@ public async Task HandleResponseEmpty()
Assert.IsTrue(!parsed.Content.Any());
}
[TestMethod]
[Test]
public async Task HandleResponseError()
{
var response = CreateResponseMessage(Encoding.UTF8.GetString(ArtistApiResponses.ArtistGetTopTagsError));

View File

@ -3,7 +3,7 @@
using IF.Lastfm.Core.Api.Commands;
using IF.Lastfm.Core.Api.Helpers;
using IF.Lastfm.Core.Objects;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;
using Moq;
using Newtonsoft.Json;
using System.Net;

View File

@ -1,7 +1,7 @@
using IF.Lastfm.Core.Api.Enums;
using IF.Lastfm.Core.Objects;
using IF.Lastfm.Core.Tests.Resources;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Text;
@ -10,7 +10,7 @@
namespace IF.Lastfm.Core.Tests.Api.Commands.Library
{
[TestClass]
public class LibraryGetTracksCommandTests : CommandTestsBase
{
private readonly GetTracksCommand _command;
@ -23,7 +23,7 @@ public LibraryGetTracksCommandTests()
};
}
[TestMethod]
[Test]
public async Task HandleResponseMultiple()
{
//Testing the second track returned
@ -48,7 +48,7 @@ public async Task HandleResponseMultiple()
await CompareResultsMultiple(_command, expectedTrack, LibraryApiResponses.LibraryGetTracksMultiple, 1);
}
[TestMethod]
[Test]
public async Task HandleResponseSingle()
{
var expectedTrack = new LastTrack
@ -73,7 +73,7 @@ public async Task HandleResponseSingle()
await CompareResultsSingle(_command, expected, LibraryApiResponses.LibraryGetTracksSingle);
}
[TestMethod]
[Test]
public async Task HandleErrorResponse()
{
var response = CreateResponseMessage(Encoding.UTF8.GetString(AlbumApiResponses.AlbumGetInfoMissing));

View File

@ -1,6 +1,6 @@
using IF.Lastfm.Core.Api.Enums;
using IF.Lastfm.Core.Tests.Resources;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -8,7 +8,7 @@
namespace IF.Lastfm.Core.Tests.Api.Commands.TrackApi
{
[TestClass]
public class GetTrackShoutsCommandTests : CommandTestsBase
{
private GetShoutsCommand _command;
@ -25,7 +25,7 @@ public GetTrackShoutsCommandTests()
_command.SetParameters();
}
[TestMethod]
[Test]
public void Constructor()
{
Assert.AreEqual(_command.Method, "track.getShouts");
@ -38,7 +38,7 @@ public void Constructor()
//Assert.AreEqual(_command.Parameters["disablecachetoken"], "1");
}
[TestMethod]
[Test]
public async Task HandleSuccessResponse()
{
var response = CreateResponseMessage(Encoding.UTF8.GetString(TrackApiResponses.TrackGetShouts));
@ -51,7 +51,7 @@ public async Task HandleSuccessResponse()
Assert.IsTrue(parsed.Content.Count() == 7);
}
[TestMethod]
[Test]
public async Task HandleResponseSingle()
{
var response = CreateResponseMessage(Encoding.UTF8.GetString(TrackApiResponses.TrackGetShoutsSingle));
@ -63,7 +63,7 @@ public async Task HandleResponseSingle()
Assert.IsTrue(parsed.Content.Count() == 1);
}
[TestMethod]
[Test]
public async Task HandleEmptyResponse()
{
var response = CreateResponseMessage(Encoding.UTF8.GetString(TrackApiResponses.TrackGetShoutsEmpty));
@ -75,7 +75,7 @@ public async Task HandleEmptyResponse()
Assert.IsTrue(!parsed.Content.Any());
}
[TestMethod]
[Test]
public async Task HandleErrorResponse()
{
var response = CreateResponseMessage(Encoding.UTF8.GetString(TrackApiResponses.TrackGetShoutsError));

View File

@ -1,7 +1,7 @@
using IF.Lastfm.Core.Api.Enums;
using IF.Lastfm.Core.Objects;
using IF.Lastfm.Core.Tests.Resources;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Text;
@ -11,12 +11,12 @@
namespace IF.Lastfm.Core.Tests.Api.Commands
{
[TestClass]
public class UserGetRecentTracksCommandTests : CommandTestsBase
{
private GetRecentTracksCommand _command;
[TestInitialize]
[SetUp]
public void Initialise()
{
_command = new GetRecentTracksCommand(MAuth.Object, "rj")
@ -25,7 +25,7 @@ public void Initialise()
};
}
[TestMethod]
[Test]
public async Task HandleResponseMultiple()
{
var expectedTrack = new LastTrack
@ -47,7 +47,7 @@ public async Task HandleResponseMultiple()
await CompareResultsMultiple(_command, expectedTrack, UserApiResponses.UserGetRecentTracksMultiple, 2);
}
[TestMethod]
[Test]
public async Task HandleResponseSingle()
{
var expectedTrack = new LastTrack
@ -72,7 +72,7 @@ public async Task HandleResponseSingle()
await CompareResultsSingle(_command, expected, UserApiResponses.UserGetRecentTracksSingle);
}
[TestMethod]
[Test]
public async Task HandleErrorResponse()
{
var response = CreateResponseMessage(Encoding.UTF8.GetString(UserApiResponses.UserGetRecentTracksError));

View File

@ -5,22 +5,22 @@
using IF.Lastfm.Core.Api.Commands.User;
using IF.Lastfm.Core.Objects;
using IF.Lastfm.Core.Tests.Resources;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;
namespace IF.Lastfm.Core.Tests.Api.Commands
{
[TestClass]
public class UserGetRecommendedArtistsCommandTests : CommandTestsBase
{
private GetRecommendedArtistsCommand _commmand;
[TestInitialize]
[SetUp]
public void Initialise()
{
_commmand = new GetRecommendedArtistsCommand(MAuth.Object);
}
[TestMethod]
[Test]
public async Task HandleResponseSingle()
{
var expectedArtist = new LastArtist
@ -46,7 +46,7 @@ public async Task HandleResponseSingle()
Assert.AreEqual(expectedJson, actualJson, expectedJson.DifferencesTo(actualJson));
}
[TestMethod]
[Test]
public async Task HandleResponseMultiple()
{
var expectedArtists = new List<LastArtist>

View File

@ -9,12 +9,12 @@
using IF.Lastfm.Core.Api.Helpers;
using IF.Lastfm.Core.Objects;
using IF.Lastfm.Core.Tests.Resources;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;
using Moq;
namespace IF.Lastfm.Core.Tests.Api.Commands
{
[TestClass]
public class UserGetTopAlbumsCommandTests : CommandTestsBase
{
private const string USER = "test";
@ -23,7 +23,7 @@ public class UserGetTopAlbumsCommandTests : CommandTestsBase
private GetTopAlbumsCommand _command;
private Mock<ILastAuth> _mockAuth;
[TestInitialize]
[SetUp]
public void TestInitialise()
{
_mockAuth = new Mock<ILastAuth>();
@ -36,7 +36,7 @@ public void TestInitialise()
_command.SetParameters();
}
[TestMethod]
[Test]
public void CorrectParameters()
{
var expected = new Dictionary<string, string>
@ -53,7 +53,7 @@ public void CorrectParameters()
TestHelper.AssertSerialiseEqual(expected, _command.Parameters);
}
[TestMethod]
[Test]
public async Task HandleErrorResponse()
{
var http = CreateResponseMessage(Encoding.UTF8.GetString(UserApiResponses.UserGetTopAlbumsError));
@ -62,7 +62,7 @@ public async Task HandleErrorResponse()
Assert.IsFalse(response.Success);
}
[TestMethod]
[Test]
public async Task HandleResponseEmpty()
{
var http = CreateResponseMessage(Encoding.UTF8.GetString(UserApiResponses.UserGetTopAlbumsEmpty));
@ -74,7 +74,7 @@ public async Task HandleResponseEmpty()
Assert.AreEqual(1, response.TotalPages);
}
[TestMethod]
[Test]
public async Task HandleResponseSingle()
{
var expectedAlbum = new LastAlbum
@ -106,7 +106,7 @@ public async Task HandleResponseSingle()
TestHelper.AssertSerialiseEqual(expectedAlbum, actualAlbum);
}
[TestMethod]
[Test]
public async Task HandleResponseMultiple()
{

View File

@ -1,5 +1,5 @@
using IF.Lastfm.Core.Api.Helpers;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;
namespace IF.Lastfm.Core.Tests.Api.Helpers
{
@ -14,10 +14,10 @@ internal enum TestApiEnum
Cats
}
[TestClass]
public class ApiHelperTests
{
[TestMethod]
[Test]
public void GetApiNameReturnsAttribute()
{
var enumValue = TestApiEnum.Dogs;
@ -28,7 +28,7 @@ public void GetApiNameReturnsAttribute()
Assert.AreEqual(expected, actual);
}
[TestMethod]
[Test]
public void GetApiNameReturnsValueIfNoAttribute()
{
var enumValue = TestApiEnum.Unknown;

View File

@ -1,21 +1,21 @@
using IF.Lastfm.Core.Api;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;
using System.Collections.Generic;
namespace IF.Lastfm.Core.Tests.Api
{
[TestClass]
public class LastAuthTests
{
private ILastAuth _auth;
[TestInitialize]
[SetUp]
public void Initialise()
{
_auth = new LastAuth("user", "pass");
}
[TestMethod]
[Test]
public void GeneratesCorrectMethodSignature()
{
const string method = "test.method";

View File

@ -43,7 +43,6 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Moq, Version=4.2.1502.911, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Moq.4.2.1502.0911\lib\net40\Moq.dll</HintPath>
@ -52,6 +51,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="nunit.framework">
<HintPath>..\..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>

View File

@ -3,15 +3,15 @@
using System.Text;
using IF.Lastfm.Core.Api.Enums;
using IF.Lastfm.Core.Tests.Resources;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;
using Moq;
namespace IF.Lastfm.Core.Tests
{
[TestClass]
public class LastFmTests
{
[TestMethod]
[Test]
public void ApiUrlFormatReturnsCorrectly()
{
const string expected = "https://ws.audioscrobbler.com/2.0/?method=tobias.funke&api_key=suddenvalley&blue=performance&format=json&uncle=t-bag";
@ -25,7 +25,7 @@ public void ApiUrlFormatReturnsCorrectly()
Assert.AreEqual(expected, actual);
}
[TestMethod]
[Test]
public void IsResponseValid()
{
LastResponseStatus status;

View File

@ -7,7 +7,7 @@
using System.Runtime.CompilerServices;
using System.Text;
using IF.Lastfm.Core.Api.Helpers;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
@ -185,9 +185,10 @@ public static void AssertValues<T>(
Assert.IsNotNull(pageResponse.Content, "page content is null");
Assert.IsTrue(pageResponse.Content.Count == totalItems, testMessage("content length", totalItems));
}
public static HttpResponseMessage CreateResponseMessage(HttpStatusCode status, byte[] resource)
{
var now = new DateTimeOffset(2015, 03, 04, 20, 07, 21, TimeSpan.Zero);
var responseJson = Encoding.UTF8.GetString(resource);
var stringContent = new StringContent(responseJson, Encoding.UTF8, "application/json");

View File

@ -5,4 +5,5 @@
<package id="Microsoft.Net.Http" version="2.2.28" targetFramework="net45" />
<package id="Moq" version="4.2.1502.0911" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
<package id="NUnit" version="2.6.4" targetFramework="net45" />
</packages>

View File

@ -101,9 +101,9 @@ public async Task<PageResponse<LastShout>> GetShoutsForArtistAsync(string artist
return await command.ExecuteAsync();
}
public async Task<LastResponse> AddShoutAsync(string artistname, string messaage)
public async Task<LastResponse> AddShoutAsync(string artistname, string message)
{
var command = new AddShoutCommand(Auth, artistname, messaage);
var command = new AddShoutCommand(Auth, artistname, message);
return await command.ExecuteAsync();
}

View File

@ -0,0 +1,36 @@
using System;
using System.Net.Http;
using System.Threading.Tasks;
using IF.Lastfm.Core.Api.Helpers;
using IF.Lastfm.Core.Api.Enums;
using IF.Lastfm.Core.Objects;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
namespace IF.Lastfm.Core.Api.Commands.Library {
internal class RemoveScrobbleCommand : PostAsyncCommandBase<LastResponse> {
public string Artist { get; set; }
public string Track { get; set; }
public DateTimeOffset Timestamp { get; set; }
public RemoveScrobbleCommand( ILastAuth auth, string artist, string track, DateTimeOffset timestamp ) : base( auth ) {
Method = "library.removeScrobble";
Artist = artist;
Track = track;
Timestamp = timestamp;
}
public override void SetParameters() {
Parameters.Add( "artist", Artist );
Parameters.Add( "track", Track );
Parameters.Add( "timestamp", Timestamp.AsUnixTime().ToString() );
}
public async override Task<LastResponse> HandleResponse( HttpResponseMessage response ) {
return await LastResponse.HandleResponse( response );
}
}
}

View File

@ -0,0 +1,28 @@
using System.Net.Http;
using System.Threading.Tasks;
using IF.Lastfm.Core.Api.Helpers;
namespace IF.Lastfm.Core.Api.Commands.Library {
internal class RemoveTrackCommand : PostAsyncCommandBase<LastResponse> {
public string Artist { get; set; }
public string Track { get; set; }
public RemoveTrackCommand( ILastAuth auth, string artist, string track) : base( auth ) {
Method = "library.removeTrack";
Artist = artist;
Track = track;
}
public override void SetParameters() {
Parameters.Add( "artist", Artist );
Parameters.Add( "track", Track );
}
public async override Task<LastResponse> HandleResponse( HttpResponseMessage response ) {
return await LastResponse.HandleResponse( response );
}
}
}

View File

@ -28,72 +28,72 @@ public enum LastResponseStatus
/// <summary>
/// The service requested does not exist (2)
/// </summary>
BadService,
BadService = 2,
/// <summary>
/// The method requested does not exist in this service (3)
/// </summary>
BadMethod,
BadMethod = 3,
/// <summary>
/// This credential does not have permission to access the service requested (4)
/// </summary>
BadAuth,
BadAuth = 4,
/// <summary>
/// This service doesn't exist in the requested format
/// </summary>
BadFormat,
BadFormat = 5,
/// <summary>
/// Required parameters were missing from the request (6)
/// </summary>
MissingParameters,
MissingParameters = 6,
/// <summary>
/// The requested resource is invalid (7)
/// </summary>
BadResource,
BadResource = 7,
/// <summary>
/// An unknown failure occured when creating the response (8)
/// </summary>
Failure,
Failure = 8,
/// <summary>
/// The session has expired, reauthenticate before retrying (9)
/// </summary>
SessionExpired,
SessionExpired = 9,
/// <summary>
/// The provided API key was invalid (10)
/// </summary>
BadApiKey,
BadApiKey = 10,
/// <summary>
/// This service is temporarily offline, retry later (11)
/// </summary>
ServiceDown,
ServiceDown = 11,
/// <summary>
/// The request signature was invalid. Check that your API key and secret are valid. (13)
/// You can generate new keys at http://www.last.fm/api/accounts
/// </summary>
BadMethodSignature,
BadMethodSignature = 13,
/// <summary>
/// There was a temporary error while processing the request, retry later (16)
/// </summary>
TemporaryFailure,
TemporaryFailure = 16,
/// <summary>
/// This API key has been suspended, please generate a new key at http://www.last.fm/api/accounts (26)
/// </summary>
KeySuspended,
KeySuspended = 26,
/// <summary>
/// This API key has been rate-limited because too many requests have been made in a short period. Retry later (29)
/// </summary>
RateLimited
RateLimited = 29
}
}

View File

@ -43,7 +43,7 @@ Task<PageResponse<LastShout>> GetShoutsForArtistAsync(string artistname,
int count = LastFm.DefaultPageLength,
bool autocorrect = false);
Task<LastResponse> AddShoutAsync(string artistname, string messaage);
Task<LastResponse> AddShoutAsync(string artistname, string message);
Task<PageResponse<LastArtist>> SearchForArtistAsync(string artistname,
int page = 1,

View File

@ -16,6 +16,11 @@ Task<PageResponse<LastTrack>> GetTracks(string username,
DateTimeOffset since,
int startIndex = 0,
int endIndex = LastFm.DefaultPageLength);
Task<LastResponse> RemoveScrobble(
string artist,
string track,
DateTimeOffset timestamp );
Task<LastResponse> RemoveTrack( string artist, string track );
}
}

View File

@ -8,8 +8,10 @@ namespace IF.Lastfm.Core.Api
{
public class LibraryApi : ILibraryApi
{
public LibraryApi( ILastAuth auth ) { Auth = auth; }
public ILastAuth Auth { get; private set; }
public async Task<PageResponse<LastTrack>> GetTracks(string username, string artist, string album, DateTimeOffset since, int pagenumber = 0, int count = LastFm.DefaultPageLength)
{
var command = new GetTracksCommand(Auth, username, artist, album, since)
@ -20,5 +22,14 @@ public async Task<PageResponse<LastTrack>> GetTracks(string username, string art
return await command.ExecuteAsync();
}
public async Task<LastResponse> RemoveScrobble( string artist, string track, DateTimeOffset timestamp ) {
var command = new RemoveScrobbleCommand( Auth, artist, track, timestamp );
return await command.ExecuteAsync();
}
public async Task<LastResponse> RemoveTrack( string artist, string track ) {
var command = new RemoveTrackCommand( Auth, artist, track );
return await command.ExecuteAsync();
}
}
}

View File

@ -61,6 +61,8 @@
<Compile Include="Api\Commands\Artist\GetTagsByUserCommand.cs" />
<Compile Include="Api\Commands\Artist\GetTopTagsCommand.cs" />
<Compile Include="Api\Commands\Library\GetTracksCommand.cs" />
<Compile Include="Api\Commands\Library\RemoveScrobbleCommand.cs" />
<Compile Include="Api\Commands\Library\RemoveTrackCommand.cs" />
<Compile Include="Api\Commands\Track\ScrobbleCommand.cs" />
<Compile Include="Api\Commands\Track\UpdateNowPlayingCommand.cs" />
<Compile Include="Api\Commands\UnauthenticatedPostAsyncCommandBase.cs" />

View File

@ -115,51 +115,7 @@ public static bool IsResponseValid(string json, out LastResponseStatus status)
int code;
if (Int32.TryParse(codeString, out code))
{
switch (code)
{
case 2:
status = LastResponseStatus.BadService;
break;
case 3:
status = LastResponseStatus.BadMethod;
break;
case 4:
status = LastResponseStatus.BadAuth;
break;
case 5:
status = LastResponseStatus.BadFormat;
break;
case 6:
status = LastResponseStatus.MissingParameters;
break;
case 7:
status = LastResponseStatus.BadResource;
break;
case 8:
status = LastResponseStatus.Failure;
break;
case 9:
status = LastResponseStatus.SessionExpired;
break;
case 10:
status = LastResponseStatus.BadApiKey;
break;
case 11:
status = LastResponseStatus.ServiceDown;
break;
case 13:
status = LastResponseStatus.BadMethodSignature;
break;
case 16:
status = LastResponseStatus.TemporaryFailure;
break;
case 26:
status = LastResponseStatus.KeySuspended;
break;
case 29:
status = LastResponseStatus.RateLimited;
break;
}
status = (LastResponseStatus) code;
}
return false;

View File

@ -24,7 +24,7 @@ These are all the Last.fm API methods currently available.
- Methods ~~marked with strikethrough~~ aren't currently implemented. Pull requests are welcome!
- Methods _marked with an asterisk *_ aren't listed on [the Last.fm documentation](http://www.last.fm/api), so they might not work!
This list is generated by the [ProgressReport](https://github.com/inflatablefriends/lastfm/tree/master/src/IF.Lastfm.ProgressReport) tool in the solution. Last updated on {1}
This list is generated by the [ProgressReport](src/IF.Lastfm.ProgressReport) tool in the solution. Last updated on {1}
";
#region Scrape