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. 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 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! - 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
- [album.getInfo](http://www.last.fm/api/show/album.getInfo) - [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
- [library.getTracks](http://www.last.fm/api/show/library.getTracks) - [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.addAlbum](http://www.last.fm/api/show/library.addAlbum)~~
- ~~[library.addArtist](http://www.last.fm/api/show/library.addArtist)~~ - ~~[library.addArtist](http://www.last.fm/api/show/library.addArtist)~~
- ~~[library.addTrack](http://www.last.fm/api/show/library.addTrack)~~ - ~~[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.getArtists](http://www.last.fm/api/show/library.getArtists)~~
- ~~[library.removeAlbum](http://www.last.fm/api/show/library.removeAlbum)~~ - ~~[library.removeAlbum](http://www.last.fm/api/show/library.removeAlbum)~~
- ~~[library.removeArtist](http://www.last.fm/api/show/library.removeArtist)~~ - ~~[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 ## Playlist

View File

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

View File

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

View File

@ -1,20 +1,20 @@
using IF.Lastfm.Core.Api; using IF.Lastfm.Core.Api;
using IF.Lastfm.Core.Objects; using IF.Lastfm.Core.Objects;
using Microsoft.VisualStudio.TestTools.UnitTesting; using NUnit.Framework;
using System; using System;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace IF.Lastfm.Core.Tests.Integration.Commands namespace IF.Lastfm.Core.Tests.Integration.Commands
{ {
[TestClass]
public class TrackUpdateNowPlayingCommandTests : CommandIntegrationTestsBase public class TrackUpdateNowPlayingCommandTests : CommandIntegrationTestsBase
{ {
private const string ARTIST_NAME = "Crystal Castles"; private const string ARTIST_NAME = "Crystal Castles";
private const string ALBUM_NAME = "Crystal Castles ( II )"; private const string ALBUM_NAME = "Crystal Castles ( II )";
private const string TRACK_NAME = "Not in Love"; private const string TRACK_NAME = "Not in Love";
[TestMethod] [Test]
public async Task UpdatesNowPlaying() public async Task UpdatesNowPlaying()
{ {
var trackPlayed = DateTime.UtcNow.AddMinutes(-1); 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"> <Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath> <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>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Net.Http" /> <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" /> <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
</ItemGroup> </ItemGroup>
</When> </When>
<Otherwise> <Otherwise />
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
</ItemGroup>
</Otherwise>
</Choose> </Choose>
<ItemGroup> <ItemGroup>
<Compile Include="Commands\CommandIntegrationTestsBase.cs" /> <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.Bcl.Build" version="1.0.21" targetFramework="net45" />
<package id="Microsoft.Net.Http" version="2.2.28" 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="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" /> <package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
</packages> </packages>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,15 +3,15 @@
using System.Text; using System.Text;
using IF.Lastfm.Core.Api.Enums; using IF.Lastfm.Core.Api.Enums;
using IF.Lastfm.Core.Tests.Resources; using IF.Lastfm.Core.Tests.Resources;
using Microsoft.VisualStudio.TestTools.UnitTesting; using NUnit.Framework;
using Moq; using Moq;
namespace IF.Lastfm.Core.Tests namespace IF.Lastfm.Core.Tests
{ {
[TestClass]
public class LastFmTests public class LastFmTests
{ {
[TestMethod] [Test]
public void ApiUrlFormatReturnsCorrectly() 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"; 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); Assert.AreEqual(expected, actual);
} }
[TestMethod] [Test]
public void IsResponseValid() public void IsResponseValid()
{ {
LastResponseStatus status; LastResponseStatus status;

View File

@ -7,7 +7,7 @@
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Text; using System.Text;
using IF.Lastfm.Core.Api.Helpers; using IF.Lastfm.Core.Api.Helpers;
using Microsoft.VisualStudio.TestTools.UnitTesting; using NUnit.Framework;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
@ -188,6 +188,7 @@ public static void AssertValues<T>(
public static HttpResponseMessage CreateResponseMessage(HttpStatusCode status, byte[] resource) 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 responseJson = Encoding.UTF8.GetString(resource);
var stringContent = new StringContent(responseJson, Encoding.UTF8, "application/json"); 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="Microsoft.Net.Http" version="2.2.28" targetFramework="net45" />
<package id="Moq" version="4.2.1502.0911" targetFramework="net45" /> <package id="Moq" version="4.2.1502.0911" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" /> <package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
<package id="NUnit" version="2.6.4" targetFramework="net45" />
</packages> </packages>

View File

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

View File

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

View File

@ -16,6 +16,11 @@ Task<PageResponse<LastTrack>> GetTracks(string username,
DateTimeOffset since, DateTimeOffset since,
int startIndex = 0, int startIndex = 0,
int endIndex = LastFm.DefaultPageLength); 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 class LibraryApi : ILibraryApi
{ {
public LibraryApi( ILastAuth auth ) { Auth = auth; }
public ILastAuth Auth { get; private set; } 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) 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) 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(); 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\GetTagsByUserCommand.cs" />
<Compile Include="Api\Commands\Artist\GetTopTagsCommand.cs" /> <Compile Include="Api\Commands\Artist\GetTopTagsCommand.cs" />
<Compile Include="Api\Commands\Library\GetTracksCommand.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\ScrobbleCommand.cs" />
<Compile Include="Api\Commands\Track\UpdateNowPlayingCommand.cs" /> <Compile Include="Api\Commands\Track\UpdateNowPlayingCommand.cs" />
<Compile Include="Api\Commands\UnauthenticatedPostAsyncCommandBase.cs" /> <Compile Include="Api\Commands\UnauthenticatedPostAsyncCommandBase.cs" />

View File

@ -115,51 +115,7 @@ public static bool IsResponseValid(string json, out LastResponseStatus status)
int code; int code;
if (Int32.TryParse(codeString, out code)) if (Int32.TryParse(codeString, out code))
{ {
switch (code) status = (LastResponseStatus) 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;
}
} }
return false; 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 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! - 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 #region Scrape